Repository navigation
Use REST bot logins for lockdown checks on GraphQL authors - #3782
VISHNU0906 wants to merge 2 commits into
Conversation
GraphQL returns bot logins without the [bot] suffix, so lockdown mode looked up the collaborator permission for the wrong account and dropped content from bots that do have push access. Fetch __typename alongside the author login and map Bot actors to their REST login before the permission check in get_review_comments, get_parent and the issue_read parent and closing pull request enrichment. Fixes github#3777 Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Missing bot-specific regression tests leave parent and closing-PR reference retention unprotected if author-type metadata is dropped during flattening.
1 open issue
What changed in this PR
Aligns GraphQL bot logins with REST permission lookups so lockdown can retain content from bots with push access, addressing #3777 without changing MCP tool schemas.
Changes:
- Adds actor-type-aware
[bot]normalization while preserving existing trusted-login handling. - Applies the helper to review comments and issue parent/closing-PR references.
- Adds unit tests and lockdown regression cases.
| File | Description |
|---|---|
pkg/lockdown/lockdown.go |
Adds GraphQL actor login normalization for lockdown checks. |
pkg/lockdown/lockdown_test.go |
Tests normalization, user distinction, trusted-login handling, and nil-cache behavior. |
pkg/github/pullrequests.go |
Fetches author types and normalizes review-comment permission checks. |
pkg/github/pullrequests_test.go |
Tests retaining bot review comments under lockdown. |
pkg/github/issues.go |
Propagates author types through parent and closing-PR checks. |
pkg/github/issues_test.go |
Updates query fixtures and tests bot-authored get_parent results. |
Review effort: Max (auto)
| return false | ||
| } | ||
| safe, err := cache.IsSafeContent(ctx, authorLogin, owner, repo) | ||
| safe, err := cache.IsSafeActorContent(ctx, authorLogin, authorTypeName, owner, repo) |
There was a problem hiding this comment.
Good catch, added in abc470e. Test_GetIssue_Enrichment_Lockdown_BotAuthors runs issue_read get under lockdown with a Bot parent and two Bot closing PRs, where write access exists only for the [bot] logins. The parent and the bot with push access are kept, and a bot without push access is still filtered. Dropping AuthorTypeName from either the parent or the closing PR flattening now fails the test. ./script/lint and go test -race ./... pass.
The issue_read get enrichment fixtures had no __typename, so dropping AuthorTypeName while flattening the query would not fail any test. Add Bot fixtures whose write access exists only under their [bot] login, plus a bot without push access that must still be filtered. Signed-off-by: KVR Vishnu <46535652+VISHNU0906@users.noreply.github.com>

Summary
Lockdown mode now checks bot authors from GraphQL results under their REST login (
name[bot]), so content from bots with push access is no longer filtered out.Why
Fixes #3777
Thanks for the clear report @MartinNowak. GraphQL returns
dependabotwhere the collaborators permission endpoint expectsdependabot[bot], so the lookup hit the wrong account and failed closed.What changed
lockdown.RepoAccessCache.IsSafeActorContenttakes the GraphQL__typenameand appends[bot]forBotactors that don't already have it. Trusted bots are checked first, soCopilot(same login in both APIs) behaves as before.get_parentauthor, and the parent and closing pull request authors in theissue_readenrichment query now fetch__typenameand go through that helper.Userwith the same name, Copilot and a nil cache. Each one fails if the mapping is removed.MCP impact
Tool schemas are unchanged. The only behavior change is that lockdown stops dropping content from bots that have push access.
Prompts tested (tool changes only)
Security / limits
The suffix is only added when GraphQL reports
__typename: Bot, so a user account can't pass as a bot. Everything still fails closed on lookup errors.Tool renaming
Lint & tests
./script/lint./script/testDocs