feat: add authorize-commenter action - #286
Draft
cryptodev-2s wants to merge 4 commits into
Draft
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit d30ca1c. Configure here.
| if: github.event.pull_request.head.repo.fork == false | ||
| uses: ./.github/actions/authorize-commenter | ||
| with: | ||
| username: ${{ github.actor }} |
There was a problem hiding this comment.
Bot PRs fail write-access test
Low Severity
The write-access step treats github.actor as a collaborator with push rights on every non-fork pull request. Same-repository bot PRs, including Dependabot, usually get none from the permission API, so that step fails and the new check goes red.
Reviewed by Cursor Bugbot for commit d30ca1c. Configure here.
cryptodev-2s
marked this pull request as draft
September 2, 2026 18:26
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.


Workflows triggered by
issue_commentrun from the default branch with access to secrets. The two inMetaMask/corethat use them,update-changelogsandpublish-preview, gate only on the comment body, so on a public repository anyone who can comment can start them.publish-previewpublishes to npm. There is nothing shared to check the commenter, so today each workflow would have to grow its own copy of the check.This adds an
authorize-commenteraction. It reads the commenter's repository permission and fails unless that permission iswriteoradmin. A workflow runs it as its first job and gives every privileged jobneedson that job, so a refusal skips them.A few notes on the choices:
authorizedoutput. Action outputs are strings, and every non empty string is truthy in a workflow expression, so a consumer writing the naturalif: needs.authorize.outputs.authorizedwould get'false'and a wide open gate. Failing removes the trap instead of documenting around it, and it means the integration is justneeds, with no condition to forget.github.event.comment.author_association. The association returnsNONEfor org members whose membership is private, and itsCOLLABORATORvalue does not distinguish a read only collaborator from one who can push.permissionfield collapses custom roles onto admin, write, read and none, so admin and write are exactly the logins that can push. Everyone else reads back asreadon a public repository andnoneon a private one.GITHUB_TOKENis enough. I was unsure whether that endpoint would need a token minted byget-token, so I tested it: with onlycontents: readit readswritefor a maintainer andreadforoctocat. See the run on this pull request.test-authorize-commenter.ymlcovers both directions, a login with write access being authorized andoctocatbeing refused. It triggers onpull_requestdirectly rather than throughworkflow_calllike the othertest-*.ymlworkflows, because those are not wired intomain.ymland so never run. The positive case is skipped on fork pull requests, where the author legitimately has read access.Worth knowing for whoever adopts this: it authorizes the person who wrote the comment, not the code they wrote it on. A workflow that passes this gate and then checks out the pull request head or merge ref runs untrusted code with exactly the privileges the gate was protecting. That caveat is in the action description too.
Adoption in
MetaMask/corewill be a separate pull request covering both workflows. See MetaMask/core#10077, where this came up.