cve-lite-cli 1.24.0 → 1.26.0-beta.1

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.
Files changed (77) hide show
  1. package/README.md +83 -2
  2. package/assets/OWASP_Logo_Black_TM.png +0 -0
  3. package/assets/logo-with-title-removebg-preview.png +0 -0
  4. package/dist/advisory/local-db.js +7 -1
  5. package/dist/advisory/osv-advisory-source.js +2 -1
  6. package/dist/audit-log/events.js +3 -0
  7. package/dist/audit-log/handle.js +20 -0
  8. package/dist/audit-log/index.js +16 -0
  9. package/dist/audit-log/ndjson-writer.js +28 -0
  10. package/dist/cli/args.js +75 -0
  11. package/dist/cli/fix-overrides-hook.js +64 -0
  12. package/dist/cli/help.js +24 -1
  13. package/dist/cli/overrides.js +67 -0
  14. package/dist/cli/validate.js +9 -1
  15. package/dist/index.js +310 -21
  16. package/dist/osv/cache.js +28 -4
  17. package/dist/output/formatters.js +22 -18
  18. package/dist/output/html-reporter.js +37 -8
  19. package/dist/output/logos.js +18 -0
  20. package/dist/output/multi-folder-html-reporter.js +3 -4
  21. package/dist/output/override-findings-html.js +63 -0
  22. package/dist/output/override-findings-json.js +3 -0
  23. package/dist/output/override-findings-sarif.js +52 -0
  24. package/dist/output/override-findings-terminal.js +106 -0
  25. package/dist/output/printers.js +66 -23
  26. package/dist/output/sarif.js +77 -8
  27. package/dist/output/write-outputs.js +7 -3
  28. package/dist/overrides/api.js +79 -0
  29. package/dist/overrides/composite.js +23 -0
  30. package/dist/overrides/context-builder.js +150 -0
  31. package/dist/overrides/context.js +3 -0
  32. package/dist/overrides/detectors/index.js +23 -0
  33. package/dist/overrides/detectors/oa001-orphaned-target.js +36 -0
  34. package/dist/overrides/detectors/oa002-floating-tag.js +40 -0
  35. package/dist/overrides/detectors/oa003-wrong-section.js +48 -0
  36. package/dist/overrides/detectors/oa004-surpassed-pin.js +49 -0
  37. package/dist/overrides/detectors/oa005-nested-ineffective.js +128 -0
  38. package/dist/overrides/detectors/oa006-coupled-platform-binary.js +170 -0
  39. package/dist/overrides/detectors/oa007-frozen-latest.js +69 -0
  40. package/dist/overrides/detectors/oa008-materialized.js +75 -0
  41. package/dist/overrides/detectors/platform-binary.js +37 -0
  42. package/dist/overrides/fixer.js +199 -0
  43. package/dist/overrides/index.js +5 -0
  44. package/dist/overrides/parsing/installed-tree.js +164 -0
  45. package/dist/overrides/parsing/json-pointer.js +8 -0
  46. package/dist/overrides/parsing/node-modules.js +19 -0
  47. package/dist/overrides/parsing/package-json.js +139 -0
  48. package/dist/overrides/parsing/registry.js +66 -0
  49. package/dist/overrides/types.js +2 -0
  50. package/dist/parsers/pnpm-lock.js +46 -3
  51. package/dist/parsers/yarn-lock.js +2 -2
  52. package/dist/remediation/fix-commands.js +59 -5
  53. package/dist/remediation/npm-registry.js +55 -43
  54. package/dist/remediation/npm-transitive-resolution.js +2 -2
  55. package/dist/remediation/transitive-chain-resolver.js +100 -0
  56. package/dist/scan/multi-folder-scan.js +37 -1
  57. package/dist/scanner.js +122 -46
  58. package/dist/types.js +13 -1
  59. package/dist/utils/baseline.js +16 -0
  60. package/dist/utils/create-pr.js +19 -4
  61. package/dist/utils/fix-runner.js +6 -0
  62. package/dist/utils/package-json.js +21 -0
  63. package/dist/utils/severity.js +16 -0
  64. package/dist/utils/string.js +34 -0
  65. package/dist/utils/validate-url.js +223 -0
  66. package/dist/utils/version.js +135 -2
  67. package/package.json +8 -2
  68. package/dist/learn/keypress.js +0 -50
  69. package/dist/learn/runner.js +0 -96
  70. package/dist/learn/scenario.js +0 -47
  71. package/dist/learn/session.js +0 -36
  72. package/dist/learn/types.js +0 -1
  73. package/dist/llm/client.js +0 -40
  74. package/dist/llm/config.js +0 -48
  75. package/dist/llm/explainer.js +0 -31
  76. package/dist/output/logo-base64.js +0 -1
  77. package/dist/output/owasp-logo-base64.js +0 -1
