feat(update): verify SHA-256 sidecar before self-replace #33
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/update-checksum-verify"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Closes the last actionable item from the post-audit backlog:
yt updatenow verifies a SHA-256 sidecar before replacing the running binary, and both Forgejo workflows emit that sidecar at publish time. This is supply-chain hardening on top of the existing TLS hop and the permission pre-check.CI side
.forgejo/workflows/build-linux.ymlandbuild-windows.ymleach gain aCompute SHA-256 sidecarstep right after the binary is extracted. The step runssha256sum <binary>and saves the GNU-format result to<binary>.sha256. The publish step then uploads the sidecar to the same Generic Package path (/latest/<binary>.sha256, plus every tagged path) and deletes the old sidecar alongside the old binary on overwrite, so the pair never drifts.CLI side
After
yt updatefinishes downloading the binary it issues a second GET for<url>.sha256:tracing::warn!and continue. This keeps installs working against pre-checksum releases until every tag has a sidecar.The sidecar parser accepts GNU
<hash> <file>, BSDSHA256 (file) = <hash>, and a bare 64-char hex digest. Verification fires after the freshness short-circuit, so an already-up-to-date binary still skips both the download and the sidecar fetch.--forcestill bypasses freshness; it does NOT bypass checksum verification because a mismatch is a security signal, not user preference.Nine new tests: parser cases (GNU, BSD, bare, rejected garbage), a known SHA-256 vector for
"abc", and four wiremock round-trips (match-allows-install, mismatch-blocks-install, missing-sidecar-is-not-fatal, unparseable-sidecar-errors). The existingnon_2xx_response_errorstest now also asserts the error message points at the binary URL, not the sidecar URL.Test plan
cargo fmt --allcargo clippy --all-targets --all-features -- --deny warningscargo test --all-targets(202 passed; was 193)sha256sum | save --raw+open --raw | decode utf-8patternbuild-linux.ymlpublishes bothyt-linux-x86_64ANDyt-linux-x86_64.sha256under the Generic Packageyt updateagainst a tag that now has a sidecar verifies and installs cleanly