Repository navigation
Check the PR author's repo permission instead of org association - #28
Merged
Merged
Conversation
tnsardesai
requested review from
sjmiller609
and removed request for
sjmiller609
October 27, 2026 21:36
Contributor
Author
|
@sjmiller609 my agent went rogue trying to figure out how to get the right permission to gate approval to owners only! so sorry for some many review requests. I just manually tested that this version though and it looks good! So this should work See https://github.com/kernel/infra/actions/runs/40590614886/job/122493576280 which tests that And see https://github.com/kernel/infra/actions/runs/40590621451 which tests the happy case. Leaving a comment like https://github.com/kernel/infra/pull/1852#issuecomment-6454580049 |
sjmiller609
approved these changes
Oct 28, 2026
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
#26 and #27 didn't fix the "author is not an org member" skips, because no token we have can see private org membership. Every Kernel member is private. A throwaway probe run in kernel/infra checked three tokens (the workflow token, a
kernel-internalrepo token, and akernel-internaltoken requested withmembers: read):author_association, from the API and from thepull_requestpayloadCONTRIBUTORfor org membersGET /orgs/kernel/members/{user}GET /repos/{repo}/collaborators/{user}/permissionwrite/adminfor members,noneforkernel-internal[bot]and outsidersSo the check is now "the author has write or admin access to the repo", read with the workflow token. Bots have no repo permission and are still skipped. The one difference from "org member" is that an outside collaborator with write access would also qualify, and they can already push to the repo.
This also removes the read-only app token #27 added, since the workflow token is enough. The credential layout is back to how it was in #25.
Testing
CONTRIBUTOR, so the tests fail if the check goes back toauthor_association. New cases coverread/nonepermission, a silent skip for a bot author, and the exactgh apicall for the permission endpoint, including URL-quotingkernel-internal[bot]. All 41 repo tests pass and actionlint is clean.kernel-internal[bot]) is skipped with "author does not have write access".Note
Medium Risk
Changes who enters automated PR risk classification—a security workflow gate—though behavior aligns with intended trust (people who can push).
Overview
Fixes PR Risk incorrectly skipping private org members, who always appear as
CONTRIBUTORonauthor_associationregardless of token.Eligibility now requires the PR author to have
adminorwriteon the repo viaGET .../collaborators/{user}/permission, which correctly identifies members while still excluding bots (none) and read-only users. Outside collaborators with write access qualify as well—they can already push.The
Generate read tokenGitHub App step is removed; Gather usesgithub.tokenagain because the workflow token is sufficient for the permission API. Docs and tests are updated for the new skip reason and API call (including URL-encoding for bot logins).Reviewed by Cursor Bugbot for commit 29b35e8. Bugbot is set up for automated code reviews on this repo. Configure here.