Skip to content

verify-action-build: tighten JS download heuristic#830

Merged
potiuk merged 1 commit into
apache:mainfrom
potiuk:verify-action-build-tighten-js-download-heuristics
May 11, 2026
Merged

verify-action-build: tighten JS download heuristic#830
potiuk merged 1 commit into
apache:mainfrom
potiuk:verify-action-build-tighten-js-download-heuristics

Conversation

@potiuk
Copy link
Copy Markdown
Member

@potiuk potiuk commented May 9, 2026

Summary

#817 (graalvm/setup-graalvm@v1.5.3) flagged 7 "unverified downloads" — all 7 were false positives, surfacing three distinct gaps in the JS download / verification heuristic. Each fix is independent.

  1. accept: 'application/json' recognised as data-parse markerhttp.get(url, { accept: 'application/json' }) followed by JSON.parse(...) is a JSON metadata call. Add the accept-header regex (single- and double-quoted) to _JS_DATA_PARSE_PATTERNS.
  2. Function definitions no longer mis-flagged as callsasync function downloadTool(...) matched the downloadTool( regex literally. Add _JS_FUNCTION_DEFINITION_RE covering function, async function, export [default], function* and skip those lines in _find_binary_downloads_js.
  3. Bare createHash + custom helper names recognised as verificationimport { createHash } from 'crypto' then createHash('sha256') was missed because the existing pattern required crypto.createHash(. Add bare createHash\s*\(\s*['"\]sha and helper-function names (calculateSHA[\d+], calculateChecksum, calculateDigest, verifyHash, computeChecksum`).

12 new tests in test_security.py pin each fix.

Test plan

Generated-by Claude Code.

…tives

graalvm/setup-graalvm v1.5.3 (PR apache#817) flagged 7 "unverified
downloads" all of which were false positives:

  * 2x http.get(url, { accept: 'application/json' }) followed by
    JSON.parse — JSON metadata calls, not binary downloads.
  * 1x async function downloadTool(...) — function definition
    that happens to start with the helper's name.
  * 4x downloads (across gds.ts/utils.ts) where verification IS
    in the same file via createHash('sha256') and a custom
    calculateSHA256 helper, but the regex required crypto.
    createHash (with module prefix) and missed the bare imported
    form + custom helper names.

Three fixes:

  1. Add ``accept: 'application/json'`` (single- or double-quoted)
     as a data-parse marker.  An HTTP call asking for JSON in its
     own request headers is data, not bytes.
  2. Skip lines that look like function definitions in the
     download-pattern scanner.  ``function name(``,
     ``async function name(``, ``export default async function
     name(`` and ``function* name(`` all match the new
     ``_JS_FUNCTION_DEFINITION_RE`` and are excluded.
  3. Recognize bare ``createHash('sha…')`` and the conventional
     ``calculateSHA[256|512|...]`` / ``calculateChecksum`` /
     ``verifyHash`` / ``computeChecksum`` helper names as
     verification.

12 new tests pin each fix.  Re-running verify-action-build against
graalvm/setup-graalvm@bef4b0e9 (the v1.5.3 SHA): exit 0; the 6
remaining findings are recognized as "verification present in
file" and reported as warnings rather than failures.
@potiuk potiuk merged commit c28cbd5 into apache:main May 11, 2026
8 checks passed
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