Skip to content

fix(ci): constrain and verify branch action pins - #577

Merged
vladimirrott merged 2 commits into
lacs-project:mainfrom
QinXi-ai:fix/547-verify-branch-pins
Oct 12, 2026
Merged

vladimirrott merged 2 commits into
lacs-project:mainfrom
QinXi-ai:fix/547-verify-branch-pins

Conversation

@QinXi-ai

@QinXi-ai QinXi-ai commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Any action could use a (branch) comment to bypass tag-to-SHA verification. Restrict the marker to exact dtolnay/rust-toolchain / stable in 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: stable explicit 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 return behind: 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

  • Offline action-pin fixtures and the sole-allowlist removal mutation passed their expected green/red checks.
  • Bash syntax and git diff --check passed.
  • Live action-pin verification passed all 59 references, using the unchanged Linux parser and verifier loop with authenticated local gh.
  • Security impact considered and trust boundary preserved.
  • Full workspace nextest: 1,943 passed, six configured skips; recorded baseline matched. Strict all-features/all-targets Clippy, fmt and Rust docs passed.
  • Frontend install, audit, TypeScript and 72-test baseline passed; setup tests, release/E2E fixtures, configured Markdown/YAML lint and changed-doc Markdown lint passed.
  • All executed GitHub checks passed on this head, including Rust, docs/hygiene, frontend, PostgreSQL, scripts-lint, security-audit, TruffleHog, CodeQL and container-image. Container-smoke was skipped by its workflow condition.

scripts/ci-local.sh --no-postgres completed as FAIL/INCOMPLETE: its sole failed gate was missing remote gh, 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 is stable...<pin>: behind or identical proves the pinned head is an ancestor of stable. The reachable parent is 2c7215f132e9ebf062739d9130488b56d53c060c; TruffleHog's exact tag resolves to 6f3c981e7b77f235fd2702dd74af25fc4b72bf11.

Assisted by OpenAI Codex; the full diff was reviewed and validation claims come from actual runs.

@QinXi-ai
QinXi-ai requested a review from vladimirrott as a code owner October 6, 2026 16:18

@vladimirrott vladimirrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:

  1. 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.
  2. Keep one allowlist. action-pin-comments.py raises before the shell loop ever sees the row, so the copy in verify-action-pins.sh never 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.

@QinXi-ai
QinXi-ai force-pushed the fix/547-verify-branch-pins branch from 9a4a883 to 959e3c1 Compare October 9, 2026 02:17

@vladimirrott vladimirrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@vladimirrott
vladimirrott merged commit 9d865a9 into lacs-project:main Oct 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

verify-action-pins.sh skips any action whose comment ends in (branch), not only the one it was meant for

2 participants