Skip to content

v3.0.0 ci: test the pinned-tool installer's outage and integrity guards - #392

Merged
Anatolie merged 1 commit into
3.x.xfrom
test-pinned-tool-installer
Sep 15, 2026
Merged

Anatolie merged 1 commit into
3.x.xfrom
test-pinned-tool-installer

Conversation

@Anatolie

@Anatolie Anatolie commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Summary

#380 hardened .github/scripts/install-pinned-tool.sh against release-host outages, but its validation harness lived outside the repository and was described in the PR body, so nothing in CI exercised the retry window, the hard deadline, the verified cache, or the fail-closed handling of bad cache entries. A refactor could break any of those while both required checks stayed green. This commits that harness as .github/scripts/test-install-pinned-tool.sh and runs it as a step in lint-compile-compose.

The test is hermetic: a Python http.server on 127.0.0.1 stands in for the release host, driven by a control file (serve, 504 until a deadline, 404, stall, refuse) and logging every connection so scenarios assert request counts, not only exit statuses. No network, no Docker, no GitHub reachability.

Two narrow bridges close the gap between a hermetic test and the installer's hardcoded pins and 180/210-second timing, and both leave every guard as the committed code:

  • A routing-only curl shim on PATH rewrites the pinned https://github.com/ URL to the loopback host and execs the real curl with every other argument untouched, so the installer's own retry, deadline, and error handling run as written. The shim refuses any other http(s) URL, so an accidental network reach fails the test.
  • Scripts under test are derived from the committed installer by replacing exactly four whole lines — the two sha256= pins (with the digests of the fixture assets) and the two timing lines. Each line must match exactly once, and a diff against the committed file must show only those lines, so an edit to any guard flows straight into the test and an edit to a substituted line fails loudly. sha256sum is never shimmed: verify() runs as committed, only the expected value differs. The pure-failure scenarios also run against the unmodified installer, with its real pins and timing, through the shim alone.

38 scenarios and 453 assertions cover both tools (the cargo-deny tar.gz path and the hadolint bare-binary path) in about 22 seconds:

Scenario Asserted
504 for longer than the pre-#380 seven-second window, then the real asset Install succeeds; retries observed
Warm verified cache, host refusing every connection Install succeeds with zero requests
Warm cache under a path sha256sum cannot name Passes only because the private copy is what is checked
Substituted download bytes, with and without a cache Non-zero exit, nothing installed, nothing executed
Poisoned cache: wrong bytes, a FIFO, a symlink to a FIFO, a symlink to a digest-correct file Rejected, no refetch, nothing installed
404 Fails immediately, one request, under a time bound
Stalled transfer Killed by the hard deadline, no digest message
Pins Both versions and both digests asserted against current values

Bad assets and poisoned cache entries carry an execution marker: running them touches a sentinel file, which must never appear.

Pins and installer behaviour are unchanged; this adds coverage only.

Validation

  • Adversarial mutation pass: 12/12 guard reversions make the test fail, each on a scratch copy — the regular-file check, the copy-to-private-scratch-then-verify ordering, fail-closed on a bad cache entry (made to refetch), the post-download digest check (with and without a cache dir), --retry-all-errors on a 404, the deadline deleted / disabled / its exit status ignored, a pin bump, and a reachability probe added before the cache check.
  • Two mutations were initially masked and the assertions were tightened until both were caught: the post-download check was masked by the cache-publish check's similar message (fixed by asserting the exact message naming the URL, plus a no-cache variant), and the dropped deadline status was masked by the digest check rejecting the partial body (fixed by asserting no digest message appears in the stalled run).
  • Four consecutive full runs at 22.1–22.3s on Ubuntu 24.04.
  • shellcheck -x clean (the job lints every tracked *.sh), bash -n clean, actionlint 1.7.12 clean.

Not covered, deliberately: the "verify the private copy, then install from the shared entry" mutation is not detectable without a race; a continuous-504 exhaustion run would cost the whole retry window. Removing the regular-file check is caught through the 20-second per-run bound, since cp on a FIFO blocks by nature.

Closes #389

Integration notes

Target branch: 3.x.x. Close #389 manually after merge, because the closing keyword does not apply to this non-default base.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

#380 hardened install-pinned-tool.sh against release-host outages, but its
validation harness lived outside the repository, so nothing in CI exercised
the retry window, the hard deadline, the verified cache or the fail-closed
handling of bad cache entries. Commit that harness as
.github/scripts/test-install-pinned-tool.sh and run it in
lint-compile-compose.

The test is hermetic: a Python http.server on 127.0.0.1 stands in for the
release host, and a routing-only curl shim on PATH sends the pinned
https://github.com/ URL there while passing every other argument through
to the real curl. Scripts under test are derived from the committed
installer by replacing exactly four whole lines (the two sha256= pins with
the fixture digests, the timeout --signal=KILL line and the --retry line);
each must match once and a diff must show nothing else, so every guard
runs as committed and sha256sum is never shimmed. The pure-failure
scenarios also run against the unmodified installer through the shim alone.

38 scenarios and 453 assertions cover both tools in about 22 seconds:
a 504 outage longer than the old seven-second window, a warm cache with
the host refusing connections (zero requests), a warm cache under a path
sha256sum cannot name (the private copy is what is checked), substituted
download bytes with and without a cache, poisoned cache entries with wrong
bytes, a FIFO, a symlink to a FIFO and a symlink to a digest-correct file,
a 404 failing fast, a stalled transfer killed by the deadline, and the pins
themselves. Bad assets carry an execution marker that must never appear.

Closes #389

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T17:18:35.661035Z 4ee9838 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant