cve-lite-cli 1.27.0 → 1.28.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.
@@ -1,12 +1,14 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { spawn } from "node:child_process";
4
- import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandWithPublishDates } from "./formatters.js";
4
+ import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandWithPublishDates, formatCooldownWarning } from "./formatters.js";
5
5
  import { loadLogoDataUri } from "./logos.js";
6
6
  import { isMajorVersionBump } 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 } from "../constants.js";
9
9
  import { renderOverrideFindingsHtml } from "./override-findings-html.js";
10
+ import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
11
+ import { UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
10
12
  export function serializeHtmlFinding(finding, plan) {
11
13
  return {
12
14
  ...serializeFinding(finding, plan),
@@ -26,7 +28,9 @@ export function buildReportData(params) {
26
28
  suggestedFixCommands: params.suggestedFixCommands,
27
29
  notes: params.notes,
28
30
  warnings: params.warnings,
31
+ skippedDependencies: params.skippedDependencies,
29
32
  overrideFindings: params.overrideFindings,
33
+ maintenanceFindings: params.maintenanceFindings,
30
34
  };
31
35
  }
32
36
  export const REPORT_STYLES = `:root{--bg:#0d1117;--surface:#161b22;--surface-hi:#1c2128;--input:#21262d;--border:#30363d;--border-sub:#21262d;--text:#e6edf3;--text-2:#8b949e;--text-3:#6b7280;--link:#58a6ff;--link-h:#79c0ff;--green:#3fb950;--logo-bg:#fff}
@@ -77,6 +81,9 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
77
81
  .skipped-rel.direct{color:#3fb950}
78
82
  .skipped-rel.transitive{color:#e3b341}
79
83
  .skipped-reason{color:var(--text-3)}
84
+ .skipped-deps{padding:12px 18px;display:flex;flex-direction:column;gap:4px}
85
+ .skipped-deps .skipped-deps-hint{font-size:11px;color:var(--text-2);margin-bottom:4px}
86
+ .skipped-dep{font-size:11px;padding:5px 8px;border-radius:4px;background:var(--bg);border:1px solid var(--border-sub)}
80
87
  .fix-cmd{display:flex;align-items:center;gap:12px;background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:10px 14px}
81
88
  .fix-cmd .cmd-text{flex:1;font-family:'SF Mono','Cascadia Code','Fira Code',monospace;font-size:12px;color:var(--green)}
82
89
  .fix-cmd .cmd-meta{font-size:11px;color:var(--text-2);white-space:nowrap}
@@ -166,18 +173,21 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
166
173
  .override-hygiene{margin:0 32px 32px}
167
174
  .override-hygiene h2{font-size:13px;font-weight:600;color:var(--text);margin-bottom:12px}
168
175
  .override-hygiene p{font-size:13px;color:var(--text-2)}
169
- .override-hygiene table{width:100%;border-collapse:collapse;background:var(--surface);border:1px solid var(--border);border-radius:8px;overflow:hidden}
170
- .override-hygiene table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:var(--text-2);padding:10px 14px;border-bottom:1px solid var(--border-sub);background:var(--surface-hi)}
176
+ .override-hygiene table{width:100%;border-collapse:collapse}
177
+ .override-hygiene table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:var(--text-2);padding:10px 14px;border-bottom:1px solid var(--border-sub);background:var(--surface);white-space:nowrap}
171
178
  .override-hygiene table tbody tr{border-bottom:1px solid var(--border-sub)}
172
179
  .override-hygiene table tbody tr:last-child{border-bottom:none}
173
- .override-hygiene table tbody tr.severity-group{background:var(--surface-hi)}
174
- .override-hygiene table tbody tr.severity-group th{font-weight:600;color:var(--text);padding:10px 14px;text-align:left}
175
- .override-hygiene table tbody tr.finding td{padding:11px 14px;font-size:12px;color:var(--text);vertical-align:middle}
176
- .override-hygiene table tbody tr.critical{border-left:3px solid #f85149}
177
- .override-hygiene table tbody tr.high{border-left:3px solid #fb8500}
178
- .override-hygiene table tbody tr.medium{border-left:3px solid #e3b341}
179
- .override-hygiene table tbody tr.low{border-left:3px solid #388bfd}
180
- .override-hygiene table tbody tr.unknown{border-left:3px solid #8b949e}`;
180
+ .override-hygiene table tbody tr:hover{background:var(--surface)}
181
+ .override-hygiene table tbody td{padding:11px 14px;font-size:13px;color:var(--text);vertical-align:middle}
182
+ .maintenance-risk{margin:0 32px 32px}
183
+ .maintenance-risk h2{font-size:13px;font-weight:600;color:var(--text);margin-bottom:12px}
184
+ .maintenance-risk p{font-size:13px;color:var(--text-2)}
185
+ .maintenance-risk table{width:100%;border-collapse:collapse}
186
+ .maintenance-risk table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:var(--text-2);padding:10px 14px;border-bottom:1px solid var(--border-sub);background:var(--surface);white-space:nowrap}
187
+ .maintenance-risk table tbody tr{border-bottom:1px solid var(--border-sub)}
188
+ .maintenance-risk table tbody tr:last-child{border-bottom:none}
189
+ .maintenance-risk table tbody tr:hover{background:var(--surface)}
190
+ .maintenance-risk table tbody td{padding:11px 14px;font-size:13px;color:var(--text);vertical-align:middle}`;
181
191
  export function renderHtmlReport(data) {
182
192
  const projectName = path.basename(data.projectPath);
183
193
  const scanDate = new Date(data.scannedAt).toLocaleString();
@@ -192,6 +202,7 @@ export function renderHtmlReport(data) {
192
202
  const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
193
203
  const skippedKeys = new Set((data.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
194
204
  const skippedSectionHtml = renderSkippedSection(data.suggestedFixCommands);
205
+ const skippedDepsHtml = renderSkippedDependenciesSection(data.skippedDependencies);
195
206
  const findingRowsHtml = data.findings.map((f, i) => renderFindingRow(f, i, skippedKeys)).join("\n");
196
207
  const dataJson = JSON.stringify(data)
197
208
  .replace(/</g, "\\u003c")
@@ -294,7 +305,9 @@ ${findingRowsHtml}
294
305
  </table>
295
306
  </div>
296
307
  ${renderOverrideFindingsHtml(data.overrideFindings, data.projectPath)}
308
+ ${renderMaintenanceFindingsHtml(data.maintenanceFindings)}
297
309
 
310
+ ${skippedDepsHtml}
298
311
  ${noticesHtml}
299
312
 
300
313
  <div class="report-footer">
@@ -577,6 +590,23 @@ export function renderSkippedSection(plan) {
577
590
  </div>
578
591
  </div>`;
579
592
  }
