Repository navigation
test(ci): enforce the fork-execution invariant in claude-run.yml - #7026
Merged
Merged
Conversation
The review workflow checks out fork code with secrets in scope, and the only thing keeping that safe was a comment saying no step may run the checked-out tree without the same-repo gate. A new test now fails if any step after the checkout installs, builds or runs workspace code (or uses a local action) without that gate, if any other workflow opts into unsafe PR checkout, or if a caller requests the evidence stage outside pull_request_target.
This comment has been minimized.
This comment has been minimized.
… fork guard The evidence stage is designed for pull_request_target only; its gate now requires that event alongside a same-repo head, and the guard treats a step as gated only when it requires both. The guard also catches more shell forms and workspace paths, starts watching at a gh pr checkout, allows only listed actions after a checkout, checks every workflow that calls claude-run.yml, and ignores comments when looking for unsafe checkout.
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.
The PR-review workflow checks out fork code while holding the Anthropic credential and a write-scoped token. It stays safe only because no step runs that code unless the PR comes from this repo, and until now a code comment was the only thing enforcing that. A unit test now fails CI if any step after a checkout installs, builds or runs the checked-out tree without requiring both
pull_request_targetand a same-repo head. It also fails on any action not on an explicit allowlist, on any other workflow that opts into unsafe PR checkout, and on any caller that asks for the evidence stage outsidepull_request_target. The evidence stage is designed for pull_request_target only. Its gate now says so explicitly, and its only caller already runs on that event, so behaviour is unchanged.Test plan
python -m pytest tests/unit/test_claude_run_fork_gate.py tests/unit/test_evidence_harness_failure_signal.pypassesDetect testable surfacefails itif npm test; then,while pytest; do,! npm ci,{ npm ci; },cmd & npm ci,eval "$(cat x)","$GITHUB_WORKSPACE/x.sh",${{ github.workspace }}/x.sh,python3.12,pre-commit,docker build, an unlisted remote action, a local action||/negation bypasses, a fork-only or event-only gate,gh pr checkoutas a checkout, and safe shapes that must not be flaggedactionlintclean in CIRemaining on #2948
execution_fileoutput name on the nextclaude-code-actionbumpRefs #2948