Skip to content

Align npm and CI supply-chain posture with the docsy repo - #487

Merged
chalin merged 21 commits into
docsy:mainfrom
chalin:chalin-m24-secure-npm-2026-0825
Aug 26, 2026
Merged

chalin merged 21 commits into
docsy:mainfrom
chalin:chalin-m24-secure-npm-2026-0825

Conversation

@chalin

@chalin chalin commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Aligns this template with the supply-chain posture the docsy repo adopted for 0.17.0; what lands here is guidance-by-example for consumers who clone it.

  • Drops bare npx: calls package-script bins by plain name; on a stale tree, npx BIN silently falls back to the public registry.
  • Pins and audits: exact-pins the direct dependencies and clears the single audit advisory via an override; npm audit is clean.
  • Commits the lockfile and the generated hugoautogen workspace, normalized to an owned scoped name and marked private (regeneration reapplies both); verified drift-free from a renamed clone. Makes CI and Netlify installs lock-exact, with Netlify's auto-install constrained to resolution only.
  • Gates install scripts: blocks unreviewed dependency install scripts via a committed .npmrc policy, with hugo-extended as the one version-pinned approval; fails closed on npm versions that ignore the policy. Routes hugo updates through a two-step install-then-approve flow with a review checkpoint, excluded from automated bumps. Red/green tested: an unapproved install script fails the install.
  • Hardens the workflow surface: adds a 7-day dependency cooldown (security updates bypass it), a github-actions ecosystem to keep the SHA pins fresh, and credential-free checkouts; drops the Gemfile-less bundler ecosystem.