593
+ export function renderSkippedDependenciesSection(skipped) {
594
+ if (skipped.length === 0)
595
+ return "";
596
+ const rows = skipped
597
+ .map(dep => ` <div class="skipped-dep"><span class="skipped-pkg">${escapeHtml(dep)}</span></div>`)
598
+ .join("\n");
599
+ return `<div class="fix-plan">
600
+ <div class="fix-plan-header">
601
+ <h2><span class="icon">⊖</span> Skipped manifest dependencies</h2>
602
+ <span class="badge">${skipped.length} skipped</span>
603
+ </div>
604
+ <div class="skipped-deps">
605
+ <div class="skipped-deps-hint">Declared in the manifest but not scanned, because no resolvable version was found (for example private-registry packages, git or file specifiers, or version ranges that could not be parsed).</div>
606
+ ${rows}
607
+ </div>
608
+ </div>`;
609
+ }
580
610
  export function renderFixPlan(plan) {
581
611
  if (!plan || plan.sections.length === 0)
582
612
  return "";
@@ -596,6 +626,12 @@ export function renderFixPlan(plan) {
596
626
  const noteHtml = t.adjusted && t.adjustmentNote
597
627
  ? ` <span class="fix-target-note">${escapeHtml(t.adjustmentNote)}</span>`
598
628
  : "";
629
+ const cooldownHtml = t.cooldownWarning
630
+ ? ` <span class="fix-target-note">${escapeHtml(formatCooldownWarning(t.cooldownWarning))}</span>`
631
+ : "";
632
+ const unverifiedHtml = t.confidence === "unverified"
633
+ ? ` <span class="fix-target-note">${escapeHtml(UNVERIFIED_PARENT_UPGRADE_NOTE)}</span>`
634
+ : "";
599
635
  const coverageHtml = t.coverage === "partial"
600
636
  ? ` <span class="fix-target-coverage">Path-specific remediation. Run this command, then rescan; ${t.remainingPaths?.length ?? 0} other known ${pluralize(t.remainingPaths?.length ?? 0, "path")} may still need separate parent upgrades.</span>`
601
637
  : "";
@@ -609,7 +645,7 @@ export function renderFixPlan(plan) {
609
645
  return ` <span class="chain-proof">${proofText}</span>`;
610
646
  })()
611
647
  : "";
612
- return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}${coverageHtml}${chainProofHtml}</div>`;
648
+ return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}${cooldownHtml}${unverifiedHtml}${coverageHtml}${chainProofHtml}</div>`;
613
649
  }).join("\n");
