Skip to content

v3.0.0 ci: make pinned tool downloads resilient to release outages - #380

Merged
kiwidream merged 2 commits into
3.x.xfrom
resilient-pinned-tool-downloads
Sep 15, 2026
Merged

kiwidream merged 2 commits into
3.x.xfrom
resilient-pinned-tool-downloads

Conversation

@kiwidream

@kiwidream kiwidream commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Pinned cargo-deny and hadolint installs exhausted their CDN retries in roughly seven seconds, causing both required checks to fail during short release outages. Restore and save the original pinned release assets with exact tool/version/SHA256 cache keys, and allow 13 transient download attempts with a 15-second delay, a 180-second retry window, and a hard 210-second download deadline.

Every cached or downloaded asset is verified against the existing SHA256 before extraction, installation, or execution. Bad cache entries fail closed, including symlinks and special files. Pins and release URLs are unchanged. GitHub remains the only download source; no maintained independent mirror was identified.

INT/TERM interrupts the download promptly, forwards termination to curl, and waits for cleanup before exiting. The hard deadline remains effective for stalled transfers.

Closes #374

Validation

A loopback HTTP server served the authentic pinned release assets after timed errors. A routing-only curl shim redirected the pinned URLs while preserving all curl arguments; the production installer and SHA256 check were unmodified. Wrong-digest assets contained an execution marker, which remained absent on every failure. Cache restore/save was simulated using the exact paths and keys emitted for both CI jobs.

Local Ubuntu 24.04, Linux x86_64, curl 8.5.0: all 26 scenarios and 248 assertions passed.

Scenario cargo-deny hadolint
504 for 175 seconds, then real asset Pass at 180.69s, 13 requests Pass at 180.98s, 13 requests
Continuous 504 Fail at 180.44s Fail at 180.42s
Stalled response Fail at 210.10s Fail at 210.12s
Missing URL (404) Fail at 0.19s, one request Fail at 0.23s, one request
Verified cache with network unavailable Pass at 0.22s, zero requests Pass at 0.32s, zero requests
Wrong download / poisoned cache Fail; no execution Fail; no execution

Also passed: non-regular cache rejection, concurrent cache writers, Retry-After handling, input checks, Docker ShellCheck, Bash syntax, unchanged pin comparison, and whitespace checks. Workflow structure validation passed. Full actionlint reports the same pre-existing SC2086 warning in the unchanged Compose validation step at the pinned base.

Independent adversarial review reproduced the outage and integrity checks. The final installer also handles cancellation promptly: all six INT/TERM scenarios across both tools exit in 0.02 seconds with the expected status, no surviving curl, clean scratch and no installation or cache publication. Bash waits interruptibly for the bounded downloader, forwards termination and reaps it before cleanup.

Integration notes

Target branch: 3.x.x. Close #374 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.

…374)

curl --retry 3 gave cargo-deny and hadolint about seven seconds of retries,
so a GitHub release CDN 504 failed both required jobs.

- Retry transient failures every 15 seconds for up to 180 seconds (12
  retries, 10-second connect and 30-second per-attempt limits) and kill the
  download at a hard 210 seconds. A 404 still fails at once.
- With PINNED_TOOL_CACHE_DIR set, keep the original release asset under
  tool/version/sha256. A cached asset must be a regular file and is copied to
  private scratch and checked against the pin before anything is extracted,
  installed or run; a bad entry fails without refetching. A new download is
  checked, then published through a checked temporary file renamed into place.
- --cache-metadata writes the actions/cache key and path, so both jobs restore
  and save the asset with actions/cache while the pins stay in the script.
@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-15T15:04:58.160721Z fad31ae 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.

@kiwidream
kiwidream merged commit 3dcc80b into 3.x.x Sep 15, 2026
20 checks passed
Anatolie added a commit that referenced this pull request Sep 15, 2026
…ds (#392)

#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]>
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