lockdown mode: remove RepoAccessCache singleton and isolate viewer st… · github/github-mcp-server@b5397f6 · GitHub
Skip to content

Commit b5397f6

Browse files
kerobbiSamMorrowDrums
authored andcommitted
lockdown mode: remove RepoAccessCache singleton and isolate viewer state per instance
1 parent 3fbf64f commit b5397f6

5 files changed

Lines changed: 231 additions & 107 deletions

File tree

‎internal/ghmcp/server.go‎

Lines changed: 1 addition & 1 deletion

‎pkg/github/dependencies.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ func (d *RequestDeps) GetRepoAccessCache(ctx context.Context) (*lockdown.RepoAcc
399399
}
400400

401401
// Create repo access cache
402-
instance := lockdown.GetInstance(gqlClient, restClient, d.RepoAccessOpts...)
402+
instance := lockdown.NewRepoAccessCache(gqlClient, restClient, d.RepoAccessOpts...)
403403
return instance, nil
404404
}
405405

‎pkg/github/issues_test.go‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,15 @@ func (rt *repoAccessMockTransport) RoundTrip(req *http.Request) (*http.Response,
7070
value = repoAccessValue{isPrivate: false}
7171
}
7272

73-
responseBody, err := json.Marshal(map[string]any{
74-
"data": map[string]any{
75-
"viewer": map[string]any{
76-
"login": "test-viewer",
77-
},
78-
"repository": map[string]any{
79-
"isPrivate": value.isPrivate,
80-
},
81-
},
82-
})
73+
data := map[string]any{}
74+
if strings.Contains(payload.Query, "viewer") {
75+
data["viewer"] = map[string]any{"login": "test-viewer"}
76+
}
77+
if strings.Contains(payload.Query, "repository") {
78+
data["repository"] = map[string]any{"isPrivate": value.isPrivate}
79+
}
80+
81+
responseBody, err := json.Marshal(map[string]any{"data": data})
8382
if err != nil {
8483
return nil, err
8584
}

‎pkg/lockdown/lockdown.go‎

Lines changed: 86 additions & 73 deletions

0 commit comments

Comments
 (0)