cve-lite-cli 1.30.0 → 1.32.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.
@@ -9,6 +9,7 @@ import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, severit
9
9
  import { hasMaliciousAdvisory } from "../utils/vuln.js";
10
10
  import { renderOverrideFindingsHtml } from "./override-findings-html.js";
11
11
  import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
12
+ import { renderLicenseFindingsHtml } from "./license-findings-html.js";
12
13
  import { UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
13
14
  import { getCompletenessImpact } from "../scan/completeness.js";
14
15
  export function serializeHtmlFinding(finding, plan) {
@@ -33,6 +34,8 @@ export function buildReportData(params) {
33
34
  skippedDependencies: params.skippedDependencies,
34
35
  overrideFindings: params.overrideFindings,
35
36
  maintenanceFindings: params.maintenanceFindings,
37
+ licenseFindings: params.licenseFindings,
38
+ licenseLimitedToDirectOnly: params.licenseLimitedToDirectOnly,
36
39
  completeness: params.completeness,
37
40
  };
38
41
  }
@@ -180,7 +183,7 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
180
183
  .fix-target-note{color:var(--text-3);font-style:italic;font-size:10px}
181
184
  .fix-target-coverage{flex-basis:100%;color:var(--text-3);font-size:10px;line-height:1.45}
182
185
  .chain-proof{font-size:0.78rem;color:var(--text-2);margin-left:6px;font-family:monospace}
183
- .completeness-banner{margin:16px 32px 0;background:#e3b34111;border:1px solid #e3b34144;border-radius:8px;padding:14px 18px;display:flex;gap:14px;align-items:flex-start}
186
+ .completeness-banner{margin:16px 32px;background:#e3b34111;border:1px solid #e3b34144;border-radius:8px;padding:14px 18px;display:flex;gap:14px;align-items:flex-start}
184
187
  .completeness-banner-icon{font-size:22px;flex-shrink:0;line-height:1}
185
188
  .completeness-banner-body strong{font-size:13px;color:var(--text);display:block;margin-bottom:4px}
186
189
  .completeness-banner-body p{font-size:12px;color:var(--text-2);margin:0}
@@ -331,7 +334,7 @@ ${findingRowsHtml}
331
334
  </div>
332
335
  ${renderOverrideFindingsHtml(data.overrideFindings, data.projectPath)}
333
336
  ${renderMaintenanceFindingsHtml(data.maintenanceFindings)}
334
-
337
+ ${renderLicenseFindingsHtml(data.licenseFindings, { limitedToDirectOnly: data.licenseLimitedToDirectOnly })}
335
338
  ${skippedDepsHtml}
336
339
  ${noticesHtml}
337
340
 
@@ -486,6 +489,16 @@ function renderRelBadge(finding) {
486
489
  }
487
490
  return `<span class="rel-badge ${escapeHtml(finding.relationship)}">${escapeHtml(finding.relationship)}</span>`;
488
491
  }
492
+ function renderEpssHtml(epssScores) {
493
+ if (!epssScores || epssScores.length === 0)
494
+ return "";
495
+ const best = epssScores.slice().sort((a, b) => b.epss - a.epss)[0];
496
+ const pct = (best.epss * 100).toFixed(1);
497
+ const top = (1 - best.percentile) * 100;
498
+ const topStr = top < 0.01 ? "&lt;0.01" : top < 1 ? top.toFixed(2) : top.toFixed(1);
499
+ return `<h4 class="detail-subheading">EPSS</h4>
500
+ <p title="Exploit Prediction Scoring System - probability this CVE will be exploited in the next 30 days">${escapeHtml(pct)}% exploitation probability - ${escapeHtml(best.cve)} (top ${topStr}% of all CVEs)</p>`;
501
+ }
489
502
  export function renderFindingRow(finding, idx, skippedKeys) {
490
503
  const cveLinks = finding.cves.length > 0
491
504
  ? finding.cves.map(advisoryLink).join(", ")
@@ -509,7 +522,7 @@ export function renderFindingRow(finding, idx, skippedKeys) {
509
522
  const depPathHtml = finding.dependencyPaths.length > 0
510
523
  ? finding.dependencyPaths[0].map((node, i, arr) => {
511
524
  const isLast = i === arr.length - 1;
512
- return `<span class="dep-node${isLast ? " vulnerable" : ""}">${escapeHtml(node)}</span>${isLast ? "" : '<span class="dep-arrow">→</span>'}`;
525
+ return `<a href="https://www.npmjs.com/package/${encodeURIComponent(node)}" target="_blank" rel="noopener noreferrer" class="dep-node${isLast ? " vulnerable" : ""}">${escapeHtml(node)}</a>${isLast ? "" : '<span class="dep-arrow">→</span>'}`;
513
526
  }).join("")
514
527
  : `<span class="dep-node">${escapeHtml(finding.package)}</span>`;
515
528
  const description = finding.vulnerabilities[0]?.summary ?? "";
@@ -526,9 +539,9 @@ export function renderFindingRow(finding, idx, skippedKeys) {
526
539
  const rootDepsHtml = finding.rootDependencies.length > 0
527
540
  ? finding.rootDependencies.map(name => `<span class="root-dep">${escapeHtml(name)}</span>`).join(", ")
528
541
  : `<span class="root-dep-none">-</span>`;
529
- return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
542
+ return `<tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
530
543
  <td><span class="expand-icon" id="icon-${idx}">▶</span></td>
531
- <td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
544
+ <td><div class="pkg-name"><a href="https://www.npmjs.com/package/${encodeURIComponent(finding.package)}" target="_blank" rel="noopener noreferrer">${escapeHtml(finding.package)}</a></div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
532
545
  <td>${fixHtml}</td>
533
546
  <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
534
547
  <td>${renderRelBadge(finding)}</td>
@@ -554,6 +567,7 @@ export function renderFindingRow(finding, idx, skippedKeys) {
554
567
  <p>${escapeHtml(finding.riskSummary)}</p>
555
568
  <h4 class="detail-subheading">Next action</h4>
556
569
  <p>${escapeHtml(finding.nextAction)}</p>
570
+ ${renderEpssHtml(finding.epssScores)}
557
571
  </div>
558
572
  </div>
559
573
  </td>
@@ -758,7 +772,7 @@ export function renderFixPlan(plan) {
758
772
  : "";
759
773
  const chainProofHtml = t.chainProof && t.chainSafeVersion
760
774
  ? (() => {
761
- const hops = t.chainProof.map(h => `${escapeHtml(h.name)}@${escapeHtml(h.version)}`);
775
+ const hops = t.chainProof.map(h => `<a href="https://www.npmjs.com/package/${encodeURIComponent(h.name)}" target="_blank" rel="noopener noreferrer">${escapeHtml(h.name)}</a>@${escapeHtml(h.version)}`);
762
776
  const safe = escapeHtml(t.chainSafeVersion);
763
777
  const proofText = hops.length > 0
764
778
  ? `resolves via ${hops.join(" -&gt; ")} -&gt; ${safe} (safe)`
@@ -0,0 +1,63 @@
1
+ function esc(s) {
2
+ return s
3
+ .replace(/&/g, "&amp;")
4
+ .replace(/</g, "&lt;")
5
+ .replace(/>/g, "&gt;")
6
+ .replace(/"/g, "&quot;");
7
+ }
8
+ export function renderLicenseFindingsHtml(findings, opts) {
9
+ // undefined = license checking was never requested -> render nothing, so a plain
10
+ // `cve-lite .` report shows no License Issues panel at all. An empty array =
11
+ // it ran and found nothing -> render the "no findings" reassurance.
12
+ if (findings === undefined) {
13
+ return "";
14
+ }
15
+ if (findings.length === 0) {
16
+ const note = opts?.limitedToDirectOnly
17
+ ? `\n <p style="margin-top:8px;font-size:12px;color:var(--text-2)">Note: license data is not available for transitive packages in pnpm/Yarn/Bun - direct dependencies only.</p>`
18
+ : "";
19
+ return `
20
+ <div class="findings-section">
21
+ <div class="findings-header">
22
+ <div style="display:flex;align-items:center;gap:8px">
23
+ <h2>License Issues</h2>
24
+ <span class="badge-warning">informational</span>
25
+ </div>
26
+ </div>
27
+ <p style="color:var(--text-2);font-size:13px">No license issues found.</p>${note}
28
+ </div>`;
29
+ }
30
+ const rows = findings.map(f => ` <tr style="cursor:default">` +
31
+ `<td><span class="sev-badge ${esc(f.severity)}">${esc(f.ruleId)}</span></td>` +
32
+ `<td style="font-weight:500">${esc(f.package.name)}</td>` +
33
+ `<td style="color:var(--text-2)">${esc(f.package.version)}</td>` +
34
+ `<td><code style="font-size:12px;font-family:monospace;color:var(--text)">${esc(f.license ?? "(none)")}</code></td>` +
35
+ `<td><span class="rel-badge ${esc(f.relationship)}">${esc(f.relationship)}</span></td>` +
36
+ `<td style="color:var(--text-2);font-size:12px">${esc(f.message)}</td>` +
37
+ `</tr>`);
38
+ const count = findings.length;
39
+ const note = opts?.limitedToDirectOnly
40
+ ? `\n <p style="margin-top:10px;font-size:12px;color:var(--text-2)">Note: license data is not available for transitive packages in pnpm/Yarn/Bun - direct dependencies only.</p>`
41
+ : "";
42
+ return `
43
+ <div class="findings-section">
44
+ <div class="findings-header">
45
+ <div style="display:flex;align-items:center;gap:8px">
46
+ <h2>License Issues</h2>
47
+ <span class="badge-warning">informational</span>
48
+ </div>
49
+ <span style="font-size:12px;color:var(--text-2)">${count} ${count === 1 ? "finding" : "findings"}</span>
50
+ </div>
51
+ <table class="findings-table">
52
+ <thead>
53
+ <tr>
54
+ <th>Rule</th><th>Package</th><th>Version</th><th>License</th><th>Relationship</th><th>Message</th>
55
+ </tr>
56
+ </thead>
57
+ <tbody>
58
+ ${rows.join("\n")}
59
+ </tbody>
60
+ </table>${note}
61
+ </div>
62
+ `;
63
+ }
@@ -0,0 +1,10 @@
1
+ export function serializeLicenseFindings(findings) {
2
+ return findings.map(f => ({
3
+ ruleId: f.ruleId,
4
+ severity: f.severity,
5
+ package: { name: f.package.name, version: f.package.version },
6
+ license: f.license,
7
+ relationship: f.relationship,
8
+ message: f.message,
9
+ }));
10
+ }
@@ -0,0 +1,64 @@
1
+ import { getCliVersion } from "../utils/version-info.js";
2
+ import { severityToSarifLevel } from "../utils/severity.js";
3
+ import { sarifFingerprintHash } from "../utils/sarif.js";
4
+ const LC_RULES = [
5
+ {
6
+ id: "LC001",
7
+ name: "Copyleft license",
8
+ shortDescription: "Dependency uses a copyleft license that may require open-sourcing your code",
9
+ helpUri: "https://owasp.org/cve-lite-cli/docs/license-scanning/lc001",
10
+ },
11
+ {
12
+ id: "LC002",
13
+ name: "Unknown license",
14
+ shortDescription: "Dependency has no license declaration - legally ambiguous",
15
+ helpUri: "https://owasp.org/cve-lite-cli/docs/license-scanning/lc002",
16
+ },
17
+ ];
18
+ const LC_RULE_INDEX = new Map(LC_RULES.map((r, i) => [r.id, i]));
19
+ export function buildLicenseSarifComponent() {
20
+ return {
21
+ name: "cve-lite-cli-licenses",
22
+ version: getCliVersion(),
23
+ informationUri: "https://github.com/OWASP/cve-lite-cli",
24
+ rules: LC_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 buildLicenseSarifResults(findings, lockfileUri, toolComponentIndex = 0) {
33
+ return findings.map(f => {
34
+ const ruleIndex = LC_RULE_INDEX.get(f.ruleId);
35
+ if (ruleIndex === undefined) {
36
+ throw new Error(`LC_RULE_INDEX: unknown ruleId "${f.ruleId}" - add it to LC_RULES`);
37
+ }
38
+ return {
39
+ ruleId: f.ruleId,
40
+ ruleIndex,
41
+ rule: { id: f.ruleId, toolComponent: { index: toolComponentIndex } },
42
+ kind: "open",
43
+ level: severityToSarifLevel(f.severity),
44
+ message: { text: f.message },
45
+ locations: [
46
+ {
47
+ physicalLocation: {
48
+ artifactLocation: { uri: lockfileUri, uriBaseId: "%SRCROOT%" },
49
+ region: { startLine: 1 },
50
+ },
51
+ },
52
+ ],
53
+ partialFingerprints: {
54
+ primaryLocationLineHash: sarifFingerprintHash(`${f.ruleId}:${f.package.name}:${f.package.version}`),
55
+ },
56
+ properties: {
57
+ package: f.package.name,
58
+ version: f.package.version,
59
+ license: f.license,
60
+ severity: f.severity,
61
+ },
62
+ };
63
+ });
64
+ }
@@ -0,0 +1,35 @@
1
+ import { chalk } from "../utils/chalk.js";
2
+ import { formatSeverityLabel } from "../utils/severity.js";
3
+ const DIVIDER = "────────────────────────────────";
4
+ export function renderLicenseFindings(findings, opts) {
5
+ const lines = [
6
+ DIVIDER,
7
+ chalk.bold("⚖ License Issues"),
8
+ DIVIDER,
9
+ "",
10
+ ];
11
+ if (findings.length === 0) {
12
+ lines.push(chalk.greenBright("✔ No license issues found."));
13
+ return lines.join("\n");
14
+ }
15
+ for (const f of findings) {
16
+ const pkg = `${f.package.name}@${f.package.version}`;
17
+ const sevPad = " ".repeat(Math.max(0, 8 - f.severity.length));
18
+ lines.push(`${formatSeverityLabel(f.severity.toUpperCase())}${sevPad} ${f.ruleId} ${pkg}`);
19
+ lines.push(` ${f.message}`);
20
+ lines.push(` Type: ${f.relationship}`);
21
+ lines.push("");
22
+ }
23
+ const highCount = findings.filter((f) => f.severity === "high").length;
24
+ const medCount = findings.filter((f) => f.severity === "medium").length;
25
+ const parts = [];
26
+ if (highCount > 0)
27
+ parts.push(`${highCount} high`);
28
+ if (medCount > 0)
29
+ parts.push(`${medCount} medium`);
30
+ lines.push(chalk.yellow(`⚖ License scan: ${parts.join(", ")} (informational)`));
31
+ if (opts.limitedToDirectOnly) {
32
+ lines.push(chalk.gray("Note: license data not available for transitive packages in pnpm/Yarn/Bun - direct dependencies only."));
33
+ }
34
+ return lines.join("\n");
35
+ }
@@ -4,6 +4,7 @@ import { aggregateMultiFolderCompleteness } from "../scan/completeness.js";
4
4
  import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, renderCompletenessBanner, serializeHtmlFinding, } from "./html-reporter.js";
5
5
  import { renderOverrideFindingsHtml } from "./override-findings-html.js";
6
6
  import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
7
+ import { renderLicenseFindingsHtml } from "./license-findings-html.js";
7
8
  import { loadLogoDataUri } from "./logos.js";
8
9
  import { pluralize } from "../utils/string.js";
9
10
  export function buildMultiFolderReportData(params) {
@@ -45,12 +46,12 @@ function renderFolderNotices(coverage) {
45
46
  if (coverage.length === 0)
46
47
  return "";
47
48
  const items = coverage.map(n => `<li>${escapeHtml(n)}</li>`).join("\n");
48
- return `<div class="scan-notes" style="margin:16px 32px 0">
49
+ return `<div class="scan-notes" style="margin:16px 32px">
49
50
  <button class="scan-notes-toggle" onclick="toggleNotes(this)"><span class="arrow">▶</span> Scan notes (${coverage.length})</button>
50
51
  <div class="scan-notes-body"><ul>${items}</ul></div>
51
52
  </div>`;
52
53
  }
53
- function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRoot, includeOverrides, includeMaintenance) {
54
+ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRoot, includeOverrides, includeMaintenance, includeLicenses) {
54
55
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 };
55
56
  for (const f of result.sorted) {
56
57
  const sev = f.severity;
@@ -67,7 +68,6 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
67
68
  const findingRowsHtml = serialized.map((f, i) => renderFindingRow(f, idxOffset + i)).join("\n");
68
69
  const fixPlanHtml = renderFixPlan(result.suggestedFixCommands);
69
70
  const noticesHtml = renderFolderNotices(result.coverage);
70
- const completenessBannerHtml = renderCompletenessBanner(result.completeness);
71
71
  const folderAbs = path.join(projectRoot, result.subfolder);
72
72
  const overrideHtml = includeOverrides
73
73
  ? renderOverrideFindingsHtml(result.overrideFindings, folderAbs)
@@ -75,6 +75,9 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
75
75
  const maintenanceHtml = includeMaintenance
76
76
  ? renderMaintenanceFindingsHtml(result.maintenanceFindings)
77
77
  : "";
78
+ const licenseHtml = includeLicenses
79
+ ? renderLicenseFindingsHtml(result.licenseFindings, { limitedToDirectOnly: result.licenseLimitedToDirectOnly })
80
+ : "";
78
81
  const emptyRow = result.sorted.length === 0
79
82
  ? `<tr><td colspan="7" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
80
83
  : "";
@@ -88,7 +91,6 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
88
91
  <span class="folder-counts">${escapeHtml(summaryText)}</span>
89
92
  </summary>
90
93
  <div class="folder-body">
91
- ${completenessBannerHtml}
92
94
  ${fixPlanHtml}
93
95
  ${noticesHtml}
94
96
  <div class="findings-section" style="margin:16px 32px 32px">
@@ -125,6 +127,7 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
125
127
  </div>
126
128
  ${overrideHtml}
127
129
  ${maintenanceHtml}
130
+ ${licenseHtml}
128
131
  </div>
129
132
  </details>`;
130
133
  }
@@ -147,6 +150,7 @@ export async function writeMultiFolderHtmlReport(params) {
147
150
  cliVersion: params.cliVersion,
148
151
  includeOverrides: params.includeOverrides,
149
152
  includeMaintenance: params.includeMaintenance,
153
+ includeLicenses: params.includeLicenses,
150
154
  });
151
155
  // Compact per-folder findings for JavaScript (only fields needed for filter/sort/search)
152
156
  const folderFindingsJson = JSON.stringify(allSerialized.map(findings => findings.map(f => ({
@@ -163,7 +167,7 @@ export async function writeMultiFolderHtmlReport(params) {
163
167
  let idxOffset = 0;
164
168
  const folderSectionsHtml = params.results
165
169
  .map((r, fi) => {
166
- const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi], params.projectPath, params.includeOverrides, params.includeMaintenance);
170
+ const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi], params.projectPath, params.includeOverrides, params.includeMaintenance, params.includeLicenses);
167
171
  idxOffset += r.sorted.length;
168
172
  return html;
169
173
  })
@@ -7,6 +7,7 @@ import { formatSeverityLabel } from "../utils/severity.js";
7
7
  import { pluralize } from "../utils/string.js";
8
8
  import { hasMaliciousAdvisory } from "../utils/vuln.js";
9
9
  import { selectFindingsForCompact } from "./finding-display.js";
10
+ import { renderLicenseFindings } from "./license-terminal.js";
10
11
  import { getCompletenessImpact } from "../scan/completeness.js";
11
12
  import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, MAL_GIT_SOURCE_COMPACT_MESSAGE, MAL_GIT_SOURCE_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, OVERRIDES_COMMAND, } from "../constants.js";
12
13
  export function printSummary(findings, packageCount, scanInput) {
@@ -193,7 +194,7 @@ export function printSkippedDependencies(skipped) {
193
194
  }
194
195
  }
195
196
  export function printTable(findings, threshold, skippedKeys) {
196
- const headers = ["Package", "Version", "Severity", "Type", "Root", "Usage", "Fixed", "IDs"];
197
+ const headers = ["Package", "Version", "Severity", "Type", "Root", "Usage", "Fixed", "EPSS", "IDs"];
197
198
  const rawRows = findings.map(f => {
198
199
  let usageText = "n/a";
199
200
  if (f.usage) {
@@ -220,6 +221,11 @@ export function printTable(findings, threshold, skippedKeys) {
220
221
  else {
221
222
  fixedDisplay = chalk.yellow("⚠ no fix");
222
223
  }
224
+ let epssDisplay = "-";
225
+ if (f.epssScores && f.epssScores.length > 0) {
226
+ const best = f.epssScores.slice().sort((a, b) => b.epss - a.epss)[0];
227
+ epssDisplay = `${(best.epss * 100).toFixed(1)}%`;
228
+ }
223
229
  return [
224
230
  f.pkg.name,
225
231
  f.pkg.version,
@@ -228,6 +234,7 @@ export function printTable(findings, threshold, skippedKeys) {
228
234
  formatRootDependencySummary(f),
229
235
  usageText,
230
236
  fixedDisplay,
237
+ epssDisplay,
231
238
  f.vulnerabilities.map(v => v.id).join(", ")
232
239
  ];
233
240
  });
@@ -256,7 +263,8 @@ export function printTable(findings, threshold, skippedKeys) {
256
263
  row[4],
257
264
  usageDecorated,
258
265
  row[6],
259
- row[7]
266
+ chalk.gray(String(row[7])),
267
+ row[8]
260
268
  ];
261
269
  console.log(renderRow(decorated, widths));
262
270
  }
@@ -433,6 +441,13 @@ export function printCompactOutput(findings, scanInput, options) {
433
441
  }
434
442
  console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(finding.pkg.name)}@${finding.pkg.version}`);
435
443
  console.log(` ${typeLabel}${usageContext}`);
444
+ if (finding.epssScores && finding.epssScores.length > 0) {
445
+ const best = finding.epssScores.slice().sort((a, b) => b.epss - a.epss)[0];
446
+ const pct = (best.epss * 100).toFixed(1);
447
+ const top = ((1 - best.percentile) * 100);
448
+ const topStr = top < 0.01 ? "<0.01" : top < 1 ? top.toFixed(2) : top.toFixed(1);
449
+ console.log(` ${chalk.gray(`EPSS: ${pct}% exploitation probability - ${best.cve} (top ${topStr}% of all CVEs)`)}`);
450
+ }
436
451
  const isMalicious = hasMaliciousAdvisory(finding.vulnerabilities);
437
452
  if (isMalicious) {
438
453
  if (finding.maliciousUnverifiable) {
@@ -511,6 +526,11 @@ export function printCompactOutput(findings, scanInput, options) {
511
526
  }
512
527
  }
513
528
  }
529
+ if (options?.licenseFindings) {
530
+ console.log(renderLicenseFindings(options.licenseFindings, { limitedToDirectOnly: !!options.licenseLimitedToDirectOnly }));
531
+ console.log("");
532
+ console.log("");
533
+ }
514
534
  // Summary
515
535
  console.log("────────────────────────────────");
516
536
  console.log("Summary");
@@ -545,6 +565,16 @@ export function printCompactOutput(findings, scanInput, options) {
545
565
  console.log(`${chalk.cyan(String(direct))} ${chalk.white("direct")}` +
546
566
  `${chalk.gray(" · ")}` +
547
567
  `${chalk.cyan(String(transitive))} ${chalk.white("transitive")}`);
568
+ if (options?.licenseFindings && options.licenseFindings.length > 0) {
569
+ const lHigh = options.licenseFindings.filter(f => f.severity === "high").length;
570
+ const lMed = options.licenseFindings.filter(f => f.severity === "medium").length;
571
+ const lParts = [];
572
+ if (lHigh > 0)
573
+ lParts.push(chalk.red(`${lHigh} high`));
574
+ if (lMed > 0)
575
+ lParts.push(chalk.yellow(`${lMed} medium`));
576
+ console.log(chalk.gray("⚖ Licenses: ") + lParts.join(chalk.gray(" · ")) + chalk.gray(" (informational)"));
577
+ }
548
578
  const maliciousCompact = findings.filter(f => hasMaliciousAdvisory(f.vulnerabilities));
549
579
  if (maliciousCompact.length > 0 && !options?.all) {
550
580
  console.log("");
@@ -585,13 +615,13 @@ export function printCompactOutput(findings, scanInput, options) {
585
615
  else {
586
616
  console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found.`));
587
617
  }
588
- if (!options?.all) {
589
- console.log(chalk.gray(`Run with ${chalk.whiteBright("--verbose")} for fix plan, paths, and full table.`));
590
- }
618
+ printIncompleteDiagnostics(options?.completeness);
591
619
  if (hasRemediationGap) {
592
620
  console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
593
621
  }
594
- printIncompleteDiagnostics(options?.completeness);
622
+ if (!options?.all) {
623
+ console.log(chalk.gray(`Run with ${chalk.whiteBright("--verbose")} for fix plan, paths, and full table.`));
624
+ }
595
625
  if (options?.completeness?.complete !== false) {
596
626
  console.log("");
597
627
  }
@@ -599,12 +629,12 @@ export function printCompactOutput(findings, scanInput, options) {
599
629
  export function printIncompleteDiagnostics(completeness) {
600
630
  if (!completeness || completeness.complete)
601
631
  return;
602
- console.log("");
603
632
  for (const diag of completeness.diagnostics) {
604
- const prefix = diag.impact === "detection" ? chalk.yellow(" ·") : chalk.gray(" ·");
605
- console.log(prefix + " " + chalk.gray(diag.message));
633
+ const color = diag.impact === "detection" ? chalk.yellow : chalk.gray;
634
+ console.log(color(`⚠ ${diag.message}`));
606
635
  }
607
- console.log(chalk.gray(" Resolve the issues above and re-run the scan."));
636
+ console.log("");
637
+ console.log(chalk.gray("Resolve the issues above and re-run the scan."));
608
638
  }
609
639
  function renderSeverityTable(counts) {
610
640
  const labels = ["Critical", "High", "Medium", "Low", "Unknown"];
@@ -7,6 +7,7 @@ import { severityToSarifLevel } from "../utils/severity.js";
7
7
  import { sarifFingerprintHash } from "../utils/sarif.js";
8
8
  import { buildOverrideSarifComponent, buildOverrideSarifResults } from "./override-findings-sarif.js";
9
9
  import { buildMaintenanceSarifComponent, buildMaintenanceSarifResults } from "./maintenance-findings-sarif.js";
10
+ import { buildLicenseSarifComponent, buildLicenseSarifResults } from "./license-findings-sarif.js";
10
11
  const SARIF_SCHEMA = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
11
12
  const LOCKFILE_NAMES = {
12
13
  "package-lock": "package-lock.json",
@@ -77,7 +78,7 @@ export function deriveLockfileUri(scanInput) {
77
78
  return path.basename(scanInput.filePath);
78
79
  return LOCKFILE_NAMES[scanInput.source] ?? "lockfile";
79
80
  }
80
- export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings) {
81
+ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings, licenseFindings) {
81
82
  const ruleMap = new Map();
82
83
  const ruleIndexMap = new Map();
83
84
  const results = [];
@@ -135,17 +136,23 @@ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideF
135
136
  }
136
137
  const hasOverrides = overrideFindings != null && overrideFindings.length > 0;
137
138
  const hasMaintenance = maintenanceFindings != null && maintenanceFindings.length > 0;
139
+ const hasLicense = licenseFindings != null && licenseFindings.length > 0;
138
140
  const extensions = [
139
141
  ...(hasOverrides ? [buildOverrideSarifComponent()] : []),
140
142
  ...(hasMaintenance ? [buildMaintenanceSarifComponent()] : []),
143
+ ...(hasLicense ? [buildLicenseSarifComponent()] : []),
141
144
  ];
142
145
  const maintenanceExtensionIndex = hasOverrides ? 1 : 0;
146
+ const licenseExtensionIndex = (hasOverrides ? 1 : 0) + (hasMaintenance ? 1 : 0);
143
147
  const allResults = [
144
148
  ...results,
145
149
  ...(hasOverrides ? buildOverrideSarifResults(overrideFindings) : []),
146
150
  ...(hasMaintenance
147
151
  ? buildMaintenanceSarifResults(maintenanceFindings, lockfileUri, maintenanceExtensionIndex)
148
152
  : []),
153
+ ...(hasLicense
154
+ ? buildLicenseSarifResults(licenseFindings, lockfileUri, licenseExtensionIndex)
155
+ : []),
149
156
  ];
150
157
  return {
151
158
  $schema: SARIF_SCHEMA,
@@ -169,11 +176,11 @@ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideF
169
176
  ],
170
177
  };
171
178
  }
172
- export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings) {
179
+ export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings, licenseFindings) {
173
180
  const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
174
181
  const filename = `cve-lite-scan-${ts}.sarif`;
175
182
  const outputPath = path.join(process.cwd(), filename);
176
- const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings);
183
+ const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings, licenseFindings);
177
184
  try {
178
185
  fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
179
186
  }
