cve-lite-cli 1.28.0 → 1.29.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.
@@ -12,13 +12,70 @@ function pad(s, width) {
12
12
  function truncate(s, max) {
13
13
  return s.length > max ? s.slice(0, max - 1) + "…" : s;
14
14
  }
15
+ // Word-wrap a detail line to the column width so the actionable tail (e.g. the
16
+ // "- upgrade to X" target) spills onto a continuation row instead of truncating
17
+ // to a useless "upgrade to 1…". A single word longer than the width is hard-broken.
18
+ function wrap(text, width) {
19
+ const out = [];
20
+ let line = "";
21
+ for (const word of text.split(" ")) {
22
+ let w = word;
23
+ while (w.length > width) {
24
+ if (line.length > 0) {
25
+ out.push(line);
26
+ line = "";
27
+ }
28
+ out.push(w.slice(0, width));
29
+ w = w.slice(width);
30
+ }
31
+ if (w.length === 0) {
32
+ continue;
33
+ }
34
+ if (line.length === 0) {
35
+ line = w;
36
+ }
37
+ else if (line.length + 1 + w.length <= width) {
38
+ line += " " + w;
39
+ }
40
+ else {
41
+ out.push(line);
42
+ line = w;
43
+ }
44
+ }
45
+ if (line.length > 0) {
46
+ out.push(line);
47
+ }
48
+ return out.length > 0 ? out : [""];
49
+ }
50
+ // Terminal only: reduce a freeform npm deprecation message for a width-capped box
51
+ // cell. Strip URLs (they truncate to a useless "https://gi…"; the full message and
52
+ // URL are kept in the HTML/JSON/SARIF outputs), and only surface the remaining text
53
+ // when it carries actionable guidance - a "use X instead" replacement. A generic
54
+ // "<pkg> has been deprecated" adds nothing over the bare flag.
55
+ function formatDeprecationFlag(message) {
56
+ const cleaned = message
57
+ .replace(/https?:\/\/\S+/g, "")
58
+ .replace(/[,;]?\s*(see|at)\s*$/i, "")
59
+ .replace(/\s+/g, " ")
60
+ .trim()
61
+ .replace(/[.,;:]+$/, "");
62
+ const hasGuidance = /\b(instead|use\s|replaced|migrate|switch to)\b/i.test(cleaned);
63
+ if (hasGuidance && cleaned.length > 0) {
64
+ return `Deprecated: ${cleaned}`;
65
+ }
66
+ return "Deprecated";
67
+ }
15
68
  function buildDetailLines(finding) {
16
69
  const lines = [];
17
70
  for (const d of finding.drag ?? []) {
18
71
  lines.push(`Drags ${d.constrainedPackage}@${d.installedVersion} below fix ${d.fixVersion} - upgrade to ${d.parentTargetVersion}`);
19
72
  }
20
73
  if (finding.deprecated) {
21
- lines.push(`npm deprecated: ${finding.deprecated.message}`);
74
+ lines.push(formatDeprecationFlag(finding.deprecated.message));
75
+ }
76
+ if (finding.staleness) {
77
+ const year = new Date(finding.staleness.lastPublish).getUTCFullYear();
78
+ lines.push(`Last release: ${year} (${finding.staleness.ageYears} years ago)`);
22
79
  }
23
80
  if (lines.length === 0) {
24
81
  lines.push(finding.message);
@@ -51,7 +108,8 @@ export function renderMaintenanceFindings(findings, options) {
51
108
  continue;
52
109
  lines.push(`${formatSeverityLabel(sev.toUpperCase())} (${bucket.length})`);
53
110
  const sorted = [...bucket].sort((a, b) => a.package.name.localeCompare(b.package.name));
54
- const allDetailLines = sorted.flatMap(f => buildDetailLines(f));
111
+ const detailsByFinding = sorted.map(f => buildDetailLines(f).flatMap(l => wrap(l, COL_DET_MAX)));
112
+ const allDetailLines = detailsByFinding.flat();
55
113
  const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => `${f.package.name}@${f.package.version}`.length)));
56
114
  const detWidth = Math.min(COL_DET_MAX, Math.max(7, ...allDetailLines.map(l => l.length)));
57
115
  const ruleWidth = COL_RULE_MAX;
@@ -60,14 +118,14 @@ export function renderMaintenanceFindings(findings, options) {
60
118
  lines.push(hr("┌", "┬", "┐"));
61
119
  lines.push(row("Rule", "Package", "Details"));
62
120
  lines.push(hr("├", "┼", "┤"));
63
- for (const finding of sorted) {
121
+ sorted.forEach((finding, idx) => {
64
122
  const pkgLabel = truncate(`${finding.package.name}@${finding.package.version}`, pkgWidth);
65
- const detailLines = buildDetailLines(finding).map(l => truncate(l, detWidth));
123
+ const detailLines = detailsByFinding[idx] ?? [];
66
124
  lines.push(row("DM001", pkgLabel, detailLines[0] ?? ""));
67
125
  for (let i = 1; i < detailLines.length; i++) {
68
126
  lines.push(row("", "", detailLines[i] ?? ""));
69
127
  }
70
- }
128
+ });
71
129
  lines.push(hr("└", "┴", "┘"));
72
130
  lines.push("");
73
131
  }
@@ -1,8 +1,35 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, serializeHtmlFinding, } from "./html-reporter.js";
3
+ import { aggregateMultiFolderCompleteness } from "../scan/completeness.js";
4
+ import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, renderCompletenessBanner, serializeHtmlFinding, } from "./html-reporter.js";
5
+ import { renderOverrideFindingsHtml } from "./override-findings-html.js";
6
+ import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
4
7
  import { loadLogoDataUri } from "./logos.js";
