fix: anchor checksum field matching and add sha256sum fallback#66
Open
kitsuyui wants to merge 1 commit into
Open
fix: anchor checksum field matching and add sha256sum fallback#66kitsuyui wants to merge 1 commit into
kitsuyui wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Two issues were found in the checksum verification logic in
action.yml:Unanchored grep matching:
grep -F " ${target}"performs substring matching without end-of-line anchoring. If upstream ever adds a release artifact whose filename ends with the same suffix as an existing one (e.g. a.sigfile), the extracted.sha256file would contain multiple lines, causingsha256sum --checkto fail with a misleading "no such file or directory" error.sha256sum portability:
sha256sumis a GNU coreutils command and is not present on bare macOS/BSD. GitHub-hosted runners have Homebrew coreutils installed so this is not normally a problem, but self-hosted runners and localactruns fail withcommand not found.Changes
Added
sha256_verify()helper function immediately afterset -euo pipefail. The function preferssha256sumwhen available and falls back toshasum -a 256for BSD/macOS compatibility.Replaced
sha256sum --check -withsha256_verify -for the checksums file anchor verification step.Replaced
grep -qF " ${target}"withawk -v t="${target}" '$2 == t {found=1} END {exit !found}'for the existence check, performing exact field-2 matching instead of substring matching.Replaced
grep -F " ${target}"withawk -v t="${target}" '$2 == t'for the line extraction step, ensuring only lines where field 2 exactly equals the target filename are included.Replaced
sha256sum --checkwithsha256_verifyfor the archive checksum verification step.Verification
Tested locally. There is no behavioral change for current gibo releases where all artifact filenames are unique — the
awkexact-field match produces the same single-line output as the previousgrepfor non-conflicting filenames.Trade-offs
The
sha256_verify()helper adds a runtimecommand -vcheck per invocation. This is a negligible cost for an install action that runs once per workflow job.