614
650
  const targetsHtml = section.targets.length > 0
615
651
  ? `<div class="fix-targets-list">${targetRows}</div>`
@@ -0,0 +1,56 @@
1
+ import { SEVERITY_ORDER } from "../utils/severity.js";
2
+ function esc(s) {
3
+ return s
4
+ .replace(/&/g, "&amp;")
5
+ .replace(/</g, "&lt;")
6
+ .replace(/>/g, "&gt;")
7
+ .replace(/"/g, "&quot;");
8
+ }
9
+ function detailHtml(finding) {
10
+ const lines = [];
11
+ for (const d of finding.drag ?? []) {
12
+ lines.push(`Drags ${esc(d.constrainedPackage)}@${esc(d.installedVersion)} below fix ${esc(d.fixVersion)} - upgrade to ${esc(d.parentTargetVersion)}`);
13
+ }
14
+ if (finding.deprecated) {
15
+ lines.push(`npm deprecated: ${esc(finding.deprecated.message)}`);
16
+ }
17
+ if (lines.length === 0)
18
+ lines.push(esc(finding.message));
19
+ return lines.join("<br>");
20
+ }
21
+ export function renderMaintenanceFindingsHtml(findings) {
22
+ // undefined = maintenance risk was never requested -> render nothing, so a plain
23
+ // `cve-lite .` report shows no Maintenance risk panel at all. An empty array =
24
+ // it ran and found nothing -> render the "no findings" reassurance.
25
+ if (findings === undefined) {
26
+ return "";
27
+ }
28
+ if (findings.length === 0) {
29
+ return `
30
+ <section class="maintenance-risk">
31
+ <h2>Maintenance risk</h2>
32
+ <p>No maintenance risk findings.</p>
33
+ </section>
34
+ `;
35
+ }
36
+ const sorted = [...findings].sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity));
37
+ const rows = sorted.map(f => ` <tr class="finding ${esc(f.severity)}">` +
38
+ `<td><span class="dep-node">${esc(f.ruleId)}</span></td>` +
39
+ `<td><div class="pkg-name">${esc(f.package.name)}</div><div class="pkg-version">${esc(f.package.version)}</div></td>` +
40
+ `<td><span class="sev-badge ${esc(f.severity)}">${esc(f.severity)}</span></td>` +
41
+ `<td>${detailHtml(f)}</td>` +
42
+ `</tr>`);
43
+ return `
44
+ <section class="maintenance-risk">
45
+ <h2>Maintenance risk</h2>
46
+ <table>
47
+ <thead>
48
+ <tr><th>Rule</th><th>Package</th><th>Severity</th><th>Details</th></tr>
49
+ </thead>
50
+ <tbody>
51
+ ${rows.join("\n")}
52
+ </tbody>
53
+ </table>
54
+ </section>
55
+ `;
56
+ }
@@ -0,0 +1,3 @@
1
+ export function maintenanceFindingsToJson(findings) {
2
+ return { maintenanceFindings: [...findings] };
3
+ }
@@ -0,0 +1,80 @@
1
+ import { chalk } from "../utils/chalk.js";
2
+ import { formatSeverityLabel, SEVERITY_ORDER } from "../utils/severity.js";
3
+ import { pluralize } from "../utils/string.js";
4
+ const COL_RULE_MAX = 8;
5
+ const COL_PKG_MAX = 30;
6
+ const COL_DET_MAX = 60;
7
+ function pad(s, width) {
8
+ if (s.length >= width)
9
+ return s.slice(0, width);
10
+ return s + " ".repeat(width - s.length);
11
+ }
12
+ function truncate(s, max) {
13
+ return s.length > max ? s.slice(0, max - 1) + "…" : s;
14
+ }
15
+ function buildDetailLines(finding) {
16
+ const lines = [];
17
+ for (const d of finding.drag ?? []) {
18
+ lines.push(`Drags ${d.constrainedPackage}@${d.installedVersion} below fix ${d.fixVersion} - upgrade to ${d.parentTargetVersion}`);
19
+ }
20
+ if (finding.deprecated) {
21
+ lines.push(`npm deprecated: ${finding.deprecated.message}`);
22
+ }
23
+ if (lines.length === 0) {
24
+ lines.push(finding.message);
25
+ }
26
+ return lines;
27
+ }
28
+ export function renderMaintenanceFindings(findings, options) {
29
+ const lines = [];
30
+ if (options?.verbose) {
31
+ lines.push(chalk.bold.cyan("🔧 Maintenance Risk"));
32
+ }
33
+ else {
34
+ lines.push("────────────────────────────────");
35
+ lines.push(chalk.bold("🔧 Maintenance Risk"));
36
+ lines.push("────────────────────────────────");
37
+ }
38
+ lines.push("");
39
+ if (findings.length === 0) {
40
+ lines.push(chalk.greenBright("✔ No maintenance risk findings."));
41
+ return lines.join("\n");
42
+ }
43
+ const grouped = new Map();
44
+ for (const sev of SEVERITY_ORDER)
45
+ grouped.set(sev, []);
46
+ for (const f of findings)
47
+ grouped.get(f.severity)?.push(f);
48
+ for (const sev of SEVERITY_ORDER) {
49
+ const bucket = grouped.get(sev) ?? [];
50
+ if (bucket.length === 0)
51
+ continue;
52
+ lines.push(`${formatSeverityLabel(sev.toUpperCase())} (${bucket.length})`);
53
+ const sorted = [...bucket].sort((a, b) => a.package.name.localeCompare(b.package.name));
54
+ const allDetailLines = sorted.flatMap(f => buildDetailLines(f));
55
+ const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => `${f.package.name}@${f.package.version}`.length)));
56
+ const detWidth = Math.min(COL_DET_MAX, Math.max(7, ...allDetailLines.map(l => l.length)));
57
+ const ruleWidth = COL_RULE_MAX;
58
+ const hr = (l, m, r) => l + "─".repeat(ruleWidth + 2) + m + "─".repeat(pkgWidth + 2) + m + "─".repeat(detWidth + 2) + r;
59
+ const row = (rule, pkg, det) => `│ ${pad(rule, ruleWidth)} │ ${pad(pkg, pkgWidth)} │ ${pad(det, detWidth)} │`;
60
+ lines.push(hr("┌", "┬", "┐"));
61
+ lines.push(row("Rule", "Package", "Details"));
62
+ lines.push(hr("├", "┼", "┤"));
63
+ for (const finding of sorted) {
64
+ const pkgLabel = truncate(`${finding.package.name}@${finding.package.version}`, pkgWidth);
65
+ const detailLines = buildDetailLines(finding).map(l => truncate(l, detWidth));
66
+ lines.push(row("DM001", pkgLabel, detailLines[0] ?? ""));
67
+ for (let i = 1; i < detailLines.length; i++) {
68
+ lines.push(row("", "", detailLines[i] ?? ""));
69
+ }
70
+ }
71
+ lines.push(hr("└", "┴", "┘"));
72
+ lines.push("");
73
+ }
74
+ const worstSev = SEVERITY_ORDER.find(s => (grouped.get(s) ?? []).length > 0);
75
+ const footerColor = worstSev === "critical" || worstSev === "high" ? chalk.redBright : chalk.yellow;
76
+ lines.push(footerColor(`${findings.length} maintenance risk ${pluralize(findings.length, "issue")} found.`));
77
+ lines.push("");
78
+ lines.push(chalk.gray("────────────────────────────────"));
79
+ return lines.join("\n");
80
+ }
@@ -22,43 +22,33 @@ export function renderOverrideFindingsHtml(findings, projectPath) {
22
22
  </section>
23
23
  `;
24
24
  }
25
- const grouped = new Map();
26
- for (const sev of SEVERITY_ORDER)
27
- grouped.set(sev, []);
28
- for (const f of findings)
29
- grouped.get(f.severity)?.push(f);
30
- const rows = [];
31
- for (const sev of SEVERITY_ORDER) {
32
- const bucket = grouped.get(sev) ?? [];
33
- if (bucket.length === 0)
34
- continue;
35
- rows.push(` <tr class="severity-group ${esc(sev)}"><th>${esc(sev.toUpperCase())} (${bucket.length})</th><td></td><td></td><td></td></tr>`);
36
- for (const f of bucket) {
37
- const location = f.location.jsonPath
38
- ? `${esc(f.location.file)} › ${esc(f.location.jsonPath)}`
39
- : esc(f.location.file);
40
- const relPath = projectPath ? relative(process.cwd(), projectPath) : "";
41
- const projectInfix = relPath && relPath !== "." ? ` ${relPath}` : "";
42
- const runnableCmd = f.fix?.runnableCommand && projectInfix
43
- ? f.fix.runnableCommand.replace("cve-lite overrides", `cve-lite${projectInfix} overrides`)
44
- : f.fix?.runnableCommand;
45
- const fixHtml = runnableCmd
46
- ? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(runnableCmd)}</code><button class="copy-btn" data-cmd="${esc(runnableCmd)}">Copy</button></div>`
47
- : "";
48
- rows.push(` <tr class="finding ${esc(f.severity)}">` +
49
- `<td>${esc(f.ruleId)}</td>` +
50
- `<td>${esc(f.package.name)}</td>` +
51
- `<td>${location}</td>` +
52
- `<td>${esc(f.message)}${fixHtml}</td>` +
53
- `</tr>`);
54
- }
55
- }
25
+ const sorted = [...findings].sort((a, b) => SEVERITY_ORDER.indexOf(a.severity) - SEVERITY_ORDER.indexOf(b.severity));
26
+ const rows = sorted.map(f => {
27
+ const location = f.location.jsonPath
28
+ ? `${esc(f.location.file)} › ${esc(f.location.jsonPath)}`
29
+ : esc(f.location.file);
30
+ const relPath = projectPath ? relative(process.cwd(), projectPath) : "";
31
+ 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>`
37
+ : "";
38
+ return (` <tr class="finding ${esc(f.severity)}">` +
39
+ `<td><span class="dep-node">${esc(f.ruleId)}</span></td>` +
40
+ `<td><div class="pkg-name">${esc(f.package.name)}</div></td>` +
41
+ `<td><span class="sev-badge ${esc(f.severity)}">${esc(f.severity)}</span></td>` +
42
+ `<td>${location}</td>` +
43
+ `<td>${esc(f.message)}${fixHtml}</td>` +
44
+ `</tr>`);
45
+ });
56
46
  return `
57
47
  <section class="override-hygiene">
58
48
  <h2>Override hygiene</h2>
59
49
  <table>
60
50
  <thead>
61
- <tr><th>Rule</th><th>Package</th><th>Location</th><th>Message</th></tr>
51
+ <tr><th>Rule</th><th>Package</th><th>Severity</th><th>Location</th><th>Message</th></tr>
62
52
  </thead>
63
53
  <tbody>
64
54
  ${rows.join("\n")}
@@ -1,8 +1,8 @@
1
1
  import { chalk, stripAnsi } from "../utils/chalk.js";
2
- import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
2
+ import { buildSuggestedFixCommandPlan, UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
3
3
  import { isMajorVersionBump } from "../utils/version.js";
4
4
  import { getPrimaryParent } from "../utils/finding.js";
5
- import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, } from "./formatters.js";
5
+ import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, formatCooldownWarning, } from "./formatters.js";
6
6
  import { formatSeverityLabel } from "../utils/severity.js";
7
7
  import { pluralize } from "../utils/string.js";
8
8
  import { selectFindingsForCompact } from "./finding-display.js";
@@ -56,6 +56,16 @@ export function printActionSummary(findings, overrideCount = 0, packageManager)
56
56
  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")}.`);
57
57
  }
