Skip to content

fix(audit-gate): confirm in-range fixes before failing on them - #2027

Merged
mrbobbytables merged 1 commit into
cncf:mainfrom
mrbobbytables:fix/audit-gate-confirm-in-range-fixes
Oct 31, 2026
Merged

mrbobbytables merged 1 commit into
cncf:mainfrom
mrbobbytables:fix/audit-gate-confirm-in-range-fixes

Conversation

@mrbobbytables

Copy link
Copy Markdown
Member

Problem

Since about 00:25Z on 2026-10-31 the required "Validate repository" check fails on every full-path PR (#2025, #2026) at npm run check:audit:

audit-gate: moderate/low advisories npm can fix within the declared ranges:
  deepmerge (low): GHSA-gcqx-w48m-w2h4 — a fix is available

Nothing in those PRs touches the lockfile; the merge-queue runs of #2022/#2024 at 00:06Z passed on the identical Node 22 / npm 10.9.9 toolchain. The registry advisory for deepmerge now carries a bounded vulnerable range (>=4.2.0 <=4.3.1) with no patched release — 4.3.1 is the latest deepmerge, published in 2023 — and npm 10 turns that into fixAvailable: true. Running npm audit fix --package-lock-only with npm 10 leaves deepmerge at 4.3.1 and re-reports the same finding, so the gate's instruction cannot be carried out. npm 11 reports the same advisory as fixAvailable: false.

Change

scripts/audit-gate.mjs no longer trusts fixAvailable on its own for the moderate/low in-range check. It runs npm audit fix --package-lock-only --ignore-scripts --no-fund --json on a scratch copy of package.json, package-lock.json (and .npmrc when present), then compares the named package's locked versions at every nesting depth before and after:

  • versions moved (or the package disappeared): the gate fails exactly as before;
  • versions unchanged: the finding is a phantom; it is named in the log as a warning and the gate passes;
  • the scratch run cannot be judged (spawn error, deadline, non-JSON output, npm error document, unreadable lockfile): every finding is treated as real, so a registry fault fails closed as it did before.

The scratch run is judged by the same contract runAudit() uses: a completed npm audit fix --json carries audit.vulnerabilities, an outage prints an error document; the exit code is 1 either way while any advisory remains.

Verified locally with npx npm@10 on PATH: the current lockfile now yields the warning and audit-gate: ok, and the working tree is untouched. SECURITY.md gains a sentence describing the confirmation step.

Tests: the stubbed-npm harness in tests/audit-gate.test.mjs gains a lockfile sandbox and per-step lockfile writes; 11 new/updated CLI cases cover the confirmed, phantom, mixed, nested, removed, v1-lockfile and each fail-closed arm, and that the scratch copy is a temp dir (removed afterwards) rather than the project tree. npm run test:unit:coverage:check, check:lint, check:format, check:unused, check:duplication and check:markdown pass.

Remit: required CI check ("Validate repository") failing on every full-path PR on main.

npm 10 (the CI toolchain) reports deepmerge's GHSA-gcqx-w48m-w2h4 as
fixAvailable: true although every published release of deepmerge sits
inside the advisory's vulnerable range, so `npm audit fix
--package-lock-only` leaves the lockfile where it is. Taken at face
value that reds the Validate repository check on every full-path PR
(cncf#2025, cncf#2026) with an instruction nobody can carry out; npm 11 reports
the same advisory as unfixable.

The gate now asks `npm audit fix` itself: when a moderate/low finding is
reported as fixable in range, it runs the fix on a scratch copy of
package.json and package-lock.json and compares the named package's
locked versions (at every nesting depth) before and after. A finding
whose versions did not move is logged as a warning and no longer fails
the gate; one that did move fails it exactly as before. A scratch run
that cannot be judged (spawn error, deadline, no JSON, npm error
document, unreadable lockfile) fails closed by treating every finding
as real, so a registry fault behaves as it did before this check.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
@netlify

netlify Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for endusers ready!

Name Link
🔨 Latest commit db6635f
🔍 Latest deploy log https://app.netlify.com/projects/endusers/deploys/6ae53fd2cc0825de9cb9bfad
😎 Deploy Preview https://deploy-preview-2027--endusers.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mrbobbytables
mrbobbytables added this pull request to the merge queue Oct 31, 2026
Merged via the queue into cncf:main with commit 3ebb098 Oct 31, 2026
15 checks passed
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