Repository navigation
fix(frontend): override lodash-es and update vulnerable dependencies - #976
Conversation
lodash-es 4.17.23 has a high-severity advisory for code injection through _.template imports keys (GHSA-r5fr-rjxr-66jc) and a moderate one for prototype pollution in _.unset and _.omit (GHSA-f23m-r3pf-42rh). It reaches the frontend bundle through mermaid 12.0.0, which pins chevrotain ~11.1.2, and chevrotain 11.1.2 pins lodash-es to exactly 4.17.23, so no normal update can move it. npm audit's suggested fix is to downgrade mermaid to 11.17.2. Mermaid 12.0.0 is the latest release, so an override is the smaller change. 4.18.0 changes behavior only in _.template, _.unset and _.omit, and 4.18.1 fixes a build regression in 4.18.0. Neither chevrotain nor dagre-d3-es, the other lodash-es consumer, calls those three. Drop this override once mermaid ships a newer chevrotain (mermaid-js/mermaid#8273).
After the lodash-es override, npm audit still reported 16 findings in the frontend lockfile. All have patched releases inside the ranges their dependents already declare, so package.json is untouched. In the non-dev dependency tree: gray-matter's js-yaml 3.15.2, mdast-util-to-hast 13.2.1, yaml 1.10.3 (via cosmiconfig) and uuid 14.0.2. uuid is the one major bump: it comes in through mermaid 12, whose range is ^11.1.0 || ^12 || ^13 || ^14.0.0, so npm resolves 14 on any fresh install as well. The rest are build and test tooling, such as postcss, browserslist, nanoid, fast-uri, picomatch, minimatch and serialize-javascript. npm audit fix left three stale nested entries behind (webpack/node_modules/browserslist, its update-browserslist-db, and @humanfs/node 0.16.6). They were removed from the lockfile and re-resolved to the patched hoisted versions rather than bumping webpack and eslint themselves. npm audit now reports 0 for packages/frontend.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review. 📝 WalkthroughWalkthroughThe frontend package overrides configuration adds ChangesFrontend dependency configuration
Priority: ➖ Normal Estimated code review effort: 1 (Trivial) | ~3 minutes Change: Other Merge Risk: ⚪ Minimal · up to The dependency updates show no established compatibility failure in the reachable frontend path, so no actionable merge risk remains. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Some tools did not complete. Review the errors below. 🔧 ESLint
packages/frontend/package.jsonESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
✅ Deploy Preview for mdts-unhappychoice ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #976 +/- ##
=======================================
Coverage 99.33% 99.33%
=======================================
Files 71 71
Lines 1663 1663
Branches 397 408 +11
=======================================
Hits 1652 1652
Misses 10 10
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
unhappychoice
left a comment
There was a problem hiding this comment.
Thanks! Verified locally: clean npm ci, tests, lint and builds pass.
Why
npm auditinpackages/frontendreported 21 findings (14 high, 6 moderate, 1 low). Seven advisories are in non-dev dependencies:lodash-es4.17.23_.templateimports keyslodash-es4.17.23_.unsetand_.omitjs-yaml3.15.0 (viagray-matter)!!omapresolutionjs-yaml3.15.0 (viagray-matter)maxTotalMergeKeysdoes not limit CPU for empty merge sourcesmdast-util-to-hast13.2.0classattributeuuid11.1.0 (viamermaid)yaml1.10.2The rest are in build and test tooling.
lodash-escannot be fixed by an update.mermaid12.0.0, the latest release, pinschevrotain ~11.1.2, andchevrotain11.1.2 pinslodash-esto exactly 4.17.23. npm's only suggested fix isnpm audit fix --force, which downgradesmermaidto 11.17.2. The upstream fix is mermaid-js/mermaid#8273, which is still open.What changed
One
overridesentry and a lockfile refresh. No source changes.packages/frontend/package.json:"lodash-es": "^4.18.1"added tooverrides.packages/frontend/package-lock.json: the override,npm audit fix, and three stale nested entries thataudit fixleft behind (webpack/node_modules/browserslist, itsupdate-browserslist-db, and@humanfs/node0.16.6). Those were re-resolved to the patched hoisted versions, which avoids bumpingwebpackandeslintthemselves.The other 17 version changes are dev-only (
postcss,browserslist,nanoid,fast-uri,picomatch,minimatch,serialize-javascript,lodashand others). None crosses a major version.Why this is safe:
lodash-es4.18: 4.18.0 changes behavior only in_.template,_.unsetand_.omit, and 4.18.1 fixes a build regression in 4.18.0 (release notes). Its two consumers here,chevrotainanddagre-d3-es, call none of those three functions.uuid14 is the one major bump.mermaid12 declares^11.1.0 || ^12 || ^13 || ^14.0.0, so a fresh install already resolves 14. Nothing insrc/importsuuiddirectly.How it was verified
The Jest suite mocks
mermaid(test/__mocks__/mermaid.tsx), so it exercises neitherlodash-esnoruuid. The built app was therefore rendered in headless Chrome, on this branch and onmain.example_documents/features/mermaid.md, served bynode dist/index.jsand loaded over the Chrome DevTools protocol, renders all 8 diagrams (flowchart, sequence, class, state, gantt, pie, gitGraph, journey) with no mermaid error output.pieandgitGraphgo through mermaid's langium/chevrotain parser, the code that useslodash-es.mainalso renders 8/8.defaultCollapseIcon,defaultExpandIconand a non-booleanbuttonattribute).npm run build:frontendpasses afternpm cifrom the new lockfile, with 37 webpack warnings, the same count as onmain.packages/frontend,npm test321/321 andnpm run lint124/124, the same asmain.npm auditreports 0.Reviewer note
The
lodash-esoverride should be removed oncemermaidships a newerchevrotain(mermaid-js/mermaid#8273). Until then, it holdslodash-esat 4.18.x for every package in the frontend tree, not justchevrotain.Summary by CodeRabbit