Skip to content

Clear 17 of 18 allowlisted npm advisories (dompurify browser-mode tests, dev-tooling major bumps) - #1869

Merged
malibio merged 3 commits into
mainfrom
issue-1744-npm-advisories
Aug 1, 2026
Merged

malibio merged 3 commits into
mainfrom
issue-1744-npm-advisories

Conversation

@malibio

@malibio malibio commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Clears 17 of the 18 npm advisories tracked in scripts/audit-npm.ts's allowlist since #1728. Only the cookie advisory remains, genuinely blocked on an upstream @sveltejs/kit bump (still pins cookie: ^0.6.0 as of the latest release).

  • brace-expansion (3 advisories): pinned to 1.1.17 via overrides (transitive through eslint's minimatch).
  • happy-dom (3 advisories): bumped 18 → 20.11.1.
  • vite/launch-editor (4 advisories): bumped top-level vite 6.0.3 → 6.4.3. These turned out to also be reachable through vitest 2.x's own internal peer resolution (vite-node, @vitest/mocker), which vendored a second and third copy of vite independent of the top-level one — fully resolved by the vitest bump below.
  • vitest / @vitest/browser / esbuild (3 advisories): bumped vitest 2.x → 3.2.7 across both workspaces (packages/desktop-app, packages/skill). This collapsed the extra vendored vite/esbuild instances vitest 2.x was carrying internally.
  • dompurify (4 advisories): sanitizeSvg's tests (and renderMermaid's tests, which call the real unmocked sanitizeSvg on every render) moved from the Happy-DOM tier to src/tests/browser/mermaid-sanitize.test.ts (real Chromium via test:browser), since DOMPurify >3.4.7 fails open under Happy-DOM's DOM approximation — confirmed directly: bumping dompurify before moving the tests silently dropped the <svg> wrapper from sanitized output under Happy-DOM, while real Chromium sanitized correctly. dompurify bumped 3.4.7 → 3.4.12.

Test fix

shared-node-store-coverage.test.ts's "should handle errors during flush with timeout" test raced a mocked 10s persistence call against the store's own internal 5s flush timeout, which itself raced vitest's 5s default testTimeout — a zero-margin double race vitest 3.x's scheduler now consistently loses. Gave the test a 10s timeout; the 5s internal timeout is real production behavior and didn't change.

Note for reviewers

sanitizeSvg/renderMermaid tests now live under src/tests/browser/, which is currently not part of test:all or the pre-push gate (test:browser is available but not wired into the required gate — see vitest.browser.config.ts and the WebKit nightly-tier comments). This PR does not change that gating; flagging it here since it means this security-relevant sanitization coverage only runs when a dev explicitly runs bun run test:browser (or in the nightly WebKit smoke tier, non-blocking). Happy to wire test:browser into test:all as a follow-up if that's wanted — it's a broader gating-policy call (ADR-047 territory) beyond this issue's scope.

Test plan

  • bun run test — 170 files / 4097 tests passed
  • bun run test:browser — 7 files / 106 tests passed (incl. 16 in mermaid-sanitize.test.ts)
  • bun run test:skill — 20 tests passed
  • bun run rust:test — all passed
  • bun run quality:check — 0 errors/warnings
  • bun run --cwd packages/desktop-app build — succeeds
  • bun run audit — clean, 1 remaining allowlisted advisory (cookie, upstream-blocked)
  • Full pre-push gate (test:all, cargo build --bin nodespaced, test:e2e, Tauri-seam integration tests) — green

Closes #1744

Co-Authored-By: Claude [email protected]

malibio and others added 3 commits August 1, 2026 00:03
…1744)

Pin brace-expansion to 1.1.17 via overrides (transitive through eslint's
minimatch), bump happy-dom 18 -> 20.11.1, and bump vite 6.0.3 -> 6.4.3.
Clears 7 of the 18 allowlisted GHSA advisories.

The remaining vite/launch-editor/esbuild advisories turned out to be
unreachable from our top-level vite (already bumped) - they come from a
second and third vite instance vendored inside vitest 2.x's own peer
resolution (@vitest/mocker, vite-node), which only clears with the
vitest 3.x major bump tracked separately in this issue.

