ci: drop the redundant PR-head checkout from claude.yml - #2070
Open
cliffhall wants to merge 1 commit into
Open
Conversation
Code scanning alert 71 (actions/untrusted-checkout/high) has stayed open against main at the `Checkout PR branch` step — the same step #1966 added the `is_fork == 'false'` guard to. The rule is syntactic, so it cannot see that guard, the job-level author_association check, or the repo's `collaborators_only` fork-PR policy; no hardening around the step clears it while the step exists. The step turns out to be redundant anyway. claude-code-action fetches and checks out the PR branch itself, and its own docs name a bare base-ref checkout as the preferred pattern — which is what upstream's own claude.yml does. Our lookup-then-checkout pair is vestigial from the v1 example workflow inherited in #1869. So: delete the PR-head checkout, make the base checkout unconditional, and drop the now-unused `sha` output. The `is_fork` gate on Run Claude Code stays, and is now the only thing keeping fork code out of the workspace — the action fetches a cross-repository head via refs/pull/N/head on its own. Closes #2069 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JTHVxSu8AUgHRLvo1ntZ8H Signed-off-by: cliffhall <cliff@futurescale.com>
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.
Closes #2069
Code scanning alert #71 (
actions/untrusted-checkout/high) has stayed open againstmainat.github/workflows/claude.yml:91— theCheckout PR branchstep, i.e. the step #1966 added theis_fork == 'false'guard to. The alert is current, not a stale pre-#1966 instance:Why it can't be argued away
The rule is syntactic: privileged trigger (
issue_comment) +actions/checkoutwith aref:derived from PR data ⇒ high. It does not evaluatesteps.pr.outputs.is_fork(a runtime step output), the job-levelauthor_associationgate, or the repo'spull_request_creation_policy: collaborators_only(verified against the API). All three of #1966's mitigations are invisible to it, so no further hardening around the step clears the alert while the step exists. The choice was dismiss-as-false-positive or remove the step.The step was redundant
anthropics/claude-code-actionchecks out the PR branch itself. Fromsrc/github/operations/branch.tsat the pinned v1.0.190:Its own
docs/security.mdnames a bare base-ref checkout (noref:) as the preferred pattern, and upstream's own.github/workflows/claude.ymlis exactly that — oneactions/checkout, no PR lookup, no head checkout. OurGet PR details→Checkout PR branchpair is vestigial from the v1 example workflow inherited in #1869; the action re-checked-out the same branch moments later on every PR run.So this removes the alert legitimately rather than by dismissal, and drops one redundant checkout plus one
github-scriptround trip per PR run.What changed
Checkout PR branch(the flagged step).Checkout repositoryis now unconditional — base ref, noref:input, so nothing a PR controls selects what is checked out. (It still carries an implicitsuccess(), so a failed lookup skips it, same as before.)shaoutput fromGet PR details;is_forkis its only consumer.Get PR details,Decline fork PR, and theis_forkgate onRun Claude Code, unchanged.Resolved conditions:
steps.pr.outcomeis_forkskippedsuccessfalsesuccesstruefailuresuccess())The gate that must not go
Keeping the
is_forkgate is load-bearing, and more so after this change, not less. The action fetches a cross-repository head on its own viarefs/pull/N/head:So skipping
Run Claude Codeis now the only thing keeping fork code out of the workspace. The comment onDecline fork PRsays this explicitly so nobody removes it as dead weight once the visible checkout is gone.Testing
No test surface — workflow file only. Workflows run from the default branch, so this is inert until
v2/mainreachesmainat the next milestone merge; alert 71 clears on the CodeQL run after that.npm run cipasses.checkoutv7.0.1,github-scriptv9.0.0,claude-code-actionv1.0.190).No UI change, so no screenshots.
🤖 Generated with Claude Code
https://claude.ai/code/session_01JTHVxSu8AUgHRLvo1ntZ8H