58
58
  }
59
+ function printCooldownWarning(target) {
60
+ if (target.cooldownWarning) {
61
+ console.log(chalk.yellow(` ⚠ ${formatCooldownWarning(target.cooldownWarning)}`));
62
+ }
63
+ }
64
+ function printUnverifiedParentUpgradeWarning(target) {
65
+ if (target.confidence === "unverified") {
66
+ console.log(chalk.yellow(` ${UNVERIFIED_PARENT_UPGRADE_NOTE}`));
67
+ }
68
+ }
59
69
  function printChainProofLines(targets) {
60
70
  for (const target of targets) {
61
71
  if (!target.chainProof || !target.chainSafeVersion)
@@ -112,6 +122,10 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
112
122
  else if (shouldRenderParentUpgradeTable(section.targets)) {
113
123
  printParentUpgradeTargetsTable(section.targets, sharedParentUpgradeTableWidths);
114
124
  }
125
+ for (const target of section.targets) {
126
+ printCooldownWarning(target);
127
+ printUnverifiedParentUpgradeWarning(target);
128
+ }
115
129
  console.log(renderCommandCallout(section.command, section.targets));
116
130
  printChainProofLines(section.targets);
117
131
  }
@@ -446,12 +460,11 @@ export function printCompactOutput(findings, scanInput, options) {
446
460
  console.log("");
447
461
  for (const section of plan.sections.slice(0, 3)) {
448
462
  console.log(`${section.title}`);
449
- if (section.kind === "direct-adjusted") {
450
- for (const target of section.targets) {
451
- if (!target.adjustmentNote)
452
- continue;
463
+ for (const target of section.targets) {
464
+ if (section.kind === "direct-adjusted" && target.adjustmentNote) {
453
465
  console.log(chalk.gray(` Note: ${target.adjustmentNote}`));
454
466
  }
467
+ printCooldownWarning(target);
455
468
  }
456
469
  console.log(renderCommandCallout(section.command, section.targets));
457
470
  printChainProofLines(section.targets);
@@ -7,6 +7,7 @@ export function createSpinner(initialMessage, options) {
7
7
  update: () => { },
8
8
  succeed: () => { },
9
9
  fail: () => { },
10
+ warn: () => { },
10
11
  stop: () => { }
11
12
  };
12
13
  }
@@ -36,6 +37,10 @@ export function createSpinner(initialMessage, options) {
36
37
  clearLine();
37
38
  console.log(chalk.red(`✗ ${message}`));
38
39
  },
40
+ warn(message) {
41
+ clearLine();
42
+ console.log(chalk.yellow(`⚠ ${message}`));
43
+ },
39
44
  stop() {
40
45
  clearLine();
41
46
  }
@@ -5,6 +5,7 @@ import { serializeFinding } from "./formatters.js";
5
5
  import { writeSarifReport, deriveLockfileUri } from "./sarif.js";
6
6
  import { writeCycloneDxReport } from "./cyclonedx.js";
7
7
  import { overrideFindingsToJson } from "./override-findings-json.js";
8
+ import { maintenanceFindingsToJson } from "./maintenance-findings-json.js";
8
9
  function readProjectMeta(projectPath) {
9
10
  try {
10
11
  const pkgPath = path.join(projectPath, "package.json");
@@ -41,7 +42,8 @@ export async function writeOutputs(options, scanState, scanInput, projectPath) {
41
42
  findings: scanState.sorted.map(finding => serializeFinding(finding, scanState.suggestedFixCommands)),
42
43
  };
43
44
  const overridePayload = overrideFindingsToJson(scanState.overrideFindings ?? []);
44
- const combined = { ...payload, ...overridePayload };
45
+ const maintenancePayload = maintenanceFindingsToJson(scanState.maintenanceFindings ?? []);
46
+ const combined = { ...payload, ...overridePayload, ...maintenancePayload };
45
47
  fs.writeFileSync(jsonOutputPath, JSON.stringify(combined, null, 2));
46
48
  console.log(`${chalk.gray("JSON saved to")} ${chalk.cyan(jsonFilename)}`);
47
49
  }
@@ -0,0 +1,74 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { parse as parseYaml } from "yaml";
4
+ // Design basis - verified against current PM docs. npm: days; pnpm/yarn: minutes.
5
+ const PM_CONFIG = {
6
+ npm: { file: ".npmrc", key: "min-release-age", unitMs: 86_400_000, unitLabel: "day", format: "ini" },
7
+ pnpm: { file: "pnpm-workspace.yaml", key: "minimumReleaseAge", unitMs: 60_000, unitLabel: "min", format: "yaml" },
8
+ yarn: { file: ".yarnrc.yml", key: "npmMinimalAgeGate", unitMs: 60_000, unitLabel: "min", format: "yaml" },
9
+ };
10
+ function readIniValue(contents, key) {
11
+ for (const rawLine of contents.split(/\r?\n/)) {
12
+ const line = rawLine.trim();
13
+ if (!line || line.startsWith("#") || line.startsWith(";"))
14
+ continue;
15
+ const eq = line.indexOf("=");
16
+ if (eq === -1)
17
+ continue;
18
+ if (line.slice(0, eq).trim() === key)
19
+ return line.slice(eq + 1).trim();
20
+ }
21
+ return null;
22
+ }
23
+ function readYamlValue(contents, key) {
24
+ try {
25
+ const doc = parseYaml(contents);
26
+ if (doc && typeof doc === "object" && key in doc) {
27
+ return doc[key];
28
+ }
29
+ }
30
+ catch {
31
+ // fall through to null
32
+ }
33
+ return null;
34
+ }
35
+ /**
36
+ * Reads the project-level release cooldown configured for the detected package
37
+ * manager and normalizes it to milliseconds. Returns null when no usable
38
+ * cooldown is configured (absent file/key, value 0, or malformed). Never throws.
39
+ * CVE Lite never invents a cooldown - this only surfaces what the team set.
40
+ */
41
+ export function readConfiguredCooldown(projectPath, pm) {
42
+ const cfg = PM_CONFIG[pm];
43
+ const filePath = path.join(projectPath, cfg.file);
44
+ let contents;
45
+ try {
46
+ contents = fs.readFileSync(filePath, "utf-8");
47
+ }
48
+ catch {
49
+ return null;
50
+ }
51
+ const raw = cfg.format === "ini" ? readIniValue(contents, cfg.key) : readYamlValue(contents, cfg.key);
52
+ const value = typeof raw === "number" ? raw : typeof raw === "string" ? Number(raw) : NaN;
53
+ if (!Number.isFinite(value) || value <= 0)
54
+ return null;
55
+ return {
56
+ windowMs: value * cfg.unitMs,
57
+ windowLabel: `${value} ${cfg.unitLabel}`,
58
+ sourceFile: cfg.file,
59
+ };
60
+ }
61
+ /**
62
+ * Returns a cooldown warning when a recommended fix version was published within
63
+ * the configured window, else null. Pure comparison - all inputs injected.
64
+ */
65
+ export function cooldownWarningFor(publishedAtIso, cooldown, nowMs) {
66
+ if (!cooldown || !publishedAtIso)
67
+ return null;
68
+ const publishedMs = Date.parse(publishedAtIso);
69
+ if (!Number.isFinite(publishedMs))
70
+ return null;
71
+ if (nowMs - publishedMs >= cooldown.windowMs)
72
+ return null;
73
+ return { publishedAt: publishedAtIso, windowLabel: cooldown.windowLabel, sourceFile: cooldown.sourceFile };
74
+ }
@@ -1,3 +1,4 @@
1
+ import path from "node:path";
1
2
  import { severityOrder } from "../constants.js";
2
3
  import { compareVersions, looksLikeVersion } from "../utils/version.js";
3
4
  import { getPrimaryParent } from "../utils/finding.js";
@@ -7,6 +8,12 @@ import { buildNpmWorkspaceMap } from "../parsers/package-lock.js";
7
8
  import { buildPnpmWorkspaceMap } from "../parsers/pnpm-lock.js";
8
9
  import { buildYarnWorkspaceMap } from "../parsers/yarn-lock.js";
9
10
  import { buildBunWorkspaceMap } from "../parsers/bun-lock.js";
11
+ import { readConfiguredCooldown, cooldownWarningFor } from "./cooldown.js";
12
+ import { isVerifiedUpgrade } from "./parent-upgrade.js";
13
+ // Rendered next to a parent-upgrade fix target whose recommendedParentUpgrade
14
+ // could not be verified end-to-end (parent-upgrade.ts confidence: "unverified").
15
+ // Shared across terminal and HTML output so the wording stays in sync.
16
+ export const UNVERIFIED_PARENT_UPGRADE_NOTE = "⚠ unverified - rescan after upgrading to confirm this resolves the finding";
10
17
  export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
11
18
  const packageManager = inferPackageManager(scanInput);
12
19
  if (!packageManager)
@@ -241,6 +248,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
241
248
  chainProof: chainForParentUpgrade?.chain,
242
249
  chainSafeVersion: chainForParentUpgrade?.safeVersion,
243
250
  chainVulnerablePackage: chainForParentUpgrade ? finding.pkg.name : undefined,
251
+ confidence: finding.recommendedParentUpgrade.confidence,
244
252
  });
245
253
  continue;
246
254
  }
@@ -336,6 +344,15 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
336
344
  return kindDelta;
337
345
  return a.package.localeCompare(b.package);
338
346
  });