5
8
  import { pluralize } from "../utils/string.js";
9
+ export function buildMultiFolderReportData(params) {
10
+ const findings = params.results.flatMap((r, i) => params.serializedByFolder[i].map(f => ({
11
+ ...f,
12
+ subfolder: r.subfolder,
13
+ })));
14
+ return {
15
+ multiFolder: true,
16
+ projectPath: params.projectPath,
17
+ scannedAt: new Date().toISOString(),
18
+ cliVersion: params.cliVersion,
19
+ folders: params.results.map(r => r.subfolder),
20
+ findings,
21
+ ...(params.includeOverrides
22
+ ? {
23
+ overrideFindings: params.results.flatMap(r => r.overrideFindings.map(f => ({ ...f, subfolder: r.subfolder }))),
24
+ }
25
+ : {}),
26
+ ...(params.includeMaintenance
27
+ ? {
28
+ maintenanceFindings: params.results.flatMap(r => r.maintenanceFindings.map(f => ({ ...f, subfolder: r.subfolder }))),
29
+ }
30
+ : {}),
31
+ };
32
+ }
6
33
  function summaryCounts(results) {
7
34
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
8
35
  for (const r of results) {
@@ -23,7 +50,7 @@ function renderFolderNotices(coverage) {
23
50
  <div class="scan-notes-body"><ul>${items}</ul></div>
24
51
  </div>`;
25
52
  }
26
- function renderFolderSection(result, folderIdx, idxOffset, serialized) {
53
+ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRoot, includeOverrides, includeMaintenance) {
27
54
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 };
28
55
  for (const f of result.sorted) {
29
56
  const sev = f.severity;
@@ -40,16 +67,28 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized) {
40
67
  const findingRowsHtml = serialized.map((f, i) => renderFindingRow(f, idxOffset + i)).join("\n");
41
68
  const fixPlanHtml = renderFixPlan(result.suggestedFixCommands);
42
69
  const noticesHtml = renderFolderNotices(result.coverage);
70
+ const completenessBannerHtml = renderCompletenessBanner(result.completeness);
71
+ const folderAbs = path.join(projectRoot, result.subfolder);
72
+ const overrideHtml = includeOverrides
73
+ ? renderOverrideFindingsHtml(result.overrideFindings, folderAbs)
74
+ : "";
75
+ const maintenanceHtml = includeMaintenance
76
+ ? renderMaintenanceFindingsHtml(result.maintenanceFindings)
77
+ : "";
43
78
  const emptyRow = result.sorted.length === 0
44
79
  ? `<tr><td colspan="6" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
45
80
  : "";
46
81
  return `
47
82
  <details class="folder-section"${isOpen ? " open" : ""}>
48
83
  <summary class="folder-summary">
84
+ <svg class="chevron" width="16" height="16" viewBox="0 0 16 16" fill="currentColor">
85
+ <path fill-rule="evenodd" d="M6.22 3.22a.75.75 0 011.06 0l4.25 4.25a.75.75 0 010 1.06l-4.25 4.25a.75.75 0 01-1.06-1.06L9.94 8 6.22 4.28a.75.75 0 010-1.06z"></path>
86
+ </svg>
49
87
  <span class="folder-name">${escapeHtml(result.subfolder)}/</span>
50
88
  <span class="folder-counts">${escapeHtml(summaryText)}</span>
51
89
  </summary>
52
90
  <div class="folder-body">
91
+ ${completenessBannerHtml}
53
92
  ${fixPlanHtml}
54
93
  ${noticesHtml}
55
94
  <div class="findings-section" style="margin:16px 32px 32px">
@@ -83,6 +122,8 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized) {
83
122
  </tbody>
84
123
  </table>
85
124
  </div>
125
+ ${overrideHtml}
126
+ ${maintenanceHtml}
86
127
  </div>
87
128
  </details>`;
88
129
  }
@@ -94,8 +135,18 @@ export async function writeMultiFolderHtmlReport(params) {
94
135
  const totalFindings = params.results.reduce((sum, r) => sum + r.sorted.length, 0);
95
136
  const totalCVEs = params.results.reduce((sum, r) => sum + r.sorted.reduce((s, f) => s + f.cveAliases.length, 0), 0);
96
137
  const folderCount = params.results.length;
138
+ const aggregateCompleteness = aggregateMultiFolderCompleteness(params.results);
139
+ const aggregateBannerHtml = renderCompletenessBanner(aggregateCompleteness);
97
140
  // Pre-serialize findings once per folder for both HTML rendering and JS filter/sort
98
141
  const allSerialized = params.results.map(r => r.sorted.map(f => serializeHtmlFinding(f, r.suggestedFixCommands)));
142
+ const reportData = buildMultiFolderReportData({
143
+ results: params.results,
144
+ serializedByFolder: allSerialized,
145
+ projectPath: params.projectPath,
146
+ cliVersion: params.cliVersion,
147
+ includeOverrides: params.includeOverrides,
148
+ includeMaintenance: params.includeMaintenance,
149
+ });
99
150
  // Compact per-folder findings for JavaScript (only fields needed for filter/sort/search)
100
151
  const folderFindingsJson = JSON.stringify(allSerialized.map(findings => findings.map(f => ({
101
152
  package: f.package,
@@ -111,7 +162,7 @@ export async function writeMultiFolderHtmlReport(params) {
111
162
  let idxOffset = 0;
112
163
  const folderSectionsHtml = params.results
113
164
  .map((r, fi) => {
114
- const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi]);
165
+ const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi], params.projectPath, params.includeOverrides, params.includeMaintenance);
115
166
  idxOffset += r.sorted.length;
116
167
  return html;
117
168
  })
@@ -129,12 +180,13 @@ ${REPORT_STYLES}
129
180
  .folder-section{margin:0 32px 16px;background:#161b22;border:1px solid #30363d;border-radius:8px;overflow:hidden}
130
181
  .folder-summary{display:flex;align-items:center;gap:12px;padding:12px 18px;cursor:pointer;user-select:none;list-style:none;background:#1c2128;border-bottom:1px solid #30363d}
131
182
  .folder-summary::-webkit-details-marker{display:none}
132
- .folder-summary::before{content:"▶";font-size:10px;color:#8b949e;transition:transform .15s;flex-shrink:0}
133
- details[open] .folder-summary::before{transform:rotate(90deg)}
183
+ .folder-summary .chevron{transition:transform .15s;flex-shrink:0;color:#8b949e}
184
+ details[open] > .folder-summary .chevron{transform:rotate(90deg)}
134
185
  .folder-name{font-size:13px;font-weight:600;color:#e6edf3;font-family:'SF Mono','Cascadia Code','Fira Code',monospace}
135
186
  .folder-counts{font-size:11px;color:#8b949e;margin-left:auto}
136
187
  .folder-body{padding:0}
137
188
  .folder-body .fix-plan{margin:24px 32px 0}
189
+ .folder-body .override-hygiene,.folder-body .maintenance-risk{margin:0 32px 24px}
138
190
  </style>
139
191
  </head>
140
192
  <body>
@@ -178,6 +230,8 @@ details[open] .folder-summary::before{transform:rotate(90deg)}
178
230
  <div class="sev-card total"><span class="count">${totalCVEs}</span><span class="label">CVEs</span></div>
179
231
  </div>
180
232
 
233
+ ${aggregateBannerHtml}
234
+
181
235
  ${folderSectionsHtml}
182
236
 
183
237
  <div class="report-footer">
@@ -314,6 +368,8 @@ document.addEventListener('click', function(e) {
314
368
  </body>
315
369
  </html>`;
316
370
  const indexPath = path.join(params.outputDir, "index.html");
371
+ const jsonPath = path.join(params.outputDir, "report.json");
372
+ fs.writeFileSync(jsonPath, JSON.stringify(reportData, null, 2), "utf8");
317
373
  fs.writeFileSync(indexPath, html, "utf8");
318
374
  if (params.autoOpen)
319
375
  openInBrowser(indexPath);
@@ -30,17 +30,26 @@ export function printMultiFolderResults(results, options) {
30
30
  }
31
31
  }
32
32
  printCoverage([...result.scanInput.notes, ...result.coverage]);
33
- printFinalStatus(result.sorted);
33
+ printFinalStatus(result.sorted, 0, result.completeness);
34
34
  }
35
35
  else {
36
- printCompactOutput(result.sorted, result.scanInput, { offline, all: !!options.all, subfolder: result.subfolder });
36
+ printCompactOutput(result.sorted, result.scanInput, { offline, all: !!options.all, subfolder: result.subfolder, completeness: result.completeness });
37
37
  }
38
38
  if (i < results.length - 1) {
39
39
  console.log(chalk.gray("\n" + "─".repeat(50)));
40
40
  }
41
41
  }
42
42
  const totalFindings = results.reduce((sum, r) => sum + r.sorted.length, 0);
43
+ const totalSuppressed = results.reduce((sum, r) => sum + (r.suppressedCount ?? 0), 0);
43
44
  const folderNames = results.map(r => `${r.subfolder}/`).join(", ");
44
45
  console.log(chalk.gray(`\nScanned ${results.length} ${pluralize(results.length, "folder")}: ${folderNames}`));
45
46
  console.log(chalk.gray(`${totalFindings} total ${pluralize(totalFindings, "finding")} across all folders`));
47
+ if (totalSuppressed > 0) {
48
+ if (totalFindings === 0) {
49
+ console.log(chalk.green(`No new findings above baseline - ${totalSuppressed} existing ${pluralize(totalSuppressed, "finding")} suppressed`));
50
+ }
51
+ else {
52
+ console.log(chalk.yellow(`${totalFindings} new ${pluralize(totalFindings, "finding")} above baseline - ${totalSuppressed} existing ${pluralize(totalSuppressed, "finding")} suppressed`));
53
+ }
54
+ }
46
55
  }
@@ -5,7 +5,9 @@ import { getPrimaryParent } from "../utils/finding.js";
5
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
+ import { hasMaliciousAdvisory } from "../utils/vuln.js";
8
9
  import { selectFindingsForCompact } from "./finding-display.js";
10
+ import { getCompletenessImpact } from "../scan/completeness.js";
9
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";
10
12
  export function printSummary(findings, packageCount, scanInput) {
11
13
  if (findings.length === 0) {
@@ -212,7 +214,7 @@ export function printTable(findings, threshold, skippedKeys) {
212
214
  else if (f.maliciousGitSource) {
213
215
  fixedDisplay = chalk.yellow(f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_DISPLAY : MAL_GIT_SOURCE_FLOATING_DISPLAY);
214
216
  }
215
- else if (f.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
217
+ else if (hasMaliciousAdvisory(f.vulnerabilities)) {
216
218
  fixedDisplay = chalk.yellow("⚠ Malicious");
217
219
  }
218
220
  else {
@@ -257,7 +259,7 @@ export function printTable(findings, threshold, skippedKeys) {
257
259
  console.log(renderRow(decorated, widths));
258
260
  }
259
261
  console.log(line("└", "┴", "┘"));
260
- const maliciousFindings = findings.filter(f => f.vulnerabilities.some(v => v.id.startsWith("MAL-")));
262
+ const maliciousFindings = findings.filter(f => hasMaliciousAdvisory(f.vulnerabilities));
261
263
  if (maliciousFindings.length > 0) {
262
264
  console.log("");
263
265
  console.log(chalk.bold.red("⚠ Malicious package advisory:"));
@@ -285,28 +287,49 @@ export function printTable(findings, threshold, skippedKeys) {
285
287
  console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
286
288
  }
287
289
  }
288
- export function printFinalStatus(findings, overrideCount = 0) {
290
+ export function printFinalStatus(findings, overrideCount = 0, completeness) {
289
291
  console.log("");
290
292
  console.log(chalk.gray("────────────────────────────────"));
293
+ const { hasDetectionGap, hasRemediationGap } = getCompletenessImpact(completeness);
291
294
  const overrideSuffix = overrideCount > 0
292
295
  ? `, ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")}`
293
296
  : "";
294
297
  if (findings.length === 0) {
295
- if (overrideCount > 0) {
298
+ if (hasDetectionGap) {
299
+ const overrideNote = overrideCount > 0
300
+ ? ` ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} detected.`
301
+ : "";
302
+ console.log(chalk.yellow(`⚠ Partial scan: vulnerability findings may be incomplete.${overrideNote}`));
303
+ }
304
+ else if (overrideCount > 0) {
296
305
  console.log(chalk.yellow(`▲ Scan complete. No known vulnerabilities found, but ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} detected.`));
297
306
  }
298
307
  else {
299
308
  console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
300
309
  }
301
- return;
302
310
  }
303
- const criticalCount = findings.filter(f => f.severity === "critical").length;
304
- const highCount = findings.filter(f => f.severity === "high").length;
305
- if (criticalCount > 0 || highCount > 0) {
306
- console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
307
- return;
311
+ else {
312
+ const criticalCount = findings.filter(f => f.severity === "critical").length;
313
+ const highCount = findings.filter(f => f.severity === "high").length;
314
+ const urgent = criticalCount > 0 || highCount > 0;
315
+ const label = `${findings.length} ${pluralize(findings.length, "vulnerability", "vulnerabilities")}`;
316
+ if (hasDetectionGap) {
317
+ const severityNote = urgent ? ` (${criticalCount} critical, ${highCount} high)` : "";
318
+ const action = urgent ? "Start with the priority fixes above." : "Review the suggested fix plan above.";
319
+ const renderStatus = urgent ? chalk.redBright : chalk.yellow;
320
+ console.log(renderStatus(`⚠ Partial scan: ${label} found${overrideSuffix}${severityNote}. Vulnerability findings may be incomplete. ${action}`));
321
+ }
322
+ else if (urgent) {
323
+ console.log(chalk.redBright(`✖ Scan complete. ${label}${overrideSuffix} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
324
+ }
325
+ else {
326
+ console.log(chalk.yellow(`▲ Scan complete. ${label}${overrideSuffix} found. Review the suggested fix plan above.`));
327
+ }
328
+ }
329
+ if (hasRemediationGap) {
330
+ console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
308
331
  }
309
- console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found. Review the suggested fix plan above.`));
332
+ printIncompleteDiagnostics(completeness);
310
333
  }
311
334
  export function printOverrideHint() {
312
335
  console.log("💡 " + chalk.gray("Tip:") + " override entries detected - run with --check-overrides to audit them for stale or broken overrides.");
@@ -361,12 +384,26 @@ function wrapCell(value, width) {
361
384
  }
362
385
  export function printCompactOutput(findings, scanInput, options) {
363
386
  console.log("");
387
+ const { hasDetectionGap, hasRemediationGap } = getCompletenessImpact(options?.completeness);
364
388
  if (options?.packageManager) {
365
389
  console.log(chalk.gray("Package manager: ") + options.packageManager);
366
390
  }
367
391
  if (findings.length === 0) {
368
- console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
369
- console.log("");
392
+ if (hasDetectionGap) {
393
+ console.log(chalk.yellow("⚠ Partial scan: vulnerability findings may be incomplete."));
394
+ }
395
+ else {
396
+ console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
397
+ }
398
+ if (hasRemediationGap) {
399
+ console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
400
+ }
401
+ if (options?.completeness?.complete === false) {
402
+ printIncompleteDiagnostics(options.completeness);
403
+ }
404
+ else {
405
+ console.log("");
406
+ }
370
407
  return;
371
408
  }
372
409
  // Vulnerabilities found section
@@ -394,7 +431,7 @@ export function printCompactOutput(findings, scanInput, options) {
394
431
  }
395
432
  console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(finding.pkg.name)}@${finding.pkg.version}`);
396
433
  console.log(` ${typeLabel}${usageContext}`);
397
- const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
434
+ const isMalicious = hasMaliciousAdvisory(finding.vulnerabilities);
398
435
  if (isMalicious) {
399
436
  if (finding.maliciousUnverifiable) {
400
437
  console.log(` ${chalk.yellow(`⚠ Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE}`)}`);
@@ -506,7 +543,7 @@ export function printCompactOutput(findings, scanInput, options) {
506
543
  console.log(`${chalk.cyan(String(direct))} ${chalk.white("direct")}` +
507
544
  `${chalk.gray(" · ")}` +
508
545
  `${chalk.cyan(String(transitive))} ${chalk.white("transitive")}`);
509
- const maliciousCompact = findings.filter(f => f.vulnerabilities.some(v => v.id.startsWith("MAL-")));
546
+ const maliciousCompact = findings.filter(f => hasMaliciousAdvisory(f.vulnerabilities));
510
547
  if (maliciousCompact.length > 0 && !options?.all) {
511
548
  console.log("");
512
549
  console.log(chalk.bold.red("⚠ Malicious package advisory:"));
@@ -533,7 +570,14 @@ export function printCompactOutput(findings, scanInput, options) {
533
570
  }
534
571
  // Footer
535
572
  const urgentCount = counts.critical + counts.high;
536
- if (urgentCount > 0) {
573
+ if (hasDetectionGap) {
574
+ const label = urgentCount > 0
575
+ ? `${urgentCount} urgent ${pluralize(urgentCount, "issue")} found`
576
+ : `${findings.length} ${pluralize(findings.length, "issue")} found`;
577
+ const renderStatus = urgentCount > 0 ? chalk.redBright : chalk.yellow;
578
+ console.log(renderStatus(`⚠ Partial scan: ${label}. Vulnerability findings may be incomplete.`));
579
+ }
580
+ else if (urgentCount > 0) {
537
581
  console.log(chalk.redBright(`✖ Scan complete. ${urgentCount} urgent ${pluralize(urgentCount, "issue")} found.`));
538
582
  }
539
583
  else {
@@ -542,7 +586,23 @@ export function printCompactOutput(findings, scanInput, options) {
542
586
  if (!options?.all) {
543
587
  console.log(chalk.gray(`Run with ${chalk.whiteBright("--verbose")} for fix plan, paths, and full table.`));
544
588
  }
589
+ if (hasRemediationGap) {
590
+ console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
591
+ }
592
+ printIncompleteDiagnostics(options?.completeness);
593
+ if (options?.completeness?.complete !== false) {
594
+ console.log("");
595
+ }
596
+ }
597
+ export function printIncompleteDiagnostics(completeness) {
598
+ if (!completeness || completeness.complete)
599
+ return;
545
600
  console.log("");
601
+ for (const diag of completeness.diagnostics) {
602
+ const prefix = diag.impact === "detection" ? chalk.yellow(" ·") : chalk.gray(" ·");
603
+ console.log(prefix + " " + chalk.gray(diag.message));
604
+ }
605
+ console.log(chalk.gray(" Resolve the issues above and re-run the scan."));
546
606
  }
547
607
  function renderSeverityTable(counts) {
548
608
  const labels = ["Critical", "High", "Medium", "Low", "Unknown"];
@@ -1,10 +1,12 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { getRecommendedAction } from "./formatters.js";
3
+ import { findFixTargetForFinding } from "../remediation/fix-commands.js";
4
+ import { getRecommendedAction, formatCooldownWarning } from "./formatters.js";
4
5
  import { getCliVersion } from "../utils/version-info.js";
5
6
  import { severityToSarifLevel } from "../utils/severity.js";
6
7
  import { sarifFingerprintHash } from "../utils/sarif.js";
7
8
  import { buildOverrideSarifComponent, buildOverrideSarifResults } from "./override-findings-sarif.js";
9
+ import { buildMaintenanceSarifComponent, buildMaintenanceSarifResults } from "./maintenance-findings-sarif.js";
8
10
  const SARIF_SCHEMA = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
9
11
  const LOCKFILE_NAMES = {
10
12
  "package-lock": "package-lock.json",
@@ -75,13 +77,17 @@ export function deriveLockfileUri(scanInput) {
75
77
  return path.basename(scanInput.filePath);
76
78
  return LOCKFILE_NAMES[scanInput.source] ?? "lockfile";
77
79
  }
78
- export function buildSarifOutput(findings, lockfileUri, version, _plan, overrideFindings) {
80
+ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings) {
79
81
  const ruleMap = new Map();
80
82
  const ruleIndexMap = new Map();
81
83
  const results = [];
82
84
  for (const finding of findings) {
83
85
  const level = severityToSarifLevel(finding.severity);
84
86
  const action = getRecommendedAction(finding);
87
+ // If the recommended fix for this finding lands on a version inside the
88
+ // project's configured release cooldown, surface that on the result so it
89
+ // reaches Code Scanning (message text for humans, property for tooling).
90
+ const cooldown = plan ? findFixTargetForFinding(plan, finding)?.cooldownWarning ?? null : null;
85
91
  const location = {
86
92
  physicalLocation: {
87
93
  artifactLocation: { uri: lockfileUri, uriBaseId: "%SRCROOT%" },
@@ -116,20 +122,30 @@ export function buildSarifOutput(findings, lockfileUri, version, _plan, override
116
122
  kind: "open",
117
123
  level,
118
124
  message: {
119
- text: `${finding.pkg.name}@${finding.pkg.version} is vulnerable (${finding.severity}). ${action}`,
125
+ text: `${finding.pkg.name}@${finding.pkg.version} is vulnerable (${finding.severity}). ${action}`
126
+ + (cooldown ? ` Release cooldown: ${formatCooldownWarning(cooldown)}` : ""),
120
127
  },
121
128
  locations: [location],
122
129
  partialFingerprints: {
123
130
  primaryLocationLineHash: sarifFingerprintHash(`${ruleId}:${finding.pkg.name}@${finding.pkg.version}`),
124
131
  },
132
+ ...(cooldown ? { properties: { cooldownWarning: cooldown } } : {}),
125
133
  });
126
134
  }
127
135
  }
128
136
  const hasOverrides = overrideFindings != null && overrideFindings.length > 0;
129
- const extensions = hasOverrides ? [buildOverrideSarifComponent()] : undefined;
137
+ const hasMaintenance = maintenanceFindings != null && maintenanceFindings.length > 0;
138
+ const extensions = [
139
+ ...(hasOverrides ? [buildOverrideSarifComponent()] : []),
140
+ ...(hasMaintenance ? [buildMaintenanceSarifComponent()] : []),
141
+ ];
142
+ const maintenanceExtensionIndex = hasOverrides ? 1 : 0;
130
143
  const allResults = [
131
144
  ...results,
132
145
  ...(hasOverrides ? buildOverrideSarifResults(overrideFindings) : []),
146
+ ...(hasMaintenance
147
+ ? buildMaintenanceSarifResults(maintenanceFindings, lockfileUri, maintenanceExtensionIndex)
148
+ : []),
133
149
  ];
134
150
  return {
135
151
  $schema: SARIF_SCHEMA,
@@ -143,7 +159,7 @@ export function buildSarifOutput(findings, lockfileUri, version, _plan, override
143
159
  informationUri: "https://owasp.org/cve-lite-cli/",
144
160
  rules: Array.from(ruleMap.values()),
145
161
  },
146
- ...(extensions ? { extensions } : {}),
162
+ ...(extensions.length > 0 ? { extensions } : {}),
147
163
  },
148
164
  results: allResults,
149
165
  artifacts: [
@@ -153,11 +169,11 @@ export function buildSarifOutput(findings, lockfileUri, version, _plan, override
153
169
  ],
154
170
  };
155
171
  }
156
- export function writeSarifReport(findings, lockfileUri, plan, overrideFindings) {
172
+ export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings) {
157
173
  const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
158
174
  const filename = `cve-lite-scan-${ts}.sarif`;
159
175
  const outputPath = path.join(process.cwd(), filename);
160
- const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings);
176
+ const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings);
161
177
  try {
162
178
  fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
163
179
  }
@@ -35,6 +35,9 @@ export async function writeOutputs(options, scanState, scanInput, projectPath) {
35
35
  source: scanInput.source,
36
36
  packageCount: scanInput.packages.length,
37
37
  findingCount: scanState.sorted.length,
38
+ status: scanState.completeness.complete ? "ok" : "partial",
39
+ complete: scanState.completeness.complete,
40
+ diagnostics: scanState.completeness.diagnostics,
38
41
  suggestedFixCommands: scanState.suggestedFixCommands,
39
42
  notes: [...scanInput.notes, ...scanState.coverage],
40
43
  warnings: scanInput.warnings,
@@ -49,7 +52,7 @@ export async function writeOutputs(options, scanState, scanInput, projectPath) {
49
52
  }
50
53
  if (options.sarif) {
51
54
  const lockfileUri = deriveLockfileUri(scanInput);
52
- const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings);
55
+ const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings, scanState.maintenanceFindings);
53
56
  console.log(`${chalk.gray("SARIF report written to")} ${chalk.cyan(sarifFilename)}`);
54
57
  }
55
58
  if (options.cdx) {
@@ -54,6 +54,24 @@ function collectBunPaths(rootDepNames, childDepsByPackageName, map, packageNameT
54
54
  }
55
55
  }
56
56
  }
57
+ // Walk the package graph from a set of root dependency names and return every reachable name.
58
+ // Used to classify dev vs prod: a package is dev only when it is reachable from a
59
+ // devDependency root but not from any production root.
60
+ function collectReachableNames(rootNames, childDepsByPackageName) {
61
+ const reachable = new Set();
62
+ const stack = [...rootNames];
63
+ while (stack.length > 0) {
64
+ const name = stack.pop();
65
+ if (reachable.has(name))
66
+ continue;
67
+ reachable.add(name);
68
+ for (const child of childDepsByPackageName.get(name) ?? []) {
69
+ if (!reachable.has(child))
70
+ stack.push(child);
71
+ }
72
+ }
73
+ return reachable;
74
+ }
57
75
  export function buildBunWorkspaceMap(filePath) {
58
76
  const raw = parseJsonc(fs.readFileSync(filePath, "utf8"));
59
77
  const workspaces = raw?.workspaces ?? {};
@@ -80,15 +98,18 @@ export function loadFromBunLock(filePath, prodOnly) {
80
98
  const map = new Map();
81
99
  const childDepsByPackageName = new Map();
82
100
  const packageNameToVersion = new Map();
83
- const prodNames = new Set();
84
- const devNames = new Set();
101
+ const prodRootNames = new Set();
102
+ const devRootNames = new Set();
85
103
  const rootDepNames = [];
86
104
  for (const workspace of Object.values(workspaces)) {
87
105
  for (const name of Object.keys(workspace?.dependencies ?? {})) {
88
- prodNames.add(name);
106
+ prodRootNames.add(name);
107
+ }
108
+ for (const name of Object.keys(workspace?.optionalDependencies ?? {})) {
109
+ prodRootNames.add(name);
89
110
  }
90
111
  for (const name of Object.keys(workspace?.devDependencies ?? {})) {
91
- devNames.add(name);
112
+ devRootNames.add(name);
92
113
  }
93
114
  }
94
115
  for (const [workspacePath, workspace] of Object.entries(workspaces)) {
@@ -105,6 +126,7 @@ export function loadFromBunLock(filePath, prodOnly) {
105
126
  }
106
127
  }
107
128
  }
129
+ // First pass: build the package graph (package key -> version, package key -> child dep names).
108
130
  for (const [pkgName, entry] of Object.entries(packages)) {
109
131
  if (!Array.isArray(entry) || entry.length < 1)
110
132
  continue;
@@ -112,13 +134,31 @@ export function loadFromBunLock(filePath, prodOnly) {
112
134
  const atIndex = nameAtVersion.lastIndexOf("@");
113
135
  if (atIndex <= 0)
114
136
  continue;
115
- const name = nameAtVersion.slice(0, atIndex);
116
137
  const version = nameAtVersion.slice(atIndex + 1);
117
- if (!name || !version)
138
+ if (!version)
118
139
  continue;
119
140
  packageNameToVersion.set(pkgName, version);
120
141
  childDepsByPackageName.set(pkgName, extractChildDependencyNames(entry[2]));
121
- const dev = devNames.has(pkgName) && !prodNames.has(pkgName);
142
+ }
143
+ // Classify dev vs prod by graph reachability rather than by direct declaration only: a
144
+ // package is dev when it is reachable from a devDependency root but not from any production
145
+ // (dependencies/optionalDependencies) root. This correctly marks a transitive pulled in only
146
+ // through a devDependency as dev, while keeping any package used in production anywhere prod.
147
+ const prodReachable = collectReachableNames(prodRootNames, childDepsByPackageName);
148
+ const devReachable = collectReachableNames(devRootNames, childDepsByPackageName);
149
+ // Second pass: create package refs with the reachability-based dev flag.
150
+ for (const [, entry] of Object.entries(packages)) {
151
+ if (!Array.isArray(entry) || entry.length < 1)
152
+ continue;
153
+ const nameAtVersion = String(entry[0] ?? "");
154
+ const atIndex = nameAtVersion.lastIndexOf("@");
155
+ if (atIndex <= 0)
156
+ continue;
157
+ const name = nameAtVersion.slice(0, atIndex);
158
+ const version = nameAtVersion.slice(atIndex + 1);
159
+ if (!name || !version)
160
+ continue;
161
+ const dev = devReachable.has(name) && !prodReachable.has(name);
122
162
  if (prodOnly && dev)
123
163
  continue;
124
164
  const resolvedUrl = typeof entry[1] === "string" && entry[1] !== "" ? entry[1] : undefined;