Skip to content

Commit 1876d20

Browse files
committed
Address review: drop FetchRepoCollaborators and make confidentiality a scalar
Per Joanna's review on #2478: - Remove FetchRepoCollaborators entirely (no callers left after the marker switch). Drops the GetReposCollaboratorsByOwnerByRepo mock route too. - Change SecurityLabel.Confidentiality from []Confidentiality to a scalar Confidentiality. Wire format is now {integrity, confidentiality} where confidentiality is a single 'public' or 'private' string. Updated all tests and the LabelSearchIssues helper accordingly.
1 parent e17cf37 commit 1876d20

8 files changed

Lines changed: 20 additions & 66 deletions

File tree

pkg/github/context_tools_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,7 @@ func Test_GetMe_IFC_InsidersMode(t *testing.T) {
192192
require.NoError(t, err)
193193

194194
assert.Equal(t, "trusted", ifcMap["integrity"])
195-
confList, ok := ifcMap["confidentiality"].([]any)
196-
require.True(t, ok, "confidentiality should be a list")
197-
require.Len(t, confList, 1)
198-
assert.Equal(t, "public", confList[0])
195+
assert.Equal(t, "public", ifcMap["confidentiality"])
199196
})
200197
}
201198

pkg/github/helper_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ const (
3131
GetReposByOwnerByRepo = "GET /repos/{owner}/{repo}"
3232
GetReposBranchesByOwnerByRepo = "GET /repos/{owner}/{repo}/branches"
3333
GetReposTagsByOwnerByRepo = "GET /repos/{owner}/{repo}/tags"
34-
GetReposCollaboratorsByOwnerByRepo = "GET /repos/{owner}/{repo}/collaborators"
3534
GetReposCommitsByOwnerByRepo = "GET /repos/{owner}/{repo}/commits"
3635
GetReposCommitsByOwnerByRepoByRef = "GET /repos/{owner}/{repo}/commits/{ref}"
3736
GetReposContentsByOwnerByRepoByPath = "GET /repos/{owner}/{repo}/contents/{path}"

pkg/github/issues_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ func Test_IssueRead_IFC_InsidersMode(t *testing.T) {
352352
require.NotNil(t, result.Meta)
353353
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
354354
assert.Equal(t, "untrusted", ifcMap["integrity"])
355-
assert.Equal(t, []any{"public"}, ifcMap["confidentiality"])
355+
assert.Equal(t, "public", ifcMap["confidentiality"])
356356
})
357357

358358
t.Run("insiders mode enabled on private repo with get_comments emits private untrusted", func(t *testing.T) {
@@ -370,7 +370,7 @@ func Test_IssueRead_IFC_InsidersMode(t *testing.T) {
370370
require.NotNil(t, result.Meta)
371371
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
372372
assert.Equal(t, "untrusted", ifcMap["integrity"])
373-
assert.Equal(t, []any{"private"}, ifcMap["confidentiality"])
373+
assert.Equal(t, "private", ifcMap["confidentiality"])
374374
})
375375

376376
t.Run("insiders mode skips ifc label when visibility lookup fails", func(t *testing.T) {
@@ -896,7 +896,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
896896
require.NotNil(t, result.Meta)
897897
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
898898
assert.Equal(t, "untrusted", ifcMap["integrity"])
899-
assert.Equal(t, []any{"public"}, ifcMap["confidentiality"])
899+
assert.Equal(t, "public", ifcMap["confidentiality"])
900900
})
901901

902902
t.Run("insiders mode mixed public and private emits private untrusted", func(t *testing.T) {
@@ -921,7 +921,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
921921
require.NotNil(t, result.Meta)
922922
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
923923
assert.Equal(t, "untrusted", ifcMap["integrity"])
924-
assert.Equal(t, []any{"private"}, ifcMap["confidentiality"])
924+
assert.Equal(t, "private", ifcMap["confidentiality"])
925925
})
926926

927927
t.Run("insiders mode skips ifc label when visibility lookup fails", func(t *testing.T) {
@@ -961,7 +961,7 @@ func Test_SearchIssues_IFC_InsidersMode(t *testing.T) {
961961
require.NotNil(t, result.Meta)
962962
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
963963
assert.Equal(t, "untrusted", ifcMap["integrity"])
964-
assert.Equal(t, []any{"public"}, ifcMap["confidentiality"])
964+
assert.Equal(t, "public", ifcMap["confidentiality"])
965965
})
966966
}
967967

@@ -1729,10 +1729,7 @@ func Test_ListIssues_IFC_InsidersMode(t *testing.T) {
17291729
require.NoError(t, json.Unmarshal(ifcJSON, &ifcMap))
17301730

17311731
assert.Equal(t, "untrusted", ifcMap["integrity"])
1732-
confList, ok := ifcMap["confidentiality"].([]any)
1733-
require.True(t, ok, "confidentiality should be a list")
1734-
require.Len(t, confList, 1)
1735-
assert.Equal(t, "public", confList[0])
1732+
assert.Equal(t, "public", ifcMap["confidentiality"])
17361733
})
17371734

