cve-lite-cli 1.29.0 → 1.30.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
@@ -329,10 +329,11 @@ CVE Lite CLI is used in production across organizations and independent develope
329
329
 
330
330
  Notable adopters include:
331
331
 
332
+ - **SolidJS** - the framework's creator, Ryan Carniato, added CVE Lite CLI directly to its CI, scanning every change with results reported to GitHub Code Scanning
332
333
  - **DINUM** (France) - integrated across four French government digital service repositories, including official AI training infrastructure for civil servants
333
334
  - **DGAFP** (France) - Ministry for Civil Service, used as a pre-commit hook on a public-sector HR chatbot
334
335
  - **Government of British Columbia** (Canada) - running as a required merge gate alongside Trivy at the Ministry of Citizens' Services
335
- - **Valibot** and **Formish** - integrated as a GitHub Action and dev script with branch protection
336
+ - **Valibot** and **Formisch** - integrated as a GitHub Action and dev script with branch protection
336
337
 
337
338
 
338
339
  ## Current limitations
@@ -59,6 +59,9 @@ export class OsvAdvisorySource {
59
59
  throw new Error(`OSV batch query failed: ${response.status} ${response.statusText}`);
60
60
  }
61
61
  const data = await response.json();
62
+ if (!Array.isArray(data?.results)) {
63
+ throw new Error('OSV batch query returned a 200 response with no "results" array');
64
+ }
62
65
  return data.results.map((r, i) => ({
63
66
  package: packages[i].name,
64
67
  version: packages[i].version,
package/dist/cli/help.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { chalk } from "../utils/chalk.js";
2
2
  import { getCliVersion } from "../utils/version-info.js";
3
3
  import { checkForUpdate } from "../utils/update-check.js";
4
+ import { OVERRIDES_COMMAND } from "../constants.js";
4
5
  const CLI_VERSION = getCliVersion();
5
6
  const CLI_BANNER = [
6
7
  `${chalk.green(">_")} ${chalk.bold.whiteBright(`CVE Lite CLI (${CLI_VERSION})`)}`,
@@ -27,7 +28,7 @@ export function printHelp() {
27
28
  " cve-lite advisories init [options]",
28
29
  " cve-lite install-skill",
29
30
  " cve-lite config <set|unset|show> [key] [value]",
30
- " cve-lite overrides [path] [flags]",
31
+ ` ${OVERRIDES_COMMAND} [path] [flags]`,
31
32
  "",
32
33
  "Scan options:",
33
34
  " --json Save scan results to a timestamped JSON file",
@@ -91,7 +92,7 @@ export function printHelp() {
91
92
  export function printOverridesHelp() {
92
93
  printBanner();
93
94
  const lines = [
94
- "cve-lite overrides [path] [flags]",
95
+ `${OVERRIDES_COMMAND} [path] [flags]`,
95
96
  "",
96
97
  "Audit package.json overrides and phantom dependency imports (OA001-OA009, PD001-PD002).",
97
98
  "",
package/dist/constants.js CHANGED
@@ -30,3 +30,4 @@ export const EXCLUDED_DIRS = new Set([
30
30
  ".angular",
31
31
  ".nx"
32
32
  ]);
33
+ export const OVERRIDES_COMMAND = "cve-lite overrides";
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ import { loadPackages, buildNoPackagesMessage } from "./parsers/index.js";
9
9
  import { scanPackages, buildCoverageNotes, createAdvisorySource } from "./scanner.js";
10
10
  import { syncOsvAdvisories } from "./advisory/osv-sync.js";
11
11
  import { normalizeSeverity } from "./osv/severity.js";
12
- import { DEFAULT_BATCH_SIZE, DEFAULT_SEARCH_DEPTH } from "./constants.js";
12
+ import { DEFAULT_BATCH_SIZE, DEFAULT_SEARCH_DEPTH, OVERRIDES_COMMAND } from "./constants.js";
13
13
  import { chalk } from "./utils/chalk.js";
14
14
  import { createSpinner } from "./output/spinner.js";
15
15
  import { createDebugLogger } from "./output/debug.js";
@@ -40,6 +40,7 @@ import { hasRootLockfile, findNestedLockfiles } from "./parsers/multi-package.js
40
40
  import { handleMultiFolderScan } from "./scan/multi-folder-scan.js";
41
41
  import { collectAdvisoryIdsForPackage, createPullRequestForFixes, } from "./utils/create-pr.js";
42
42
  import { readBaseline, writeBaseline, filterNewFindings, ratchetOutcome } from "./utils/baseline.js";
43
+ import { formatDiagnosticMessage, getCompletenessImpact } from "./scan/completeness.js";
43
44
  let parsedArgs = null;
44
45
  try {
45
46
  parsedArgs = parseArgs(process.argv.slice(2));
@@ -469,6 +470,7 @@ if (parsedArgs) {
469
470
  // the nothing-to-fix case without parsing stdout.
470
471
  const fixResultJson = {
471
472
  appliedFixCount: fixResult?.appliedFixCount ?? 0,
473
+ appliedWithinRangeRefreshCount: fixResult?.appliedWithinRangeRefreshCount ?? 0,
472
474
  findingsBeforeFix,
473
475
  findingsAfterFix: scanState.sorted.length,
474
476
  applied: (fixResult?.applied ?? []).map(entry => ({
@@ -477,6 +479,11 @@ if (parsedArgs) {
477
479
  to: entry.to,
478
480
  advisories: collectAdvisoryIdsForPackage(findingsBeforeFixList, entry.package),
479
481
  })),
482
+ notAutoApplied: {
483
+ parentUpgradeCount: fixResult?.parentUpgradeCount ?? 0,
484
+ breakingUpgradeCount: fixResult?.breakingUpgradeCount ?? 0,
485
+ noFixCount: fixResult?.noFixCount ?? 0,
486
+ },
480
487
  };
481
488
  writeFixResultJson(fixResultJson, projectPath);
482
489
  if (options.createPr && fixResult) {
@@ -516,13 +523,33 @@ if (parsedArgs) {
516
523
  // baseline. Re-saving here would silently absorb a new vulnerability into a
517
524
  // fresh baseline, so a ratcheted CI job could never fail on a regression.
518
525
  if (options.ratchet) {
526
+ const { hasDetectionGap } = getCompletenessImpact(scanState.completeness);
527
+ if (hasDetectionGap) {
528
+ console.log(chalk.red("Scan data is incomplete. Refusing to create or evaluate a baseline from partial detection data."));
529
+ for (const diagnostic of scanState.completeness.diagnostics) {
530
+ if (diagnostic.impact !== "detection")
531
+ continue;
532
+ console.log(chalk.red(` ${formatDiagnosticMessage(diagnostic.code, diagnostic.count, diagnostic.affectedPackageCount)}`));
533
+ }
534
+ auditLogHandle.emit({
535
+ ts: new Date().toISOString(),
536
+ type: "scan.finished",
537
+ schemaVersion: 1,
538
+ durationMs: Date.now() - scanStartTime,
539
+ findingsCount: scanState.sorted.length,
540
+ exitCode: EXIT_ERROR,
541
+ });
542
+ auditLogHandle.close();
543
+ process.exit(EXIT_ERROR);
544
+ return;
545
+ }
519
546
  const outcome = ratchetOutcome(baseline, scanState.sorted);
520
547
  if (outcome.action === "save") {
521
548
  writeBaseline(projectArg ?? ".", scanState.sorted);
522
549
  const count = scanState.sorted.length;
523
550
  console.log(chalk.green(`✓ Baseline saved to .cve-lite/baseline.json with ${count} ${count === 1 ? "finding" : "findings"}. Future scans will only report findings above this baseline.`));
524
551
  if (options.checkOverrides) {
525
- console.log(chalk.gray("Note: override hygiene (--check-overrides) is not part of the ratchet baseline; run `cve-lite overrides` to audit overrides."));
552
+ console.log(chalk.gray(`Note: override hygiene (--check-overrides) is not part of the ratchet baseline; run \`${OVERRIDES_COMMAND}\` to audit overrides.`));
526
553
  }
527
554
  auditLogHandle.emit({
528
555
  ts: new Date().toISOString(),
@@ -3,7 +3,7 @@ import { chalk } from "../utils/chalk.js";
3
3
  import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, } from "../constants.js";
4
4
  import { loadCache } from "../osv/cache.js";
5
5
  import { inferSeverity } from "../osv/severity.js";
6
- import { getPrimaryParent } from "../utils/finding.js";
6
+ import { getPrimaryParent, getRootDependencies } from "../utils/finding.js";
7
7
  import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js";
8
8
  import { pluralize } from "../utils/string.js";
9
9
  import { hasMaliciousAdvisory } from "../utils/vuln.js";
@@ -18,6 +18,16 @@ export function formatRelLabel(finding) {
18
18
  const base = finding.relationship;
19
19
  return finding.pkg.dev === true ? `${base} · dev` : base;
20
20
  }
21
+ // Compact form for the terminal table, where column width is limited: shows
22
+ // the first root dependency plus a count of additional ones (e.g. "app +2").
23
+ export function formatRootDependencySummary(finding) {
24
+ const roots = getRootDependencies(finding);
25
+ if (roots.length === 0)
26
+ return "-";
27
+ if (roots.length === 1)
28
+ return roots[0];
29
+ return `${roots[0]} +${roots.length - 1}`;
30
+ }
21
31
  export function formatAdvisorySourceLine(sourceLabel) {
22
32
  const match = sourceLabel.match(/^(.*) \((.*)\)$/);
23
33
  if (!match) {
@@ -38,6 +48,11 @@ export function formatHintLines(lines) {
38
48
  function isMaliciousAdvisory(finding) {
39
49
  return hasMaliciousAdvisory(finding.vulnerabilities);
40
50
  }
51
+ function transitiveRiskMessage(packageName, complete) {
52
+ return complete
53
+ ? `Transitive issue. A specific parent upgrade target was found for ${packageName}.`
54
+ : `Transitive issue. A path-specific parent upgrade target was found for ${packageName}; run it, rescan, and review remaining paths separately.`;
55
+ }
41
56
  export function getRecommendedAction(finding) {
42
57
  if (isMaliciousAdvisory(finding)) {
43
58
  if (finding.maliciousUnverifiable) {
@@ -107,15 +122,11 @@ export function summarizeRisk(finding) {
107
122
  }
108
123
  else if (finding.relationship === "transitive" && finding.recommendedNpmTransitiveRemediation?.kind === "upgrade-parent-to-version") {
109
124
  const coverage = calculatePathCoverage(finding.dependencyPaths, finding.recommendedNpmTransitiveRemediation.viaPath);
110
- risk = coverage.coverage === "complete"
111
- ? `Transitive issue. A specific parent upgrade target was found for ${finding.recommendedNpmTransitiveRemediation.package}.`
112
- : `Transitive issue. A path-specific parent upgrade target was found for ${finding.recommendedNpmTransitiveRemediation.package}; run it, rescan, and review remaining paths separately.`;
125
+ risk = transitiveRiskMessage(finding.recommendedNpmTransitiveRemediation.package, coverage.coverage === "complete");
113
126
  }
114
127
  else if (finding.relationship === "transitive" && finding.recommendedParentUpgrade) {
115
128
  const coverage = calculatePathCoverage(finding.dependencyPaths, finding.recommendedParentUpgrade.viaPath);
116
- risk = coverage.coverage === "complete"
117
- ? `Transitive issue. A specific parent upgrade target was found for ${finding.recommendedParentUpgrade.package}.`
118
- : `Transitive issue. A path-specific parent upgrade target was found for ${finding.recommendedParentUpgrade.package}; run it, rescan, and review remaining paths separately.`;
129
+ risk = transitiveRiskMessage(finding.recommendedParentUpgrade.package, coverage.coverage === "complete");
119
130
  }
120
131
  else if (finding.relationship === "transitive" && (finding.validatedFirstFixedVersion ?? finding.firstFixedVersion)) {
121
132
  const target = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
@@ -226,6 +237,7 @@ export function serializeFinding(finding, plan) {
226
237
  recommendedAction: getRecommendedAction(finding),
227
238
  runnableFixCommand: plan ? findSuggestedCommandForFinding(plan, finding) : null,
228
239
  primaryParent: getPrimaryParent(finding),
240
+ rootDependencies: getRootDependencies(finding),
229
241
  recommendedParentUpgrade: finding.recommendedParentUpgrade,
230
242
  recommendedNpmTransitiveRemediation: finding.recommendedNpmTransitiveRemediation ?? null,
231
243
  cves: finding.cveAliases,
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { spawn } from "node:child_process";
4
4
  import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandWithPublishDates, formatCooldownWarning } from "./formatters.js";
5
5
  import { loadLogoDataUri } from "./logos.js";
6
- import { isMajorVersionBump } from "../utils/version.js";
6
+ import { isBreakingUpgrade } from "../utils/version.js";
7
7
  import { pluralize } from "../utils/string.js";
8
8
  import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, severityOrder } from "../constants.js";
9
9
  import { hasMaliciousAdvisory } from "../utils/vuln.js";
@@ -136,6 +136,8 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
136
136
  .rel-badge.transitive{color:#e3b341;background:#e3b34122}
137
137
  .rel-badge.unknown{color:#8b949e;background:#8b949e22}
138
138
  .rel-badge.dev{color:#a371f7;background:#6e40c922;border:1px solid #6e40c955}
139
+ .root-dep{font-size:11px;font-family:monospace;color:var(--text)}
140
+ .root-dep-none{font-size:11px;color:var(--text-3)}
139
141
  .cve-link{font-size:11px;color:var(--link);font-family:monospace;text-decoration:none;border-bottom:1px dotted var(--link)}
140
142
  .cve-link:hover{color:var(--link-h)}
141
143
  .fix-hint{font-size:11px;color:var(--green);font-family:monospace}
@@ -317,12 +319,13 @@ ${duplicatePackagesHtml}
317
319
  <th>Fix available</th>
318
320
  <th onclick="sortBy('severity')" class="sorted">Severity <span class="sort-arrow" style="color:var(--link)">↓</span></th>
319
321
  <th onclick="sortBy('relationship')">Type <span class="sort-arrow">↕</span></th>
322
+ <th>Root</th>
320
323
  <th>CVE / Advisory</th>
321
324
  </tr>
322
325
  </thead>
323
326
  <tbody id="findings-tbody">
324
327
  ${findingRowsHtml}
325
- <tr id="no-results-row" style="display:none"><td colspan="6" class="no-results">No findings match your search.</td></tr>
328
+ <tr id="no-results-row" style="display:none"><td colspan="7" class="no-results">No findings match your search.</td></tr>
326
329
  </tbody>
327
330
  </table>
328
331
  </div>
@@ -520,16 +523,20 @@ export function renderFindingRow(finding, idx, skippedKeys) {
520
523
  const contextColHtml = finding.relationship === "transitive"
521
524
  ? renderTransitiveContextCol(finding)
522
525
  : "";
526
+ const rootDepsHtml = finding.rootDependencies.length > 0
527
+ ? finding.rootDependencies.map(name => `<span class="root-dep">${escapeHtml(name)}</span>`).join(", ")
528
+ : `<span class="root-dep-none">-</span>`;
523
529
  return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
524
530
  <td><span class="expand-icon" id="icon-${idx}">▶</span></td>
525
531
  <td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
526
532
  <td>${fixHtml}</td>
527
533
  <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
528
534
  <td>${renderRelBadge(finding)}</td>
535
+ <td>${rootDepsHtml}</td>
529
536
  <td>${cveLinks}</td>
530
537
  </tr>
531
538
  <tr id="detail-${idx}" class="detail-row">
532
- <td colspan="6">
539
+ <td colspan="7">
533
540
  <div class="expanded-inner">
534
541
  <div class="detail-col" style="max-width:320px">
535
542
  <h4>Description</h4>
@@ -556,21 +563,22 @@ function renderTransitiveContextCol(finding) {
556
563
  const hasFixAvailable = finding.runnableFixCommand != null ||
557
564
  finding.recommendedNpmTransitiveRemediation != null ||
558
565
  finding.recommendedParentUpgrade != null;
566
+ const rootNames = finding.rootDependencies.join(", ");
559
567
  if (hasFixAvailable) {
560
- const parentLine = finding.primaryParent
561
- ? `<p style="font-size:12px;color:var(--text-2);margin-top:4px">Parent: ${escapeHtml(finding.primaryParent)}</p>`
568
+ const rootLine = rootNames
569
+ ? `<p style="font-size:12px;color:var(--text-2);margin-top:4px">Root: ${escapeHtml(rootNames)}</p>`
562
570
  : "";
563
571
  return `<div class="detail-col" style="max-width:200px">
564
572
  <h4>Context</h4>
565
573
  <span class="tier-ok">✓ Fix available</span>
566
- ${parentLine}
574
+ ${rootLine}
567
575
  </div>`;
568
576
  }
569
- if (finding.primaryParent) {
577
+ if (rootNames) {
570
578
  return `<div class="detail-col" style="max-width:200px">
571
579
  <h4>Context</h4>
572
580
  <span class="tier-warn">⚠ No safe version identified</span>
573
- <p style="font-size:12px;color:var(--text-2);margin-top:4px">Parent: ${escapeHtml(finding.primaryParent)}</p>
581
+ <p style="font-size:12px;color:var(--text-2);margin-top:4px">Root: ${escapeHtml(rootNames)}</p>
574
582
  </div>`;
575
583
  }
576
584
  return `<div class="detail-col" style="max-width:200px">
@@ -727,8 +735,8 @@ export function renderFixPlan(plan) {
727
735
  const skippedCount = plan.skipped.length;
728
736
  const commandRows = plan.sections.map(section => {
729
737
  const targetRows = section.targets.map(t => {
730
- const displayVersion = t.displayTargetVersion ?? t.targetVersion;
731
- const isMajor = t.currentVersion ? isMajorVersionBump(t.currentVersion, t.targetVersion) : false;
738
+ const displayVersion = t.targetVersion;
739
+ const isMajor = t.currentVersion ? isBreakingUpgrade(t.currentVersion, t.targetVersion) : false;
732
740
  const breakBadge = isMajor ? ` <span class="break-badge">⚠ breaking</span>` : "";
733
741
  const versionHtml = t.currentVersion
734
742
  ? `<span class="fix-target-pkg">${escapeHtml(t.package)}@${escapeHtml(t.currentVersion)}</span><span class="fix-target-arrow">→</span><span class="fix-target-to">${escapeHtml(displayVersion)}</span>`
@@ -76,7 +76,7 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
76
76
  ? renderMaintenanceFindingsHtml(result.maintenanceFindings)
77
77
  : "";
78
78
  const emptyRow = result.sorted.length === 0
79
- ? `<tr><td colspan="6" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
79
+ ? `<tr><td colspan="7" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
80
80
  : "";
81
81
  return `
82
82
  <details class="folder-section"${isOpen ? " open" : ""}>
@@ -113,12 +113,13 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
113
113
  <th>Fix available</th>
114
114
  <th onclick="sortBy('severity',${fi})" class="sorted">Severity <span class="sort-arrow" style="color:#58a6ff">↓</span></th>
115
115
  <th onclick="sortBy('relationship',${fi})">Type <span class="sort-arrow">↕</span></th>
116
+ <th>Root</th>
116
117
  <th>CVE / Advisory</th>
117
118
  </tr>
118
119
  </thead>
119
120
  <tbody id="findings-tbody-${fi}" data-offset="${idxOffset}">
120
121
  ${emptyRow}${findingRowsHtml}
121
- <tr id="no-results-row-${fi}" style="display:none"><td colspan="6" class="no-results">No findings match your search.</td></tr>
122
+ <tr id="no-results-row-${fi}" style="display:none"><td colspan="7" class="no-results">No findings match your search.</td></tr>
122
123
  </tbody>
123
124
  </table>
124
125
  </div>
@@ -1,5 +1,6 @@
1
1
  import { relative } from "node:path";
2
2
  import { SEVERITY_ORDER } from "../utils/severity.js";
3
+ import { OVERRIDES_COMMAND } from "../constants.js";
3
4
  function esc(s) {
4
5
  return s
5
6
  .replace(/&/g, "&amp;")
@@ -29,11 +30,11 @@ export function renderOverrideFindingsHtml(findings, projectPath) {
29
30
  : esc(f.location.file);
30
31
  const relPath = projectPath ? relative(process.cwd(), projectPath) : "";
31
32
  const projectInfix = relPath && relPath !== "." ? ` ${relPath}` : "";
32
- const runnableCmd = f.fix?.runnableCommand && projectInfix
33
- ? f.fix.runnableCommand.replace("cve-lite overrides", `cve-lite${projectInfix} overrides`)
34
- : f.fix?.runnableCommand;
35
- const fixHtml = runnableCmd
36
- ? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(runnableCmd)}</code><button class="copy-btn" data-cmd="${esc(runnableCmd)}">Copy</button></div>`
33
+ const fixCommand = f.fix && f.fix.runnableCommand
34
+ ? f.fix.runnableCommand.replace(OVERRIDES_COMMAND, `cve-lite${projectInfix} overrides`)
35
+ : null;
36
+ const fixHtml = fixCommand
37
+ ? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(fixCommand)}</code><button class="copy-btn" data-cmd="${esc(fixCommand)}">Copy</button></div>`
37
38
  : "";
38
39
  return (` <tr class="finding ${esc(f.severity)}">` +
39
40
  `<td><span class="dep-node">${esc(f.ruleId)}</span></td>` +
@@ -2,6 +2,7 @@ import { relative } from "node:path";
2
2
  import { chalk, stripAnsi } from "../utils/chalk.js";
3
3
  import { formatSeverityLabel, SEVERITY_ORDER } from "../utils/severity.js";
4
4
  import { pluralize } from "../utils/string.js";
5
+ import { OVERRIDES_COMMAND } from "../constants.js";
5
6
  const COL_RULE_MAX = 8;
6
7
  const COL_PKG_MAX = 30;
7
8
  const COL_MSG_MAX = 50;
@@ -62,7 +63,7 @@ export function renderOverrideFindings(findings, options) {
62
63
  if (f.fix?.runnableCommand && !seenRules.has(f.ruleId)) {
63
64
  seenRules.add(f.ruleId);
64
65
  const cmd = projectInfix
65
- ? f.fix.runnableCommand.replace("cve-lite overrides", `cve-lite${projectInfix} overrides`)
66
+ ? f.fix.runnableCommand.replace(OVERRIDES_COMMAND, `cve-lite${projectInfix} overrides`)
66
67
  : f.fix.runnableCommand;
67
68
  lines.push(chalk.bold.cyan(`> ${cmd}`));
68
69
  }
@@ -1,14 +1,14 @@
1
1
  import { chalk, stripAnsi } from "../utils/chalk.js";
2
2
  import { buildSuggestedFixCommandPlan, UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
3
- import { isMajorVersionBump } from "../utils/version.js";
3
+ import { isBreakingUpgrade } from "../utils/version.js";
4
4
  import { getPrimaryParent } from "../utils/finding.js";
5
- import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, formatCooldownWarning, } from "./formatters.js";
5
+ import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatRootDependencySummary, formatFixCommandWithPublishDates, formatCooldownWarning, } from "./formatters.js";
6
6
  import { formatSeverityLabel } from "../utils/severity.js";
7
7
  import { pluralize } from "../utils/string.js";
8
8
  import { hasMaliciousAdvisory } from "../utils/vuln.js";
9
9
  import { selectFindingsForCompact } from "./finding-display.js";
10
10
  import { getCompletenessImpact } from "../scan/completeness.js";
11
- import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, MAL_GIT_SOURCE_COMPACT_MESSAGE, MAL_GIT_SOURCE_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, } from "../constants.js";
11
+ import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, MAL_GIT_SOURCE_COMPACT_MESSAGE, MAL_GIT_SOURCE_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, OVERRIDES_COMMAND, } from "../constants.js";
12
12
  export function printSummary(findings, packageCount, scanInput) {
13
13
  if (findings.length === 0) {
14
14
  if (scanInput.mode === "manifest-fallback") {
@@ -46,8 +46,8 @@ export function printActionSummary(findings, overrideCount = 0, packageManager)
46
46
  console.log(`- ${chalk.gray("Package manager:")} ${packageManager}`);
47
47
  }
48
48
  if (findings.length > 0) {
49
- console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
50
- console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
49
+ console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} ${direct === 1 ? "looks" : "look"} directly fixable in this project.`);
50
+ console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} ${transitive === 1 ? "comes" : "come"} through other dependencies.`);
51
51
  if (unknown > 0) {
52
52
  console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
53
53
  }
@@ -55,7 +55,7 @@ export function printActionSummary(findings, overrideCount = 0, packageManager)
55
55
  console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
56
56
  }
57
57
  if (overrideCount > 0) {
58
- console.log(`- ${chalk.yellow(String(overrideCount))} override hygiene ${pluralize(overrideCount, "issue")} found. Run ${chalk.white("cve-lite overrides --fix")} to address ${pluralize(overrideCount, "it", "them")}.`);
58
+ console.log(`- ${chalk.yellow(String(overrideCount))} override hygiene ${pluralize(overrideCount, "issue")} found. Run ${chalk.white(`${OVERRIDES_COMMAND} --fix`)} to address ${pluralize(overrideCount, "it", "them")}.`);
59
59
  }
60
60
  }
61
61
  function printCooldownWarning(target) {
@@ -193,7 +193,7 @@ export function printSkippedDependencies(skipped) {
193
193
  }
194
194
  }
195
195
  export function printTable(findings, threshold, skippedKeys) {
196
- const headers = ["Package", "Version", "Severity", "Type", "Usage", "Fixed", "IDs"];
196
+ const headers = ["Package", "Version", "Severity", "Type", "Root", "Usage", "Fixed", "IDs"];
197
197
  const rawRows = findings.map(f => {
198
198
  let usageText = "n/a";
199
199
  if (f.usage) {
@@ -225,6 +225,7 @@ export function printTable(findings, threshold, skippedKeys) {
225
225
  f.pkg.version,
226
226
  f.severity,
227
227
  formatRelLabel(f),
228
+ formatRootDependencySummary(f),
228
229
  usageText,
229
230
  fixedDisplay,
230
231
  f.vulnerabilities.map(v => v.id).join(", ")
@@ -240,7 +241,7 @@ export function printTable(findings, threshold, skippedKeys) {
240
241
  console.log(renderRow(headers, widths));
241
242
  console.log(line("├", "┼", "┤"));
242
243
  for (const row of rawRows) {
243
- let usageDecorated = String(row[4]);
244
+ let usageDecorated = String(row[5]);
244
245
  if (usageDecorated.includes("file(s)"))
245
246
  usageDecorated = chalk.red(usageDecorated);
246
247
  else if (usageDecorated.includes("unused"))
@@ -252,9 +253,10 @@ export function printTable(findings, threshold, skippedKeys) {
252
253
  row[1],
253
254
  formatSeverityLabel(String(row[2])),
254
255
  formatRelationshipLabel(String(row[3])),
256
+ row[4],
255
257
  usageDecorated,
256
- row[5],
257
- row[6]
258
+ row[6],
259
+ row[7]
258
260
  ];
259
261
  console.log(renderRow(decorated, widths));
260
262
  }
@@ -686,7 +688,7 @@ function printDirectTargetsTable(targets, remainingNotes, validationSummary, wid
686
688
  remainingNotes.push(target.adjustmentNote);
687
689
  }
688
690
  }
689
- const isBreaking = !!target.currentVersion && isMajorVersionBump(target.currentVersion, target.targetVersion);
691
+ const isBreaking = !!target.currentVersion && isBreakingUpgrade(target.currentVersion, target.targetVersion);
690
692
  let usageText = chalk.gray("n/a");
691
693
  if (target.usage) {
692
694
  usageText = target.usage.imported ? chalk.red(`${target.usage.files.length} file(s)`) : chalk.green("unused");
@@ -743,7 +745,7 @@ function printParentUpgradeTargetsTable(targets, widthsOverride) {
743
745
  return [
744
746
  target.package,
745
747
  target.currentVersion ?? "-",
746
- chalk.cyan(target.displayTargetVersion ?? target.targetVersion),
748
+ chalk.cyan(target.targetVersion),
747
749
  usageText,
748
750
  chalk.gray(target.reason),
749
751
  ];
@@ -777,7 +779,7 @@ function computeSharedDirectTableWidths(sections) {
777
779
  const rows = [];
778
780
  for (const section of directSections) {
779
781
  for (const target of section.targets) {
780
- const isBreaking = !!target.currentVersion && isMajorVersionBump(target.currentVersion, target.targetVersion);
782
+ const isBreaking = !!target.currentVersion && isBreakingUpgrade(target.currentVersion, target.targetVersion);
781
783
  let usageText = "n/a";
782
784
  if (target.usage) {
783
785
  usageText = target.usage.imported ? `${target.usage.files.length} file(s)` : "unused";
@@ -815,7 +817,7 @@ function computeSharedParentUpgradeTableWidths(sections) {
815
817
  rows.push([
816
818
  target.package,
817
819
  target.currentVersion ?? "-",
818
- target.displayTargetVersion ?? target.targetVersion,
820
+ target.targetVersion,
819
821
  usageText,
820
822
  target.reason,
821
823
  ]);
@@ -1,4 +1,5 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
+ import { OVERRIDES_COMMAND } from "../../constants.js";
2
3
  const RULE_ID = "OA001";
3
4
  export function detect(ctx) {
4
5
  if (ctx.skippedDetectors.some((s) => s.ruleId === RULE_ID))
@@ -25,7 +26,7 @@ export function detect(ctx) {
25
26
  fix: {
26
27
  type: "rfc6902",
27
28
  patch: [{ op: "remove", path: jsonPointer(entry.path) }],
28
- runnableCommand: `cve-lite overrides --fix --rule OA001`,
29
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA001`,
29
30
  },
30
31
  references: [
31
32
  "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA001.md",
@@ -1,5 +1,6 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
2
  import { isValidRange } from "../../utils/version.js";
3
+ import { OVERRIDES_COMMAND } from "../../constants.js";
3
4
  const RULE_ID = "OA002";
4
5
  const FLOATING = new Set(['latest', 'next', '*', 'x', '']);
5
6
  export function detect(ctx) {
@@ -31,7 +32,7 @@ export function detect(ctx) {
31
32
  finding.fix = {
32
33
  type: 'rfc6902',
33
34
  patch: [{ op: 'replace', path: jsonPointer(entry.path), value: floor }],
34
- runnableCommand: `cve-lite overrides --fix --rule OA002`,
35
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA002`,
35
36
  };
36
37
  }
37
38
  findings.push(finding);
@@ -1,4 +1,5 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
+ import { OVERRIDES_COMMAND } from "../../constants.js";
2
3
  const RULE_ID = "OA003";
3
4
  const EXPECTED_CONTAINER = {
4
5
  npm: "overrides",
@@ -37,7 +38,7 @@ export function detect(ctx) {
37
38
  from: jsonPointer(entry.path),
38
39
  path: jsonPointer(destination),
39
40
  }],
40
- runnableCommand: `cve-lite overrides --fix --rule OA003`,
41
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA003`,
41
42
  },
42
43
  references: [
43
44
  "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA003.md",
@@ -1,5 +1,6 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
2
  import { compareVersions, looksLikeVersion, majorVersion } from "../../utils/version.js";
3
+ import { OVERRIDES_COMMAND } from "../../constants.js";
3
4
  const RULE_ID = "OA004";
4
5
  export function detect(ctx) {
5
6
  if (ctx.skippedDetectors.some((s) => s.ruleId === RULE_ID))
@@ -40,7 +41,7 @@ export function detect(ctx) {
40
41
  finding.fix = {
41
42
  type: "rfc6902",
42
43
  patch: [{ op: "remove", path: jsonPointer(entry.path) }],
43
- runnableCommand: `cve-lite overrides --fix --rule OA004`,
44
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA004`,
44
45
  };
45
46
  }
46
47
  findings.push(finding);
@@ -1,6 +1,7 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
2
  import { readInstalledManifest } from "../parsing/node-modules.js";
3
3
  import { satisfiesRange, isValidRange } from "../../utils/version.js";
4
+ import { OVERRIDES_COMMAND } from "../../constants.js";
4
5
  const RULE_ID = "OA005";
5
6
  /**
6
7
  * OA005-NESTED-INEFFECTIVE - nested overrides in two shapes:
@@ -74,7 +75,7 @@ function classify(args) {
74
75
  fix: {
75
76
  type: "rfc6902",
76
77
  patch: [{ op: "remove", path: jsonPointer(entryPath) }],
77
- runnableCommand: `cve-lite overrides --fix --rule OA005`,
78
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA005`,
78
79
  },
79
80
  }
80
81
  : {}),
@@ -1,6 +1,7 @@
1
1
  import { jsonPointer } from '../parsing/json-pointer.js';
2
2
  import { compareVersions, looksLikeVersion, satisfiesRange, isValidRange } from '../../utils/version.js';
3
3
  import { looksLikePlatformBinary } from './platform-binary.js';
4
+ import { OVERRIDES_COMMAND } from "../../constants.js";
4
5
  const RULE_ID = 'OA006';
5
6
  /**
6
7
  * OA006 - the override target is a package that one or more INSTALLED parents
@@ -98,7 +99,7 @@ export function detect(ctx) {
98
99
  fix: {
99
100
  type: 'rfc6902',
100
101
  patch: patches,
101
- runnableCommand: `cve-lite overrides --fix --rule OA006`,
102
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA006`,
102
103
  tier: 'proposed',
103
104
  },
104
105
  references: ['https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA006.md'],
@@ -1,5 +1,6 @@
1
1
  import { looksLikeVersion, compareVersions } from "../../utils/version.js";
2
2
  import { jsonPointer } from "../parsing/json-pointer.js";
3
+ import { OVERRIDES_COMMAND } from "../../constants.js";
3
4
  const RULE_ID = "OA007";
4
5
  const FLOATING_TAGS = new Set(["latest", "next"]);
5
6
  /**
@@ -60,7 +61,7 @@ export function detect(ctx) {
60
61
  fix: {
61
62
  type: "rfc6902",
62
63
  patch: [{ op: "replace", path: jsonPointer(entry.path), value: `>=${registryVersion}` }],
63
- runnableCommand: `cve-lite overrides --fix --rule OA007`,
64
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA007`,
64
65
  },
65
66
  references: ["https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA007.md"],
66
67
  });
@@ -1,5 +1,6 @@
1
1
  import { jsonPointer } from "../parsing/json-pointer.js";
2
2
  import { looksLikeVersion, coerceVersion, compareVersions } from "../../utils/version.js";
3
+ import { OVERRIDES_COMMAND } from "../../constants.js";
3
4
  const RULE_ID = "OA009";
4
5
  function majorOf(version) {
5
6
  return parseInt(version.split(".")[0] ?? "0", 10);
@@ -69,7 +70,7 @@ export function detect(ctx) {
69
70
  fix: {
70
71
  type: "rfc6902",
71
72
  patch: [{ op: "remove", path: jsonPointer(entry.path) }],
72
- runnableCommand: `cve-lite overrides --fix --rule OA009`,
73
+ runnableCommand: `${OVERRIDES_COMMAND} --fix --rule OA009`,
73
74
  },
74
75
  references: [
75
76
  "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA009.md",
@@ -48,9 +48,24 @@ function hasProjectImporterSections(document) {
48
48
  }
49
49
  return false;
50
50
  }
51
+ // pnpm-lock.yaml is by far the most expensive lockfile to parse (a full YAML document
52
+ // model, ~380ms on a large monorepo), yet a single scan reads it up to four times: the
53
+ // package load, the scanner's workspace map, the suggested-fix workspace map, and override
54
+ // context. Cache the parsed document per (path, mtime, size) so each unchanged lockfile is
55
+ // parsed exactly once. The mtime/size key invalidates automatically after `--fix` rewrites
56
+ // the lockfile, so a re-scan in the same process always sees the fresh contents.
57
+ const parsedLockCache = new Map();
58
+ function readAndParsePnpmLock(filePath) {
59
+ const stat = fs.statSync(filePath);
60
+ const cacheKey = `${filePath}::${stat.mtimeMs}::${stat.size}`;
61
+ if (parsedLockCache.has(cacheKey))
62
+ return parsedLockCache.get(cacheKey);
63
+ const parsed = parsePnpmLockContent(fs.readFileSync(filePath, "utf8"));
64
+ parsedLockCache.set(cacheKey, parsed);
65
+ return parsed;
66
+ }
51
67
  export function buildPnpmWorkspaceMap(filePath) {
52
- const content = fs.readFileSync(filePath, "utf8");
53
- const parsed = parsePnpmLockContent(content);
68
+ const parsed = readAndParsePnpmLock(filePath);
54
69
  const importers = parsed?.importers ?? {};
55
70
  const map = new Map();
56
71
  for (const [importerPath, importer] of Object.entries(importers)) {
@@ -69,8 +84,7 @@ export function buildPnpmWorkspaceMap(filePath) {
69
84
  return map;
70
85
  }
71
86
  export function loadFromPnpmLock(filePath, prodOnly) {
72
- const content = fs.readFileSync(filePath, "utf8");
73
- const parsed = parsePnpmLockContent(content);
87
+ const parsed = readAndParsePnpmLock(filePath);
74
88
  const majorVersion = parseInt(String(parsed?.lockfileVersion ?? "0"), 10);
75
89
  return majorVersion >= 9 ? loadV9(parsed, prodOnly) : loadLegacy(parsed, prodOnly);
76
90
  }
@@ -174,7 +174,6 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
174
174
  package: finding.recommendedNpmTransitiveRemediation.package,
175
175
  currentVersion: finding.recommendedNpmTransitiveRemediation.currentVersion,
176
176
  targetVersion: finding.recommendedNpmTransitiveRemediation.targetChildVersion,
177
- displayTargetVersion: "npm install",
178
177
  scannedVersions: null,
179
178
  knownVulnerableVersions: null,
180
179
  kind: "parent-update",
@@ -198,6 +197,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
198
197
  const chainForNpmRemediation = finding.chainResolution?.directDep === finding.recommendedNpmTransitiveRemediation.package
199
198
  ? finding.chainResolution
200
199
  : null;
200
+ const npmParentUpgradeWorkspaces = workspaceMap.get(finding.recommendedNpmTransitiveRemediation.package)?.filter(w => w !== ".") ?? [];
201
201
  upsertTarget(targetsByPackage, {
202
202
  package: finding.recommendedNpmTransitiveRemediation.package,
203
203
  currentVersion: finding.recommendedNpmTransitiveRemediation.currentVersion,
@@ -215,6 +215,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
215
215
  remainingPaths: coverage.remainingPaths,
216
216
  usage: finding.usage ?? null,
217
217
  isDev: devLookup.get(`${finding.recommendedNpmTransitiveRemediation.package}@${finding.recommendedNpmTransitiveRemediation.currentVersion}`) ?? false,
218
+ workspaces: npmParentUpgradeWorkspaces.length > 0 ? npmParentUpgradeWorkspaces : undefined,
218
219
  chainProof: chainForNpmRemediation?.chain,
219
220
  chainSafeVersion: chainForNpmRemediation?.safeVersion,
220
221
  chainVulnerablePackage: chainForNpmRemediation ? finding.pkg.name : undefined,
@@ -228,6 +229,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
228
229
  const chainForParentUpgrade = finding.chainResolution?.directDep === finding.recommendedParentUpgrade.package
229
230
  ? finding.chainResolution
230
231
  : null;
232
+ const parentUpgradeWorkspaces = workspaceMap.get(finding.recommendedParentUpgrade.package)?.filter(w => w !== ".") ?? [];
231
233
  upsertTarget(targetsByPackage, {
232
234
  package: finding.recommendedParentUpgrade.package,
233
235
  currentVersion: finding.recommendedParentUpgrade.currentVersion,
@@ -245,6 +247,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
245
247
  remainingPaths: coverage.remainingPaths,
246
248
  usage: finding.usage ?? null,
247
249
  isDev: devLookup.get(`${finding.recommendedParentUpgrade.package}@${finding.recommendedParentUpgrade.currentVersion}`) ?? false,
250
+ workspaces: parentUpgradeWorkspaces.length > 0 ? parentUpgradeWorkspaces : undefined,
248
251
  chainProof: chainForParentUpgrade?.chain,
249
252
  chainSafeVersion: chainForParentUpgrade?.safeVersion,
250
253
  chainVulnerablePackage: chainForParentUpgrade ? finding.pkg.name : undefined,
@@ -291,6 +294,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
291
294
  if (finding.chainResolution) {
292
295
  const isDev = devLookup.get(`${finding.chainResolution.directDep}@${finding.chainResolution.directDepCurrentVersion}`) ?? false;
293
296
  const coverage = calculatePathCoverage(finding.dependencyPaths, [finding.chainResolution.directDep]);
297
+ const chainWorkspaces = workspaceMap.get(finding.chainResolution.directDep)?.filter(w => w !== ".") ?? [];
294
298
  upsertTarget(targetsByPackage, {
295
299
  package: finding.chainResolution.directDep,
296
300
  currentVersion: finding.chainResolution.directDepCurrentVersion,
@@ -307,6 +311,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
307
311
  chainVulnerablePackage: finding.pkg.name,
308
312
  usage: finding.usage ?? null,
309
313
  isDev,
314
+ workspaces: chainWorkspaces.length > 0 ? chainWorkspaces : undefined,
310
315
  });
311
316
  continue;
312
317
  }
@@ -344,6 +349,17 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
344
349
  return kindDelta;
345
350
  return a.package.localeCompare(b.package);
346
351
  });
352
+ // Some install targets carry an explicit `command` built without workspace
353
+ // context (e.g. a chain-resolution command). This raw field is exposed in JSON
354
+ // and embedded in the HTML report, so scope it to the declaring member too -
355
+ // parent-update commands are already workspace-aware and left untouched.
356
+ for (const target of targets) {
357
+ if (target.kind !== "parent-update" && target.command && target.workspaces?.length) {
358
+ const scoped = buildWorkspaceInstallCommands([target], packageManager);
359
+ if (scoped.length > 0)
360
+ target.command = scoped.join(" && ");
361
+ }
362
+ }
347
363
  const nowMs = options?.nowMs ?? Date.now();
348
364
  if (scanInput.filePath && (packageManager === "npm" || packageManager === "pnpm" || packageManager === "yarn")) {
349
365
  const cooldown = readConfiguredCooldown(path.dirname(scanInput.filePath), packageManager);
@@ -422,7 +438,7 @@ function buildPnpmLockfileRefreshCommand(pkg, workspaces) {
422
438
  if (workspace === ".") {
423
439
  return `pnpm update --no-save ${pkg}`;
424
440
  }
425
- return `pnpm -C ${workspace} update --no-save ${pkg}`;
441
+ return `pnpm --filter ./${workspace} update --no-save ${pkg}`;
426
442
  }
427
443
  export function commandPrefix(packageManager) {
428
444
  if (packageManager === "npm")
@@ -462,19 +478,32 @@ export function findFixTargetForFinding(plan, finding) {
462
478
  });
463
479
  return target ?? null;
464
480
  }
465
- export function findSuggestedCommandForFinding(plan, finding) {
466
- const target = findFixTargetForFinding(plan, finding);
467
- if (!target)
468
- return null;
469
- if (target.command)
481
+ // The single command that applies (or refreshes) one fix target, workspace-scoped
482
+ // where the target declares a member. Shared by the displayed per-finding command
483
+ // and the --fix executor so both stay consistent.
484
+ export function buildTargetCommand(target, packageManager) {
485
+ // parent-update targets carry an explicit command that is already
486
+ // workspace-scoped (npm update --workspace / pnpm --filter ... update).
487
+ if (target.kind === "parent-update" && target.command)
470
488
  return target.command;
489
+ // For install targets (direct / parent-upgrade), a workspace membership must
490
+ // win over any flat explicit command (e.g. a chain-resolution command built
491
+ // without workspace context), mirroring the plan-level command builder.
471
492
  if (target.workspaces?.length) {
472
- const commands = buildWorkspaceInstallCommands([target], plan.packageManager);
493
+ const commands = buildWorkspaceInstallCommands([target], packageManager);
473
494
  if (commands.length > 0)
474
495
  return commands.join(" && ");
475
496
  }
476
- const flag = target.isDev ? ` ${devFlag(plan.packageManager)}` : "";
477
- return `${commandPrefix(plan.packageManager)}${flag} ${target.package}@${target.targetVersion}`;
497
+ if (target.command)
498
+ return target.command;
499
+ const flag = target.isDev ? ` ${devFlag(packageManager)}` : "";
500
+ return `${commandPrefix(packageManager)}${flag} ${target.package}@${target.targetVersion}`;
501
+ }
502
+ export function findSuggestedCommandForFinding(plan, finding) {
503
+ const target = findFixTargetForFinding(plan, finding);
504
+ if (!target)
505
+ return null;
506
+ return buildTargetCommand(target, plan.packageManager);
478
507
  }
479
508
  function packageManagerSourceLabel(scanInput) {
480
509
  if (scanInput.filePath) {
@@ -507,7 +536,6 @@ function upsertTarget(targetsByPackage, next) {
507
536
  : existing.kind === "parent-update" || next.kind === "parent-update"
508
537
  ? "parent-update"
509
538
  : "parent-upgrade",
510
- displayTargetVersion: existing.displayTargetVersion ?? next.displayTargetVersion,
511
539
  command: existing.command ?? next.command,
512
540
  isDev: (existing.isDev ?? false) && (next.isDev ?? false),
513
541
  workspaces: mergeStringArrays(existing.workspaces, next.workspaces),
@@ -690,8 +718,11 @@ function buildWorkspaceInstallCommands(targets, packageManager) {
690
718
  commands.push(`npm install${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
691
719
  }
692
720
  else if (packageManager === "pnpm") {
721
+ // pnpm's --filter selector is a CLI-level flag that precedes the command
722
+ // (`pnpm --filter ./client add pkg`), not a trailing argument.
693
723
  const wsFlags = workspaces.map(ws => `--filter ./${ws}`).join(" ");
694
- commands.push(`pnpm add${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
724
+ const prefix = wsFlags ? `pnpm ${wsFlags} add` : "pnpm add";
725
+ commands.push(`${prefix}${flag} ${pkgArgs}`);
695
726
  }
696
727
  else if (packageManager === "yarn") {
697
728
  if (workspaces.length === 0) {
@@ -1,6 +1,7 @@
1
1
  import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "../utils/version.js";
2
2
  import { fetchPackument } from "./npm-registry.js";
3
3
  import { findSafeVersionWithinParentRange } from "./npm-transitive-graph.js";
4
+ import { findPackageAlongPath } from "./package-path-lookup.js";
4
5
  export async function resolveTransitiveRemediationViaRegistry(args) {
5
6
  if (args.finding.relationship !== "transitive")
6
7
  return null;
@@ -14,7 +15,6 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
14
15
  const vulnerableName = args.finding.pkg.name;
15
16
  const fixHint = args.finding.validatedFirstFixedVersion ?? args.finding.firstFixedVersion;
16
17
  if (directParentName !== immediateParentName) {
17
- const packagesByName = new Map(args.packages.map(p => [p.name, p]));
18
18
  return resolveWithinRangeForDeepChainViaRegistry({
19
19
  immediateParentName,
20
20
  vulnerableName,
@@ -22,7 +22,6 @@ export async function resolveTransitiveRemediationViaRegistry(args) {
22
22
  fixHint,
23
23
  viaPath,
24
24
  packages: args.packages,
25
- packagesByName,
26
25
  workspaceMap: args.workspaceMap,
27
26
  });
28
27
  }
@@ -70,7 +69,6 @@ export async function resolveNpmTransitiveRemediation(args) {
70
69
  // immediate parent's declared range for the vulnerable package already covers a safe version.
71
70
  // If so, a lockfile refresh of the vulnerable package itself is sufficient.
72
71
  if (directParentName !== immediateParentName) {
73
- const packagesByName = new Map(args.packages.map(p => [p.name, p]));
74
72
  return resolveWithinRangeForDeepChain({
75
73
  graph: args.graph,
76
74
  immediateParentName,
@@ -79,7 +77,6 @@ export async function resolveNpmTransitiveRemediation(args) {
79
77
  fixHint,
80
78
  viaPath,
81
79
  packages: args.packages,
82
- packagesByName,
83
80
  offline: args.offline,
84
81
  });
85
82
  }
@@ -305,7 +302,8 @@ function parseCoreVersion(version) {
305
302
  return [Number(major), Number(minor), Number(patch)];
306
303
  }
307
304
  async function resolveWithinRangeForDeepChainViaRegistry(args) {
308
- const immediateParent = args.packagesByName.get(args.immediateParentName);
305
+ const immediateParentPathPrefix = args.viaPath.slice(0, -1);
306
+ const immediateParent = findPackageAlongPath(args.packages, args.immediateParentName, immediateParentPathPrefix);
309
307
  if (!immediateParent || !looksLikeVersion(immediateParent.version))
310
308
  return null;
311
309
  const safeCandidates = await findSafeChildCandidates(args.vulnerableName, args.installedVersion, args.fixHint);
@@ -335,7 +333,8 @@ async function resolveWithinRangeForDeepChainViaRegistry(args) {
335
333
  };
336
334
  }
337
335
  async function resolveWithinRangeForDeepChain(args) {
338
- const immediateParent = args.packagesByName.get(args.immediateParentName);
336
+ const immediateParentPathPrefix = args.viaPath.slice(0, -1);
337
+ const immediateParent = findPackageAlongPath(args.packages, args.immediateParentName, immediateParentPathPrefix);
339
338
  if (!immediateParent || !looksLikeVersion(immediateParent.version))
340
339
  return null;
341
340
  const nodeIds = args.graph.nodeIdsFor(args.immediateParentName, immediateParent.version);
@@ -0,0 +1,29 @@
1
+ export function startsWithPath(path, prefix) {
2
+ if (prefix.length > path.length)
3
+ return false;
4
+ for (let i = 0; i < prefix.length; i++) {
5
+ if (path[i] !== prefix[i])
6
+ return false;
7
+ }
8
+ return true;
9
+ }
10
+ /**
11
+ * Finds the specific installed instance of `name` reachable via `pathPrefix`.
12
+ * Cannot use a name-keyed Map here: the same package name is commonly
13
+ * installed at multiple different versions in an npm tree (e.g. minimatch
14
+ * nested under eslint at one version and used top-level at another), and a
15
+ * Map would collapse them to a single arbitrary entry. Path-aware iteration
16
+ * across all installed versions is required to find the one actually on
17
+ * this dependency chain.
18
+ */
19
+ export function findPackageAlongPath(packages, name, pathPrefix) {
20
+ for (const pkg of packages) {
21
+ if (pkg.name !== name)
22
+ continue;
23
+ const paths = pkg.paths ?? [];
24
+ if (paths.some(path => startsWithPath(path, pathPrefix))) {
25
+ return pkg;
26
+ }
27
+ }
28
+ return null;
29
+ }
@@ -1,5 +1,6 @@
1
1
  import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "../utils/version.js";
2
2
  import { fetchPackument } from "./npm-registry.js";
3
+ import { findPackageAlongPath } from "./package-path-lookup.js";
3
4
  export function isVerifiedUpgrade(confidence) {
4
5
  return confidence === "verified";
5
6
  }
@@ -84,28 +85,7 @@ function resolveDirectParentContext(viaPath, packages, directDependencyNames, pa
84
85
  return { directParentName, immediateParentName, directParent };
85
86
  }
86
87
  function findPackageVersion(packages, name, pathPrefix) {
87
- // Cannot use a name-keyed Map here: when the same package is installed at
88
- // multiple versions (e.g. lodash@3 and lodash@4 on different paths), a Map
89
- // would only hold one entry. We need path-aware iteration across all installed
90
- // versions to find the right one for this specific dependency chain.
91
- for (const pkg of packages) {
92
- if (pkg.name !== name)
93
- continue;
94
- const paths = pkg.paths ?? [];
95
- if (paths.some(path => startsWithPath(path, pathPrefix))) {
96
- return pkg.version;
97
- }
98
- }
99
- return null;
100
- }
101
- function startsWithPath(path, prefix) {
102
- if (prefix.length > path.length)
103
- return false;
104
- for (let i = 0; i < prefix.length; i++) {
105
- if (path[i] !== prefix[i])
106
- return false;
107
- }
108
- return true;
88
+ return findPackageAlongPath(packages, name, pathPrefix)?.version ?? null;
109
89
  }
110
90
  /**
111
91
  * Highest published, non-prerelease version of `name` that satisfies `range`,
@@ -9,7 +9,7 @@ import { normalizeSeverity } from "../osv/severity.js";
9
9
  import { selectFindingsForTable } from "../output/finding-display.js";
10
10
  import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
11
11
  import { readDirectDependencyNames, hasOverrideEntries } from "../utils/package-json.js";
12
- import { DEFAULT_SEARCH_DEPTH, severityOrder } from "../constants.js";
12
+ import { DEFAULT_SEARCH_DEPTH, severityOrder, OVERRIDES_COMMAND } from "../constants.js";
13
13
  import { printMultiFolderResults } from "../output/multi-folder-printer.js";
14
14
  import { printOverrideHint } from "../output/printers.js";
15
15
  import { writeMultiFolderHtmlReport } from "../output/multi-folder-html-reporter.js";
@@ -21,7 +21,7 @@ import { detectDM001 } from "../maintenance/dm001-maintenance-risk.js";
21
21
  import { reachesFailOn } from "../utils/severity.js";
22
22
  import { readBaseline, writeBaseline, filterNewFindings, ratchetOutcome } from "../utils/baseline.js";
23
23
  import { pluralize } from "../utils/string.js";
24
- import { aggregateMultiFolderCompleteness } from "./completeness.js";
24
+ import { aggregateMultiFolderCompleteness, formatDiagnosticMessage, getCompletenessImpact, } from "./completeness.js";
25
25
  import { scanProjectForPackageUsage } from "../usage/scanner.js";
26
26
  export async function runMultiFolderScan(params) {
27
27
  const searchDepth = Math.max(0, Number(params.options.searchDepth || DEFAULT_SEARCH_DEPTH));
@@ -120,7 +120,19 @@ export async function runMultiFolderScan(params) {
120
120
  */
121
121
  function handleMultiFolderRatchet(results, projectRoot, options) {
122
122
  let anyNewFindings = false;
123
+ let hasDetectionGaps = false;
123
124
  for (const r of results) {
125
+ const { hasDetectionGap } = getCompletenessImpact(r.completeness);
126
+ if (hasDetectionGap) {
127
+ hasDetectionGaps = true;
128
+ console.log(chalk.red(`${r.subfolder}/: Scan data is incomplete. Refusing to create or evaluate a baseline from partial detection data.`));
129
+ for (const diagnostic of r.completeness.diagnostics) {
130
+ if (diagnostic.impact !== "detection")
131
+ continue;
132
+ console.log(chalk.red(` ${formatDiagnosticMessage(diagnostic.code, diagnostic.count, diagnostic.affectedPackageCount)}`));
133
+ }
134
+ continue;
135
+ }
124
136
  const subfolderAbs = path.join(projectRoot, r.subfolder);
125
137
  const baseline = readBaseline(subfolderAbs);
126
138
  const outcome = ratchetOutcome(baseline, r.sorted);
@@ -143,8 +155,11 @@ function handleMultiFolderRatchet(results, projectRoot, options) {
143
155
  console.log(` ${chalk.yellow(f.severity)} ${f.pkg.name}@${f.pkg.version}${ids ? ` (${ids})` : ""}`);
144
156
  }
145
157
  }
158
+ if (hasDetectionGaps) {
159
+ return EXIT_ERROR;
160
+ }
146
161
  if (options.checkOverrides) {
147
- console.log(chalk.gray("Note: override hygiene (--check-overrides) is not part of the ratchet baseline; run `cve-lite overrides` to audit overrides."));
162
+ console.log(chalk.gray(`Note: override hygiene (--check-overrides) is not part of the ratchet baseline; run \`${OVERRIDES_COMMAND}\` to audit overrides.`));
148
163
  }
149
164
  if (anyNewFindings) {
150
165
  console.log(chalk.gray("To accept these, re-baseline intentionally by deleting the folder's .cve-lite/baseline.json and re-running --ratchet."));
@@ -4,3 +4,31 @@ export function getPrimaryParent(finding) {
4
4
  return null;
5
5
  return firstPath[1] ?? null;
6
6
  }
7
+ /**
8
+ * Unique root (top-level) dependencies that pull in this package, derived from
9
+ * every known dependencyPaths chain. Paths of length < 3 (direct dependencies,
10
+ * where the package itself is path[1]) are excluded — there is no meaningful
11
+ * root distinct from the package.
12
+ *
13
+ * Gated on relationship === "transitive": a package can be a direct dependency
14
+ * while also being reachable via another root's transitive chain (same
15
+ * resolved version, deduped into one PackageRef). classifyRelationship marks
16
+ * that case "direct", so treat it the same way here rather than surfacing a
17
+ * root that contradicts the Type column.
18
+ */
19
+ export function getRootDependencies(finding) {
20
+ if (finding.relationship !== "transitive")
21
+ return [];
22
+ const roots = [];
23
+ const seen = new Set();
24
+ for (const path of finding.dependencyPaths ?? []) {
25
+ if (path.length < 3)
26
+ continue;
27
+ const root = path[1];
28
+ if (root && !seen.has(root)) {
29
+ seen.add(root);
30
+ roots.push(root);
31
+ }
32
+ }
33
+ return roots;
34
+ }
@@ -4,18 +4,8 @@ import path from "node:path";
4
4
  import { createSpinner } from "../output/spinner.js";
5
5
  import { chalk } from "./chalk.js";
6
6
  import { pluralize } from "./string.js";
7
- export function buildFixCommandParts(packageManager, targets) {
8
- if (packageManager === "npm") {
9
- return ["npm", "install", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
10
- }
11
- if (packageManager === "pnpm") {
12
- return ["pnpm", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
13
- }
14
- if (packageManager === "bun") {
15
- return ["bun", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
16
- }
17
- return ["yarn", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
18
- }
7
+ import { isBreakingUpgrade } from "./version.js";
8
+ import { buildTargetCommand } from "../remediation/fix-commands.js";
19
9
  export async function runInstallCommand(command, args, cwd, debugLog) {
20
10
  const commandLine = [command, ...args].join(" ");
21
11
  debugLog?.("Fix command", { command: commandLine, cwd });
@@ -45,63 +35,101 @@ export function commandLabelForPackageManager(packageManager) {
45
35
  return "bun add";
46
36
  return "yarn add";
47
37
  }
38
+ // Categorize the fixes that --fix does NOT auto-apply. Direct upgrades and
39
+ // within-range refreshes (parent-update) are auto-applied, so only parent
40
+ // upgrades (breaking ones especially) and no-fix findings remain here.
41
+ export function categorizeUnappliedTargets(plan) {
42
+ let parentUpgradeCount = 0;
43
+ let breakingUpgradeCount = 0;
44
+ for (const target of plan.targets) {
45
+ if (target.kind === "parent-upgrade") {
46
+ parentUpgradeCount += 1;
47
+ if (target.currentVersion && isBreakingUpgrade(target.currentVersion, target.targetVersion)) {
48
+ breakingUpgradeCount += 1;
49
+ }
50
+ }
51
+ }
52
+ return {
53
+ parentUpgradeCount,
54
+ breakingUpgradeCount,
55
+ noFixCount: plan.skipped.length,
56
+ };
57
+ }
58
+ const EMPTY_UNAPPLIED = {
59
+ parentUpgradeCount: 0,
60
+ breakingUpgradeCount: 0,
61
+ noFixCount: 0,
62
+ };
63
+ // Build the command(s) to apply a target. Within-range refresh (parent-update)
64
+ // targets carry an explicit, already-workspace-scoped command; direct targets
65
+ // are installed by version. A multi-member workspace command is `&&`-joined and
66
+ // is split into one spawn per member.
67
+ function buildApplyCommands(packageManager, target) {
68
+ // Use the same workspace-scoped command the report/plan shows, so --fix applies
69
+ // fixes to the declaring member (npm install -w, pnpm --filter ...) rather than
70
+ // flat at the root. A multi-member command is `&&`-joined; split per spawn.
71
+ return buildTargetCommand(target, packageManager)
72
+ .split("&&")
73
+ .map(part => part.trim())
74
+ .filter(Boolean)
75
+ .map(part => part.split(/\s+/));
76
+ }
48
77
  export function writeFixResultJson(json, projectPath) {
49
78
  const outPath = path.join(projectPath, "cve-lite-fix-result.json");
50
79
  fs.writeFileSync(outPath, JSON.stringify(json, null, 2), "utf8");
51
80
  }
52
81
  export async function applyFixesIfRequested(params) {
82
+ const runCommand = params.runCommand ?? runInstallCommand;
53
83
  console.log("");
54
84
  console.log(chalk.bold.cyan("Applying fixes (--fix)"));
55
85
  if (!params.plan) {
56
86
  return {
57
87
  appliedFixCount: 0,
58
- skippedCount: params.totalFindings,
59
- skippedTransitiveCount: 0,
60
- skippedNoValidatedTargetCount: params.totalFindings,
88
+ appliedWithinRangeRefreshCount: 0,
89
+ ...EMPTY_UNAPPLIED,
61
90
  applied: [],
62
91
  note: "No package-manager-native fix command is available for this project.",
63
92
  };
64
93
  }
65
- const directTargets = params.plan.targets.filter(target => target.kind === "direct");
66
- const transitiveTargets = params.plan.targets.filter(target => target.kind !== "direct");
67
- const skippedDirect = params.plan.skipped.filter(skip => skip.relationship === "direct" || skip.relationship === "unknown");
68
- if (directTargets.length === 0) {
69
- const skippedCount = transitiveTargets.length + skippedDirect.length;
94
+ // Auto-apply the safe fixes: direct upgrades and within-range transitive
95
+ // refreshes (parent-update). Parent upgrades (breaking or otherwise) still
96
+ // need review and are left for the user.
97
+ const applyTargets = params.plan.targets.filter(target => target.kind === "direct" || target.kind === "parent-update");
98
+ const unapplied = categorizeUnappliedTargets(params.plan);
99
+ if (applyTargets.length === 0) {
70
100
  return {
71
101
  appliedFixCount: 0,
72
- skippedCount,
73
- skippedTransitiveCount: transitiveTargets.length,
74
- skippedNoValidatedTargetCount: skippedDirect.length,
102
+ appliedWithinRangeRefreshCount: 0,
103
+ ...unapplied,
75
104
  applied: [],
76
- note: "No validated direct dependency fixes were eligible for auto-apply.",
105
+ note: "No fixes were auto-applied. `--fix` auto-applies safe direct upgrades and within-range refreshes; the remaining fixes are parent upgrades that need review. See the Suggested Fix Plan above.",
77
106
  };
78
107
  }
79
108
  const commandLabel = commandLabelForPackageManager(params.plan.packageManager);
80
- const total = directTargets.length;
81
- const spinner = createSpinner(`Applying direct package fixes with ${commandLabel}... 0/${total}`, params.options);
109
+ const total = applyTargets.length;
110
+ const spinner = createSpinner(`Applying safe package fixes with ${commandLabel}... 0/${total}`, params.options);
82
111
  const fixHint = `\nHint: Check that \`${params.plan.packageManager}\` is available and you have write access to node_modules.\nIf running in CI, ensure the install step has already run before cve-lite --fix.`;
83
- for (let i = 0; i < directTargets.length; i++) {
84
- const target = directTargets[i];
85
- const commandParts = buildFixCommandParts(params.plan.packageManager, [target]);
86
- spinner.update(`Applying direct fix ${i + 1}/${total}: ${commandParts.join(" ")}`);
87
- const run = await runInstallCommand(commandParts[0], commandParts.slice(1), params.projectPath, params.debugLog);
88
- if (run.error) {
89
- spinner.fail("Failed to apply fixes");
90
- throw new Error(`Failed to apply fixes: ${run.error.message}${fixHint}`);
91
- }
92
- if ((run.status ?? 1) !== 0) {
93
- spinner.fail(`Fix command failed (${commandLabel})`);
94
- throw new Error(`Fix command exited with status ${run.status ?? 1}${fixHint}`);
112
+ for (let i = 0; i < applyTargets.length; i++) {
113
+ const target = applyTargets[i];
114
+ for (const commandParts of buildApplyCommands(params.plan.packageManager, target)) {
115
+ spinner.update(`Applying fix ${i + 1}/${total}: ${commandParts.join(" ")}`);
116
+ const run = await runCommand(commandParts[0], commandParts.slice(1), params.projectPath, params.debugLog);
117
+ if (run.error) {
118
+ spinner.fail("Failed to apply fixes");
119
+ throw new Error(`Failed to apply fixes: ${run.error.message}${fixHint}`);
120
+ }
121
+ if ((run.status ?? 1) !== 0) {
122
+ spinner.fail(`Fix command failed (${commandLabel})`);
123
+ throw new Error(`Fix command exited with status ${run.status ?? 1}${fixHint}`);
124
+ }
95
125
  }
96
126
  }
97
- spinner.succeed(`Applied ${directTargets.length} direct package ${pluralize(directTargets.length, "fix", "fixes")} with ${commandLabel}`);
98
- const skippedCount = transitiveTargets.length + skippedDirect.length;
127
+ spinner.succeed(`Applied ${applyTargets.length} package ${pluralize(applyTargets.length, "fix", "fixes")} with ${commandLabel}`);
99
128
  return {
100
- appliedFixCount: directTargets.length,
101
- skippedCount,
102
- skippedTransitiveCount: transitiveTargets.length,
103
- skippedNoValidatedTargetCount: skippedDirect.length,
104
- applied: directTargets.map(target => ({
129
+ appliedFixCount: applyTargets.length,
130
+ appliedWithinRangeRefreshCount: applyTargets.filter(target => target.kind === "parent-update").length,
131
+ ...unapplied,
132
+ applied: applyTargets.map(target => ({
105
133
  package: target.package,
106
134
  from: target.currentVersion ?? "unknown",
107
135
  to: target.targetVersion,
@@ -125,11 +153,20 @@ export function printFixModeSummary(params) {
125
153
  }
126
154
  console.log("");
127
155
  console.log(chalk.bold.cyan("Fix summary"));
128
- console.log(`- Applied fixes: ${chalk.green(String(result.appliedFixCount))}`);
129
- console.log(`- Skipped findings: ${chalk.yellow(String(result.skippedCount))}`);
130
- if (result.skippedCount > 0) {
131
- console.log(` - Transitive (v1 skip): ${chalk.yellow(String(result.skippedTransitiveCount))}`);
132
- console.log(` - No validated direct target: ${chalk.yellow(String(result.skippedNoValidatedTargetCount))}`);
156
+ const refreshNote = result.appliedWithinRangeRefreshCount > 0
157
+ ? ` (incl. ${result.appliedWithinRangeRefreshCount} within-range ${pluralize(result.appliedWithinRangeRefreshCount, "refresh", "refreshes")})`
158
+ : "";
159
+ console.log(`- Applied fixes: ${chalk.green(String(result.appliedFixCount))}${chalk.gray(refreshNote)}`);
160
+ const notAutoApplied = result.parentUpgradeCount + result.noFixCount;
161
+ console.log(`- Not auto-applied: ${chalk.yellow(String(notAutoApplied))}`);
162
+ if (result.parentUpgradeCount > 0) {
163
+ const breakingNote = result.breakingUpgradeCount > 0
164
+ ? `, ${result.breakingUpgradeCount} breaking`
165
+ : "";
166
+ console.log(` - Parent upgrades (review + test): ${chalk.yellow(String(result.parentUpgradeCount))}${chalk.gray(breakingNote)}`);
167
+ }
168
+ if (result.noFixCount > 0) {
169
+ console.log(` - No fix available: ${chalk.yellow(String(result.noFixCount))}`);
133
170
  }
134
171
  console.log(`- Findings before fix: ${chalk.white(String(params.findingsBeforeFix))}`);
135
172
  console.log(`- Remaining findings after fix: ${chalk.white(String(params.findingsAfterFix))}`);
@@ -45,10 +45,19 @@ export function parseExactManifestVersion(spec) {
45
45
  return cleaned;
46
46
  return null;
47
47
  }
48
- export function isMajorVersionBump(from, to) {
49
- const fromMajor = Number(from.split(".")[0]);
50
- const toMajor = Number(to.split(".")[0]);
51
- return !Number.isNaN(fromMajor) && !Number.isNaN(toMajor) && toMajor > fromMajor;
48
+ export function isBreakingUpgrade(from, to) {
49
+ const [fromMajor, fromMinor] = from.split(".").map(Number);
50
+ const [toMajor, toMinor] = to.split(".").map(Number);
51
+ if (Number.isNaN(fromMajor) || Number.isNaN(toMajor))
52
+ return false;
53
+ if (toMajor > fromMajor)
54
+ return true;
55
+ // Under semver, 0.x releases treat the minor as the breaking position
56
+ // (^0.21.1 resolves to >=0.21.1 <0.22.0), so a 0.x cross-minor bump is breaking.
57
+ if (fromMajor === 0 && toMajor === 0) {
58
+ return !Number.isNaN(fromMinor) && !Number.isNaN(toMinor) && toMinor > fromMinor;
59
+ }
60
+ return false;
52
61
  }
53
62
  export function isPreReleaseVersion(version) {
54
63
  return /^\d+\.\d+\.\d+-[^\s]+$/.test(version);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.29.0",
3
+ "version": "1.30.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": {
@@ -47,7 +47,7 @@
47
47
  ],
48
48
  "license": "MIT",
49
49
  "engines": {
50
- "node": ">=18"
50
+ "node": ">=20"
51
51
  },
52
52
  "repository": {
53
53
  "type": "git",