verify-action-build: normalize package.json before comparing - #1136
Open
potiuk wants to merge 1 commit into
Open
verify-action-build: normalize package.json before comparing#1136potiuk wants to merge 1 commit into
potiuk 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
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.
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.