@@ -1,12 +1,12 @@
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 } from "./formatters.js";
5
- import { LOGO_BASE64 } from "./logo-base64.js";
6
- import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
4
+ import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandWithPublishDates } from "./formatters.js";
5
+ import { loadLogoDataUri } from "./logos.js";
7
6
  import { isMajorVersionBump } from "../utils/version.js";
8
7
  import { pluralize } from "../utils/string.js";
9
8
  import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY } from "../constants.js";
9
+ import { renderOverrideFindingsHtml } from "./override-findings-html.js";
10
10
  export function serializeHtmlFinding(finding, plan) {
11
11
  return {
12
12
  ...serializeFinding(finding, plan),
@@ -26,6 +26,7 @@ export function buildReportData(params) {
26
26
  suggestedFixCommands: params.suggestedFixCommands,
27
27
  notes: params.notes,
28
28
  warnings: params.warnings,
29
+ overrideFindings: params.overrideFindings,
29
30
  };
30
31
  }
31
32
  export const REPORT_STYLES = `*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
@@ -153,10 +154,26 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
153
154
  .fix-target-stats{color:#6b7280;font-size:10px}
154
155
  .fix-target-note{color:#6b7280;font-style:italic;font-size:10px}
155
156
  .fix-target-coverage{flex-basis:100%;color:#6b7280;font-size:10px;line-height:1.45}
157
+ .chain-proof{font-size:0.78rem;color:#8b949e;margin-left:6px;font-family:monospace}
156
158
  .break-badge{font-size:10px;font-weight:700;background:#fb850022;color:#fb8500;border:1px solid #fb850066;border-radius:4px;padding:1px 5px}
157
159
  .tier-ok{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#3fb95022;color:#3fb950;border:1px solid #3fb95033;margin-bottom:6px}
158
160
  .tier-warn{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#e3b34122;color:#e3b341;border:1px solid #e3b34133;margin-bottom:6px}
159
- .tier-err{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#ff000011;color:#ff7b72;border:1px solid #ff7b7222;margin-bottom:6px}`;
161
+ .tier-err{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#ff000011;color:#ff7b72;border:1px solid #ff7b7222;margin-bottom:6px}
162
+ .override-hygiene{margin:0 32px 32px}
163
+ .override-hygiene h2{font-size:13px;font-weight:600;color:#e6edf3;margin-bottom:12px}
164
+ .override-hygiene p{font-size:13px;color:#8b949e}
165
+ .override-hygiene table{width:100%;border-collapse:collapse;background:#161b22;border:1px solid #30363d;border-radius:8px;overflow:hidden}
166
+ .override-hygiene table thead th{text-align:left;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:#8b949e;padding:10px 14px;border-bottom:1px solid #21262d;background:#1c2128}
167
+ .override-hygiene table tbody tr{border-bottom:1px solid #21262d}
168
+ .override-hygiene table tbody tr:last-child{border-bottom:none}
169
+ .override-hygiene table tbody tr.severity-group{background:#1c2128}
170
+ .override-hygiene table tbody tr.severity-group th{font-weight:600;color:#e6edf3;padding:10px 14px;text-align:left}
171
+ .override-hygiene table tbody tr.finding td{padding:11px 14px;font-size:12px;color:#e6edf3;vertical-align:middle}
172
+ .override-hygiene table tbody tr.critical{border-left:3px solid #f85149}
173
+ .override-hygiene table tbody tr.high{border-left:3px solid #fb8500}
174
+ .override-hygiene table tbody tr.medium{border-left:3px solid #e3b341}
175
+ .override-hygiene table tbody tr.low{border-left:3px solid #388bfd}
176
+ .override-hygiene table tbody tr.unknown{border-left:3px solid #8b949e}`;
160
177
  export function renderHtmlReport(data) {
161
178
  const projectName = path.basename(data.projectPath);
162
179
  const scanDate = new Date(data.scannedAt).toLocaleString();
@@ -193,10 +210,10 @@ ${REPORT_STYLES}
193
210
  <div class="report-header">
194
211
  <div class="header-left">
195
212
  <div class="header-logo-pair">
196
- <img src="${LOGO_BASE64}" alt="CVE Lite" class="header-logo" />
213
+ <img src="${loadLogoDataUri("cve-lite")}" alt="CVE Lite" class="header-logo" />
197
214
  <span class="header-logo-plus">+</span>
198
215
  <a href="https://owasp.org/cve-lite-cli/" target="_blank" rel="noopener" style="display:flex;align-items:center">
199
- <img src="${OWASP_LOGO_BASE64}" alt="An OWASP Foundation Project" class="header-logo" />
216
+ <img src="${loadLogoDataUri("owasp")}" alt="An OWASP Foundation Project" class="header-logo" />
200
217
  </a>
201
218
  </div>
202
219
  <div class="header-divider"></div>
@@ -267,6 +284,8 @@ ${findingRowsHtml}
267
284
  </tbody>
268
285
  </table>
269
286
  </div>
287
+ ${renderOverrideFindingsHtml(data.overrideFindings)}
288
+
270
289
  ${noticesHtml}
271
290
 
272
291
  <div class="report-footer">
@@ -562,14 +581,24 @@ export function renderFixPlan(plan) {
562
581
  const coverageHtml = t.coverage === "partial"
563
582
  ? ` <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>`
564
583
  : "";
565
- return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}${coverageHtml}</div>`;
584
+ const chainProofHtml = t.chainProof && t.chainSafeVersion
585
+ ? (() => {
586
+ const hops = t.chainProof.map(h => `${escapeHtml(h.name)}@${escapeHtml(h.version)}`);
587
+ const safe = escapeHtml(t.chainSafeVersion);
588
+ const proofText = hops.length > 0
589
+ ? `resolves via ${hops.join(" -&gt; ")} -&gt; ${safe} (safe)`
590
+ : `resolves to ${safe} (safe)`;
591
+ return ` <span class="chain-proof">${proofText}</span>`;
592
+ })()
593
+ : "";
594
+ return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}${coverageHtml}${chainProofHtml}</div>`;
566
595
  }).join("\n");
567
596
  const targetsHtml = section.targets.length > 0
568
597
  ? `<div class="fix-targets-list">${targetRows}</div>`
569
598
  : "";
570
599
  return `
571
600
  <div class="fix-cmd">
572
- <span class="cmd-text">${escapeHtml(section.command)}</span>
601
+ <span class="cmd-text">${escapeHtml(formatFixCommandWithPublishDates(section.command, section.targets))}</span>
573
602
  <span class="cmd-meta">${escapeHtml(section.title)}</span>
574
603
  <button class="copy-btn" data-cmd="${escapeHtml(section.command)}">Copy</button>
575
604
  </div>${targetsHtml}`;
@@ -0,0 +1,18 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ const FILES = {
5
+ "cve-lite": "logo-with-title-removebg-preview.png",
6
+ "owasp": "OWASP_Logo_Black_TM.png",
7
+ };
8
+ const ASSET_DIR = path.join(fileURLToPath(new URL("../../assets/", import.meta.url)));
9
+ const cache = new Map();
10
+ export function loadLogoDataUri(name) {
11
+ const cached = cache.get(name);
12
+ if (cached)
13
+ return cached;
14
+ const buf = fs.readFileSync(path.join(ASSET_DIR, FILES[name]));
15
+ const uri = `data:image/png;base64,${buf.toString("base64")}`;
16
+ cache.set(name, uri);
17
+ return uri;
18
+ }
@@ -1,8 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, serializeHtmlFinding, } from "./html-reporter.js";
4
- import { LOGO_BASE64 } from "./logo-base64.js";
5
- import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
4
+ import { loadLogoDataUri } from "./logos.js";
6
5
  import { pluralize } from "../utils/string.js";
7
6
  function summaryCounts(results) {
8
7
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
@@ -143,10 +142,10 @@ details[open] .folder-summary::before{transform:rotate(90deg)}
143
142
  <div class="report-header">
144
143
  <div class="header-left">
145
144
  <div class="header-logo-pair">
146
- <img src="${LOGO_BASE64}" alt="CVE Lite" class="header-logo" />
145
+ <img src="${loadLogoDataUri("cve-lite")}" alt="CVE Lite" class="header-logo" />
147
146
  <span class="header-logo-plus">+</span>
148
147
  <a href="https://owasp.org/cve-lite-cli/" target="_blank" rel="noopener" style="display:flex;align-items:center">
149
- <img src="${OWASP_LOGO_BASE64}" alt="An OWASP Foundation Project" class="header-logo" />
148
+ <img src="${loadLogoDataUri("owasp")}" alt="An OWASP Foundation Project" class="header-logo" />
150
149
  </a>
151
150
  </div>
152
151
  <div class="header-divider"></div>
@@ -0,0 +1,63 @@
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
+ export function renderOverrideFindingsHtml(findings) {
10
+ // undefined = override hygiene was never requested -> render nothing, so a plain
11
+ // `cve-lite .` report shows no Override hygiene panel at all. An empty array =
12
+ // it ran and found nothing -> render the "no findings" reassurance.
13
+ if (findings === undefined) {
14
+ return "";
15
+ }
16
+ if (findings.length === 0) {
17
+ return `
18
+ <section class="override-hygiene">
19
+ <h2>Override hygiene</h2>
20
+ <p>No override hygiene findings.</p>
21
+ </section>
22
+ `;
23
+ }
24
+ const grouped = new Map();
25
+ for (const sev of SEVERITY_ORDER)
26
+ grouped.set(sev, []);
27
+ for (const f of findings)
28
+ grouped.get(f.severity)?.push(f);
29
+ const rows = [];
30
+ for (const sev of SEVERITY_ORDER) {
31
+ const bucket = grouped.get(sev) ?? [];
32
+ if (bucket.length === 0)
33
+ continue;
34
+ rows.push(` <tr class="severity-group ${esc(sev)}"><th>${esc(sev.toUpperCase())} (${bucket.length})</th><td></td><td></td><td></td></tr>`);
35
+ for (const f of bucket) {
36
+ const location = f.location.jsonPath
37
+ ? `${esc(f.location.file)} › ${esc(f.location.jsonPath)}`
38
+ : esc(f.location.file);
39
+ const fixHtml = f.fix?.runnableCommand
40
+ ? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(f.fix.runnableCommand)}</code><button class="copy-btn" data-cmd="${esc(f.fix.runnableCommand)}">Copy</button></div>`
41
+ : "";
42
+ rows.push(` <tr class="finding ${esc(f.severity)}">` +
43
+ `<td>${esc(f.ruleId)}</td>` +
44
+ `<td>${esc(f.package.name)}</td>` +
45
+ `<td>${location}</td>` +
46
+ `<td>${esc(f.message)}${fixHtml}</td>` +
47
+ `</tr>`);
48
+ }
49
+ }
50
+ return `
51
+ <section class="override-hygiene">
52
+ <h2>Override hygiene</h2>
53
+ <table>
54
+ <thead>
55
+ <tr><th>Rule</th><th>Package</th><th>Location</th><th>Message</th></tr>
56
+ </thead>
57
+ <tbody>
58
+ ${rows.join("\n")}
59
+ </tbody>
60
+ </table>
61
+ </section>
62
+ `;
63
+ }
@@ -0,0 +1,3 @@
1
+ export function overrideFindingsToJson(findings) {
2
+ return { overrideFindings: [...findings] };
3
+ }
@@ -0,0 +1,52 @@
1
+ import { getCliVersion } from "../utils/version-info.js";
2
+ const OA_RULES = [
3
+ { id: "OA001", name: "OrphanedTarget", shortDescription: "Override target not in resolved tree", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA001.md" },
4
+ { id: "OA002", name: "FloatingTag", shortDescription: "Override pins to a moving tag", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA002.md" },
5
+ { id: "OA003", name: "WrongSection", shortDescription: "Override in unrecognised package-manager section", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA003.md" },
6
+ { id: "OA004", name: "SurpassedPin", shortDescription: "Installed version surpasses the override pin", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA004.md" },
7
+ { id: "OA005", name: "NestedIneffective", shortDescription: "Nested override has no effective scope", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA005.md" },
8
+ { id: "OA006", name: "CoupledPlatformBinary", shortDescription: "Override fights exact-pinned parent", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA006.md" },
9
+ { id: "OA007", name: "FrozenLatest", shortDescription: "\"latest\" tag has moved", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA007.md" },
10
+ { id: "OA008", name: "MaterializedVulnerable", shortDescription: "Vulnerable copy still on disk", helpUri: "https://github.com/OWASP/cve-lite-cli/blob/main/docs/rules/OA008.md" },
11
+ ];
12
+ const SEVERITY_TO_LEVEL = {
13
+ critical: "error",
14
+ high: "error",
15
+ medium: "warning",
16
+ low: "note",
17
+ info: "note",
18
+ };
19
+ export function buildOverrideSarifComponent() {
20
+ return {
21
+ name: "cve-lite-cli-overrides",
22
+ version: getCliVersion(),
23
+ informationUri: "https://github.com/OWASP/cve-lite-cli",
24
+ rules: OA_RULES.map((r) => ({
25
+ id: r.id,
26
+ name: r.name,
27
+ shortDescription: { text: r.shortDescription },
28
+ helpUri: r.helpUri,
29
+ })),
30
+ };
31
+ }
32
+ export function buildOverrideSarifResults(findings) {
33
+ return findings.map((f) => ({
34
+ ruleId: f.ruleId,
35
+ rule: { id: f.ruleId, toolComponent: { index: 0 } },
36
+ level: SEVERITY_TO_LEVEL[f.severity] ?? "warning",
37
+ message: { text: f.message },
38
+ locations: [
39
+ {
40
+ physicalLocation: {
41
+ artifactLocation: { uri: f.location.file, uriBaseId: "%SRCROOT%" },
42
+ region: { startLine: f.location.line ?? 1 },
43
+ },
44
+ },
45
+ ],
46
+ properties: {
47
+ package: f.package.name,
48
+ jsonPath: f.location.jsonPath,
49
+ severity: f.severity,
50
+ },
51
+ }));
52
+ }
@@ -0,0 +1,106 @@
1
+ import { chalk, stripAnsi } 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_MSG_MAX = 50;
7
+ export function renderOverrideFindings(findings, options) {
8
+ const lines = [];
9
+ lines.push("");
10
+ if (options?.verbose) {
11
+ lines.push(chalk.bold.cyan("🔍 Override Hygiene"));
12
+ }
13
+ else {
14
+ lines.push("────────────────────────────────");
15
+ lines.push(chalk.bold("🔍 Override Hygiene"));
16
+ lines.push("────────────────────────────────");
17
+ }
18
+ lines.push("");
19
+ if (findings.length === 0) {
20
+ lines.push(chalk.greenBright("✔ No override hygiene issues found."));
21
+ return lines.join("\n");
22
+ }
23
+ const grouped = new Map();
24
+ for (const sev of SEVERITY_ORDER)
25
+ grouped.set(sev, []);
26
+ for (const f of findings)
27
+ grouped.get(f.severity)?.push(f);
28
+ for (const sev of SEVERITY_ORDER) {
29
+ const bucket = grouped.get(sev) ?? [];
30
+ if (bucket.length === 0)
31
+ continue;
32
+ lines.push(`${formatSeverityLabel(sev.toUpperCase())} (${bucket.length})`);
33
+ const sorted = [...bucket].sort((a, b) => a.ruleId.localeCompare(b.ruleId));
34
+ const ruleWidth = Math.min(COL_RULE_MAX, Math.max(4, ...sorted.map(f => f.ruleId.length)));
35
+ const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => f.package.name.length)));
36
+ const msgWidth = Math.min(COL_MSG_MAX, Math.max(7, ...sorted.map(f => Math.min(COL_MSG_MAX, Math.max(f.message.length, locationString(f).length)))));
37
+ const hr = (l, m, r) => l + "─".repeat(ruleWidth + 2) + m + "─".repeat(pkgWidth + 2) + m + "─".repeat(msgWidth + 2) + r;
38
+ lines.push(hr("┌", "┬", "┐"));
39
+ lines.push(tableRow(["Rule", "Package", "Message"], [ruleWidth, pkgWidth, msgWidth]));
40
+ lines.push(hr("├", "┼", "┤"));
41
+ for (let i = 0; i < sorted.length; i++) {
42
+ const f = sorted[i];
43
+ const msgLines = wrapText(f.message, msgWidth);
44
+ const locLines = wrapText(locationString(f), msgWidth);
45
+ lines.push(tableRow([chalk.gray(f.ruleId), chalk.whiteBright(f.package.name), msgLines[0] ?? ""], [ruleWidth, pkgWidth, msgWidth]));
46
+ for (let m = 1; m < msgLines.length; m++) {
47
+ lines.push(tableRow(["", "", msgLines[m]], [ruleWidth, pkgWidth, msgWidth]));
48
+ }
49
+ for (const locLine of locLines) {
50
+ lines.push(tableRow(["", "", chalk.gray(locLine)], [ruleWidth, pkgWidth, msgWidth]));
51
+ }
52
+ if (i < sorted.length - 1)
53
+ lines.push(hr("├", "┼", "┤"));
54
+ }
55
+ lines.push(hr("└", "┴", "┘"));
56
+ const seenRules = new Set();
57
+ for (const f of sorted) {
58
+ if (f.fix?.runnableCommand && !seenRules.has(f.ruleId)) {
59
+ seenRules.add(f.ruleId);
60
+ lines.push(chalk.bold.cyan(`> ${f.fix.runnableCommand}`));
61
+ }
62
+ }
63
+ lines.push("");
64
+ }
65
+ const worstSev = SEVERITY_ORDER.find(s => (grouped.get(s) ?? []).length > 0);
66
+ const footerColor = worstSev === "critical" || worstSev === "high" ? chalk.redBright : chalk.yellow;
67
+ lines.push(footerColor(`${findings.length} override hygiene ${pluralize(findings.length, "issue")} found.`));
68
+ lines.push("");
69
+ lines.push(chalk.gray("────────────────────────────────"));
70
+ return lines.join("\n");
71
+ }
72
+ function locationString(f) {
73
+ return f.location.jsonPath
74
+ ? `${f.location.file} › ${f.location.jsonPath}`
75
+ : f.location.file;
76
+ }
77
+ function tableRow(cells, widths) {
78
+ return "│" + cells.map((c, i) => padCell(c, widths[i])).join("│") + "│";
79
+ }
80
+ function padCell(value, width) {
81
+ const truncated = truncate(value, width);
82
+ const visible = stripAnsi(truncated).length;
83
+ return ` ${truncated}${" ".repeat(Math.max(0, width - visible))} `;
84
+ }
85
+ function truncate(value, width) {
86
+ const plain = stripAnsi(value);
87
+ if (plain.length <= width)
88
+ return value;
89
+ return plain.slice(0, Math.max(0, width - 1)) + "…";
90
+ }
91
+ function wrapText(text, width) {
92
+ if (text.length <= width)
93
+ return [text];
94
+ const lines = [];
95
+ let remaining = text.trim();
96
+ while (remaining.length > width) {
97
+ let breakAt = remaining.lastIndexOf(" ", width);
98
+ if (breakAt <= 0)
99
+ breakAt = width;
100
+ lines.push(remaining.slice(0, breakAt).trimEnd());
101
+ remaining = remaining.slice(breakAt).trimStart();
102
+ }
103
+ if (remaining.length > 0)
104
+ lines.push(remaining);
105
+ return lines.length > 0 ? lines : [text];
106
+ }
@@ -2,7 +2,8 @@ import { chalk, stripAnsi } from "../utils/chalk.js";
2
2
  import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
3
3
  import { isMajorVersionBump } from "../utils/version.js";
4
4
  import { getPrimaryParent } from "../utils/finding.js";
5
- import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel, formatRelLabel } from "./formatters.js";
5
+ import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, } from "./formatters.js";
6
+ import { formatSeverityLabel } from "../utils/severity.js";
6
7
  import { pluralize } from "../utils/string.js";
7
8
  import { selectFindingsForCompact } from "./finding-display.js";
8
9
  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";
@@ -29,8 +30,8 @@ export function printSummary(findings, packageCount, scanInput) {
29
30
  console.log(chalk.redBright(`✗ Found ${findings.length} ${pkgLabel} (${totalCVEs} ${cveLabel}) with known OSV matches from ${scanInput.source}`));
30
31
  console.log(renderSeverityTable(counts));
31
32
  }
32
- export function printActionSummary(findings) {
33
- if (findings.length === 0)
33
+ export function printActionSummary(findings, overrideCount = 0, packageManager) {
34
+ if (findings.length === 0 && overrideCount === 0)
34
35
  return;
35
36
  const direct = findings.filter(f => f.relationship === "direct").length;
36
37
  const transitive = findings.filter(f => f.relationship === "transitive").length;
@@ -39,13 +40,35 @@ export function printActionSummary(findings) {
39
40
  const fixable = findings.filter(f => Boolean(f.firstFixedVersion)).length;
40
41
  console.log("");
41
42
  console.log(chalk.bold.cyan("Quick take"));
42
- console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
43
- console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
44
- if (unknown > 0) {
45
- console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
43
+ if (packageManager) {
44
+ console.log(`- ${chalk.gray("Package manager:")} ${packageManager}`);
45
+ }
46
+ if (findings.length > 0) {
47
+ console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
48
+ console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
49
+ if (unknown > 0) {
50
+ console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
51
+ }
52
+ console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} ${pluralize(uniqueAdvisories, "CVE")} matched overall.`);
53
+ console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
54
+ }
55
+ if (overrideCount > 0) {
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
+ }
58
+ }
59
+ function printChainProofLines(targets) {
60
+ for (const target of targets) {
61
+ if (!target.chainProof || !target.chainSafeVersion)
62
+ continue;
63
+ const pkgLabel = target.chainVulnerablePackage
64
+ ? `${target.chainVulnerablePackage}@${target.chainSafeVersion}`
65
+ : target.chainSafeVersion;
66
+ const hops = target.chainProof.map(h => `${h.name}@${h.version}`);
67
+ const proof = hops.length > 0
68
+ ? ` resolves via ${hops.join(" -> ")} -> ${pkgLabel} (safe)`
69
+ : ` resolves to ${pkgLabel} (safe)`;
70
+ console.log(chalk.gray(proof));
46
71
  }
47
- console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} ${pluralize(uniqueAdvisories, "CVE")} matched overall.`);
48
- console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
49
72
  }
50
73
  export function printSuggestedFixCommands(findings, scanInput, options) {
51
74
  const plan = buildSuggestedFixCommandPlan(findings, scanInput, options);
@@ -56,8 +79,7 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
56
79
  const sharedDirectTableWidths = computeSharedDirectTableWidths(plan.sections);
57
80
  const sharedParentUpgradeTableWidths = computeSharedParentUpgradeTableWidths(plan.sections);
58
81
  console.log("");
59
- console.log(chalk.bold.yellow("🛠 Copy And Run These Fix Commands"));
60
- console.log(`${chalk.gray("Detected package manager:")} ${chalk.cyan(plan.packageManager)} ${chalk.gray(`(${plan.sourceLabel})`)}`);
82
+ console.log(chalk.bold.yellow("🛠 Suggested Fix Commands"));
61
83
  console.log(chalk.white(formatFixCommandSummary(plan)));
62
84
  for (const section of plan.sections) {
63
85
  console.log("");
@@ -90,14 +112,19 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
90
112
  else if (shouldRenderParentUpgradeTable(section.targets)) {
91
113
  printParentUpgradeTargetsTable(section.targets, sharedParentUpgradeTableWidths);
92
114
  }
93
- console.log(renderCommandCallout(section.command));
115
+ console.log(renderCommandCallout(section.command, section.targets));
116
+ printChainProofLines(section.targets);
94
117
  }
95
118
  if (plan.coveredFindingCount > 0) {
96
119
  console.log("");
97
120
  const coverage = plan.coveredFindingCount === plan.totalFindingCount
98
- ? chalk.gray(`Running all commands above should fix all ${plan.totalFindingCount} findings.`)
99
- : chalk.gray(`Running all commands above should fix ${chalk.white(String(plan.coveredFindingCount))} of ${chalk.white(String(plan.totalFindingCount))} findings.`);
121
+ ? chalk.gray(`Running all commands above should fix all ${plan.totalFindingCount} vulnerability ${pluralize(plan.totalFindingCount, "finding")}.`)
122
+ : chalk.gray(`Running all commands above should fix ${chalk.white(String(plan.coveredFindingCount))} of ${chalk.white(String(plan.totalFindingCount))} vulnerability findings.`);
100
123
  console.log(coverage);
124
+ const overrideCount = options?.overrideCount ?? 0;
125
+ if (overrideCount > 0) {
126
+ console.log(chalk.gray(`${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} also ${pluralize(overrideCount, "requires", "require")} attention - see the Override Hygiene section below.`));
127
+ }
101
128
  }
102
129
  }
103
130
  export function printSuggestedFixCommandSkips(findings, scanInput, options) {
@@ -244,20 +271,31 @@ export function printTable(findings, threshold, skippedKeys) {
244
271
  console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
245
272
  }
246
273
  }
247
- export function printFinalStatus(findings) {
274
+ export function printFinalStatus(findings, overrideCount = 0) {
248
275
  console.log("");
249
276
  console.log(chalk.gray("────────────────────────────────"));
277
+ const overrideSuffix = overrideCount > 0
278
+ ? `, ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")}`
279
+ : "";
250
280
  if (findings.length === 0) {
251
- console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
281
+ if (overrideCount > 0) {
282
+ console.log(chalk.yellow(`▲ Scan complete. No known vulnerabilities found, but ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} detected.`));
283
+ }
284
+ else {
285
+ console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
286
+ }
252
287
  return;
253
288
  }
254
289
  const criticalCount = findings.filter(f => f.severity === "critical").length;
255
290
  const highCount = findings.filter(f => f.severity === "high").length;
256
291
  if (criticalCount > 0 || highCount > 0) {
257
- console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
292
+ console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
258
293
  return;
259
294
  }
260
- console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found. Review the suggested fix plan above.`));
295
+ console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found. Review the suggested fix plan above.`));
296
+ }
297
+ export function printOverrideHint() {
298
+ console.log("💡 " + chalk.gray("Tip:") + " override entries detected - run with --check-overrides to audit them for stale or broken overrides.");
261
299
  }
262
300
  function renderRow(cells, widths) {
263
301
  const formatted = cells.map((cell, i) => {
@@ -309,6 +347,9 @@ function wrapCell(value, width) {
309
347
  }
310
348
  export function printCompactOutput(findings, scanInput, options) {
311
349
  console.log("");
350
+ if (options?.packageManager) {
351
+ console.log(chalk.gray("Package manager: ") + options.packageManager);
352
+ }
312
353
  if (findings.length === 0) {
313
354
  console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
314
355
  console.log("");
@@ -356,7 +397,7 @@ export function printCompactOutput(findings, scanInput, options) {
356
397
  }
357
398
  }
358
399
  else if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
359
- console.log(` ${chalk.gray(`Fix: lockfile refresh — ${finding.recommendedNpmTransitiveRemediation.package} already permits a safe version`)}`);
400
+ console.log(` ${chalk.gray(`Fix: run \`npm install\` - ${finding.recommendedNpmTransitiveRemediation.package} already permits a safe version`)}`);
360
401
  }
361
402
  else if (finding.recommendedParentUpgrade) {
362
403
  console.log(` ${chalk.gray(`Fix: upgrade ${finding.recommendedParentUpgrade.package} to ${finding.recommendedParentUpgrade.targetVersion}`)}`);
@@ -394,7 +435,7 @@ export function printCompactOutput(findings, scanInput, options) {
394
435
  if (plan) {
395
436
  if (plan?.sections.length) {
396
437
  console.log("────────────────────────────────");
397
- console.log(chalk.bold.yellow("🛠 Copy And Run These Fix Commands"));
438
+ console.log(chalk.bold.yellow("🛠 Suggested Fix Commands"));
398
439
  console.log("────────────────────────────────\n");
399
440
  console.log(`${chalk.gray("Detected package manager:")} ${chalk.cyan(plan.packageManager)} ${chalk.gray(`(${plan.sourceLabel})`)}`);
400
441
  console.log(formatFixCommandSummary(plan));
@@ -412,7 +453,8 @@ export function printCompactOutput(findings, scanInput, options) {
412
453
  console.log(chalk.gray(` Note: ${target.adjustmentNote}`));
413
454
  }
414
455
  }
415
- console.log(renderCommandCallout(section.command));
456
+ console.log(renderCommandCallout(section.command, section.targets));
457
+ printChainProofLines(section.targets);
416
458
  console.log("");
417
459
  }
418
460
  }
@@ -545,8 +587,9 @@ function formatFixCommandSummary(plan) {
545
587
  const sectionLabel = sectionCount === 1 ? "group" : "groups";
546
588
  return `${sectionCount} command ${sectionLabel} ready across ${packageCount} ${packageLabel}${severitySummary ? ` (${severitySummary})` : ""}.`;
547
589
  }
548
- function renderCommandCallout(command) {
549
- return chalk.bold.cyan(`> ${command}`);
590
+ function renderCommandCallout(command, targets) {
591
+ const display = targets ? formatFixCommandWithPublishDates(command, targets) : command;
592
+ return chalk.bold.cyan(`> ${display}`);
550
593
  }
551
594
  function summarizeAdjustedValidation(targets) {
552
595
  let checked = 0;