fix(deps): clear audit advisories by dropping rimraf/minimatch and bumping fast-xml-parser - #2356
Open
rishigupta1599 wants to merge 2 commits into
Open
fix(deps): clear audit advisories by dropping rimraf/minimatch and bumping fast-xml-parser#2356rishigupta1599 wants to merge 2 commits into
rishigupta1599 wants to merge 2 commits into
Conversation
…mping fast-xml-parser
`yarn audit --groups dependencies` reported 5 advisories (4 high, 1 moderate)
against the published production closure, all reaching us transitively:
brace-expansion (ReDoS) <- minimatch <- glob <- rimraf@3 (@percy/core)
<- minimatch@9 (@percy/cli-doctor)
inflight (memory leak) <- glob <- rimraf@3
fast-xml-parser (ReDoS) <- direct dependency of @percy/core
Rather than re-pinning brace-expansion via a resolutions override, remove the
dependency chains that pull it in:
- @percy/core: drop rimraf@3; Browser#close now cleans the temp profile with
fs.promises.rm({ recursive, force, maxRetries: 3, retryDelay: 100 }). The
retry options preserve rimraf's busy-retry behaviour, which matters on
Windows where the profile dir stays locked briefly after the browser exits.
- scripts/test.js: same swap for the coverage-dir cleanup.
- @percy/cli-doctor: drop minimatch@9. The PAC check only needed shExpMatch
glob semantics (`*` and `?`, no `**`/braces/character classes), so it is
now a small self-contained matcher instead of a full glob engine.
- @percy/core: fast-xml-parser ^4.4.1 -> ^5.7.0.
Note the advisory's own recommendation (brace-expansion 1.1.12 / 2.0.2) does
not clear the audit -- only 5.0.8 does, and that requires Node 20+, which is
what broke the reporting customer. Removing the chains avoids that trap.
Verified: audit on the published prod closure goes 5 -> 0 with the vulnerable
packages absent from the tree; cli-doctor 514/514 specs pass; repo-wide lint
clean; fast-xml-parser v4 vs v5 produce byte-identical output across 7 real
fixtures plus 6 synthetic cases using our exact parser options.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…tive deps The previous commit bumped fast-xml-parser to ^5.7.0, which broke `yarn install` on every CI job (all pin Node 14): error xml-naming@0.3.0: The engine "node" is incompatible with this module. Expected version ">=16.0.0". Got "14.21.3" ^5.7.0 floats to 5.10.1, which depends on xml-naming (engines: >=16). Pinning fast-xml-parser alone does not help: 5.7.x depends on fast-xml-builder ^1.1.7, and fast-xml-builder 1.2.0+ pulls xml-naming in as well, so staying on 5.x would additionally require a `resolutions` pin on a dependency-of-a-dependency to hold Node 14 -- the same class of fragile pin this PR set out to avoid. So take the top of the 4.x line (4.5.7, npm `legacy` tag) instead. That still clears every fast-xml-parser advisory that has a 4.x fix: GHSA-m7jm-9gc2-mpf2 (CRITICAL) patched 4.5.4 GHSA-8gc5-j5rx-235r (HIGH) patched 4.5.5 GHSA-jp2q-39xq-3w4g (MODERATE) patched 4.5.5 GHSA-fj3w-jwp8-x2g3 (LOW) patched 4.5.4 One advisory remains unfixed on 4.x: GHSA-gh4j-gqv2-49f6 (MODERATE, vulnerable range `< 5.7.0`) -- XMLBuilder comment/CDATA injection via unescaped delimiters. It is not reachable from our code: maestro-hierarchy.js is the only consumer, it imports XMLParser only (never XMLBuilder), and it parses with processEntities: false. Production closure computed from yarn.lock (127 external packages) confirms rimraf, minimatch, glob, inflight and brace-expansion are all absent, and that no Node-16-only package is pulled in; fast-xml-parser resolves to 4.5.7 with strnum 1.1.2 as its only dependency (strnum has no advisories). Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
yarn audit --groups dependencieson the published production closure reported 5 advisories (4 high, 1 moderate). All reached us transitively:brace-expansion(ReDoS)minimatch←glob←rimraf@3(@percy/core)brace-expansion(ReDoS)minimatch@9(@percy/cli-doctor)inflight(memory leak)glob←rimraf@3fast-xml-parser@percy/coreWhy not the override the ticket recommends
PER-10247 recommends pinning
brace-expansion@1 → 1.1.12/@2 → 2.0.2viaresolutions. That does not clear the audit — only5.0.8satisfies the advisory, and 5.0.8 requires Node 20+. Requiring a newer Node is exactly what broke the reporting customer, so re-pinning trades one break for another. This PR removes the dependency chains instead.Changes
@percy/core: droprimraf@3.Browser#closecleans the temp profile withfs.promises.rm({ recursive: true, force: true, maxRetries: 3, retryDelay: 100 }). The retry options preserve rimraf's busy-retry behaviour — on Windows the profile dir stays locked briefly after the browser exits, and a plainrmwould throwEBUSY.scripts/test.js: same swap for the coverage-dir cleanup (the only otherrimrafconsumer).@percy/cli-doctor: dropminimatch@9. The PAC check only neededshExpMatchsemantics (*and?— no**, braces, or character classes), so it is a small self-contained matcher now. 6 new specs cover the semantics, including the cases whereshExpMatchand minimatch differ.@percy/core:fast-xml-parser^4.4.1→^4.5.7.On fast-xml-parser: why 4.5.7 and not 5.x
My first push bumped this to
^5.7.0and brokeyarn installon every CI job, all of which pin Node 14:^5.7.0floats to 5.10.1, which depends onxml-naming(engines>=16). Pinning fxp alone does not help — 5.7.x depends onfast-xml-builder ^1.1.7, andfast-xml-builder@1.2.0+pullsxml-namingin as well. Holding Node 14 on 5.x would require aresolutionspin on a dependency-of-a-dependency — the same class of fragile pin this PR set out to avoid.So this takes the top of the 4.x line (4.5.7, npm
legacytag), which clears every fast-xml-parser advisory that has a 4.x fix:GHSA-m7jm(CRITICAL, patched 4.5.4),GHSA-8gc5(HIGH, 4.5.5),GHSA-jp2q(MODERATE, 4.5.5),GHSA-fj3w(LOW, 4.5.4).One advisory remains and is deliberately accepted:
GHSA-gh4j-gqv2-49f6(MODERATE, vulnerable range< 5.7.0) — XMLBuilder comment/CDATA injection via unescaped delimiters. It is not reachable from our code:maestro-hierarchy.jsis the only consumer, it importsXMLParseronly (neverXMLBuilder), and parses withprocessEntities: false.So the honest score is 5 advisories → 1, not zero. Reaching literal zero requires either Node ≥16 or a transitive-dep pin. Happy to go either way if reviewers prefer — flagging it rather than burying it.
Verification
yarn.lock(127 external packages, prod deps only, seeded from each workspace package'sdependencies):rimraf,minimatch,glob,inflight,brace-expansionall absent; no Node-16-only package present;fast-xml-parserresolves to 4.5.7 withstrnum@1.1.2as its only dependency (strnumhas no advisories).@percy/cli-doctor: 514/514 specs pass (508 existing + 6 new). Independent confirmation thatminimatch@9is gone: master'spac.jscan no longer even load in this tree.fs.promises.rmbehaviour checked directly: recursive delete, missing-path tolerance underforce, and thatmaxRetries/retryDelayare accepted on our Node floor.@percy/coresuite: gating on CI. Local runs here are contaminated by leftover real temp dirs (percy-self-hosted-real-root,percy-bs-tmp-real-root) from an earlier crashed run: core mocksfswith memfs, so thefs.rmSync(recursive, force)cleanup inapi.test.jscannot clear real leftovers, and the whole maestro self-hosted group then 404s. Those paths do not exist on a fresh CI machine, whereforce: trueno-ops. Please gate on the CI result rather than my local run.Ref: PER-10247
🤖 Generated with Claude Code