cve-lite-cli 1.18.1 → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/osv/cache.js CHANGED
@@ -14,15 +14,23 @@ export function getCacheFilePath(cacheDirOverride) {
14
14
  export function isEntryStale(entry, nowMs) {
15
15
  return nowMs - new Date(entry.cachedAt).getTime() > 30 * 60 * 1000;
16
16
  }
17
- export function loadCache(cacheDirOverride) {
17
+ export function loadCache(cacheDirOverride, debugLog) {
18
18
  const filePath = getCacheFilePath(cacheDirOverride);
19
19
  if (!fs.existsSync(filePath)) {
20
+ debugLog?.("Cache loaded", {
21
+ path: filePath,
22
+ queryEntries: 0,
23
+ detailEntries: 0,
24
+ exists: false,
25
+ });
20
26
  return createEmptyCache();
21
27
  }
22
28
  try {
23
29
  const parsed = JSON.parse(fs.readFileSync(filePath, "utf8"));
24
- if (typeof parsed !== "object" || parsed === null)
30
+ if (typeof parsed !== "object" || parsed === null) {
31
+ debugLog?.("Cache load failed", { path: filePath, reason: "invalid root object" });
25
32
  return createEmptyCache();
33
+ }
26
34
  const entries = (parsed.entries && typeof parsed.entries === "object")
27
35
  ? parsed.entries
28
36
  : {};
@@ -33,11 +41,25 @@ export function loadCache(cacheDirOverride) {
33
41
  for (const [key, vulnIds] of Object.entries(rawQuery ?? {})) {
34
42
  queryEntries[key] = { vulnIds: Array.isArray(vulnIds) ? vulnIds : [], cachedAt: new Date(0).toISOString() };
35
43
  }
36
- return { version: 3, createdAt: String(parsed.createdAt ?? new Date().toISOString()), entries, queryEntries };
44
+ const migrated = { version: 3, createdAt: String(parsed.createdAt ?? new Date().toISOString()), entries, queryEntries };
45
+ debugLog?.("Cache loaded", {
46
+ path: filePath,
47
+ queryEntries: Object.keys(migrated.queryEntries).length,
48
+ detailEntries: Object.keys(migrated.entries).length,
49
+ migratedFrom: 2,
50
+ });
51
+ return migrated;
37
52
  }
38
53
  // v1 or unknown: no queryEntries
39
54
  if (parsed.version !== 3) {
40
- return { version: 3, createdAt: new Date().toISOString(), entries, queryEntries: {} };
55
+ const upgraded = { version: 3, createdAt: new Date().toISOString(), entries, queryEntries: {} };
56
+ debugLog?.("Cache loaded", {
57
+ path: filePath,
58
+ queryEntries: 0,
59
+ detailEntries: Object.keys(upgraded.entries).length,
60
+ migratedFrom: parsed.version ?? "unknown",
61
+ });
62
+ return upgraded;
41
63
  }
42
64
  const rawQuery = parsed.queryEntries;
43
65
  const queryEntries = {};
@@ -46,19 +68,36 @@ export function loadCache(cacheDirOverride) {
46
68
  queryEntries[key] = value;
47
69
  }
48
70
  }
49
- return {
71
+ const loaded = {
50
72
  version: 3,
51
73
  createdAt: String(parsed.createdAt ?? new Date().toISOString()),
52
74
  entries,
53
75
  queryEntries,
54
76
  };
77
+ debugLog?.("Cache loaded", {
78
+ path: filePath,
79
+ queryEntries: Object.keys(loaded.queryEntries).length,
80
+ detailEntries: Object.keys(loaded.entries).length,
81
+ });
82
+ return loaded;
55
83
  }
56
- catch {
84
+ catch (error) {
85
+ debugLog?.("Cache load failed", {
86
+ path: filePath,
87
+ reason: error instanceof Error ? error.message : String(error),
88
+ });
57
89
  return createEmptyCache();
58
90
  }
59
91
  }
60
- export function saveCache(cache, cacheDirOverride) {
92
+ export function saveCache(cache, cacheDirOverride, debugLog) {
61
93
  const filePath = getCacheFilePath(cacheDirOverride);
62
94
  cache.createdAt = new Date().toISOString();
63
95
  fs.writeFileSync(filePath, JSON.stringify(cache, null, 2), "utf8");
96
+ if (debugLog) {
97
+ debugLog("Cache saved", {
98
+ path: filePath,
99
+ queryEntries: Object.keys(cache.queryEntries).length,
100
+ detailEntries: Object.keys(cache.entries).length,
101
+ });
102
+ }
64
103
  }
@@ -0,0 +1,38 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ export function createDebugLogger(enabled) {
4
+ if (!enabled) {
5
+ return {
6
+ log: () => { },
7
+ announcePath: () => { },
8
+ };
9
+ }
10
+ const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
11
+ const filename = `cve-lite-debug-${ts}.log`;
12
+ const outputPath = path.join(process.cwd(), filename);
13
+ let announced = false;
14
+ const log = (message, details) => {
15
+ const time = new Date().toISOString();
16
+ const payload = details === undefined
17
+ ? ""
18
+ : ` ${formatJson(details)}`;
19
+ fs.appendFileSync(outputPath, `${time} [debug] ${message}${payload}\n`, "utf8");
20
+ };
21
+ const announcePath = () => {
22
+ if (announced)
23
+ return;
24
+ announced = true;
25
+ console.error(`[debug] Writing debug log to ./${filename}`);
26
+ };
27
+ return { log, announcePath };
28
+ }
29
+ function formatJson(details) {
30
+ if (typeof details === "string")
31
+ return details;
32
+ try {
33
+ return JSON.stringify(details);
34
+ }
35
+ catch {
36
+ return String(details);
37
+ }
38
+ }
@@ -0,0 +1,30 @@
1
+ import { severityOrder } from "../constants.js";
2
+ import { normalizeSeverity } from "../osv/severity.js";
3
+ export function selectFindingsForTable(findings, minSeverity) {
4
+ const normalized = normalizeSeverity(minSeverity);
5
+ return findings.filter(finding => severityOrder[finding.severity] >= severityOrder[normalized] || finding.severity === "unknown");
6
+ }
7
+ export function selectFindingsForCompact(findings, options) {
8
+ const urgentLimit = options?.urgentLimit ?? 3;
9
+ const urgent = findings
10
+ .filter(finding => finding.severity === "critical" || finding.severity === "high")
11
+ .slice(0, urgentLimit);
12
+ const unknownDirect = findings.filter(finding => finding.severity === "unknown" && finding.relationship === "direct");
13
+ return mergeUniqueFindings(urgent, unknownDirect);
14
+ }
15
+ function mergeUniqueFindings(primary, extra) {
16
+ const result = [...primary];
17
+ const seen = new Set(result.map(findingIdentity));
18
+ for (const finding of extra) {
19
+ const id = findingIdentity(finding);
20
+ if (seen.has(id))
21
+ continue;
22
+ seen.add(id);
23
+ result.push(finding);
24
+ }
25
+ return result;
26
+ }
27
+ function findingIdentity(finding) {
28
+ const vulnIds = finding.vulnerabilities.map(v => v.id).sort().join(",");
29
+ return `${finding.pkg.name}@${finding.pkg.version}|${finding.relationship}|${finding.severity}|${vulnIds}`;
30
+ }
@@ -0,0 +1,323 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { REPORT_STYLES, escapeHtml, renderFindingRow, renderFixPlan, openInBrowser } from "./html-reporter.js";
4
+ import { LOGO_BASE64 } from "./logo-base64.js";
5
+ import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
6
+ import { serializeFinding } from "./formatters.js";
7
+ import { pluralize } from "../utils/string.js";
8
+ function summaryCounts(results) {
9
+ const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
10
+ for (const r of results) {
11
+ for (const f of r.sorted) {
12
+ const sev = f.severity;
13
+ if (sev in counts)
14
+ counts[sev]++;
15
+ }
16
+ }
17
+ return counts;
18
+ }
19
+ function renderFolderNotices(coverage) {
20
+ if (coverage.length === 0)
21
+ return "";
22
+ const items = coverage.map(n => `<li>${escapeHtml(n)}</li>`).join("\n");
23
+ return `<div class="scan-notes" style="margin:16px 32px 0">
24
+ <button class="scan-notes-toggle" onclick="toggleNotes(this)"><span class="arrow">▶</span> Scan notes (${coverage.length})</button>
25
+ <div class="scan-notes-body"><ul>${items}</ul></div>
26
+ </div>`;
27
+ }
28
+ function renderFolderSection(result, folderIdx, idxOffset, serialized) {
29
+ const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 };
30
+ for (const f of result.sorted) {
31
+ const sev = f.severity;
32
+ if (sev in counts)
33
+ counts[sev]++;
34
+ }
35
+ const severityParts = ["critical", "high", "medium", "low", "unknown"]
36
+ .filter(s => counts[s] > 0)
37
+ .map(s => `${counts[s]} ${s}`)
38
+ .join(", ");
39
+ const summaryText = severityParts || "no findings";
40
+ const isOpen = counts.critical > 0;
41
+ const fi = folderIdx;
42
+ const findingRowsHtml = serialized.map((f, i) => renderFindingRow(f, idxOffset + i)).join("\n");
43
+ const fixPlanHtml = renderFixPlan(result.suggestedFixCommands);
44
+ const noticesHtml = renderFolderNotices(result.coverage);
45
+ const emptyRow = result.sorted.length === 0
46
+ ? `<tr><td colspan="6" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
47
+ : "";
48
+ return `
49
+ <details class="folder-section"${isOpen ? " open" : ""}>
50
+ <summary class="folder-summary">
51
+ <span class="folder-name">${escapeHtml(result.subfolder)}/</span>
52
+ <span class="folder-counts">${escapeHtml(summaryText)}</span>
53
+ </summary>
54
+ <div class="folder-body">
55
+ ${fixPlanHtml}
56
+ ${noticesHtml}
57
+ <div class="findings-section" style="margin:16px 32px 32px">
58
+ <div class="findings-header">
59
+ <h2>Findings</h2>
60
+ <div style="display:flex;align-items:center;gap:8px;flex-wrap:wrap">
61
+ <input class="search-input" type="text" id="findings-search-${fi}" placeholder="Search package, version, CVE…" oninput="applyFilters(${fi})" />
62
+ <div class="filter-bar">
63
+ <button class="filter-btn active" onclick="setFilter('all',this,${fi})">All (${result.sorted.length})</button>
64
+ <button class="filter-btn" onclick="setFilter('critical',this,${fi})">Critical (${counts.critical})</button>
65
+ <button class="filter-btn" onclick="setFilter('high',this,${fi})">High (${counts.high})</button>
66
+ <button class="filter-btn" onclick="setFilter('medium',this,${fi})">Medium (${counts.medium})</button>
67
+ <button class="filter-btn" onclick="setFilter('direct',this,${fi})">Direct only</button>
68
+ </div>
69
+ </div>
70
+ </div>
71
+ <table class="findings-table" id="findings-table-${fi}">
72
+ <thead>
73
+ <tr>
74
+ <th style="width:32px"></th>
75
+ <th onclick="sortBy('package',${fi})">Package <span class="sort-arrow">↕</span></th>
76
+ <th>Fix available</th>
77
+ <th onclick="sortBy('severity',${fi})" class="sorted">Severity <span class="sort-arrow" style="color:#58a6ff">↓</span></th>
78
+ <th onclick="sortBy('relationship',${fi})">Type <span class="sort-arrow">↕</span></th>
79
+ <th>CVE / Advisory</th>
80
+ </tr>
81
+ </thead>
82
+ <tbody id="findings-tbody-${fi}" data-offset="${idxOffset}">
83
+ ${emptyRow}${findingRowsHtml}
84
+ <tr id="no-results-row-${fi}" style="display:none"><td colspan="6" class="no-results">No findings match your search.</td></tr>
85
+ </tbody>
86
+ </table>
87
+ </div>
88
+ </div>
89
+ </details>`;
90
+ }
91
+ export async function writeMultiFolderHtmlReport(params) {
92
+ fs.mkdirSync(params.outputDir, { recursive: true });
93
+ const projectName = path.basename(params.projectPath);
94
+ const scanDate = new Date().toLocaleString();
95
+ const counts = summaryCounts(params.results);
96
+ const totalFindings = params.results.reduce((sum, r) => sum + r.sorted.length, 0);
97
+ const totalCVEs = params.results.reduce((sum, r) => sum + r.sorted.reduce((s, f) => s + f.cveAliases.length, 0), 0);
98
+ const folderCount = params.results.length;
99
+ // Pre-serialize findings once per folder for both HTML rendering and JS filter/sort
100
+ const allSerialized = params.results.map(r => r.sorted.map(f => serializeFinding(f, r.suggestedFixCommands)));
101
+ // Compact per-folder findings for JavaScript (only fields needed for filter/sort/search)
102
+ const folderFindingsJson = JSON.stringify(allSerialized.map(findings => findings.map(f => ({
103
+ package: f.package,
104
+ version: f.version,
105
+ severity: f.severity,
106
+ relationship: f.relationship,
107
+ cves: f.cves,
108
+ vulnerabilities: f.vulnerabilities.map(v => ({ id: v.id })),
109
+ }))))
110
+ .replace(/</g, "\\u003c")
111
+ .replace(/>/g, "\\u003e")
112
+ .replace(/&/g, "\\u0026");
113
+ let idxOffset = 0;
114
+ const folderSectionsHtml = params.results
115
+ .map((r, fi) => {
116
+ const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi]);
117
+ idxOffset += r.sorted.length;
118
+ return html;
119
+ })
120
+ .join("\n");
121
+ // The OWASP SVG inline icon used in the header link
122
+ const owaspSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 261.49332 261.50668" width="16" height="16" style="flex-shrink:0"><g transform="matrix(1.3333333,0,0,-1.3333333,0,261.50667)"><g transform="scale(0.1)"><path fill="#F68B1F" d="M 980.629,0 C 439.043,0 0,439.051 0,980.637 0,1522.22 439.043,1961.27 980.629,1961.27 1522.2,1961.27 1961.25,1522.22 1961.25,980.637 1961.25,439.051 1522.2,0 980.629,0 m -0.008,1810.35 c -458.226,0 -829.707,-371.48 -829.707,-829.705 0,-458.235 371.481,-829.715 829.707,-829.715 458.219,0 829.699,371.48 829.699,829.715 0,458.225 -371.48,829.705 -829.699,829.705"/><path fill="#F68B1F" d="m 1299.1,285.75 c -31.36,0.02 -145.64,203.41 -161,261.398 -32.11,121.411 -25.2,172.704 -23.28,189.102 5.88,50.07 54.46,75.09 57.4,142.801 0.91,20.91 11.47,125.449 19.9,207.109 -20.8,4.07 -41.52,13.45 -59.94,28 55.3,-74.17 -26.09,-163.058 -144.352,-281.332 C 862.305,707.309 583.695,590.809 583.695,590.809 c 0,0 116.508,278.613 242.024,404.132 92.269,92.259 166.636,162.079 230.101,162.079 17.89,0 34.92,-5.55 51.23,-17.7 -14.56,18.41 -23.93,39.12 -28.01,59.92 -81.661,-8.45 -186.208,-18.99 -207.106,-19.91 -67.719,-2.94 -92.743,-51.52 -142.782,-57.39 -5.761,-0.68 -15.828,-1.98 -31.722,-1.98 -29.367,0 -78.629,4.42 -157.387,25.27 -63.07,16.68 -298.078,150.37 -256.512,167.17 21.196,8.58 88.75,14.38 177.715,14.38 85.559,0 190.922,-5.36 293.844,-18.77 128.328,-16.72 246,-37.87 326.19,-53.6 1.3,4.31 2.86,8.5 4.73,12.57 l -81.98,39.29 c 0,0 -65.479,75.14 -58.487,80.32 0.27,0.2 0.613,0.3 1.023,0.3 10.27,0 62.654,-59.89 67.694,-66.71 3.88,-1.29 26.09,-8.7 49.45,-16.47 l -23.19,20.28 c 0,0 -31.74,117.55 -23.47,120.32 0.1,0.03 0.21,0.05 0.33,0.05 8.71,0 37.51,-102.22 39.98,-109.56 5.66,-4.96 24.78,-12.41 48.67,-26.19 l -25.12,64.62 c 0,0 11.37,106.61 19.88,106.61 0.07,0 0.13,-0.01 0.2,-0.02 8.57,-1.71 -1.68,-88.92 -3.85,-99.78 3.11,-4.77 22.38,-34.33 41.7,-63.97 11.89,4.48 24.68,6.69 37.81,6.69 15.07,0 30.57,-2.92 45.61,-8.67 -19.26,41.01 -17.8,83.75 7.74,109.27 8.08,8.1 17.9,13.75 28.84,17.1 1.32,7.46 4.78,14.54 10.45,20.22 7.39,7.38 17.12,11.05 26.97,11.05 10.31,0 20.76,-4.03 28.76,-12.04 7.67,-7.65 11.65,-17.54 11.99,-27.39 12.33,25.41 26.88,59.7 25.86,70.81 -2.37,25.14 -31.53,69.64 -31.8,70.09 -1.9,2.87 -1.11,6.75 1.78,8.66 1.05,0.69 2.24,1.02 3.42,1.02 2.03,0 4.02,-0.99 5.21,-2.82 1.29,-1.92 31.17,-47.54 33.83,-75.79 1.48,-16.16 -17.07,-56.88 -27.18,-77.68 14.2,-7.77 28.04,-18.03 40.68,-30.67 12.63,-12.63 22.89,-26.47 30.67,-40.68 20.01,9.73 58.4,27.26 75.71,27.26 0.69,0 1.35,-0.02 1.97,-0.08 28.24,-2.66 73.87,-32.54 75.78,-33.81 2.88,-1.89 3.68,-5.77 1.78,-8.65 -1.2,-1.82 -3.19,-2.81 -5.22,-2.81 -1.17,0 -2.36,0.33 -3.41,1.03 -0.45,0.29 -44.94,29.44 -70.09,31.79 -0.38,0.04 -0.79,0.05 -1.22,0.05 -12.23,0 -45.07,-13.97 -69.61,-25.89 9.87,-0.33 19.76,-4.33 27.4,-12 15.67,-15.65 16.1,-40.59 0.99,-55.7 -5.67,-5.68 -12.74,-9.17 -20.2,-10.47 -3.37,-10.95 -9.03,-20.77 -17.11,-28.85 -14.08,-14.09 -33.38,-20.84 -54.76,-20.84 -17.38,0 -36.13,4.47 -54.52,13.1 10.77,-28.12 11.59,-57.89 1.99,-83.41 29.62,-19.32 59.22,-38.6 63.96,-41.71 7.78,1.55 54.5,7.22 81.17,7.22 10.66,0 18.13,-0.9 18.61,-3.34 1.73,-8.56 -106.57,-20.12 -106.57,-20.12 l -64.63,25.15 c 13.79,-23.91 21.21,-43.02 26.18,-48.69 7.47,-2.5 112.26,-32.04 109.5,-40.31 -0.31,-0.96 -2.15,-1.37 -5.16,-1.37 -23.1,0 -115.14,24.85 -115.14,24.85 l -20.3,23.19 c 7.79,-23.37 15.18,-45.56 16.49,-49.45 7.1,-5.25 71.57,-61.7 66.4,-68.708 -0.27,-0.363 -0.71,-0.524 -1.32,-0.524 -11.31,0 -78.99,58.992 -78.99,58.992 l -39.3,81.99 c -4.06,-1.88 -8.26,-3.42 -12.58,-4.73 15.73,-80.19 36.89,-197.861 53.63,-326.181 27.34,-209.949 21.19,-429.969 4.39,-471.571 -1.35,-3.347 -3.46,-4.898 -6.2,-4.898"/></g></g></svg>`;
123
+ const html = `<!DOCTYPE html>
124
+ <html lang="en">
125
+ <head>
126
+ <meta charset="UTF-8">
127
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
128
+ <title>CVE Lite — ${escapeHtml(projectName)}</title>
129
+ <style>
130
+ ${REPORT_STYLES}
131
+ .folder-section{margin:0 32px 16px;background:#161b22;border:1px solid #30363d;border-radius:8px;overflow:hidden}
132
+ .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}
133
+ .folder-summary::-webkit-details-marker{display:none}
134
+ .folder-summary::before{content:"▶";font-size:10px;color:#8b949e;transition:transform .15s;flex-shrink:0}
135
+ details[open] .folder-summary::before{transform:rotate(90deg)}
136
+ .folder-name{font-size:13px;font-weight:600;color:#e6edf3;font-family:'SF Mono','Cascadia Code','Fira Code',monospace}
137
+ .folder-counts{font-size:11px;color:#8b949e;margin-left:auto}
138
+ .folder-body{padding:0}
139
+ .folder-body .fix-plan{margin:24px 32px 0}
140
+ </style>
141
+ </head>
142
+ <body>
143
+
144
+ <div class="report-header">
145
+ <div class="header-left">
146
+ <div class="header-logo-pair">
147
+ <img src="${LOGO_BASE64}" alt="CVE Lite" class="header-logo" />
148
+ <span class="header-logo-plus">+</span>
149
+ <a href="https://owasp.org/cve-lite-cli/" target="_blank" rel="noopener" style="display:flex;align-items:center">
150
+ <img src="${OWASP_LOGO_BASE64}" alt="An OWASP Foundation Project" class="header-logo" />
151
+ </a>
152
+ </div>
153
+ <div class="header-divider"></div>
154
+ <div class="header-project">
155
+ <span class="project-name">${escapeHtml(projectName)}</span>
156
+ <span class="project-meta">${folderCount} ${pluralize(folderCount, "folder")} &nbsp;·&nbsp; ${escapeHtml(scanDate)} &nbsp;·&nbsp; CVE Lite ${escapeHtml(params.cliVersion)}</span>
157
+ </div>
158
+ </div>
159
+ <div class="header-right">
160
+ <div class="header-stats">
161
+ <span><strong>${folderCount}</strong> ${pluralize(folderCount, "folder")}</span>
162
+ <span><strong>${totalFindings}</strong> findings</span>
163
+ </div>
164
+ <div class="header-links">
165
+ <a class="header-link owasp-link" href="https://owasp.org/cve-lite-cli/" target="_blank">${owaspSvg} An OWASP Foundation Project</a>
166
+ <a class="header-link" href="https://github.com/OWASP/cve-lite-cli" target="_blank">
167
+ <svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor"><path d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"/></svg>
168
+ GitHub
169
+ </a>
170
+ </div>
171
+ </div>
172
+ </div>
173
+
174
+ <div class="summary-bar">
175
+ <div class="sev-card critical"><span class="count">${counts.critical}</span><span class="label">Critical</span></div>
176
+ <div class="sev-card high"><span class="count">${counts.high}</span><span class="label">High</span></div>
177
+ <div class="sev-card medium"><span class="count">${counts.medium}</span><span class="label">Medium</span></div>
178
+ <div class="sev-card low"><span class="count">${counts.low}</span><span class="label">Low</span></div>
179
+ <div class="sev-card total"><span class="count">${totalFindings}</span><span class="label">Findings</span></div>
180
+ <div class="sev-card total"><span class="count">${totalCVEs}</span><span class="label">CVEs</span></div>
181
+ </div>
182
+
183
+ ${folderSectionsHtml}
184
+
185
+ <div class="report-footer">
186
+ <span>Generated by <strong>cve-lite v${escapeHtml(params.cliVersion)}</strong></span>
187
+ <span>${folderCount} ${pluralize(folderCount, "folder")} &nbsp;·&nbsp; ${totalFindings} findings &nbsp;·&nbsp; ${totalCVEs} CVEs</span>
188
+ </div>
189
+
190
+ <script>
191
+ const SEV_ORDER = {critical:5,high:4,medium:3,low:2,unknown:1,none:0};
192
+ const folderFindings = ${folderFindingsJson};
193
+ const folderState = {};
194
+
195
+ function getFolderState(fi) {
196
+ if (!folderState[fi]) folderState[fi] = { sortCol: 'severity', sortAsc: false, activeFilter: 'all' };
197
+ return folderState[fi];
198
+ }
199
+
200
+ function toggleRow(idx) {
201
+ const detail = document.getElementById('detail-' + idx);
202
+ const mainRow = document.getElementById('row-' + idx);
203
+ const icon = document.getElementById('icon-' + idx);
204
+ if (!detail) return;
205
+ const isVisible = detail.classList.contains('visible');
206
+ detail.classList.toggle('visible', !isVisible);
207
+ mainRow.classList.toggle('is-expanded', !isVisible);
208
+ icon.textContent = isVisible ? '▶' : '▼';
209
+ }
210
+
211
+ function toggleNotes(btn) {
212
+ btn.classList.toggle('open');
213
+ btn.nextElementSibling.classList.toggle('open');
214
+ }
215
+
216
+ // toggleSkipped is called inline by renderFixPlan; actual work is done via event delegation below
217
+ function toggleSkipped() {}
218
+
219
+ function setFilter(filter, btn, fi) {
220
+ const state = getFolderState(fi);
221
+ state.activeFilter = filter;
222
+ const table = document.getElementById('findings-table-' + fi);
223
+ if (table) table.querySelectorAll('.filter-btn').forEach(b => b.classList.remove('active'));
224
+ btn.classList.add('active');
225
+ applyFilters(fi);
226
+ }
227
+
228
+ function applyFilters(fi) {
229
+ const state = getFolderState(fi);
230
+ const searchEl = document.getElementById('findings-search-' + fi);
231
+ const query = searchEl ? (searchEl.value || '').toLowerCase().trim() : '';
232
+ const tbody = document.getElementById('findings-tbody-' + fi);
233
+ if (!tbody) return;
234
+ const offset = parseInt(tbody.dataset.offset || '0', 10);
235
+ const findings = folderFindings[fi] || [];
236
+ let visibleCount = 0;
237
+
238
+ findings.forEach((f, i) => {
239
+ const absIdx = offset + i;
240
+ const mainRow = document.getElementById('row-' + absIdx);
241
+ const detailRow = document.getElementById('detail-' + absIdx);
242
+ let visible = true;
243
+ if (state.activeFilter === 'critical') visible = f.severity === 'critical';
244
+ else if (state.activeFilter === 'high') visible = f.severity === 'high';
245
+ else if (state.activeFilter === 'medium') visible = f.severity === 'medium';
246
+ else if (state.activeFilter === 'direct') visible = f.relationship === 'direct';
247
+ if (visible && query) {
248
+ const ids = [...(f.cves || []), ...(f.vulnerabilities || []).map(v => v.id)].join(' ').toLowerCase();
249
+ visible = f.package.toLowerCase().includes(query) || f.version.toLowerCase().includes(query) || ids.includes(query);
250
+ }
251
+ if (mainRow) mainRow.style.display = visible ? '' : 'none';
252
+ if (detailRow && !visible) {
253
+ detailRow.classList.remove('visible');
254
+ if (mainRow) mainRow.classList.remove('is-expanded');
255
+ const icon = document.getElementById('icon-' + absIdx);
256
+ if (icon) icon.textContent = '▶';
257
+ }
258
+ if (visible) visibleCount++;
259
+ });
260
+ const noResults = document.getElementById('no-results-row-' + fi);
261
+ if (noResults) noResults.style.display = visibleCount === 0 ? '' : 'none';
262
+ }
263
+
264
+ function sortBy(col, fi) {
265
+ const state = getFolderState(fi);
266
+ if (state.sortCol === col) { state.sortAsc = !state.sortAsc; } else { state.sortCol = col; state.sortAsc = col === 'package'; }
267
+
268
+ const table = document.getElementById('findings-table-' + fi);
269
+ if (table) {
270
+ table.querySelectorAll('thead th').forEach(th => th.classList.remove('sorted'));
271
+ const colIndex = ['', 'package', '', 'severity', 'relationship'].indexOf(col);
272
+ if (colIndex > 0) table.querySelectorAll('thead th')[colIndex].classList.add('sorted');
273
+ }
274
+
275
+ const tbody = document.getElementById('findings-tbody-' + fi);
276
+ if (!tbody) return;
277
+ const offset = parseInt(tbody.dataset.offset || '0', 10);
278
+ const findings = folderFindings[fi] || [];
279
+ const indexed = findings.map((f, i) => ({ f, absIdx: offset + i }));
280
+ indexed.sort((a, b) => {
281
+ let cmp = 0;
282
+ if (col === 'package') cmp = a.f.package.localeCompare(b.f.package);
283
+ else if (col === 'severity') cmp = (SEV_ORDER[b.f.severity] || 0) - (SEV_ORDER[a.f.severity] || 0);
284
+ else if (col === 'relationship') cmp = a.f.relationship.localeCompare(b.f.relationship);
285
+ return state.sortAsc ? -cmp : cmp;
286
+ });
287
+ indexed.forEach(({ absIdx }) => {
288
+ const mainRow = document.getElementById('row-' + absIdx);
289
+ const detailRow = document.getElementById('detail-' + absIdx);
290
+ if (mainRow) tbody.appendChild(mainRow);
291
+ if (detailRow) tbody.appendChild(detailRow);
292
+ });
293
+ const noResults = document.getElementById('no-results-row-' + fi);
294
+ if (noResults) tbody.appendChild(noResults);
295
+ }
296
+
297
+ document.addEventListener('click', function(e) {
298
+ // Per-folder skipped section toggle (renderFixPlan uses a shared onclick="toggleSkipped()")
299
+ if (e.target.classList.contains('skipped-toggle')) {
300
+ const fixPlan = e.target.closest('.fix-plan');
301
+ const section = fixPlan ? fixPlan.querySelector('.skipped-section') : null;
302
+ if (!section) return;
303
+ const isOpen = section.classList.toggle('open');
304
+ (fixPlan || document).querySelectorAll('.skipped-toggle').forEach(btn => {
305
+ btn.textContent = (isOpen ? '↑' : '↓') + btn.textContent.slice(1);
306
+ });
307
+ return;
308
+ }
309
+ const btn = e.target.closest('.copy-btn');
310
+ if (btn && btn.dataset.cmd !== undefined) {
311
+ e.stopPropagation();
312
+ navigator.clipboard.writeText(btn.dataset.cmd).catch(() => {});
313
+ }
314
+ });
315
+ </script>
316
+ </body>
317
+ </html>`;
318
+ const indexPath = path.join(params.outputDir, "index.html");
319
+ fs.writeFileSync(indexPath, html, "utf8");
320
+ if (params.autoOpen)
321
+ openInBrowser(indexPath);
322
+ return { reportPath: indexPath };
323
+ }
@@ -0,0 +1,46 @@
1
+ import { chalk } from "../utils/chalk.js";
2
+ import { logInfo, logWarn } from "./formatters.js";
3
+ import { printCompactOutput, printSummary, printActionSummary, printSuggestedFixCommands, printSuggestedFixCommandSkips, printCoverage, printSkippedDependencies, printTable, printFinalStatus, } from "./printers.js";
4
+ import { pluralize } from "../utils/string.js";
5
+ export function printMultiFolderResults(results, options) {
6
+ const offline = !!options.offline || !!options.offlineDb;
7
+ for (let i = 0; i < results.length; i++) {
8
+ const result = results[i];
9
+ console.log(`\n${chalk.bold(`📁 ${result.subfolder}/`)}`);
10
+ console.log(chalk.gray("─".repeat(50)));
11
+ if (result.scanInput.warnings.length > 0) {
12
+ for (const warning of result.scanInput.warnings) {
13
+ logWarn(warning, options);
14
+ }
15
+ }
16
+ if (options.verbose) {
17
+ printSummary(result.sorted, result.allPackages.length, result.scanInput);
18
+ printActionSummary(result.sorted);
19
+ printSuggestedFixCommands(result.sorted, result.scanInput, { offline, subfolder: result.subfolder });
20
+ printSuggestedFixCommandSkips(result.sorted, result.scanInput, { offline, subfolder: result.subfolder });
21
+ if (result.scanInput.skippedDependencies.length > 0) {
22
+ printSkippedDependencies(result.scanInput.skippedDependencies);
23
+ }
24
+ if (result.sorted.length > 0) {
25
+ if (result.tableFindings.length > 0) {
26
+ printTable(result.tableFindings, options.all ? null : result.minSeverity);
27
+ }
28
+ else {
29
+ logInfo(`No findings met the table threshold of ${result.minSeverity}. Re-run with --all to show everything.`, options);
30
+ }
31
+ }
32
+ printCoverage([...result.scanInput.notes, ...result.coverage]);
33
+ printFinalStatus(result.sorted);
34
+ }
35
+ else {
36
+ printCompactOutput(result.sorted, result.scanInput, { offline, all: !!options.all, subfolder: result.subfolder });
37
+ }
38
+ if (i < results.length - 1) {
39
+ console.log(chalk.gray("\n" + "─".repeat(50)));
40
+ }
41
+ }
42
+ const totalFindings = results.reduce((sum, r) => sum + r.sorted.length, 0);
43
+ const folderNames = results.map(r => `${r.subfolder}/`).join(", ");
44
+ console.log(chalk.gray(`\nScanned ${results.length} ${pluralize(results.length, "folder")}: ${folderNames}`));
45
+ console.log(chalk.gray(`${totalFindings} total ${pluralize(totalFindings, "finding")} across all folders`));
46
+ }
@@ -4,6 +4,7 @@ import { isMajorVersionBump } from "../utils/version.js";
4
4
  import { getPrimaryParent } from "../utils/finding.js";
5
5
  import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel } from "./formatters.js";
6
6
  import { pluralize } from "../utils/string.js";
7
+ import { selectFindingsForCompact } from "./finding-display.js";
7
8
  export function printSummary(findings, packageCount, scanInput) {
8
9
  if (findings.length === 0) {
9
10
  if (scanInput.mode === "manifest-fallback") {
@@ -283,10 +284,9 @@ export function printCompactOutput(findings, scanInput, options) {
283
284
  console.log("────────────────────────────────");
284
285
  console.log(chalk.bold("📦 Vulnerabilities found"));
285
286
  console.log("────────────────────────────────\n");
286
- // Get top 3 critical/high issues plus all unknown (malicious) findings
287
- const urgentFindings = findings
288
- .filter(f => f.severity === "critical" || f.severity === "high" || f.severity === "unknown")
289
- .slice(0, 3);
287
+ // Reuse shared display selection logic so compact mode does not silently
288
+ // drop direct unknown-severity findings.
289
+ const urgentFindings = selectFindingsForCompact(findings, { urgentLimit: 3 });
290
290
  for (const finding of urgentFindings) {
291
291
  const sevLabel = finding.severity.toUpperCase().padEnd(8);
292
292
  const typeLabel = finding.relationship === "direct"
@@ -1,6 +1,5 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
4
3
  import { getRecommendedAction } from "./formatters.js";
5
4
  import { getCliVersion } from "../utils/version-info.js";
6
5
  import { severityToSarifLevel } from "../utils/severity.js";
@@ -19,13 +18,12 @@ export function deriveLockfileUri(scanInput) {
19
18
  return path.basename(scanInput.filePath);
20
19
  return LOCKFILE_NAMES[scanInput.source] ?? "lockfile";
21
20
  }
22
- export function buildSarifOutput(findings, lockfileUri, version, plan) {
21
+ export function buildSarifOutput(findings, lockfileUri, version, _plan) {
23
22
  const ruleMap = new Map();
24
23
  const results = [];
25
24
  for (const finding of findings) {
26
25
  const level = severityToSarifLevel(finding.severity);
27
26
  const action = getRecommendedAction(finding);
28
- const runnableFixCommand = plan ? findSuggestedCommandForFinding(plan, finding) : null;
29
27
  const location = {
30
28
  physicalLocation: {
31
29
  artifactLocation: { uri: lockfileUri, uriBaseId: "%SRCROOT%" },
@@ -47,18 +45,14 @@ export function buildSarifOutput(findings, lockfileUri, version, plan) {
47
45
  properties: { tags: ["security", "dependency"] },
48
46
  });
49
47
  }
50
- const result = {
48
+ results.push({
51
49
  ruleId,
52
50
  level,
53
51
  message: {
54
52
  text: `${finding.pkg.name}@${finding.pkg.version} is vulnerable (${finding.severity}). ${action}`,
55
53
  },
56
54
  locations: [location],
57
- };
58
- if (runnableFixCommand) {
59
- result.fixes = [{ description: { text: runnableFixCommand }, artifactChanges: [] }];
60
- }
61
- results.push(result);
55
+ });
62
56
  }
63
57
  }
64
58
  return {
@@ -1,7 +1,7 @@
1
1
  import process from "node:process";
2
2
  import { chalk } from "../utils/chalk.js";
3
3
  export function createSpinner(initialMessage, options) {
4
- const enabled = Boolean(process.stdout.isTTY);
4
+ const enabled = Boolean(process.stdout.isTTY) && !options?.json;
5
5
  if (!enabled) {
6
6
  return {
7
7
  update: () => { },