Repository navigation
fix(ci): constrain and verify branch action pins - #577
Conversation
vladimirrott
left a comment
There was a problem hiding this comment.
Reviewed at 9a4a883d. One blocking item, in the test.
The reachability check is the part I liked most. You compare stable...<sha> and accept only identical or behind, so a fork-only commit comes back diverged and fails. I checked both pins upstream:
$ gh api repos/dtolnay/rust-toolchain/compare/stable...4cda84d5c5c54efe2404f9d843567869ab1699d4 --jq .status
diverged
$ gh api repos/dtolnay/rust-toolchain/compare/stable...2c7215f132e9ebf062739d9130488b56d53c060c --jq .status
behind
$ gh api repos/trufflesecurity/trufflehog/git/ref/tags/v3.96.0 --jq .object.sha
6f3c981e7b77f235fd2702dd74af25fc4b72bf11
So the pin on main today would fail your new check, and that explains the re-pin. The TruffleHog tag resolves to the SHA in the diff, and it sits one commit ahead of the old main pin, so nothing moves backwards. The toolchain: stable inputs are needed now that the ref is a SHA.
Blocking: the allowlist from #547 has no test that fails without it. I ran tests/release/action-pin-comments.test.sh in a container with no network against five trees:
| Tree | rc |
|---|---|
| this head | 0 |
Python allowlist (if (action, branch) != (...) and its raise) replaced by pass |
0 |
shell allowlist if [[ "$action" != dtolnay/rust-toolchain || ... ]] replaced by if false |
0 |
| both removed | 0 |
identical|behind) widened to *) |
1 |
With both allowlists gone, actions/checkout ... # main (branch) still fails, because the gh stub has no compare arm for actions/checkout and returns 404, and ERROR actions/checkout ... cannot verify branch main reachability matches 'actions/checkout.*branch'. Against the real API the reachability check would accept it: gh api repos/actions/checkout/compare/main...3d3c42e5aac5ba805825da76410c181273ba90b1 --jq .status returns behind.
Two changes fix it:
- Assert on the refusal itself. With
expect_failure '<action>.*not allowed'in the three marker cases, I measured rc=0 on this head and rc=1 with both allowlists removed. - Keep one allowlist.
action-pin-comments.pyraises before the shell loop ever sees the row, so the copy inverify-action-pins.shnever runs, and with two copies, removing either one leaves the test green (I measured both with the stronger assertion too: rc=0 each). I'd keep the Python one, since it fails while parsing, and delete the shell branch.
Nothing else blocks. I did not build or execute this branch on my machine; every run above was in a --network=none container with the tree read-only. This PR edits .github/workflows/**, so I'll read the final diff and merge it myself rather than through the automated path.
9a4a883 to
959e3c1
Compare
vladimirrott
left a comment
There was a problem hiding this comment.
Approving at 959e3c13.
You did both things I asked for. The three marker cases now expect not allowed, and the allowlist lives in action-pin-comments.py alone, with the shell copy gone. The stub's new compare arms are the part I'd have missed: they make actions/checkout@main, rust-toolchain@nightly and the subpath case reachable, so nothing except the allowlist can refuse them.
I re-ran tests/release/action-pin-comments.test.sh in a container with no network and the tree read-only, against your head and three mutations:
| Tree | rc |
|---|---|
| this head | 0 |
Python allowlist if (action, branch) != (...) replaced by if False: |
1 (checker unexpectedly passed) |
identical|behind) widened to *) |
1 |
The shell allowlist row from my last table no longer applies, since verify-action-pins.sh mentions rust-toolchain only in a comment now. I did not build or run this branch on my machine.
Nothing blocks. This PR edits .github/workflows/**, so I'll read the workflow diff once more and merge it by hand rather than through my automated path.
Entries for #570, #571, #572, #573, #575, #576, #577, #578, #579, #584, #586, #587, #589, #592, #594 and #603, plus the dependency bumps in #595, #596, #597, #599 and #600. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UpyrhbDTW1gBwzGAC44GYU
Summary
Any action could use a
(branch)comment to bypass tag-to-SHA verification. Restrict the marker to exactdtolnay/rust-toolchain/stablein the Python parser and verify the pin is reachable from that branch. API errors and unexpected comparison states fail closed.The original toolchain pin is a generated stable commit that has diverged from the branch. Replace its seven occurrences with the reachable direct parent and make
toolchain: stableexplicit at previously defaulted sites. Migrate TruffleHog's disallowed branch marker to the exact v3.96.0 tag; its action metadata is unchanged. The review revision retains these same workflow pins.The parser now owns the sole allowlist. The three forbidden-marker cases assert
not allowed, and their mocked API comparisons deliberately returnbehind: the regression must reject the marker even when its commit is reachable. Removing the parser guard makes the checker pass and the regression fail; reachability failures can no longer mask a missing allowlist.Related Issue
Closes #547.
Validation
git diff --checkpassed.gh.scripts/ci-local.sh --no-postgrescompleted as FAIL/INCOMPLETE: its sole failed gate was missing remotegh, covered by the live equivalent verification above. Markdown-link-check, ShellCheck and cargo-audit were unavailable; the non-root run skipped privileged action-steps assertions and the requested local PostgreSQL skip. These remaining gates require Ubuntu CI. No Rust tests or measured baseline files change in this PR.Notes for Reviewers
Rebased onto main at
d4a702e. The comparison isstable...<pin>:behindoridenticalproves the pinned head is an ancestor of stable. The reachable parent is2c7215f132e9ebf062739d9130488b56d53c060c; TruffleHog's exact tag resolves to6f3c981e7b77f235fd2702dd74af25fc4b72bf11.Assisted by OpenAI Codex; the full diff was reviewed and validation claims come from actual runs.