Skip to content

ci: pin every workflow and download release artifacts by source - #2794

Merged
thiras merged 1 commit into
mainfrom
ci/pin-all-workflows
Oct 30, 2026
Merged

thiras merged 1 commit into
mainfrom
ci/pin-all-workflows

Conversation

@thiras

@thiras thiras commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

What

These are the two follow-ups from the #2783 reviews.

1. Every workflow is hardened, not only the release ones. ci.yml, codeql.yml, sdk-contract.yml and the foundry-setup composite action floated in three ways:

  • tag and branch action refs (re-actors/alls-green@release/v1 was a branch);
  • unversioned tools (tool: cargo-nextest, cargo-llvm-cov);
  • 26 checkouts that kept the token.

These jobs also write: code-quality on test/solidity-coverage, pull-requests on solidity-build-test, and security-events on codeql analyze. ci.yml's clippy cache also feeds release.yml's verify. What changed:

  • Every remote action is pinned by commit SHA with a # vX.Y.Z comment. Each floating major resolves today to the same commit as the exact tag pinned. release/v1 is identical to v1.3.0. setup-mold has only a v1 tag.
  • dtolnay/rust-toolchain is pinned to its master SHA, with toolchain: 1.99.1 added to the existing with:. This keeps the env that rust-cache hashes identical across ci.yml and release.yml.
  • Every taiki-e/install-action tool is installed at a version the pinned install-action's manifest checksums: [email protected], [email protected], [email protected]. Each step sets fallback: none.
  • Every checkout sets persist-credentials: false. Nothing needs the token after checkout:
    • submodules are fetched inside checkout;
    • paths-filter fetches its base SHA anonymously, and the repo is public;
    • the gas-snapshot and semantic-PR steps take the token from env.

Guard. check_release_hardening.py becomes check_workflow_hardening.py (with its .sh, tests, pre-commit hook and packaging step) and reads every workflow:

  • Each workflow needs a WRITE_JOBS row, so a new workflow has to declare its write grants. Rows were added for ci.yml, codeql.yml and sdk-contract.yml.
  • New rule 6: an install-action tool is [email protected] with fallback: none.
  • Against main it reports 138 errors, one for each change in this PR.

Toolchain bumps. With every dtolnay ref SHA-pinned, Dependabot's github-actions ecosystem no longer moves the Rust version. A Rust release arrives as the docker ecosystem's rust:X.Y.Z bump of deploy/sponsord, and check-toolchain-pin.sh holds that PR red until every site moves. The dependabot.yml comment, the check_toolchain_pin.py docstring and CONTRIBUTING.md § Rust Toolchain say so.

2. Release artifacts download by source (release.yml).

  • upload-assets downloads each binaries-<target> artifact into its own directory instead of merging them. An archive moves out only if its name carries that directory's target. So an extra artifact either holds a file naming another target, which fails, or adds a 16th archive, which the exact count refuses. Either way it can no longer overwrite a real archive during a merge.
  • docker downloads the two Linux artifacts by exact name.
  • attach reads each digest and SBOM from its own stage's artifact.

A step holding the run's artifact token could still replace a same-named artifact outright. The comment states that, and keeping untrusted code out of the run is the only fix.

Follows #2783.