@@ -1,6 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { chalk } from "../utils/chalk.js";
4
+ import { serializeLicenseFindings } from "./license-findings-json.js";
4
5
  import { serializeFinding } from "./formatters.js";
5
6
  import { writeSarifReport, deriveLockfileUri } from "./sarif.js";
6
7
  import { writeCycloneDxReport } from "./cyclonedx.js";
@@ -46,13 +47,19 @@ export async function writeOutputs(options, scanState, scanInput, projectPath) {
46
47
  };
47
48
  const overridePayload = overrideFindingsToJson(scanState.overrideFindings ?? []);
48
49
  const maintenancePayload = maintenanceFindingsToJson(scanState.maintenanceFindings ?? []);
49
- const combined = { ...payload, ...overridePayload, ...maintenancePayload };
50
+ const licensePayload = scanState.licenseFindings && scanState.licenseFindings.length > 0
51
+ ? {
52
+ licenseFindings: serializeLicenseFindings(scanState.licenseFindings),
53
+ ...(scanState.licenseLimitedToDirectOnly ? { licenseLimitedToDirectOnly: true } : {}),
54
+ }
55
+ : {};
56
+ const combined = { ...payload, ...overridePayload, ...maintenancePayload, ...licensePayload };
50
57
  fs.writeFileSync(jsonOutputPath, JSON.stringify(combined, null, 2));