Co-Authored-By: Claude <[email protected]>
…ries (#1744)

vitest 2.x's own peer resolution (vite-node, @vitest/mocker) vendored a
second and third copy of vite (5.4.21, 6.4.1) plus an old esbuild, all
independent of our already-bumped top-level vite. Bumping vitest (and
@vitest/browser, @vitest/coverage-v8) to 3.2.7 across both workspaces
collapses all vite/esbuild instances to the single already-clean version,
clearing 7 more GHSA advisories.

Bump one test's timeout to 10s: it races a mocked 10s persistence call
against the store's own internal 5s flush timeout, which itself races
vitest's 5s default testTimeout — a zero-margin double race that the
vitest 3.x scheduler now consistently loses. The 5s internal timeout is
real production behavior; only the test's outer timeout needed headroom.

Co-Authored-By: Claude <[email protected]>
…1744)

DOMPurify >3.4.7 fails open under Happy-DOM's DOM approximation (confirmed:
bumping first without moving tests silently dropped the <svg> wrapper from
sanitized output under Happy-DOM while real Chromium sanitized correctly).
sanitizeSvg's own tests, and renderMermaid's tests (which call the real,
unmocked sanitizeSvg on every render — only the mermaid module itself is
mocked), both needed real-DOM fidelity to mean anything, so the whole file
moves to src/tests/browser/mermaid-sanitize.test.ts.

Bumps dompurify from the 3.4.7 Happy-DOM ceiling to 3.4.12, clearing the
last 4 GHSA advisories that were blocked on this. 17 of the original 18
allowlisted advisories are now cleared; only the cookie advisory remains,
genuinely blocked on an upstream @sveltejs/kit bump.

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review Summary

Clean, well-scoped dependency-hygiene PR. It clears 17 of 18 npm advisories allowlisted in scripts/audit-npm.ts, leaving only the genuinely upstream-blocked cookie advisory. I independently verified every quantitative claim in the PR body rather than taking them at face value: ran bun run audit (clean, 1 allowlisted advisory), ran the full Happy-DOM suite (170 files / 4097 tests, matches), ran test:browser (7 files / 106 tests incl. 16 in the new mermaid-sanitize.test.ts, matches), ran test:skill (20 tests, matches), and inspected bun.lock directly to confirm every removed allowlist entry corresponds to an actually-bumped, single resolved version with no leftover vendored-vulnerable copies. This is a net positive and safe to merge.

Requirements Check (issue #1744)

  • Move sanitizeSvg/renderMermaid tests to browser mode, then bump dompurify and drop the 4 dompurify ignores — done, verified via git rename (R091) mermaid-render.test.ts → src/tests/browser/mermaid-sanitize.test.ts, dompurify 3.4.7 → 3.4.12, 4 GHSA-* dompurify entries removed from ALLOWLIST.
  • vitest/@vitest/browser 2.x → 3.x — done in both packages/desktop-app (vitest + @vitest/browser + @vitest/coverage-v8 → 3.2.7) and packages/skill (vitest → 3.2.7).
  • happy-dom 18 → 20 — done, ^20.11.1, resolved in lockfile.
  • vite (+ launch-editor) and esbuild — vite bumped ^6.0.3 → ^6.4.3; confirmed via bun.lock that vitest 3.x collapsed the previously-vendored duplicate vite/esbuild copies (vite-node's internal vite dependency and @vitest/mocker's) down to the single top-level 6.4.3 / esbuild 0.25.12 — no stray old instances remain.
  • brace-expansion via eslint — pinned to 1.1.17 via root overrides, resolved correctly in lockfile.
  • cookie — correctly left allowlisted; genuinely blocked on an upstream @sveltejs/kit bump (still pins ^0.6.0), out of scope for this issue and explicitly called out as such.

All acceptance criteria that were in scope for this issue are met. cookie is the one item intentionally deferred, consistent with the issue's own framing.

Findings

Critical Issues

None.

Suggested Improvements

  • packages/desktop-app/vitest.browser.config.ts / gating policy (not touched by this PR, but surfaced by it): Verified independently — test:browser is not part of bun run test:all (package.json:27), not part of scripts/test-gate.ts's pre-push gate, and the only CI workflow that runs the shared src/tests/browser/** suite content is .github/workflows/nightly-webkit.yml, which is explicitly non-blocking (nightly cron + manual dispatch only, not wired into any required check). So the PR body's characterization is accurate: sanitizeSvg/renderMermaid — sanitization for LLM/agent chat markdown and mermaid SVG — currently only gets exercised when a developer manually runs test:browser, or once a day in a non-blocking nightly job. That's a real gap: this is precisely the kind of security-relevant coverage (XSS sanitization) that should run on every PR touching it, not just nightly. I agree with the PR's own assessment that this is a broader gating-policy decision (whether to add a blocking Chromium browser-mode tier to CI/pre-push, separate from the currently-non-blocking nightly WebKit smoke tier) rather than something to silently bundle into a dependency-bump PR. Recommend opening a follow-up issue for this now, scoped narrowly to "wire a blocking Chromium test:browser run into test:all or the pre-push gate," rather than letting it live only as a comment in this PR's history.
  • Pre-existing, unrelated observation while verifying the above: nightly-webkit.yml's comment block states WebKit is checked nightly because "Chromium stays the fast, blocking browser tier (via test:integration:full / local runs)" — but test:integration:full is not referenced by any CI workflow or test-gate.ts; it only appears in a doc-comment inside a test file and in that workflow's own comment. It is not actually a blocking gate anywhere today. This predates this PR and isn't something to fix here, but it reinforces the point above: today, nothing CI-side blocks a PR on a Chromium browser-mode regression, nightly or otherwise-worded comments notwithstanding. Worth folding into the same follow-up issue as ground truth.

Nitpicks

  • Nit: bun run test:browser printed a Vitest 3 deprecation warning: No browser "instances" were defined... "browser.name" field is deprecated since Vitest 3. (vitest.browser.config.ts and its WebKit twin still use browser.name). Not a blocker — it still runs correctly — but since this PR is already the vitest 3.x migration vehicle, migrating to browser.instances here would avoid a second follow-up PR just for this. Given the file's own "LOCKSTEP TWIN" comment, remember to update vitest.webkit.config.ts identically if this is picked up.
  • Nit: shared-node-store-coverage.test.ts's fix comment is good — it names the exact double-race (mocked call vs. internal 5s Promise.race vs. vitest's old 5s default) and why only the outer timeout needed headroom. I verified this against shared-node-store.svelte.ts:390-393 (flushAllPending → PersistenceCoordinator.flushPending() → Promise.race([..., 5000ms])) and it's accurate; the fixed test now runs in ~6.1s real time, well under the new 10s budget, and the internal 5s timeout is untouched. No behavior was masked — good instinct to call this out explicitly rather than just bumping the number silently.

