fix(ci): advisory reviewer could never comment on a fork PR (403) - #11
Merged
Conversation
Rolls out Signetry/core#92, verified there end to end before propagating. reviewer.yml runs on `pull_request` and requested `pull-requests: write`. On a PR from a fork GitHub downgrades GITHUB_TOKEN to read-only regardless of the `permissions:` block, so the grant was silently dropped and issues.createComment failed with "Resource not accessible by integration" (403). Every outside contribution showed a red `review` check and never got the advisory comment. Split into the standard trusted/untrusted pair: * reviewer.yml (untrusted, runs PR code) now holds no write permission and uploads the rendered comment + PR number as an artifact. * reviewer-comment.yml (trusted) runs on `workflow_run` from the default branch, where the token is writable, and posts it. It never checks out, builds, or executes PR code. Deliberately not `pull_request_target`: that grants a writable token in the base repo's context, and checking out PR head code under it is an RCE footgun. Also fixes a second bug found while testing the first: the advisory step's trailing `exit 0` had never run, because GitHub invokes `run:` steps as `bash -e`, so any non-zero reviewer exit (a Block verdict) aborted the step first and turned the check red — contradicting the workflow's own "never blocks the PR" contract. Bumps the signetry-reviewer pin to v0.2.0, which carries the fix for CI rules firing on YAML comments (a workflow that documented a risk tripped the rule meant to catch it).
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.
Rolls out Signetry/core#92, which was verified end to end in
corebefore propagating here.The bug
reviewer.ymlruns onpull_requestand requestedpull-requests: write. On a PR from a fork, GitHub downgradesGITHUB_TOKENto read-only regardless of thepermissions:block — so the write grant was silently dropped andissues.createCommentreturned:Every outside contribution showed a red
reviewcheck and never received the advisory comment it was supposed to get.The fix
The standard trusted/untrusted split:
reviewer.ymlpull_requestreviewer-comment.ymlworkflow_runpull-requests: writeThe untrusted job stages
comment.md+ the PR number as an artifact; the trusted job downloads it and posts. Because the trusted job never checks out, builds, or executes PR code, holding a writable token there is safe.Why not
pull_request_target: it's the one-line fix and it's the wrong one — it grants a writable token in the base repo's context, and checking out PR head code under it is a well-known RCE footgun. Not a trade a change-control product should make.Second bug, fixed here too
Found while testing the first: the advisory step's trailing
exit 0had never run. GitHub invokesrun:steps asbash -e, soset -uo pipefaildoesn't clear errexit and any non-zero exit from the reviewer (i.e. a Block verdict) aborted the step before reaching it. That contradicted the workflow's own contract — "never blocks the PR" — by turning the check red.Hardening
workflow_run.pull_requestsis empty for forks) and is filtered to digits on both write and read.eval.Also
Bumps the
signetry-reviewerpin to v0.2.0, which carries the fix for CI rules firing on YAML comments — the reviewer had been blocking PRs for documenting a risk in a comment.Verification
actionlintclean on both files. The chain itself was proven incore: theReviewer commentworkflow fired onworkflow_run, succeeded, and posted asgithub-actions[bot]; a real fork PR'sreviewcheck went red → green.One note:
workflow_runworkflows always load from the default branch, so the chain only completes for PRs opened after this merges (an existing PR needs a rebase to pick up the artifact-upload half). Not a problem, just the reason the fix can't retroactively fix in-flight PRs.