verify-action-build: normalize package.json before comparing - #1136
verify-action-build: normalize package.json before comparing#1136potiuk wants to merge 1 commit into
Conversation
A vendored node_modules holds the manifest npm rewrote at install time,
while the registry tarball and a fresh npm ci hold the published one.
Comparing bytes reported the difference as tampering.
Two rewrites are involved: npm's _-prefixed install bookkeeping (the
enumerated list missed _args and _location), and normalize-package-data
expanding shorthand — author string to a person object, bugs to {url},
and a git+ prefix on repository.url.
reactivecircus/android-emulator-runner ships exactly this shape, and one
file, node_modules/tunnel/package.json, was the only difference across
217 — enough to fail the whole JS build check and the registry check.
Also exempts @actions/tool-cache's bundled 7zdec.exe from the in-tree
binary check, and fixes the registry mismatch line, which passed the
offending path as the URL and so never named the failing file.
Generated-by: Claude Opus 5 (1M context) via Claude Code
|
End-to-end validation done - this closes the caveat in the PR description. Ran the verifier from this branch against
The remaining failure is the unchecksummed cmdline-tools fetch from dl.google.com. That is the action's own behaviour, now tracked upstream at ReactiveCircus/android-emulator-runner#485. Exit code stays 1 on that single finding, which is correct. Note that
Drafted-by: Claude Opus 5 (1M context) via Claude Code; reviewed by @potiuk before posting |
| # runner. The general fix — crediting any binary under a node_modules | ||
| # package the registry check already verified — needs the two checks | ||
| # reordered, so this keeps the narrow, reviewable form used above. | ||
| "node_modules/@actions/tool-cache/scripts/externals/7zdec.exe", |
There was a problem hiding this comment.
We could verify its SHA256, because here we have the same binary since 10 years.
Found while triaging #1100 (
reactivecircus/android-emulator-runner), whichfails
verifyon four checks. Three are tooling gaps; this fixes them.package.json is rewritten at install time
A vendored
node_modulesholds the manifest npm rewrote when installing,while the registry tarball and a fresh
npm cihold the published one.Comparing bytes reports that difference as tampering. Two separate rewrites:
_-prefixed keys that the tarball neverhad.
diff_node_modulesalready filtered these, but by enumeration, and thelist was missing
_argsand_location. Now matched by the reserved_prefix, since the set has varied across npm versions.
normalize-package-dataturns anauthorstringinto a person object,
bugsinto{"url": ...}, and prefixesrepository.urlwithgit+.node_modules/tunnel/package.jsonhits both: it was the only differing fileout of 217, and on its own failed the whole JS build check and the registry
check.
Normalisation is deliberately narrow. Only the fields npm is known to rewrite
are touched; everything else —
main,bin,scripts,dependencies— isstill compared strictly, with a regression test asserting a tampered
mainstill fails.
Two smaller fixes
@actions/tool-cache's7zdec.exeis exempted from the in-tree binarycheck. It backs
tc.extractZipon Windows and ships inside the first-partynpm package, so every action vendoring
node_modulescarries it verbatimfrom the published tarball. Same narrow path-suffix form as the
gradle-wrapper.jarexemption in verify: exempt gradle-wrapper.jar from in-tree binary check #951. The general fix — crediting anybinary under a
node_modulespackage the registry check already verified —needs the two checks reordered, so I left it for a follow-up.
tree root as the text, so it never named the failing file. Diagnosing Pin
reactivecircus/android-emulator-runner#1100meant deriving the filename from the rebuild diff instead.
Test plan
uv run pytest utils/tests/— 320 passed.node_modules/tunnel/package.jsonata421e438vs the publishedtunnel-0.0.6.tgzfrom the registry now compare equal.prek run --all-filesclean.Not yet re-run end-to-end against the action itself — that needs a
GITHUB_TOKENand I exhausted the unauthenticated rate limit. CI on this PRwill cover it.