Skip to content

fix(action): retry and verify CLI downloads - #2769

Open
joshuarubin wants to merge 2 commits into
diggerhq:developfrom
joshuarubin:fix/retry-verify-cli-download
Open

joshuarubin wants to merge 2 commits into
diggerhq:developfrom
joshuarubin:fix/retry-verify-cli-download

Conversation

@joshuarubin

Copy link
Copy Markdown

Problem

The prebuilt CLI path makes one download attempt and executes the result without checking its digest. Two attempts of an OpenTaco plan failed downloading the existing v0.6.150/digger-cli-Linux-X64 asset; the next attempt downloaded it successfully.

Change

  • Retry release metadata and binary downloads with --retry 5 --retry-all-errors, a 10-second connection timeout, a 120-second request timeout, and a 300-second retry window.
  • Read GitHub's per-asset SHA-256 digest for the selected release and exact CE, EE, or FIPS asset. Fail before execution if the digest is unavailable or invalid, the file is empty, or its checksum differs.
  • Download into a private temporary directory, log the verified version and asset, and execute that exact path so another digger on PATH cannot override it.
  • Add HTTP fixtures using real curl and a Linux/macOS workflow. The fixtures exercise plan/apply inputs, existing asset naming variants, transient HTTP and truncated-transfer recovery, retry exhaustion, and rejection before execution.

The action now needs jq and either sha256sum or shasum, which are available on GitHub-hosted Linux and macOS runners. Releases whose assets have no GitHub SHA-256 digest fail closed.

Validation

  • All seven test methods pass locally with current Bash and GNU Bash 3.2.
  • GHES guard: the action withholds github.token outside GitHub.com. The fixture confirms empty tokens send no Authorization header; removing the host guard or forcing an empty-token Bearer header each makes the test fail.
  • Seven scratch mutations fail as expected: disable retries, change the retry limit, remove --retry-all-errors, bypass checksum comparison, bypass the empty-file guard, bypass digest validation, and skip execution.
  • A real download of the 115,584,180-byte v0.6.150/digger-cli-Linux-X64 asset matches GitHub digest 27759f162e57468d441006a3918b6bd230b218f09f1f55312159ec50eddc8969.
  • Ubuntu fixtures on the PR head: https://github.com/joshuarubin/digger/actions/runs/42647820064/job/129265748094
  • macOS fixtures (Intel runner, fork-only, because macos-latest had no hosted capacity): https://github.com/joshuarubin/digger/actions/runs/42650567478
  • Full fork action in the demo repository, running an empty OpenTofu plan without cloud credentials: https://github.com/joshuarubin/demo-opentofu/actions/runs/42647886059

🧠 Ai UsageDetails (if applicable):

Code, tests, and this description were written primarily by OpenAI Codex. PR responses may also be drafted with Codex assistance.

Verify the selected release asset against GitHub SHA-256 metadata before making it executable. Run the verified file directly so PATH cannot select a different binary.

This branch has not been deployed

No deployments
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