347
+ const nowMs = options?.nowMs ?? Date.now();
348
+ if (scanInput.filePath && (packageManager === "npm" || packageManager === "pnpm" || packageManager === "yarn")) {
349
+ const cooldown = readConfiguredCooldown(path.dirname(scanInput.filePath), packageManager);
350
+ if (cooldown) {
351
+ for (const target of targets) {
352
+ target.cooldownWarning = cooldownWarningFor(target.fixVersionPublishedAt, cooldown, nowMs);
353
+ }
354
+ }
355
+ }
339
356
  const skipped = [...skippedByKey.values()].sort((a, b) => a.package.localeCompare(b.package));
340
357
  const sections = buildSections(targets, packageManager);
341
358
  const command = targets.length > 0
@@ -351,7 +368,21 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
351
368
  coveredFindingCount: 0,
352
369
  totalFindingCount: findings.length,
353
370
  };
354
- plan.coveredFindingCount = findings.filter(f => findSuggestedCommandForFinding(plan, f) !== null).length;
371
+ // A finding only counts as covered when it has a matching fix target AND that
372
+ // target isn't an unverified parent upgrade - an unverified recommendation may
373
+ // not actually resolve the finding, so it must not inflate the "fix all" claim.
374
+ plan.coveredFindingCount = findings.filter(f => {
375
+ const target = findFixTargetForFinding(plan, f);
376
+ if (!target)
377
+ return false;
378
+ // Coverage is a per-finding property, not a per-target one: two unrelated
379
+ // findings can merge into the same target (same package upgrade), so a
380
+ // finding's own recommendedParentUpgrade confidence - not the blended
381
+ // target confidence - decides whether it is genuinely covered.
382
+ if (f.recommendedParentUpgrade)
383
+ return isVerifiedUpgrade(f.recommendedParentUpgrade.confidence);
384
+ return true;
385
+ }).length;
355
386
  if (options?.subfolder) {
356
387
  const prefix = `cd ${options.subfolder} && `;
357
388
  if (plan.command)
@@ -405,7 +436,7 @@ export function commandPrefix(packageManager) {
405
436
  function devFlag(packageManager) {
406
437
  return packageManager === "bun" ? "--dev" : "-D";
407
438
  }
408
- export function findSuggestedCommandForFinding(plan, finding) {
439
+ export function findFixTargetForFinding(plan, finding) {
409
440
  const target = plan.targets.find(item => {
410
441
  if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
411
442
  return (item.kind === "parent-update" &&
@@ -429,6 +460,10 @@ export function findSuggestedCommandForFinding(plan, finding) {
429
460
  const directTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
430
461
  return item.package === finding.pkg.name && item.targetVersion === directTarget;
431
462
  });
463
+ return target ?? null;
464
+ }
465
+ export function findSuggestedCommandForFinding(plan, finding) {
466
+ const target = findFixTargetForFinding(plan, finding);
432
467
  if (!target)
433
468
  return null;
434
469
  if (target.command)
@@ -485,6 +520,11 @@ function upsertTarget(targetsByPackage, next) {
485
520
  chainProof: existing.chainProof ?? next.chainProof,
486
521
  chainSafeVersion: existing.chainSafeVersion ?? next.chainSafeVersion,
487
522
  chainVulnerablePackage: existing.chainVulnerablePackage ?? next.chainVulnerablePackage,
523
+ // Conservative: if either contributing finding's recommendation is unverified,
524
+ // keep the merged target unverified rather than overstate coverage.
525
+ confidence: existing.confidence === "unverified" || next.confidence === "unverified"
526
+ ? "unverified"
527
+ : existing.confidence ?? next.confidence,
488
528
  };
489
529
  if (looksLikeVersion(existing.targetVersion) && looksLikeVersion(next.targetVersion)) {
490
530
  if (compareVersions(next.targetVersion, existing.targetVersion) > 0) {
@@ -27,6 +27,7 @@ export async function fetchPackument(packageName) {
27
27
  if (registryDebugLog) {
28
28
  registryDebugLog("Registry fetch", { batchId, package: packageName, url });
29
29
  }
30
+ let transientFailure = false;
30
31
  try {
31
32
  const response = await fetch(url);
32
33
  if (!response.ok) {
@@ -39,6 +40,10 @@ export async function fetchPackument(packageName) {
39
40
  versionsCount: 0,
40
41
  });
41
42
  }
43
+ if (response.status === 404) {
44
+ return null;
45
+ }
46
+ transientFailure = true;
42
47
  return null;
43
48
  }
44
49
  const json = (await response.json());
@@ -54,6 +59,7 @@ export async function fetchPackument(packageName) {
54
59
  return json;
55
60
  }
56
61
  catch (error) {
62
+ transientFailure = true;
57
63
  if (registryDebugLog) {
58
64
  registryDebugLog("Registry fetch failed", {
59
65
  batchId,
@@ -66,6 +72,11 @@ export async function fetchPackument(packageName) {
66
72
  }
67
73
  return null;
68
74
  }
75
+ finally {
76
+ if (transientFailure) {
77
+ packumentCache.delete(packageName);
78
+ }
79
+ }
69
80
  })();
70
81
  packumentCache.set(packageName, promise);
71
82
  return promise;