17381735
t.Run("insiders mode enabled on private repo emits private untrusted label", func(t *testing.T) {
@@ -1759,9 +1756,7 @@ func Test_ListIssues_IFC_InsidersMode(t *testing.T) {
17591756
require.NoError(t, json.Unmarshal(ifcJSON, &ifcMap))
17601757

17611758
assert.Equal(t, "untrusted", ifcMap["integrity"])
1762-
confList, ok := ifcMap["confidentiality"].([]any)
1763-
require.True(t, ok, "confidentiality should be a list")
1764-
assert.Equal(t, []any{"private"}, confList)
1759+
assert.Equal(t, "private", ifcMap["confidentiality"])
17651760
})
17661761
}
17671762

pkg/github/repositories.go

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -654,38 +654,6 @@ func CreateRepository(t translations.TranslationHelperFunc) inventory.ServerTool
654654
)
655655
}
656656

657-
// FetchRepoCollaborators returns the login names of all collaborators on a
658-
// repository, paginated.
659-
//
660-
// The github-mcp-server itself no longer calls this from its IFC label paths:
661-
// ingress tools emit a single "private" marker and the client engine resolves
662-
// concrete readers from the GitHub API on demand at egress decision time
663-
// (where it can paginate + cache). The helper is retained as an exported
664-
// utility for external library consumers that may want the same one-shot
665-
// pagination behaviour.
666-
func FetchRepoCollaborators(ctx context.Context, client *github.Client, owner, repo string) ([]string, error) {
667-
opts := &github.ListCollaboratorsOptions{
668-
ListOptions: github.ListOptions{PerPage: 100},
669-
}
670-
var logins []string
671-
for {
672-
page, resp, err := client.Repositories.ListCollaborators(ctx, owner, repo, opts)
673-
if err != nil {
674-
return nil, err
675-
}
676-
for _, c := range page {
677-
if login := c.GetLogin(); login != "" {
678-
logins = append(logins, login)
679-
}
680-
}
681-
if resp == nil || resp.NextPage == 0 {
682-
break
683-
}
684-
opts.Page = resp.NextPage
685-
}
686-
return logins, nil
687-
}
688-
689657
// FetchRepoIsPrivate returns whether a repository is private. It is a thin
690658
// wrapper around the GitHub Repositories.Get endpoint provided as a shared
691659
// helper for IFC label computation across tools.

pkg/github/repositories_test.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,10 +554,7 @@ func Test_GetFileContents_IFC_InsidersMode(t *testing.T) {
554554
require.NoError(t, json.Unmarshal(ifcJSON, &ifcMap))
555555

556556
assert.Equal(t, "untrusted", ifcMap["integrity"])
557-
confList, ok := ifcMap["confidentiality"].([]any)
558-
require.True(t, ok, "confidentiality should be a list")
559-
require.Len(t, confList, 1)
560-
assert.Equal(t, "public", confList[0])
557+
assert.Equal(t, "public", ifcMap["confidentiality"])
561558
})
562559

