Skip to content

verify-action-build: recognize fileSHA256()-style file-hash helpers as verification - #1001

Merged
dfoulks1 merged 1 commit into
mainfrom
fix/verify-recognize-file-sha256-helper
Jul 7, 2026
Merged

dfoulks1 merged 1 commit into
mainfrom
fix/verify-recognize-file-sha256-helper

Conversation

@potiuk

@potiuk potiuk commented Jul 2, 2026

Copy link
Copy Markdown
Member

Problem

The verify job on #980 (opentofu/setup-opentofu v2.0.1 → v2.0.2) fails with:

✗ lib/setup-tofu.js: 1 unverified JS download(s) (no checksum/signature check in file)

But the action does verify. lib/setup-tofu.js downloads the CLI zip and then:

const checksum = await fileSHA256(pathToCLIZip);
if (!checksums.includes(checksum)) {
  throw new Error(`Failed to validate OpenTofu CLI zip checksum.`);
}

fileSHA256 is imported from the sibling lib/util.js, where the actual
createHash('sha256') body lives, and resolveChecksums() falls back to the
release's published SHA256SUMS. Within the downloader file the only
verification evidence is the fileSHA256(...) call name — which no
_JS_VERIFICATION_PATTERN matched. So this is a false positive (case E), not a
real gap.

This is the same shape as the astral-sh/setup-uv validateChecksum() fix
(#910/#916): the hashing implementation lives in a sibling module and the call
name is the surviving in-file evidence.

Fix

Add one pattern recognizing a helper call whose name contains an explicit SHA
algorithm (fileSHA256(, getSHA512(, sha256File(, …). It stays tight enough
not to match createHash('sha256') (the paren precedes the algorithm there) or
non-SHA hashes.

Two regression tests: the bare helper-name family, and a faithful trim of the
real opentofu download→verify sequence.

Verification

  • uv run pytest utils/tests/ → 294 passed
  • prek run on the changed files → clean

Once merged, #980 (and future opentofu/setup-opentofu bumps) verify cleanly.

🤖 Generated with Claude Code

…s verification

opentofu/setup-opentofu's `lib/setup-tofu.js` downloads the CLI zip via
`tc.downloadTool()` and then validates it:

    const checksum = await fileSHA256(pathToCLIZip);
    if (!checksums.includes(checksum)) throw new Error(...);   // SHA256SUMS

`fileSHA256` is imported from the sibling `lib/util.js`, where the actual
`createHash('sha256')` body lives. Within the downloader file the only
verification evidence is the `fileSHA256(...)` call name — but none of the
`_JS_VERIFICATION_PATTERNS` matched that shape, so the v2.0.1 -> v2.0.2 bump
(#980) was false-flagged as an unverified download and the `verify` job failed.

This is the same class as the astral-sh/setup-uv `validateChecksum()` fix
(#910/#916): the hashing implementation lives in a sibling module and the
call name is the surviving in-file evidence.

Add a pattern that recognizes a helper call whose name contains an explicit
SHA algorithm (`fileSHA256(`, `getSHA512(`, `sha256File(`, ...). It stays
tight enough not to match `createHash('sha256')` (the paren precedes the
algorithm there) or non-SHA hashes. Covered by two regression tests: the bare
helper-name family and a faithful trim of the real opentofu download->verify
sequence.

Generated-by: Claude Code (Opus 4.8)
@potiuk

potiuk commented Jul 7, 2026

Copy link
Copy Markdown
Member Author

Gentle ping @ppkarwasz @dfoulks1 -- small verify-action-build enhancement here (recognizes fileSHA256()-style file-hash helpers as a verification step, so actions using that pattern aren't false-flagged). Open since Jul 2; no rush, but a review whenever you have a moment would be appreciated. Happy to walk through it if useful.

@dfoulks1 dfoulks1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dfoulks1
dfoulks1 merged commit 00a8abf into main Jul 7, 2026
8 checks passed
@dfoulks1
dfoulks1 deleted the fix/verify-recognize-file-sha256-helper branch July 7, 2026 11:38
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.

2 participants