Skip to content

Commit npm lockfiles; make installs lock-exact and script-free - #2700

Merged
chalin merged 34 commits into
docsy:mainfrom
chalin:chalin-m24-docsy-locks-2026-0807
Aug 7, 2026
Merged

chalin merged 34 commits into
docsy:mainfrom
chalin:chalin-m24-docsy-locks-2026-0807

Conversation

@chalin

@chalin chalin commented Aug 7, 2026 •

Copy link
Copy Markdown
Collaborator

Makes every wired dependency-install path of the repository itself (workflows, Netlify builds, and the postinstall-driven theme install that consuming sites reach) lock-exact, with unreviewed dependency scripts disabled, as part of hardening after the August 2026 npm supply-chain campaign (jaredwray/cacheable#1692). The smoke tests' scratch consumer sites intentionally keep installing as real consumers do.

  • Where to start: package.json (install:safe, install:theme-deps, allowScripts) and .npmrc, then the two workflows and netlify.toml; the locks and the rest follow from those.
  • Empirical notes (what the diff can't show):
    • npm ci --prefix on npm 11 is lock-exact: fails hard on a missing or drifted lock, no fallback to the root lock. The theme lock therefore ships in the root npm package, whose postinstall needs it. (On consumer machines that nested install is protected by its --ignore-scripts flag alone: npm never packs .npmrc, so the repo's strict-allow-scripts/engine-strict layers don't travel.)
    • The lock-drift checks are red-proven: a drifted lock fails npm ci (EUSAGE) and the diff step; the Netlify one caught a real defect (a non-install-stable lock) on its first run.
  • Lock verification record, script-checked over both committed locks:
    • None of the cacheable#1692 poisoned package@version pairs is present; no IOC-family package name at any version.
    • All 172 registry entries are sha512-integrity-pinned; the only non-registry resolutions are the two commit-SHA-pinned git deps already in package.json and workspace links. (Dropping netlify-cli, which nothing referenced, shrank the lock from 1350 to 175 packages.)
    • hugo-extended is the only third-party package with install scripts: suppressed on wired paths, deliberately re-run via targeted npm rebuild, and pinned as the sole allowScripts entry under the committed .npmrc's strict-allow-scripts (red-proven: an uncovered script-bearing tree fails with ESTRICTALLOWSCRIPTS).
  • Validation, all green on a fresh install:safe tree:
    • docsy.dev build and ci:prepare
    • set-package-version and npm-pack suites
    • consumer smoke: packed root tarball → scratch site → nested npm ci → Hugo build
  • Preview:

chalin added 30 commits August 7, 2026 06:44
- Regenerates both locks from the verified dependency graph under --ignore-scripts; differs from the long-standing local locks only by dropping stale extraneous entries
- Un-ignores them so installs become reproducible and reviewable
- Switches install:theme-deps to `npm ci --ignore-scripts`, closing the unlocked nested install that consuming sites reach through the root package's postinstall
- Ships theme/package-lock.json in the root npm package so that nested install stays lock-exact for GitHub-npm consumers
- Adds install:safe for CI: locked, script-free root install plus the two reviewed lifecycle steps (hugo-extended rebuild, theme deps)
- Workflows fail when installation changes a committed lock or runs without one (npm ci refuses a missing or drifted lock)
- Keeps the committed locks aligned across version stamping; without this, the pre-push set:version:git-info run would leave the locks one install away from drift
- Resolves the zizmor unpinned-uses findings; each pin is the current v6 tag SHA, cross-checked against the tag refs
…emantics

- Changelog entry recast per the content-placement rules: user-facing postinstall change under Other changes, committed-locks/CI half in a new For-maintainers list, both citing the PR
- Extends the postinstall setup note with the lock-exact, script-free semantics, giving that fact a current-state docs home
- Netlify's automatic install now runs script-free (NPM_FLAGS), with the reviewed lifecycle steps and a lock-drift check prepended to the build commands; previously the deploy path bypassed both controls
- Anchors the .gitignore lock negations to the two committed locks; the bare pattern un-ignored locks at every depth
- Retires the fossilized Dockerfile (Hugo 0.111); its unlocked install predates the workspace layout and fails against the locked postinstall
- The lock-only regeneration pruned netlify-cli's 27 vendored platform entries; any real npm install re-records them, so Netlify's auto-install tripped the new lock-drift check. The restored entries byte-match the pre-regeneration lock, leaving installs drift-free (verified: repeated install/ci runs leave the lock unchanged)
…heck

- _install:safe:post: positional name for install:safe's after-ci phase (hook-inert underscore form; a literal postinstall:safe would be an npm auto-hook, silently skipped under ignore-scripts)
- _diff:check:locks joins the _diff:check family; the three call sites use the name
- Replaces the lock-scoped diff with the existing _diff:check: at the check point nothing legitimate touches tracked files, so any change (lock or otherwise) should fail loudly rather than pass a lock-only filter
- Committed .npmrc turns on strict-allow-scripts: script-enabled installs and rebuilds now fail on any script-bearing package not covered by allowScripts (red-proven: uncovered tree fails with ESTRICTALLOWSCRIPTS listing all 7)
- allowScripts pins [email protected] as the one reviewed script runner (Hugo upgrades re-approve via npm approve-scripts) and denies the netlify-cli-vendored set
- The rebuild passes --ignore-scripts=false so install:safe works under user-level ignore-scripts hardening, where the rebuild would otherwise silently no-op
- Nothing references it (deploys run on Netlify's own runner; no scripts, docs, or CI invoke the CLI) and it dominated the dependency tree: the lock shrinks from 1350 to 175 packages, and hugo-extended becomes the only third-party install-script bearer, so the allowScripts denies retire
- The regenerated lock is install-stable (repeated installs leave it unchanged) and re-verified: no IOC-family package at any version, all registry entries sha512-pinned
…files

- Neuters Netlify's automatic install (--dry-run: resolution only, no tree writes, no bin linking), closing the window where a drifted manifest could plant executables on PATH before any check runs; _netlify:prepare now brackets install:safe with pristine-tree checks, and lock drift fails inside npm ci
- _status:check replaces _diff:check at the install sanity points: git diff is blind to staged and untracked files, so a payload that stages itself passed; red-proven on modified, untracked, and staged inputs
- Restores the Dockerfile pending its lock-safe update: docker-compose and the contributing guide reference it
- Changelog: "script-free" overwrote the reviewed hugo-extended exception; now "unreviewed dependency scripts are disabled"
- Replaces the inline node wrapper; a script file dodges cmd.exe quoting on Windows (the scrollspy bash precedent) since git status has no --exit-code mode
- Retires _diff:check and _status:check: two similar checks invited misuse, and the diff form is blind to staged and untracked files (the k8s/istio/node ecosystems' strict tree checks settle the same way)
- The is: predicate namespace keeps it out of check:* suite globs; strict semantics at the regen points means ci:prepare/ci:post now also require a clean tree, the accepted local trade-off
- perl's default output layer writes CRLF on Windows; with eol=lf normalization the regenerated files then show modified in git status (bytes differ, normalized content equal) — the strict is:clean-tree check surfaced this latent nondeterminism that git diff had masked
- `! git status ... | grep .` is POSIX-portable inside bash, avoids double quotes (cmd.exe-to-bash safety on Windows), and prints the offending paths on failure; the helper file retires
- The piped form died in cmd.exe, which owns `|` before bash exists; the capture-once form has no cmd metacharacters, one git call, and prints the offending paths on failure
- The scratch-site harnesses pin their own theme config, which Hugo lets an inherited HUGO_THEME override, so every such test failed from a worktree checkout (surfaced by `npm run wt -- test`); each spawn now drops the variable
chalin added 4 commits August 7, 2026 15:54
- make-site.sh scratch sites get the same npm floor + engine-strict as the repo: their allowScripts keys silently no-op on npm < 11.16 (node 24.0 bundled 11.3, so engines.node alone doesn't cover it)
- hugoEnv becomes a function so late process.env mutations stay visible to spawns
@chalin
chalin marked this pull request as ready for review August 7, 2026 20:43
@chalin
chalin merged commit 616df5f into docsy:main Aug 7, 2026
16 checks passed
@chalin
chalin deleted the chalin-m24-docsy-locks-2026-0807 branch August 7, 2026 20:43
chalin added a commit to chalin/docsy that referenced this pull request Aug 12, 2026
Prove from the committed manifests, locks, .npmrc, and workflows alone
that the hardening invariants (docsy#2700, docsy#2702, docsy#2712) still hold: registry
+ integrity coverage, non-registry allowlist, campaign IOC denylist,
install-script inventory with a lock-matching allowScripts pin, locked
script-free install commands, and credential-isolated workflow installs.
Wired into test:full via _test:full:post.
@chalin chalin added this to the 0.17.0 milestone Aug 14, 2026
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.

1 participant