fix(safety): explicit fork-PR behavior for read-only tokens (#79)#80
Merged
Conversation
The non-bot status write aborted the job when GitHub downgraded the fork-PR token to read-only, surfacing a permissions boundary as a dependency-safety scan failure. Catch the known 403, emit a notice and job-summary line, stay green; other failures and the bot/final paths stay fail-loud. Refs #79
…nion Explain that external fork PRs receive a read-only token despite statuses: write, that the workflow now logs a notice instead of a red scan failure, and add a status-only pull_request_target companion that posts the required gate without checking out or running PR code. Refs #79
This was referenced Jun 6, 2026
Closed
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.
What
dependency-safety.ymlaborted the job when GitHub gave an external fork PR'sGITHUB_TOKENa read-only token, surfacing a permissions boundary as adependency-safety scan failure. The gate step posted the
dependency-safety / gatecommit status before skipping non-Dependabot PRs; on an external forkrun that POST returns
403 Resource not accessible by integration, the job goesred, and — if the status is a required check — the fork PR is wedged with no
contributor remedy. Reproduced on a downstream consumer's external fork PR.
Changes
successstatus write is nowpermission-aware. It captures the
gh apiresult and treats only the knownread-only denial as expected — matched on both the permission message
(
Resource not accessible by integration) and a 403 marker(
HTTP 403or"status":"403") — logging a::notice::and a job-summaryline and staying green. Every other failure, and the bot/pending and final
status writes, stay fail-loud. Same-repo non-bot PRs are behaviorally
unchanged (they still post the success status and skip the scan).
README.md): explain that GitHub gives fork PRs a read-only tokenby default despite a declared
statuses: write(with the admin"Send write tokens to workflows from pull requests" exception noted),
distinguish the Dependabot-automation path from human fork PRs, state the
unavoidable gap (a green job still cannot post a required status from the
fork run), and add a status-only
pull_request_targetcompanion that poststhe gate without checking out or running PR-authored code
(
statuses: writeonly, cross-repoif:guard, PR values viaenv:only).tests/gate-status-guard.bats) extracts the gateblock, runs it under a GHA-equivalent shell against a stubbed
gh, and coversfour cases — a read-only 403 in
gh's CLI form, the same denial ingh api'sJSON-body form (exercising the
"status":"403"matcher branch), an unrelatederror (fails loudly), and a successful write (unchanged). A static shape guard
in
tests/guard-shape.batskeeps the non-bot write from regressing to anunconditional POST.
Existing Dependabot scan/status behavior is unchanged. No
scripts/*.shtouched(the gate step is inline YAML), so the inline-sync invariant is unaffected.
Fixes #79.