@chalin
chalin force-pushed the chalin-m24-secure-npm-2026-0825 branch 2 times, most recently from fe2e344 to d3b3093 Compare August 25, 2026 17:05
chalin added 8 commits August 25, 2026 21:27
On a stale or missing node_modules, a bare npx BIN silently falls back
to the public registry and executes whatever holds that name. Plain bin
names resolve through PATH only, which npm points at node_modules/.bin
for package scripts.
Semver ranges let a fresh install float to whatever the registry serves
that day; exact pins keep template clones reproducible (this repo
commits no lockfile: the generated hugoautogen workspace embeds the
checkout directory name, so a lock is not portable). The adm-zip
override clears the GHSA-xcpc-8h2w-3j85 advisory reported through
hugo-extended, matching the docsy repo's fix; npm audit is now clean.
Adopts the docsy repo's install posture: a committed .npmrc turns on
strict-allow-scripts (unreviewed dependency install scripts fail the
install; hugo-extended's binary download is the one approval) and
engine-strict (older npm silently ignores allowScripts, so the engines
floor fails closed). script-shell=bash keeps package scripts on one
interpreter everywhere: under cmd.exe, the single-quoted test:site glob
would no-match and silently run nothing.
Tag pins are mutable: a compromised action republishes the tag and every
workflow using it runs the attacker's code. The dependabot cooldown
keeps versions younger than 7 days out of update PRs (security updates
bypass it), and the new github-actions ecosystem keeps the SHA pins
fresh. Drops the bundler ecosystem: the repo has no Gemfile.
A version-qualified key is only trusted against the lockfile-recorded
resolved URL; this repo commits no lockfile, so on CI installs (Netlify
restores node_modules without a valid hidden lockfile) the pinned key
cannot match and the install fails ESTRICTALLOWSCRIPTS. The exact pin
in devDependencies already fixes the version; the policy key carries
the approval.
hugo mod npm pack names the generated workspace after the checkout
directory, which made the artifacts non-portable and forced them out of
version control; update:docsy:pack now normalizes the name to a fixed
value, making the generated set deterministic, so the lockfile and the
hugoautogen workspace can be committed and installs are lock-exact and
reproducible. Regeneration is idempotent and covered by the existing
freshness guard; README documents the regenerate-and-commit
expectation.
With the lockfile committed, npm ci replaces install in the links
workflow (the npm cache key falls back to its lockfile default), and
the hugo-extended approval can carry its version again: the strict
allowScripts matcher trusts only the lockfile-recorded registry URL,
which install paths now always have.
The allowScripts fail-closed mechanism is homed in the .npmrc comment;
the README keeps only the consumer-facing floor. The name-normalization
rationale, previously only in a commit message, gets its current-state
home in the lockfile paragraph.
@chalin
chalin force-pushed the chalin-m24-secure-npm-2026-0825 branch from 8a445f1 to bb9149c Compare August 26, 2026 01:27
chalin added 5 commits August 25, 2026 21:51
… Netlify installs lock-exact

update:hugo now installs script-free and re-approves the new version
via npm approve-scripts (which rewrites the version-pinned allowScripts
key from the installed tree); without this, the next hugo-extended
release fails ESTRICTALLOWSCRIPTS with no hint (found by adversarial
review). Netlify's automatic install is constrained to resolution only
(NPM_FLAGS) and the build commands run the real lock-exact install,
matching the docsy repo's pattern; the hugo binary self-installs at
first use.
update:hugo's inline approve-scripts turned whatever @latest resolved to
into an approval with no review checkpoint (found by adversarial
review). The update now stops after a script-free install; the separate
approve:hugo step records the approval and refreshes the generated pack
checksum. Aggregate updates and Dependabot skip hugo-extended, keeping
the dependency and its version-pinned approval in sync; README documents
the flow, the Dependabot-PR checksum refresh, and the Windows bash
requirement.
…, gate message

Exact-pins the adm-zip override (the one floating pin left; the lock
already resolved 0.6.0). Scopes the Dependabot hugo-extended ignore to
version updates so security updates still open PRs (a bare ignore
suppresses those too). The drift-gate failure message now names both
remediations (link cache vs generated manifests); it previously
misdirected package.json-edit failures to the link-cache command. README
states what the approval does and does not gate: the hugo binary
self-installs at first use, so the review window excludes builds.
@chalin
chalin marked this pull request as ready for review August 26, 2026 11:34
chalin added 8 commits August 26, 2026 07:49
Re-ignores hugo_packagemeta.json, restoring the churn call made in docsy#472
(committing it in this branch reintroduced the tax: every package.json
edit, Dependabot PRs included, staled the tracked checksum). The marker
is npm-irrelevant (only the workspace manifest feeds npm ci), builds are
warning-free without it, and installs regenerate it locally, where its
staleness warning still works. Netlify's install moves into a
_netlify:prepare script wrapped in the family clean-tree bracket, which
catches NPM_FLAGS regressions.
install:safe names the script-free lock-exact install (the path
_netlify:prepare and hardened consumers use); the README documents the
silent failure mode that makes the committed manifest load-bearing: a
script-free install without it exits 0 with no theme assets.
Netlify's Node-bundled default npm may be older than the floor that
makes allowScripts enforcement real; the pin removes the dependence on
what the build image bundles (as in opentelemetry.io).
The committed manifest exposed the unclaimed bare name hugoautogen on
the public registry with nothing preventing an accidental publish
(caught in review): a squatted name would poison audits and installs.
The pack step now normalizes to @docsy/hugoautogen (owned scope) and
reapplies private=true, both dropped by hugo mod npm pack on every
regeneration; verified npm publish now skips the workspace.
…te, doc gaps

The drift gate and Netlify bracket switch to docsy's is:clean shape
(untracked-aware): git diff misses a new generated artifact a future
Hugo could emit. Dependabot skips the theme-managed workspace deps,
whose bumps the pack regeneration reverts (guaranteed-red PRs); README
notes the security-update exception and the Dockerfile's independent
Hugo and Dart Sass pins; the Netlify comment states the bracket's
detect-not-prevent residual honestly; .npmrc restores the
workspace-coverage clause.
@chalin
chalin merged commit 88884d5 into docsy:main Aug 26, 2026
12 checks passed
@chalin
chalin deleted the chalin-m24-secure-npm-2026-0825 branch August 26, 2026 16:39
chalin added a commit to chalin/docsy-example that referenced this pull request Sep 25, 2026
- Adds the npm release cooldown and the install-time script default-deny that docsy added in #2757/#2760, three days after docsy#487 copied the older file; the registry pin stays docsy's (publisher-only)
- Pins Node to docsy's version: lts/* floated in CI and was invisible to Renovate's nvm manager
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