cve-lite-cli 1.23.0 → 1.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
 
2
- [![OWASP Incubator Project](https://img.shields.io/badge/OWASP-Incubator%20Project-48A646?logo=owasp)](https://owasp.org/cve-lite-cli)
2
+ [![OWASP Lab Project](https://img.shields.io/badge/OWASP-Lab%20Project-48A646?logo=owasp)](https://owasp.org/cve-lite-cli)
3
3
  [![npm version](https://img.shields.io/npm/v/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/cve-lite-cli)](https://www.npmjs.com/package/cve-lite-cli)
5
5
  [![CI](https://img.shields.io/github/actions/workflow/status/OWASP/cve-lite-cli/ci.yml?branch=main)](https://github.com/OWASP/cve-lite-cli/actions)
@@ -15,7 +15,7 @@
15
15
 
16
16
  <h1>CVE Lite CLI</h1>
17
17
 
18
- **🏆 Officially recognized as an [OWASP Incubator Project](https://owasp.org/cve-lite-cli)**
18
+ **🏆 Officially recognized as an [OWASP Lab Project](https://owasp.org/cve-lite-cli)**
19
19
 
20
20
  <p>Vulnerability scanning that belongs in your terminal — not your CI pipeline.<br/>Scan your lockfile, get copy-and-run fix commands, and ship clean code.</p>
21
21
 
@@ -25,7 +25,7 @@
25
25
 
26
26
  <table>
27
27
  <tr>
28
- <td align="center" width="33%"><p>🏆</p><strong>OWASP Incubator Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10 —<br/>the security standard followed by millions of developers</sub></td>
28
+ <td align="center" width="33%"><p>🏆</p><strong>OWASP Lab Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10 —<br/>the security standard followed by millions of developers</sub></td>
29
29
  <td align="center" width="33%"><p>🎯</p><strong>Remediation-first</strong><br/><sub>Validated fix commands + parent-aware<br/>transitive guidance — not just CVE IDs</sub></td>
30
30
  <td align="center" width="33%"><p>🔒</p><strong>Runs locally</strong><br/><sub>Nothing leaves your machine — not your<br/>code, not your dependency tree</sub></td>
31
31
  </tr>
@@ -226,8 +226,12 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
226
226
  - [n8n](https://owasp.org/cve-lite-cli/docs/case-studies/n8n) — verified baseline scan of a workflow automation pnpm monorepo (3,746 packages, 32 findings at revision `e2e0394`) with one direct `turbo` fix, four command groups, and email/editor transitive clusters
227
227
  - [CamoFox Browser](https://owasp.org/cve-lite-cli/docs/case-studies/camofox-browser) — verified baseline scan of an AI agent browser automation npm graph (435 packages, 2 findings at revision `ce3a3b0`) with dual `qs` fix strategies — within-range `npm update qs` and parent `npm install express@4.22.2`
228
228
  - [Storybook](https://owasp.org/cve-lite-cli/docs/case-studies/storybook) — verified baseline scan of a Yarn Berry monorepo (3,008 packages, 92 findings at revision `cc19ae1`) spanning cross-framework sandbox templates, five critical transitive chains, and one direct vite fix command
229
+ - [Twenty](https://owasp.org/cve-lite-cli/docs/case-studies/twenty) — verified baseline scan of an open-source CRM Yarn Berry monorepo (5,451 packages, 105 findings at revision `fc90b4b`) with 0 direct findings, six critical test-stack chains, and four Nx parent-upgrade command groups
230
+ - [Strapi](https://owasp.org/cve-lite-cli/docs/case-studies/strapi) — verified baseline scan of a headless CMS Yarn Berry monorepo (2,887 packages, 18 findings) with two direct findings (`lodash`, `qs`) and mixed transitive remediation paths
231
+ - [Payload CMS](https://owasp.org/cve-lite-cli/docs/case-studies/payload) — verified baseline scan of a TypeScript-first headless CMS pnpm monorepo (2,602 packages, 18 findings) with one direct finding and workspace-scoped fix commands
232
+ - [Presenton](https://owasp.org/cve-lite-cli/docs/case-studies/presenton) — verified baseline scan of an AI presentation generator with dual npm lockfiles (root + Electron shell), demonstrating multi-lockfile coverage across 9 findings
229
233
 
230
- In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, CamoFox Browser, and Storybook live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
234
+ In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, CamoFox Browser, Storybook, Twenty, Strapi, Payload CMS, and Presenton live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
231
235
 
232
236
  These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
233
237
 
@@ -251,7 +255,7 @@ If you maintain an open-source JavaScript or TypeScript project and want CVE Lit
251
255
 
252
256
  OWASP (Open Web Application Security Project) is the globally recognized nonprofit behind the security standards followed by millions of developers worldwide — most notably the [OWASP Top 10](https://owasp.org/www-project-top-ten/), the most widely cited web application security reference in the industry. Organizations from startups to Fortune 500 companies use OWASP guidelines as the foundation of their security programs.
253
257
 
254
- CVE Lite CLI is an [OWASP Incubator Project](https://owasp.org/cve-lite-cli) — reviewed and accepted by the OWASP community as a vendor-neutral, open source security tool. Being part of OWASP means:
258
+ CVE Lite CLI is an [OWASP Lab Project](https://owasp.org/cve-lite-cli) — reviewed and accepted by the OWASP community as a vendor-neutral, open source security tool. Being part of OWASP means:
255
259
 
256
260
  - **Peer-reviewed** by security professionals
257
261
  - **Community-driven** development and governance
@@ -480,7 +484,7 @@ npm run build
480
484
 
481
485
  ## Governance
482
486
 
483
- CVE Lite CLI is an OWASP Incubator Project maintained by Sonu Kapoor as project lead. The project follows a single-maintainer (benevolent dictator) governance model. The project lead makes final decisions on scope, design direction, and releases after considering input from contributors and the wider community.
487
+ CVE Lite CLI is an OWASP Lab Project maintained by Sonu Kapoor as project lead. The project follows a single-maintainer (benevolent dictator) governance model. The project lead makes final decisions on scope, design direction, and releases after considering input from contributors and the wider community.
484
488
 
485
489
  ### Roles
486
490
 
package/dist/cli/args.js CHANGED
@@ -267,9 +267,6 @@ export function parseArgs(argv) {
267
267
  }
268
268
  throw new Error(`Unexpected argument: ${arg}`);
269
269
  }
270
- if (options.sarif && options.report) {
271
- throw new Error("cannot combine --sarif and --report");
272
- }
273
270
  if (options.cdx && options.report) {
274
271
  throw new Error("cannot combine --cdx and --report");
275
272
  }
@@ -90,7 +90,7 @@ export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
90
90
  try {
91
91
  fs.rmSync(outputPath, { force: true });
92
92
  }
93
- catch { }
93
+ catch { /* best-effort cleanup */ }
94
94
  throw new Error(`Failed to write CycloneDX report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
95
95
  }
96
96
  return filename;
@@ -609,7 +609,7 @@ export async function writeHtmlReport(params) {
609
609
  try {
610
610
  fs.rmSync(params.outputDir, { recursive: true, force: true });
611
611
  }
612
- catch { }
612
+ catch { /* best-effort cleanup */ }
613
613
  }
614
614
  throw new Error(`Failed to write HTML report to ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
615
615
  }
@@ -88,7 +88,7 @@ export function writeSarifReport(findings, lockfileUri, plan) {
88
88
  try {
89
89
  fs.rmSync(outputPath, { force: true });
90
90
  }
91
- catch { }
91
+ catch { /* best-effort cleanup */ }
92
92
  throw new Error(`Failed to write SARIF report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
93
93
  }
94
94
  return filename;
@@ -1,5 +1,5 @@
1
1
  import fs from "node:fs";
2
- import { unique, uniquePathArrays } from "../utils/array.js";
2
+ import { unique } from "../utils/array.js";
3
3
  export function loadNpmLockGraph(filePath, options) {
4
4
  const raw = JSON.parse(fs.readFileSync(filePath, "utf8"));
5
5
  const packages = raw?.packages;
@@ -17,9 +17,9 @@ export function loadNpmLockGraph(filePath, options) {
17
17
  return createGraph({
18
18
  entryPackages: [],
19
19
  nodesById,
20
- nodeIdsByPackageKey,
21
- parentNodeIdsByChildNodeId,
22
- childNodeIdsByParentNodeId,
20
+ nodeIdsByPackageKey: setsToArrays(nodeIdsByPackageKey),
21
+ parentNodeIdsByChildNodeId: setsToArrays(parentNodeIdsByChildNodeId),
22
+ childNodeIdsByParentNodeId: setsToArrays(childNodeIdsByParentNodeId),
23
23
  rangeByParentNodeId,
24
24
  pathSetByNodeId,
25
25
  });
@@ -46,7 +46,9 @@ export function loadNpmLockGraph(filePath, options) {
46
46
  dev: !!meta?.dev,
47
47
  });
48
48
  nodeIdByPackagePath.set(packagePath, id);
49
- nodeIdsByPackageKey.set(packageKey, [...(nodeIdsByPackageKey.get(packageKey) ?? []), id]);
49
+ const keySet = nodeIdsByPackageKey.get(packageKey) ?? new Set();
50
+ keySet.add(id);
51
+ nodeIdsByPackageKey.set(packageKey, keySet);
50
52
  dependencyRangesByNodeId.set(id, collectDependencyRanges(resolveDependencySource(meta, rawPackages)));
51
53
  resolutionBasePathsByNodeId.set(id, resolveBasePaths(packagePath, meta));
52
54
  }
@@ -87,37 +89,56 @@ export function loadNpmLockGraph(filePath, options) {
87
89
  return createGraph({
88
90
  entryPackages,
89
91
  nodesById,
90
- nodeIdsByPackageKey,
91
- parentNodeIdsByChildNodeId,
92
- childNodeIdsByParentNodeId,
92
+ nodeIdsByPackageKey: setsToArrays(nodeIdsByPackageKey),
93
+ parentNodeIdsByChildNodeId: setsToArrays(parentNodeIdsByChildNodeId),
94
+ childNodeIdsByParentNodeId: setsToArrays(childNodeIdsByParentNodeId),
93
95
  rangeByParentNodeId,
94
96
  pathSetByNodeId,
95
97
  });
96
98
  }
97
99
  function createGraph(args) {
98
100
  const entryPackages = Object.freeze([...unique(args.entryPackages)]);
101
+ const EMPTY_ARRAY = Object.freeze([]);
102
+ // Pre-freeze all node objects so getNode() returns a pre-computed frozen copy
103
+ const frozenNodesById = new Map();
104
+ for (const [id, node] of args.nodesById) {
105
+ frozenNodesById.set(id, Object.freeze({ ...node }));
106
+ }
107
+ // Pre-freeze all package-key -> nodeId arrays
108
+ const frozenNodeIdsByPackageKey = new Map();
109
+ for (const [key, ids] of args.nodeIdsByPackageKey) {
110
+ frozenNodeIdsByPackageKey.set(key, Object.freeze([...ids]));
111
+ }
112
+ // Pre-freeze all parent arrays
113
+ const frozenParentsByChild = new Map();
114
+ for (const [id, parents] of args.parentNodeIdsByChildNodeId) {
115
+ frozenParentsByChild.set(id, Object.freeze([...parents]));
116
+ }
117
+ // Pre-freeze all children arrays
118
+ const frozenChildrenByParent = new Map();
119
+ for (const [id, children] of args.childNodeIdsByParentNodeId) {
120
+ frozenChildrenByParent.set(id, Object.freeze([...children]));
121
+ }
99
122
  return {
100
123
  entryPackages,
101
124
  nodeIdsFor(name, version) {
102
- return Object.freeze([...(args.nodeIdsByPackageKey.get(buildPackageKey(name, version)) ?? [])]);
125
+ return frozenNodeIdsByPackageKey.get(buildPackageKey(name, version)) ?? EMPTY_ARRAY;
103
126
  },
104
127
  getNode(nodeId) {
105
- const node = args.nodesById.get(nodeId);
106
- return node ? Object.freeze({ ...node }) : null;
128
+ return frozenNodesById.get(nodeId) ?? null;
107
129
  },
108
130
  parentsFor(nodeId) {
109
- return Object.freeze([...(args.parentNodeIdsByChildNodeId.get(nodeId) ?? [])]);
131
+ return frozenParentsByChild.get(nodeId) ?? EMPTY_ARRAY;
110
132
  },
111
133
  childrenFor(nodeId) {
112
- return Object.freeze([...(args.childNodeIdsByParentNodeId.get(nodeId) ?? [])]);
134
+ return frozenChildrenByParent.get(nodeId) ?? EMPTY_ARRAY;
113
135
  },
114
136
  rangeFor(parentNodeId, childName) {
115
137
  return args.rangeByParentNodeId.get(parentNodeId)?.get(childName) ?? null;
116
138
  },
117
139
  pathsFor(nodeId) {
118
- const serializedPaths = [...(args.pathSetByNodeId.get(nodeId) ?? new Set())]
140
+ return [...(args.pathSetByNodeId.get(nodeId) ?? new Set())]
119
141
  .map((item) => item.split(">"));
120
- return uniquePathArrays(serializedPaths);
121
142
  },
122
143
  };
123
144
  }
@@ -134,8 +155,12 @@ function resolveEdgesForParent(parentPackagePath, dependencyRanges, resolutionBa
134
155
  const parentNodeId = parentPackagePath ? nodeIdByPackagePath.get(parentPackagePath) : null;
135
156
  if (!parentNodeId)
136
157
  continue;
137
- childNodeIdsByParentNodeId.set(parentNodeId, unique([...(childNodeIdsByParentNodeId.get(parentNodeId) ?? []), childNodeId]));
138
- parentNodeIdsByChildNodeId.set(childNodeId, unique([...(parentNodeIdsByChildNodeId.get(childNodeId) ?? []), parentNodeId]));
158
+ const childSet = childNodeIdsByParentNodeId.get(parentNodeId) ?? new Set();
159
+ childSet.add(childNodeId);
160
+ childNodeIdsByParentNodeId.set(parentNodeId, childSet);
161
+ const parentSet = parentNodeIdsByChildNodeId.get(childNodeId) ?? new Set();
162
+ parentSet.add(parentNodeId);
163
+ parentNodeIdsByChildNodeId.set(childNodeId, parentSet);
139
164
  const rangesForParent = rangeByParentNodeId.get(parentNodeId) ?? new Map();
140
165
  rangesForParent.set(dependencyName, range);
141
166
  rangeByParentNodeId.set(parentNodeId, rangesForParent);
@@ -214,6 +239,13 @@ function rememberPath(pathSetByNodeId, nodeId, pathParts) {
214
239
  existing.add(serialized);
215
240
  pathSetByNodeId.set(nodeId, existing);
216
241
  }
242
+ function setsToArrays(map) {
243
+ const result = new Map();
244
+ for (const [key, set] of map) {
245
+ result.set(key, [...set]);
246
+ }
247
+ return result;
248
+ }
217
249
  function isRecord(value) {
218
250
  return !!value && typeof value === "object";
219
251
  }
@@ -32,6 +32,10 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
32
32
  // workspace map is best-effort
33
33
  }
34
34
  }
35
+ const devLookup = new Map();
36
+ for (const pkg of scanInput.packages) {
37
+ devLookup.set(`${pkg.name}@${pkg.version}`, pkg.dev ?? false);
38
+ }
35
39
  const prioritizedFindings = [...findings]
36
40
  .filter(f => f.severity === "critical" || f.severity === "high")
37
41
  .sort((a, b) => {
@@ -115,6 +119,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
115
119
  reason: `Direct upgrade target for ${finding.pkg.name}@${finding.pkg.version}`,
116
120
  usage: finding.usage ?? null,
117
121
  workspaces: pkgWorkspaces.length > 0 ? pkgWorkspaces : undefined,
122
+ isDev: finding.pkg.dev ?? false,
118
123
  });
119
124
  }
120
125
  else if (finding.fixVersionValidationNote) {
@@ -172,6 +177,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
172
177
  reason: finding.recommendedNpmTransitiveRemediation.reason,
173
178
  command: buildNpmUpdateCommand(finding.recommendedNpmTransitiveRemediation.package, finding.recommendedNpmTransitiveRemediation.workspaces),
174
179
  usage: finding.usage ?? null,
180
+ isDev: devLookup.get(`${finding.recommendedNpmTransitiveRemediation.package}@${finding.recommendedNpmTransitiveRemediation.currentVersion}`) ?? false,
175
181
  });
176
182
  continue;
177
183
  }
@@ -197,6 +203,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
197
203
  coveredPaths: coverage.coveredPaths,
198
204
  remainingPaths: coverage.remainingPaths,
199
205
  usage: finding.usage ?? null,
206
+ isDev: devLookup.get(`${finding.recommendedNpmTransitiveRemediation.package}@${finding.recommendedNpmTransitiveRemediation.currentVersion}`) ?? false,
200
207
  });
201
208
  continue;
202
209
  }
@@ -220,6 +227,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
220
227
  coveredPaths: coverage.coveredPaths,
221
228
  remainingPaths: coverage.remainingPaths,
222
229
  usage: finding.usage ?? null,
230
+ isDev: devLookup.get(`${finding.recommendedParentUpgrade.package}@${finding.recommendedParentUpgrade.currentVersion}`) ?? false,
223
231
  });
224
232
  continue;
225
233
  }
@@ -360,6 +368,9 @@ function commandPrefix(packageManager) {
360
368
  return "bun add";
361
369
  return "yarn add";
362
370
  }
371
+ function devFlag(packageManager) {
372
+ return packageManager === "bun" ? "--dev" : "-D";
373
+ }
363
374
  export function findSuggestedCommandForFinding(plan, finding) {
364
375
  const target = plan.targets.find(item => {
365
376
  if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
@@ -389,7 +400,8 @@ export function findSuggestedCommandForFinding(plan, finding) {
389
400
  if (commands.length > 0)
390
401
  return commands.join(" && ");
391
402
  }
392
- return `${commandPrefix(plan.packageManager)} ${target.package}@${target.targetVersion}`;
403
+ const flag = target.isDev ? ` ${devFlag(plan.packageManager)}` : "";
404
+ return `${commandPrefix(plan.packageManager)}${flag} ${target.package}@${target.targetVersion}`;
393
405
  }
394
406
  function packageManagerSourceLabel(scanInput) {
395
407
  if (scanInput.filePath) {
@@ -424,6 +436,7 @@ function upsertTarget(targetsByPackage, next) {
424
436
  : "parent-upgrade",
425
437
  displayTargetVersion: existing.displayTargetVersion ?? next.displayTargetVersion,
426
438
  command: existing.command ?? next.command,
439
+ isDev: (existing.isDev ?? false) && (next.isDev ?? false),
427
440
  workspaces: mergeStringArrays(existing.workspaces, next.workspaces),
428
441
  coverage: existing.coverage === "partial" || next.coverage === "partial"
429
442
  ? "partial"
@@ -570,32 +583,39 @@ function buildWorkspaceInstallCommands(targets, packageManager) {
570
583
  const groups = groupByWorkspaceKey(targets);
571
584
  const commands = [];
572
585
  for (const [wsKey, groupTargets] of groups) {
573
- const pkgArgs = groupTargets.map(t => `${t.package}@${t.targetVersion}`).join(" ");
574
586
  const workspaces = wsKey ? wsKey.split("\0") : [];
575
- if (packageManager === "npm") {
576
- const wsFlags = workspaces.map(ws => `-w ${ws}`).join(" ");
577
- commands.push(`npm install${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
578
- }
579
- else if (packageManager === "pnpm") {
580
- const wsFlags = workspaces.map(ws => `--filter ./${ws}`).join(" ");
581
- commands.push(`pnpm add${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
582
- }
583
- else if (packageManager === "yarn") {
584
- if (workspaces.length === 0) {
585
- commands.push(`yarn add ${pkgArgs}`);
587
+ const devTargets = groupTargets.filter(t => t.isDev);
588
+ const prodTargets = groupTargets.filter(t => !t.isDev);
589
+ for (const [targets, isDev] of [[prodTargets, false], [devTargets, true]]) {
590
+ if (targets.length === 0)
591
+ continue;
592
+ const pkgArgs = targets.map(t => `${t.package}@${t.targetVersion}`).join(" ");
593
+ const flag = isDev ? ` ${devFlag(packageManager)}` : "";
594
+ if (packageManager === "npm") {
595
+ const wsFlags = workspaces.map(ws => `-w ${ws}`).join(" ");
596
+ commands.push(`npm install${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
586
597
  }
587
- else {
588
- for (const ws of workspaces) {
589
- commands.push(`yarn workspace ${ws} add ${pkgArgs}`);
598
+ else if (packageManager === "pnpm") {
599
+ const wsFlags = workspaces.map(ws => `--filter ./${ws}`).join(" ");
600
+ commands.push(`pnpm add${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
601
+ }
602
+ else if (packageManager === "yarn") {
603
+ if (workspaces.length === 0) {
604
+ commands.push(`yarn add${flag} ${pkgArgs}`);
605
+ }
606
+ else {
607
+ for (const ws of workspaces) {
608
+ commands.push(`yarn workspace ${ws} add${flag} ${pkgArgs}`);
609
+ }
590
610
  }
591
611
  }
592
- }
593
- else if (packageManager === "bun") {
594
- const wsFlags = workspaces.map(ws => `--filter ${ws}`).join(" ");
595
- commands.push(`bun add${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
596
- }
597
- else {
598
- commands.push(`${commandPrefix(packageManager)} ${pkgArgs}`);
612
+ else if (packageManager === "bun") {
613
+ const wsFlags = workspaces.map(ws => `--filter ${ws}`).join(" ");
614
+ commands.push(`bun add${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
615
+ }
616
+ else {
617
+ commands.push(`${commandPrefix(packageManager)}${flag} ${pkgArgs}`);
618
+ }
599
619
  }
600
620
  }
601
621
  return commands;
@@ -621,7 +641,14 @@ function buildCommandForTargets(targets, packageManager) {
621
641
  commandParts.push(...buildWorkspaceInstallCommands(installTargets, packageManager));
622
642
  }
623
643
  else {
624
- commandParts.push(`${commandPrefix(packageManager)} ${installTargets.map(target => `${target.package}@${target.targetVersion}`).join(" ")}`);
644
+ const prodInstall = installTargets.filter(t => !t.isDev);
645
+ const devInstall = installTargets.filter(t => t.isDev);
646
+ if (prodInstall.length > 0) {
647
+ commandParts.push(`${commandPrefix(packageManager)} ${prodInstall.map(t => `${t.package}@${t.targetVersion}`).join(" ")}`);
648
+ }
649
+ if (devInstall.length > 0) {
650
+ commandParts.push(`${commandPrefix(packageManager)} ${devFlag(packageManager)} ${devInstall.map(t => `${t.package}@${t.targetVersion}`).join(" ")}`);
651
+ }
625
652
  }
626
653
  }
627
654
  return commandParts.join(" && ");
@@ -14,6 +14,7 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
14
14
  const vulnerableName = args.finding.pkg.name;
15
15
  const fixHint = args.finding.validatedFirstFixedVersion ?? args.finding.firstFixedVersion;
16
16
  if (directParentName !== immediateParentName) {
17
+ const packagesByName = new Map(args.packages.map(p => [p.name, p]));
17
18
  return resolveWithinRangeForDeepChainViaRegistry({
18
19
  immediateParentName,
19
20
  vulnerableName,
@@ -21,6 +22,7 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
21
22
  fixHint,
22
23
  viaPath,
23
24
  packages: args.packages,
25
+ packagesByName,
24
26
  workspaceMap: args.workspaceMap,
25
27
  });
26
28
  }
@@ -68,6 +70,7 @@ export async function resolveNpmTransitiveRemediation(args) {
68
70
  // immediate parent's declared range for the vulnerable package already covers a safe version.
69
71
  // If so, a lockfile refresh of the vulnerable package itself is sufficient.
70
72
  if (directParentName !== immediateParentName) {
73
+ const packagesByName = new Map(args.packages.map(p => [p.name, p]));
71
74
  return resolveWithinRangeForDeepChain({
72
75
  graph: args.graph,
73
76
  immediateParentName,
@@ -76,6 +79,7 @@ export async function resolveNpmTransitiveRemediation(args) {
76
79
  fixHint,
77
80
  viaPath,
78
81
  packages: args.packages,
82
+ packagesByName,
79
83
  offline: args.offline,
80
84
  });
81
85
  }
@@ -301,7 +305,7 @@ function parseCoreVersion(version) {
301
305
  return [Number(major), Number(minor), Number(patch)];
302
306
  }
303
307
  async function resolveWithinRangeForDeepChainViaRegistry(args) {
304
- const immediateParent = args.packages.find(pkg => pkg.name === args.immediateParentName);
308
+ const immediateParent = args.packagesByName.get(args.immediateParentName);
305
309
  if (!immediateParent || !looksLikeVersion(immediateParent.version))
306
310
  return null;
307
311
  const safeCandidates = await findSafeChildCandidates(args.vulnerableName, args.installedVersion, args.fixHint);
@@ -331,7 +335,7 @@ async function resolveWithinRangeForDeepChainViaRegistry(args) {
331
335
  };
332
336
  }
333
337
  async function resolveWithinRangeForDeepChain(args) {
334
- const immediateParent = args.packages.find(p => p.name === args.immediateParentName);
338
+ const immediateParent = args.packagesByName.get(args.immediateParentName);
335
339
  if (!immediateParent || !looksLikeVersion(immediateParent.version))
336
340
  return null;
337
341
  const nodeIds = args.graph.nodeIdsFor(args.immediateParentName, immediateParent.version);
@@ -10,7 +10,8 @@ export async function resolveRecommendedParentUpgrade(finding, packages, directD
10
10
  const viaPath = getBestPath(finding);
11
11
  if (!viaPath || viaPath.length < 3)
12
12
  return null;
13
- const directParentContext = resolveDirectParentContext(viaPath, packages, directDependencyNames);
13
+ const packagesByName = new Map(packages.map(p => [p.name, p]));
14
+ const directParentContext = resolveDirectParentContext(viaPath, packages, directDependencyNames, packagesByName);
14
15
  if (!directParentContext)
15
16
  return null;
16
17
  const { directParentName, immediateParentName, directParent } = directParentContext;
@@ -49,13 +50,13 @@ function getBestPath(finding) {
49
50
  return null;
50
51
  return [...paths].sort((a, b) => a.length - b.length)[0] ?? null;
51
52
  }
52
- function findDirectDependency(packages, name, directDependencyNames) {
53
+ function findDirectDependency(packages, name, directDependencyNames, packagesByName) {
54
+ if (directDependencyNames?.has(name)) {
55
+ return packagesByName.get(name) ?? null;
56
+ }
53
57
  for (const pkg of packages) {
54
58
  if (pkg.name !== name)
55
59
  continue;
56
- if (directDependencyNames?.has(name)) {
57
- return pkg;
58
- }
59
60
  const paths = pkg.paths ?? [];
60
61
  if (paths.some(path => path.at(-1) === name && path.length >= 2)) {
61
62
  return pkg;
@@ -63,7 +64,7 @@ function findDirectDependency(packages, name, directDependencyNames) {
63
64
  }
64
65
  return null;
65
66
  }
66
- function resolveDirectParentContext(viaPath, packages, directDependencyNames) {
67
+ function resolveDirectParentContext(viaPath, packages, directDependencyNames, packagesByName) {
67
68
  const immediateParentName = viaPath[viaPath.length - 2];
68
69
  const candidateSegments = viaPath.slice(1, -1);
69
70
  const directParentCandidates = directDependencyNames
@@ -72,12 +73,16 @@ function resolveDirectParentContext(viaPath, packages, directDependencyNames) {
72
73
  const directParentName = directParentCandidates[0];
73
74
  if (!directParentName)
74
75
  return null;
75
- const directParent = findDirectDependency(packages, directParentName, directDependencyNames);
76
+ const directParent = findDirectDependency(packages, directParentName, directDependencyNames, packagesByName);
76
77
  if (!directParent)
77
78
  return null;
78
79
  return { directParentName, immediateParentName, directParent };
79
80
  }
80
81
  function findPackageVersion(packages, name, pathPrefix) {
82
+ // Cannot use a name-keyed Map here: when the same package is installed at
83
+ // multiple versions (e.g. lodash@3 and lodash@4 on different paths), a Map
84
+ // would only hold one entry. We need path-aware iteration across all installed
85
+ // versions to find the right one for this specific dependency chain.
81
86
  for (const pkg of packages) {
82
87
  if (pkg.name !== name)
83
88
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.23.0",
3
+ "version": "1.24.0",
4
4
  "description": "Developer-friendly CLI for scanning JS/TS projects for dependency vulnerabilities using local lockfiles and OSV",
5
5
  "type": "module",
6
6
  "bin": {
@@ -23,7 +23,7 @@
23
23
  "@types/better-sqlite3": "^7.6.13",
24
24
  "@types/jest": "^30.0.0",
25
25
  "@types/node": "^24.0.0",
26
- "jest": "^30.3.0",
26
+ "jest": "^30.4.1",
27
27
  "ts-jest": "^29.4.9",
28
28
  "tsx": "^4.22.0",
29
29
  "typescript": "^5.8.2"