Skip to content

feat(gh-r): verify release asset checksums - #851

Open
LUX-ETVERITAS wants to merge 4 commits into
zdharma-continuum:mainfrom
LUX-ETVERITAS:feat/gh-r-checksum
Open

LUX-ETVERITAS wants to merge 4 commits into
zdharma-continuum:mainfrom
LUX-ETVERITAS:feat/gh-r-checksum

Conversation

@LUX-ETVERITAS

Copy link
Copy Markdown

Summary

Adds a checksum ice for from'gh-r' downloads, so a release asset can be verified before it is extracted or moved into place. Closes #292.

# Discover <asset>.sha256/.sha512 or a SHA256SUMS/checksums.txt manifest.
zinit ice from'gh-r' checksum'auto'
zinit light BurntSushi/ripgrep

# Pin an explicit digest.
zinit ice from'gh-r' checksum'sha256:<64 hex>'

# Point at a specific checksum manifest.
zinit ice from'gh-r' checksum'https://github.com/jqlang/jq/releases/download/jq-1.8.2/sha256sum.txt'

checksum is opt-in. Existing gh-r recipes are unchanged.

Behavior

  • auto tries per-asset sidecars (<asset>.sha256, .sha256sum, .sha512, .sha512sum) and common manifests (SHA256SUMS, SHA256SUMS.txt, sha256sum.txt, sha256sums.txt, checksums.txt, checksums-sha256.txt).
  • Parses GNU (hash file, hash *file), BSD (SHA256 (file) = hash), file: hash, filename-first, and hash-only sidecars, including CRLF.
  • auto fails closed: if no checksum file, or no entry for the selected asset, is found, the install/update is aborted.
  • A mismatch removes the downloaded file and aborts before extraction / mv / hooks.
  • Verification also applies on zinit update: the ice is persisted in ._zinit/checksum like other ices.
  • zinit update now returns a non-zero status when the gh-r setup step fails (previously the error was printed but the update still returned 0).

Implementation

  • zinit.zsh: register checksum in ZINIT[ice-list] and validate its value at parse time.
  • zinit-install.zsh: add sha256/sha512 digest helpers, checksum-file parsers, auto discovery, and the verification call in the gh-r download loop.
  • zinit-autoload.zsh: propagate gh-r setup failures from zinit update.
  • Hash tool support: sha256sum/sha512sum, shasum, openssl dgst, sha256/sha512, and certutil.

Tests

Run on Linux x86_64:

  • zunit run tests/checksum.zunit — 24/24 passed
  • zunit run 'tests/gh-r.zunit@checksum sidecar with gh-r' — passed
  • zunit run 'tests/gh-r.zunit@checksum manifest with gh-r' — passed (covers install, successful update, and failed update)
  • zunit run tests/ice-validation.zunit — 43/43 passed
  • zunit run tests/commands.zunit — 18/18 passed
  • zunit run tests/ices.zunit — 28/28 passed
  • zunit run tests/annexes.zunit — 11/11 passed
  • markdownlint on README.md — passed
  • zsh -n and zcompile on the modified .zsh files — passed

The new checksum test file is added to the CI matrix, so macOS/Ubuntu coverage will run in CI.

Security note

The checksum is fetched from the same release. This detects corrupted downloads and wrong-asset selection, but not a compromised upstream account. GPG signature verification (.sig/.asc) is intentionally left for a follow-up because it needs an isolated keyring and an explicit key-source policy.

Related

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[feat]: gh-r can validate checksums

1 participant