Verification Performed (independent, not from PR body)

  • scripts/audit-npm.ts diff: allowlist reduced from 15 entries to exactly 1 (cookie), matching claim (a).
  • bun.lock: every removed allowlist entry's package resolves to a single patched version with no leftover vendored-vulnerable duplicate (dompurify 3.4.12, happy-dom 20.11.1, vite 6.4.3, vitest/@vitest/* 3.2.7, brace-expansion 1.1.17, esbuild 0.25.12) — confirms claim (b), nothing was removed from the allowlist without the underlying fix landing.
  • git diff --name-status -M: mermaid-render.test.ts → mermaid-sanitize.test.ts is a tracked rename (R091), not an untracked deletion; new file's XSS-vector coverage (script tags, event handlers, javascript:/data: URIs, foreignObject stripping) matches the old suite's scope plus the renderMermaid integration tests.
  • Ran bun run audit, bun run test (170/4097 pass), bun run --cwd packages/desktop-app test:browser (7/106 pass, mermaid-sanitize 16/16), bun run test:skill (20/20 pass), and bun run --cwd packages/desktop-app quality:check (0 errors/warnings) myself — all green, matching the PR's test plan exactly.
  • Confirmed test:browser is absent from test:all and test-gate.ts, and that nightly-webkit.yml is non-blocking — verifies claim (c) and the PR's own framing of the open question.
  • No CI workflow files changed in this diff; bun-audit required check (.github/workflows/audit.yml) reads the same allowlist this PR shrinks and will pass.

Recommendation: APPROVE

This is a textbook example of a well-scoped, atomic dependency-hygiene PR: single cohesive purpose, every claim independently verifiable and verified, tests genuinely moved (not deleted) with equivalent-or-better coverage, a real flakiness root-cause fix rather than a timeout band-aid, and an honest, explicitly-flagged open question about test-gating policy left for a human/product call rather than silently resolved either way. Nothing here blocks merge. The one suggested improvement (wire test:browser into a blocking gate) is correctly scoped as a follow-up, not a blocker for this PR.

@malibio malibio left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review recommendation: APPROVE (self-approval blocked by GitHub — same author account). Full report posted above. Net positive, no blockers found; all quantitative claims in the PR body independently re-verified (audit output, all 4 test suites re-run, lockfile inspected directly).

@malibio
malibio merged commit f241cd7 into main Aug 1, 2026
2 checks passed
@malibio
malibio deleted the issue-1744-npm-advisories branch August 1, 2026 00:56
malibio added a commit that referenced this pull request Aug 3, 2026
…break test:coverage

Supersedes the 1.1.17 -> 1.1.18 bump this branch originally carried. Deleting the
override, rather than bumping it, fixes both problems at once.

