Skip to content

Use REST bot logins for lockdown checks on GraphQL authors - #3782

Open
VISHNU0906 wants to merge 2 commits into
github:mainfrom
VISHNU0906:fix/lockdown-graphql-bot-login
Open

VISHNU0906 wants to merge 2 commits into
github:mainfrom
VISHNU0906:fix/lockdown-graphql-bot-login

Conversation

@VISHNU0906

Copy link
Copy Markdown

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 dependabot where the collaborators permission endpoint expects dependabot[bot], so the lookup hit the wrong account and failed closed.

What changed

  • lockdown.RepoAccessCache.IsSafeActorContent takes the GraphQL __typename and appends [bot] for Bot actors that don't already have it. Trusted bots are checked first, so Copilot (same login in both APIs) behaves as before.
  • The review thread author, the get_parent author, and the parent and closing pull request authors in the issue_read enrichment query now fetch __typename and go through that helper.
  • Tests: a bot review comment that is kept under lockdown, a bot-authored parent issue, and unit tests for the login mapping, a User with the same name, Copilot and a nil cache. Each one fails if the mapping is removed.

MCP impact

  • No tool or API changes
    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)

  • Not a tool change.

Security / limits

  • Auth / permissions considered
    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

  • I am not renaming tools as part of this PR

Lint & tests

  • Linted locally with ./script/lint
  • Tested locally with ./script/test

Docs

  • Not needed

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>
@VISHNU0906
VISHNU0906 requested a review from a team as a code owner November 9, 2026 20:08
Copilot AI adaptive review requested due to automatic review settings November 9, 2026 20:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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)

Comment thread pkg/github/issues.go
return false
}
safe, err := cache.IsSafeContent(ctx, authorLogin, owner, repo)
safe, err := cache.IsSafeActorContent(ctx, authorLogin, authorTypeName, owner, repo)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lockdown mode fails to check permissions of custom bot accounts when retrieving pull request reviews

2 participants