51
58
  console.log(`${chalk.gray("JSON saved to")} ${chalk.cyan(jsonFilename)}`);
52
59
  }
53
60
  if (options.sarif) {
54
61
  const lockfileUri = deriveLockfileUri(scanInput);
55
- const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings, scanState.maintenanceFindings);
62
+ const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings, scanState.maintenanceFindings, scanState.licenseFindings);
56
63
  console.log(`${chalk.gray("SARIF report written to")} ${chalk.cyan(sarifFilename)}`);
57
64
  }
58
65
  if (options.cdx) {
@@ -294,10 +294,11 @@ function parsePnpmPackageKey(key) {
294
294
  return { key, name, version };
295
295
  }
296
296
  function parsePnpmPackageKeyV9(key) {
297
- const cleaned = key.split("(")[0]; // strip peer-dep suffix e.g. handlebars@4.7.8(foo@1.0.0)
297
+ // strip leading slash (pnpm v9 can emit /@babel/core@7.20.0) then peer-dep suffix (pkg@1.0.0(peer@2.0.0))
298
+ const cleaned = key.replace(/^\//, "").split("(")[0];
298
299
  const idx = cleaned.lastIndexOf("@");
299
300
  if (idx <= 0)
300
- return null; // no @ or @ is the first char
301
+ return null; // no @ or @ is the first char (scoped package name only)
301
302
  const name = cleaned.slice(0, idx);
302
303
  const version = cleaned.slice(idx + 1);
303
304
  if (!name || !version)
@@ -324,7 +325,7 @@ function normalizePnpmDepRef(depName, depRef) {
324
325
  }
325
326
  function normalizePnpmDepRefV9(depName, depRef) {
326
327
  if (typeof depRef === "string") {
327
- const cleaned = depRef.replace(/^link:/, "").replace(/^workspace:/, "").split("(")[0];
328
+ const cleaned = depRef.replace(/^link:/, "").replace(/^workspace:/, "").replace(/^\//, "").split("(")[0];
328
329
  if (!cleaned || cleaned.startsWith(".") || cleaned.startsWith(".."))
329
330
  return null;
330
331
  if (looksLikeVersion(cleaned))
@@ -79,7 +79,14 @@ function resolveDirectParentContext(viaPath, packages, directDependencyNames, pa
79
79
  const directParentName = directParentCandidates[0];
80
80
  if (!directParentName)
81
81
  return null;
82
- const directParent = findDirectDependency(packages, directParentName, directDependencyNames, packagesByName);
82
+ // Path-based lookup disambiguates when the same package name is installed at
83
+ // multiple versions (e.g. eslint@9.36.0 at root AND eslint@6.14.0 nested).
84
+ // A name-keyed Map (last-write-wins) would return an arbitrary version, making
85
+ // directParentVersion wrong and potentially producing downgrade suggestions.
86
+ const directParentIdx = viaPath.indexOf(directParentName);
87
+ const directParentPathPrefix = viaPath.slice(0, directParentIdx + 1);
88
+ const directParent = findPackageAlongPath(packages, directParentName, directParentPathPrefix) ??
89
+ findDirectDependency(packages, directParentName, directDependencyNames, packagesByName);
83
90
  if (!directParent)
84
91
  return null;
85
92
  return { directParentName, immediateParentName, directParent };
@@ -47,3 +47,9 @@ export function aggregateMultiFolderCompleteness(results) {
47
47
  }
48
48
  return { complete: deduped.size === 0, diagnostics: [...deduped.values()] };
49
49
  }
50
+ export function shouldFailForIncompleteScan(completeness, policy) {
51
+ if (policy !== "error") {
52
+ return false;
53
+ }
54
+ return getCompletenessImpact(completeness).hasDetectionGap;
55
+ }