Reviewer notes

  • This PR's own CI exercises part 1: ci.yml, sdk-contract.yml (which runs only on PRs) and codeql.yml all run with the pins, persist-credentials: false and the pinned tools. Worth checking:
    • changes (paths-filter's git fetch without stored credentials);
    • the solidity jobs (submodules);
    • test/solidity-coverage (upload-code-coverage);
    • the gas-snapshot comment.
  • Part 2 runs only on a tag. I ran the new upload-assets step's shell in a scratch layout with:
    • the real 15-archive layout: passes;
    • an impostor binaries-evil holding a linux archive name: fails;
    • a file naming another target: fails;
    • a non-binaries-* directory: fails;
    • a hidden extra file: fails;
    • an extra well-formed artifact: reaches 16 archives, which the next step refuses.
  • test_solidity_path_filter.py found the paths-filter step by its literal @v4 ref. It now matches by action name.

Verification

  • check-workflow-hardening.sh: OK (147 action refs in 5 workflows). check-toolchain-pin.sh (22 sites), check-image-name.sh and check-binstall-metadata.sh: OK.
  • uvx --python 3.12 --with pyyaml pytest .github/scripts/tests scripts/tests: 475 passed.
  • Guard mutation check. Each of these, weakened, fails at least one test:
    • rule 6's fallback check, version pattern and empty-tool check;
    • the every-workflow-has-a-row check.
  • actionlint on every workflow: only the existing code-quality scope and SC2012 findings remain.
  • pre-commit run on the changed files.
  • Every SHA resolved with gh api repos/O/R/commits/<ref>, and every tool version is listed in install-action v2.87.32's manifests.
  • clippy and nextest were not run locally, because no Rust changed. This PR's CI runs them under the new pins.
  • CHANGELOG entry under Security.

🤖 Generated with Claude Code

ci.yml, codeql.yml, sdk-contract.yml and the foundry-setup action
floated: tag and branch action refs, unversioned install-action tools,
and 26 checkouts that kept the token, under jobs that write PR comments,
code-quality and security events. Every remote action is now pinned by
commit SHA, dtolnay/rust-toolchain names its version in `toolchain:`,
every tool installs at a fixed version with `fallback: none`, and no
checkout persists credentials.

check_release_hardening.py becomes check_workflow_hardening.py and reads
every workflow: each needs a WRITE_JOBS row, and rule 6 holds the tool
pins. Dependabot no longer moves the toolchain through action refs; the
toolchain-pin docs say a Rust bump now arrives as the sponsord `rust:`
tag.

release.yml downloads each artifact into its own directory instead of
merging by pattern. upload-assets moves an archive out only when its
name carries the target its artifact is named for, docker takes the two
Linux artifacts by exact name, and attach reads each digest and SBOM from
its own stage's artifact, so an extra artifact cannot overwrite a real
file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@thiras thiras self-assigned this Oct 30, 2026
Copilot AI balanced review requested due to automatic review settings October 30, 2026 22:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The hardening check permits checksum verification to be disabled, undermining install integrity, and Windows path separators cause false failures in the pre-commit hook.

No open issues 🎉

What changed in this PR

Extends the release-pipeline hardening from #2783 across all workflows and separates release artifact downloads by source to prevent cross-artifact overwrites.

Changes:

  • Pins remaining action references and install-action tool versions, and disables persisted checkout credentials.
  • Expands the hardening guard to every workflow, with regression tests and updated CI/pre-commit integration.
  • Separates release artifact downloads and documents Rust toolchain update responsibilities.
File Description
RELEASING.md References the renamed hardening guard.
CONTRIBUTING.md Explains explicit toolchain inputs and coordinated version bumps.
CHANGELOG.md Records workflow and artifact-download hardening.
.pre-commit-config.yaml Applies the renamed guard to all workflows.
.github/​workflows/​sdk-contract.yml Pins SDK workflow actions and nextest.
.github/​workflows/​release.yml Separates artifact downloads and validates archive source names.
.github/​workflows/​codeql.yml Pins checkout and CodeQL actions.
.github/​workflows/​ci.yml Pins actions and tools, disables checkout credentials, and invokes the expanded guard.
.github/​scripts/​tests/​test_solidity_path_filter.py Matches paths-filter independently of its pinned reference.
.github/​scripts/​tests/​test_check_workflow_hardening.py Tests workflow registration and tool-pinning rules.
.github/​scripts/​check-workflow-hardening.sh Invokes the renamed Python checker.
.github/​scripts/​check_workflow_hardening.py Checks all workflows and validates install-action tool inputs.
.github/​scripts/​check_toolchain_pin.py Updates documentation of toolchain bump behavior.
.github/​dependabot.yml Clarifies toolchain update responsibilities in comments.
.github/​actions/​foundry-setup/​action.yml Pins Foundry setup and cache actions.

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

@github-code-quality

github-code-quality Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main a92727a ci/pin-all-workflows 92638ce +/-
77% 77% 0%

Solidity / code-coverage/forge

main a92727a ci/pin-all-workflows 92638ce +/-
92% 92% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated October 30, 2026 23:15 UTC

@thiras
thiras merged commit 0bd2393 into main Oct 30, 2026
39 checks passed
@thiras
thiras deleted the ci/pin-all-workflows branch October 30, 2026 23:19
thiras added a commit that referenced this pull request Nov 1, 2026
…iewing #2794 (#2809)

* ci: close workflow-hardening and release archive-check gaps found reviewing #2794

check_workflow_hardening.py rule 6 now refuses `checksum` set to anything
but `true`, and reads a wrapped plain or quoted `with:` value as YAML
folds it, so a second tool on a continuation line is checked. The
docstring and messages narrow to what the guard reads and name the
SHA-pinned actions that still install floating code.

release.yml's per-artifact archive check refuses a flat download, an
empty download, an empty artifact and hidden entries, and names the
version in its mismatch message. A new pytest runs the step from
release.yml against the build matrix's real layout and each refused one.

The toolchain-pin comments describe the post-#2794 path: the
`toolchain:` input sets the version and a Rust release arrives as the
docker ecosystem's `rust:` bump of deploy/sponsord.

Closes #2798

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: refuse hidden archive names and unclosed quotes in the hardening checks

A hidden archive whose name carries the right version and target passed
the per-artifact check, and the count and upload globs skip dotfiles, so
an impostor artifact went unnoticed. The step now refuses any dot-prefixed
name first.

check_workflow_hardening.py's with_input strips the folded value before
unquoting, so a value on the line after its key reads correctly, and
returns a quoted value whose close it did not find with its opening
quote, so every comparison fails rather than passing a truncated value.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: tighten hardening-check comments and pin the remaining guards with tests

Name every floating download the guard leaves out of scope, the clippy
cache's path into the release, rule 5's job keys, and where
download-artifact extracts flat. RELEASING.md and CONTRIBUTING.md name the
stable toolchain cargo-semver-checks-action installs.

Tests pin folding across a blank line, a checksum other than a literal
true, and the duplicate-name guard; the wrapper test drops inherited GIT_*
variables.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* ci: read input names case-blind and refuse non-file or untargeted archives

The runner matches a step's input names without regard to case, so
`Checksum: false` turned checksums off while the hardening check read the
input as unset. with_input now compares names case-blind; an expression
used as an input name joins the declared out-of-scope shapes.

The per-artifact archive check refuses an artifact named `binaries-` with
no target, and any entry that is not a regular file: a symlink moved to the
top level would be checksummed with another archive's bytes.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
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.

2 participants