Skip to content

build(grammars): pin npm installs in grammar-regen scripts#1014

Merged
dekobon merged 1 commit into
mainfrom
chore/dev-container
Jul 9, 2026
Merged

build(grammars): pin npm installs in grammar-regen scripts#1014
dekobon merged 1 commit into
mainfrom
chore/dev-container

Conversation

@dekobon

@dekobon dekobon commented Jul 9, 2026

Copy link
Copy Markdown
Owner

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
main independently; the branch was rebased and they dropped out.

What changed

  • generate-grammar.sh installs with npm ci --include=dev;
    generate-mozcpp.sh uses npm ci inside the upstream
    tree-sitter-cpp checkout (upstream commits a lockfile at the
    pinned revision, already locking tree-sitter-c at 0.23.1).
  • The npm install --no-save tree-sitter-c@0.23.1 override is
    replaced by an exact-version registry tarball verified with
    sha512sum --check against a hash recorded in the script
    (byte-identical to the npm registry's integrity value); its
    install scripts are never run.
  • All four internal grammar crates commit their 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 include lists keep them out of published
    packages.
  • generate-mozjs.sh gains the set -euo pipefail guard and
    stale-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 diff on regenerated parser trees, all
74 workspace test suites green each run). make pre-commit passes.

If Scorecard's heuristic does not recognize the wget +
sha512sum --check pattern for alert #761, dismiss that alert with a
pointer to the rationale on #1012.

🤖 Generated with Claude Code

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
@dekobon dekobon force-pushed the chore/dev-container branch from ac952c4 to 1e4d251 Compare July 9, 2026 00:57
@dekobon dekobon changed the title chore: dev container, Scorecard pinned-dependencies remediation, agent-docs fixes build(grammars): pin npm installs in grammar-regen scripts Jul 9, 2026
@dekobon dekobon merged commit a7889c9 into main Jul 9, 2026
39 checks passed
@dekobon dekobon deleted the chore/dev-container branch July 9, 2026 02:08
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.

build(grammars): pin npm installs in grammar-regen scripts (Scorecard Pinned-Dependencies #759-#761)

1 participant