Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes lockdown-mode permission checks by switching from a GraphQL collaborators-based approach (which can silently return empty results under limited tokens) to the REST Repositories.GetPermissionLevel endpoint, and expands the trusted bot list to avoid unnecessary lookups for known-safe actors.
Changes:
- Replace GraphQL collaborators permission checks with REST
GetPermissionLevel, keeping GraphQL only for repo metadata (viewer.login,isPrivate). - Thread a REST client into the lockdown
RepoAccessCache(singleton + new constructor for test isolation) and optimize cache-hit flows to skip GraphQL. - Update lockdown-related tests and add
github-actions[bot]to the trusted bot list.
Show a summary per file
| File | Description |
|---|---|
| pkg/lockdown/lockdown.go | Switches permission lookup to REST and adjusts cache construction / trusted-bot behavior. |
| pkg/lockdown/lockdown_test.go | Updates cache tests to mock REST permission responses. |
| pkg/github/server_test.go | Refactors test helpers to build a RepoAccessCache with an optional REST client + REST permission mock. |
| pkg/github/pullrequests_test.go | Updates PR lockdown tests to use REST permission mocking. |
| pkg/github/issues_test.go | Updates issue lockdown tests to use REST permission mocking and revised GraphQL metadata mock. |
| pkg/github/dependencies.go | Wires REST client into lockdown.GetInstance during request dependency construction. |
| internal/ghmcp/server.go | Wires REST client into lockdown.GetInstance for stdio server initialization. |
Copilot's findings
- Files reviewed: 7/7 changed files
- Comments generated: 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the GraphQL
repository.collaboratorspermission check in lockdown mode with the REST GetPermissionLevel endpoint, and addgithub-actions[bot]to the trusted bots list.Lockdown filtering behaviour is preserved; same trust model (push access = trusted), same fail-closed error handling.
Why
Lockdown mode filters issue and PR content on public repos based on whether the author has push access to the repository. It does this using the GraphQL
repository.collaboratorsfield, but this field requires the calling token to have admin/write access on the repo to enumerate collaborators.GITHUB_TOKENand GitHub App installation tokens typically don't have this, so the query silently returns empty results (no error), and lockdown ends up treating every author as untrusted, blocking all content.The REST
GetPermissionLevelendpoint works with any authenticated token and returns the exact permission level.What changed
GetPermissionLevelfor permission checks (kept GraphQL for repo metadata only:viewer.login,isPrivate)restClientas a positional parameter onGetInstanceand wired it throughNewRepoAccessCacheconstructor for test isolationgithub-actions[bot]to trustedBotLoginsisTrustedBotcheck before API calls inIsSafeContentto skip unnecessary lookups for trusted botsMCP impact
Security / limits
GetPermissionLevelrequires onlymetadata: read(included by default on all token types as far as I know) and works with any authenticated token on public repos.Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lint./script/testDocs