563560
t.Run("insiders mode enabled on private repo emits private trusted label", func(t *testing.T) {
@@ -582,9 +579,7 @@ func Test_GetFileContents_IFC_InsidersMode(t *testing.T) {
582579
require.NoError(t, json.Unmarshal(ifcJSON, &ifcMap))
583580

584581
assert.Equal(t, "trusted", ifcMap["integrity"])
585-
confList, ok := ifcMap["confidentiality"].([]any)
586-
require.True(t, ok, "confidentiality should be a list")
587-
assert.Equal(t, []any{"private"}, confList)
582+
assert.Equal(t, "private", ifcMap["confidentiality"])
588583
})
589584

590585
t.Run("insiders mode skips ifc label when visibility lookup fails", func(t *testing.T) {

pkg/github/search_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func Test_SearchRepositories_IFC_InsidersMode(t *testing.T) {
235235
require.NotNil(t, result.Meta)
236236
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
237237
assert.Equal(t, "untrusted", ifcMap["integrity"])
238-
assert.Equal(t, []any{"public"}, ifcMap["confidentiality"])
238+
assert.Equal(t, "public", ifcMap["confidentiality"])
239239
})
240240

241241
t.Run("insiders mode any private match emits private untrusted", func(t *testing.T) {
@@ -256,7 +256,7 @@ func Test_SearchRepositories_IFC_InsidersMode(t *testing.T) {
256256
require.NotNil(t, result.Meta)
257257
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
258258
assert.Equal(t, "untrusted", ifcMap["integrity"])
259-
assert.Equal(t, []any{"private"}, ifcMap["confidentiality"])
259+
assert.Equal(t, "private", ifcMap["confidentiality"])
260260
})
261261

262262
t.Run("insiders mode empty results emits public untrusted", func(t *testing.T) {
@@ -274,7 +274,7 @@ func Test_SearchRepositories_IFC_InsidersMode(t *testing.T) {
274274
require.NotNil(t, result.Meta)
275275
ifcMap := unmarshalIFC(t, result.Meta["ifc"])
276276
assert.Equal(t, "untrusted", ifcMap["integrity"])
277-
assert.Equal(t, []any{"public"}, ifcMap["confidentiality"])
277+
assert.Equal(t, "public", ifcMap["confidentiality"])
278278
})
279279
}
280280

pkg/ifc/ifc.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ const (
1818
)
1919

2020
type SecurityLabel struct {
21-
Integrity Integrity `json:"integrity"`
22-
Confidentiality []Confidentiality `json:"confidentiality"`
21+
Integrity Integrity `json:"integrity"`
22+
Confidentiality Confidentiality `json:"confidentiality"`
2323
}
2424

2525
// PublicTrusted returns a label for trusted, publicly readable data.
2626
func PublicTrusted() SecurityLabel {
2727
return SecurityLabel{
2828
Integrity: IntegrityTrusted,
29-
Confidentiality: []Confidentiality{ConfidentialityPublic},
29+
Confidentiality: ConfidentialityPublic,
3030
}
3131
}
3232

3333
// PublicUntrusted returns a label for untrusted, publicly readable data.
3434
func PublicUntrusted() SecurityLabel {
3535
return SecurityLabel{
3636
Integrity: IntegrityUntrusted,
37-
Confidentiality: []Confidentiality{ConfidentialityPublic},
37+
Confidentiality: ConfidentialityPublic,
3838
}
3939
}
4040

@@ -45,7 +45,7 @@ func PublicUntrusted() SecurityLabel {
4545
func PrivateTrusted() SecurityLabel {
4646
return SecurityLabel{
4747
Integrity: IntegrityTrusted,
48-
Confidentiality: []Confidentiality{ConfidentialityPrivate},
48+
Confidentiality: ConfidentialityPrivate,
4949
}
5050
}
5151

@@ -55,7 +55,7 @@ func PrivateTrusted() SecurityLabel {
5555
func PrivateUntrusted() SecurityLabel {
5656
return SecurityLabel{
5757
Integrity: IntegrityUntrusted,
58-
Confidentiality: []Confidentiality{ConfidentialityPrivate},
58+
Confidentiality: ConfidentialityPrivate,
5959
}
6060
}
6161

pkg/ifc/ifc_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestLabelSearchIssues(t *testing.T) {
4545
t.Parallel()
4646
label := LabelSearchIssues(tc.visibilities)
4747
assert.Equal(t, IntegrityUntrusted, label.Integrity)
48-
assert.Equal(t, []Confidentiality{tc.wantConfidential}, label.Confidentiality)
48+
assert.Equal(t, tc.wantConfidential, label.Confidentiality)
4949
})
5050
}
5151
}

0 commit comments

Comments
 (0)