build(grammars): pin npm installs in grammar-regen scripts#1014
Merged
Conversation
Switch generate-grammar.sh to `npm ci --include=dev` and generate-mozcpp.sh's upstream install to `npm ci`, and replace the `npm install --no-save tree-sitter-c@0.23.1` override with a registry tarball fetched by exact version and verified against a recorded sha512 before extraction — no npm version resolution, and the package's install scripts are never run. Commit package-lock.json for all four internal grammar crates (previously listed in each crate's .gitignore — no lockfile was ever actually in git, contrary to the issue's premise) so `npm ci` works from a clean checkout; the mozjs lockfile on disk had drifted to tree-sitter-cli 0.25.10 against the 0.26.9 package.json pin. The crates' Cargo.toml include-lists keep the lockfiles out of the published packages. Give generate-mozjs.sh the same `set -euo pipefail` fail-loud guard and stale-clone cleanup its mozcpp sibling already had, so an aborted regen can no longer fall through to cleanup and exit 0. Both mozjs and mozcpp regens verified byte-reproducible end-to-end from a clean checkout (OpenSSF Scorecard Pinned-Dependencies, code-scanning alerts #759-#761). Fixes #1012
ac952c4 to
1e4d251
Compare
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.
Fixes #1012 (OpenSSF Scorecard Pinned-Dependencies, code-scanning
alerts #759–#761). The other three commits originally on this branch
(dev container, CI Python hash-pinning, agent-docs fixes) landed on
mainindependently; the branch was rebased and they dropped out.What changed
generate-grammar.shinstalls withnpm ci --include=dev;generate-mozcpp.shusesnpm ciinside the upstreamtree-sitter-cppcheckout (upstream commits a lockfile at thepinned revision, already locking
tree-sitter-cat 0.23.1).npm install --no-save tree-sitter-c@0.23.1override isreplaced by an exact-version registry tarball verified with
sha512sum --checkagainst a hash recorded in the script(byte-identical to the npm registry's integrity value); its
install scripts are never run.
package-lock.json(previously gitignored — none was ever actually in git; the mozjs
one on disk had drifted to tree-sitter-cli 0.25.10 against the
0.26.9 pin). Crate
includelists keep them out of publishedpackages.
generate-mozjs.shgains theset -euo pipefailguard andstale-clone cleanup its mozcpp sibling already had, so an aborted
regen can no longer fall through to cleanup and exit 0.
Validation
Full mozjs + mozcpp regens from a clean checkout are
byte-reproducible (empty
git diffon regenerated parser trees, all74 workspace test suites green each run).
make pre-commitpasses.If Scorecard's heuristic does not recognize the
wget+sha512sum --checkpattern for alert #761, dismiss that alert with apointer to the rationale on #1012.
🤖 Generated with Claude Code