cve-lite-cli 1.18.2 → 1.19.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.
package/dist/index.js CHANGED
@@ -29,6 +29,8 @@ import { readConfig, validateCaCertFile } from "./cli/config.js";
29
29
  import { runConfigCommand } from "./cli/config-command.js";
30
30
  import { readDirectDependencyNames } from "./utils/package-json.js";
31
31
  import { applyFixesIfRequested, printFixModeSummary, } from "./utils/fix-runner.js";
32
+ import { hasRootLockfile, findNestedLockfiles } from "./parsers/multi-package.js";
33
+ import { handleMultiFolderScan } from "./scan/multi-folder-scan.js";
32
34
  let parsedArgs = null;
33
35
  try {
34
36
  parsedArgs = parseArgs(process.argv.slice(2));
@@ -133,6 +135,13 @@ if (parsedArgs) {
133
135
  return;
134
136
  }
135
137
  validateOptions(options);
138
+ // Multi-folder mode: if no root lockfile and 2+ nested lockfiles exist,
139
+ // route to dedicated multi-folder handler instead of single-lockfile scan
140
+ const nestedLockfiles = findNestedLockfiles(projectPath, searchDepth);
141
+ if (!hasRootLockfile(projectPath) && nestedLockfiles.length >= 2) {
142
+ await handleMultiFolderScan({ projectRoot: projectPath, batchSize, options });
143
+ return;
144
+ }
136
145
  let advisorySourceLine;
137
146
  let advisoryDbFreshnessLine = null;
138
147
  let advisoryDbWarning = null;
@@ -204,6 +213,8 @@ if (parsedArgs) {
204
213
  process.exit(0);
205
214
  return;
206
215
  }
216
+ if (!options.json)
217
+ console.log();
207
218
  let scanState = await scanProject({
208
219
  scanInput,
209
220
  batchSize,
@@ -20,33 +20,7 @@ export function buildReportData(params) {
20
20
  warnings: params.warnings,
21
21
  };
22
22
  }
23
- export function renderHtmlReport(data) {
24
- const projectName = path.basename(data.projectPath);
25
- const scanDate = new Date(data.scannedAt).toLocaleString();
26
- const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
27
- for (const f of data.findings) {
28
- const sev = f.severity;
29
- if (sev in counts)
30
- counts[sev]++;
31
- }
32
- const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
33
- const noticesHtml = renderNotices(data.notes, data.warnings);
34
- const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
35
- const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
36
- const dataJson = JSON.stringify(data)
37
- .replace(/</g, "\\u003c")
38
- .replace(/>/g, "\\u003e")
39
- .replace(/&/g, "\\u0026")
40
- .replace(/\u2028/g, "\\u2028")
41
- .replace(/\u2029/g, "\\u2029");
42
- return `<!DOCTYPE html>
43
- <html lang="en">
44
- <head>
45
- <meta charset="UTF-8">
46
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
47
- <title>CVE Lite — ${escapeHtml(projectName)}</title>
48
- <style>
49
- *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
23
+ export const REPORT_STYLES = `*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
50
24
  body{background:#0d1117;color:#e6edf3;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;font-size:14px;line-height:1.5}
51
25
  .report-header{background:#161b22;border-bottom:1px solid #30363d;padding:14px 32px;display:flex;align-items:center;justify-content:space-between;gap:24px}
52
26
  .header-left{display:flex;align-items:center;gap:20px}
@@ -169,7 +143,34 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
169
143
  .break-badge{font-size:10px;font-weight:700;background:#fb850022;color:#fb8500;border:1px solid #fb850066;border-radius:4px;padding:1px 5px}
170
144
  .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}
171
145
  .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}
172
- .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}
146
+ .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}`;
147
+ export function renderHtmlReport(data) {
148
+ const projectName = path.basename(data.projectPath);
149
+ const scanDate = new Date(data.scannedAt).toLocaleString();
150
+ const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
151
+ for (const f of data.findings) {
152
+ const sev = f.severity;
153
+ if (sev in counts)
154
+ counts[sev]++;
155
+ }
156
+ const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
157
+ const noticesHtml = renderNotices(data.notes, data.warnings);
158
+ const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
159
+ const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
160
+ const dataJson = JSON.stringify(data)
161
+ .replace(/</g, "\\u003c")
162
+ .replace(/>/g, "\\u003e")
163
+ .replace(/&/g, "\\u0026")
164
+ .replace(/\u2028/g, "\\u2028")
165
+ .replace(/\u2029/g, "\\u2029");
166
+ return `<!DOCTYPE html>
167
+ <html lang="en">
168
+ <head>
169
+ <meta charset="UTF-8">
170
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
171
+ <title>CVE Lite — ${escapeHtml(projectName)}</title>
172
+ <style>
173
+ ${REPORT_STYLES}
173
174
  </style>
174
175
  </head>
175
176
  <body>
@@ -374,7 +375,7 @@ document.addEventListener('click', function(e) {
374
375
  </body>
375
376
  </html>`;
376
377
  }
377
- function escapeHtml(str) {
378
+ export function escapeHtml(str) {
378
379
  return str
379
380
  .replace(/&/g, "&amp;")
380
381
  .replace(/</g, "&lt;")
@@ -387,7 +388,7 @@ function advisoryLink(id) {
387
388
  }
388
389
  return `<a class="cve-link" href="https://osv.dev/vulnerability/${escapeHtml(id)}" target="_blank">${escapeHtml(id)}</a>`;
389
390
  }
390
- function renderFindingRow(finding, idx) {
391
+ export function renderFindingRow(finding, idx) {
391
392
  const cveLinks = finding.cves.length > 0
392
393
  ? finding.cves.map(advisoryLink).join(", ")
393
394
  : finding.vulnerabilities.map(v => advisoryLink(v.id)).join(", ");
@@ -484,7 +485,7 @@ function renderNotices(notes, warnings) {
484
485
  <div class="scan-notes-body"><ul>${items}</ul></div>
485
486
  </div>`;
486
487
  }
487
- function renderFixPlan(plan) {
488
+ export function renderFixPlan(plan) {
488
489
  if (!plan || plan.sections.length === 0)
489
490
  return "";
490
491
  const directCount = plan.targets.filter(t => t.kind === "direct").length;
@@ -556,7 +557,7 @@ export async function writeHtmlReport(params) {
556
557
  }
557
558
  return { reportPath: indexPath };
558
559
  }
559
- function openInBrowser(filePath) {
560
+ export function openInBrowser(filePath) {
560
561
  if (!path.isAbsolute(filePath))
561
562
  return;
562
563
  const cmd = process.platform === "darwin"
@@ -309,6 +309,14 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
309
309
  totalFindingCount: findings.length,
310
310
  };
311
311
  plan.coveredFindingCount = findings.filter(f => findSuggestedCommandForFinding(plan, f) !== null).length;
312
+ if (options?.subfolder) {
313
+ const prefix = `cd ${options.subfolder} && `;
314
+ if (plan.command)
315
+ plan.command = prefix + plan.command;
316
+ for (const section of plan.sections) {
317
+ section.command = prefix + section.command;
318
+ }
319
+ }
312
320
  return plan;
313
321
  }
314
322
  function inferPackageManager(scanInput) {
@@ -8,7 +8,8 @@ const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
8
8
  const BOX_INNER_WIDTH = 50;
9
9
  export function isNewer(latest, current) {
10
10
  const parse = (v) => {
11
- const parts = v.replace(/^v/, "").split(".").map(Number);
11
+ const core = v.replace(/^v/, "").split("-")[0];
12
+ const parts = core.split(".").map(Number);
12
13
  return parts.length === 3 && parts.every(n => !isNaN(n)) ? parts : [];
13
14
  };
14
15
  const l = parse(latest);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.18.2",
3
+ "version": "1.19.0",
4
4
  "description": "Developer-friendly CLI for scanning JS/TS projects for dependency vulnerabilities using local lockfiles and OSV",
5
5
  "type": "module",
6
6
  "bin": {