The pin was added in #1869 to clear an advisory, but `overrides` applies to the
whole tree and cannot express "1.x here, 5.x there". Three consumers declare
incompatible ranges, so all three were forced onto 1.x:

  [email protected]  wants ^1.1.7   ok
  [email protected]  wants ^2.0.2   forced to 1.x
  [email protected] wants ^5.0.5   forced to 1.x  <- broken

brace-expansion 1.x is CommonJS exporting only a default; minimatch@10 imports a
named `expand`. So `bun run test:coverage` has been dead since #1869 with
`TypeError: (0 , brace_expansion_1.expand) is not a function`, reached via
test-exclude -> minimatch@10 and a braced include glob (`{test,spec}`). It went
unnoticed because test:all runs test, test:scripts, test:skill and rust:test —
never test:coverage.

Upstream has since caught up, so the override is no longer needed at all. With it
removed, natural resolution puts every consumer on its own major, each at or
above this advisory's patched floor:

  [email protected]  (floor 1.1.18)
  [email protected]   (floor 2.1.4)
  [email protected]   (floor 5.0.9)

Verified in clean clones: `bun run audit` clean, and `test:coverage` runs to
completion (172 files / 4112 tests, 88.43% lines). It still exits 1 on the 90%
global threshold, which is pre-existing project state and unrelated to this
change — the crash is what this fixes.

Scoped override keys (`test-exclude/minimatch/brace-expansion`) were tried first
and are silently ignored by Bun 1.3.11: accepted into the lockfile, no effect on
resolution. Recorded so the next person does not retry it.

Co-Authored-By: Claude <[email protected]>
malibio added a commit that referenced this pull request Aug 3, 2026
…reaks test:coverage (closes #1950) (#1949)

* Bump the brace-expansion override to 1.1.18 to clear GHSA-rgw5-rvv9-x895

`bun audit` has been failing on every PR: the pinned override sat at 1.1.17,
one patch short of the fix for GHSA-rgw5-rvv9-x895 (high, DoS via unbounded
intermediate arrays, bypassing the CVE-2026-14257 mitigation). The advisory
patches the 1.x line in 1.1.18.

The pin itself is load-bearing and stays: three different minimatch versions in
the tree ask for `^1`, `^2` and `^5` respectively, and the override flattens all
of them to one copy. Bumping the pinned version is therefore the whole fix —
nothing else in the manifest needs to move.

Verified: `bun run audit` clean, one resolved copy at 1.1.18, frontend suite
172 files / 4112 tests passing.

Co-Authored-By: Claude <[email protected]>

* Drop the brace-expansion override to clear GHSA-rgw5-rvv9-x895 and unbreak test:coverage

Supersedes the 1.1.17 -> 1.1.18 bump this branch originally carried. Deleting the
override, rather than bumping it, fixes both problems at once.

The pin was added in #1869 to clear an advisory, but `overrides` applies to the
whole tree and cannot express "1.x here, 5.x there". Three consumers declare
incompatible ranges, so all three were forced onto 1.x:

  [email protected]  wants ^1.1.7   ok
  [email protected]  wants ^2.0.2   forced to 1.x
  [email protected] wants ^5.0.5   forced to 1.x  <- broken

brace-expansion 1.x is CommonJS exporting only a default; minimatch@10 imports a
named `expand`. So `bun run test:coverage` has been dead since #1869 with
`TypeError: (0 , brace_expansion_1.expand) is not a function`, reached via
test-exclude -> minimatch@10 and a braced include glob (`{test,spec}`). It went
unnoticed because test:all runs test, test:scripts, test:skill and rust:test —
never test:coverage.

Upstream has since caught up, so the override is no longer needed at all. With it
removed, natural resolution puts every consumer on its own major, each at or
above this advisory's patched floor:

  [email protected]  (floor 1.1.18)
  [email protected]   (floor 2.1.4)
  [email protected]   (floor 5.0.9)

Verified in clean clones: `bun run audit` clean, and `test:coverage` runs to
completion (172 files / 4112 tests, 88.43% lines). It still exits 1 on the 90%
global threshold, which is pre-existing project state and unrelated to this
change — the crash is what this fixes.

Scoped override keys (`test-exclude/minimatch/brace-expansion`) were tried first
and are silently ignored by Bun 1.3.11: accepted into the lockfile, no effect on
resolution. Recorded so the next person does not retry it.

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
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.

Clear the 18 allowlisted npm advisories (dompurify→browser-mode tests, dev-tooling major bumps)

1 participant