cve-lite-cli 1.21.0 → 1.23.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/README.md CHANGED
@@ -173,7 +173,7 @@ CVE Lite CLI fits at every stage of the development workflow, not just CI.
173
173
 
174
174
  CVE Lite CLI scans its own dependencies in CI. See [`self-scan.yml`](https://github.com/OWASP/cve-lite-cli/blob/main/.github/workflows/self-scan.yml).
175
175
 
176
- For full CI patterns including offline workflows, git hooks, and scripted automation, see the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration).
176
+ For full CI patterns including offline workflows, git hooks, and scripted automation, see the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/workflow-integration).
177
177
 
178
178
  ## How it compares
179
179
 
@@ -187,9 +187,13 @@ No other free tool combines all of the following: lockfile scanning across npm,
187
187
  | Free to use | ✅ | ✅ | ✅ | ❌ | ❌ |
188
188
  | Usage-aware reachability scanning | ✅ | ❌ | ❌ | ✅ | ⚠️ |
189
189
  | Direct vs transitive visibility | ✅ | ⚠️ | ✅ | ✅ | ✅ |
190
+ | Dev vs runtime dependency labelling | ✅ | ⚠️ | ❌ | ⚠️ | ❌ |
190
191
  | Copy-and-run fix commands | ✅ | ❌ | ❌ | ✅ | ⚠️ |
191
192
  | Transitive parent update guidance | ✅ | ❌ | ⚠️ | ⚠️ | ⚠️ |
192
193
  | Suggested remediation plan | ✅ | ❌ | ⚠️ | ✅ | ⚠️ |
194
+ | Ratcheting mode (baseline suppression) | ✅ | ❌ | ❌ | ⚠️ | ❌ |
195
+ | Interactive HTML report | ✅ | ❌ | ❌ | ✅ | ❌ |
196
+ | SARIF / GitHub Code Scanning output | ✅ | ❌ | ✅ | ✅ | ❌ |
193
197
  | JSON output | ✅ | ✅ | ✅ | ✅ | ✅ |
194
198
  | Offline/local advisory DB | ✅ | ❌ | ⚠️ | ❌ | ❌ |
195
199
 
@@ -428,7 +432,7 @@ It is a good fit for:
428
432
  - **Enterprise teams with restricted networks** — offline advisory DB removes the need for runtime outbound calls during scans
429
433
  - **Teams running npm, pnpm, Yarn, and Bun** — unified scanning across all four package managers in one tool
430
434
 
431
- See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration) for concrete patterns across these scenarios.
435
+ See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/workflow-integration) for concrete patterns across these scenarios.
432
436
 
433
437
  Using CVE Lite CLI at your company or in your projects? [Share your use case in the community thread](https://github.com/OWASP/cve-lite-cli/discussions/481) - we'd love to hear about it.
434
438
 
@@ -110,13 +110,8 @@ export async function syncOsvAdvisories(options = {}) {
110
110
  return { advisoryCount, dbPath, sourceUrl };
111
111
  }
112
112
  catch (error) {
113
- try {
114
- db.close();
115
- }
116
- finally {
117
- if (fs.existsSync(dbPath)) {
118
- fs.rmSync(dbPath, { force: true });
119
- }
113
+ if (fs.existsSync(dbPath)) {
114
+ fs.rmSync(dbPath, { force: true });
120
115
  }
121
116
  throw error;
122
117
  }
package/dist/constants.js CHANGED
@@ -12,6 +12,12 @@ export const NPM_PUBLIC_REGISTRY = "https://registry.npmjs.org/";
12
12
  export const MAL_PRIVATE_REGISTRY_MESSAGE = "This package has a MAL- advisory but resolved from a private registry - unverifiable whether this advisory applies to your artifact. Inspect the source manually.";
13
13
  export const MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE = "MAL- advisory could not be confirmed for this artifact.";
14
14
  export const MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE = "verify artifact source manually";
15
+ export const MAL_GIT_SOURCE_PINNED_MESSAGE = "Advisory targets registry packages. This package resolves from a git source pinned to a commit SHA — verify the repository and org are trusted.";
16
+ export const MAL_GIT_SOURCE_FLOATING_MESSAGE = "Advisory targets registry packages. This package resolves from a git source with a floating reference — verify the repository, org, and ref are safe.";
17
+ export const MAL_GIT_SOURCE_COMPACT_MESSAGE = "Git source — verify repository and org are trusted.";
18
+ export const MAL_GIT_SOURCE_LEGEND_MESSAGE = "verify repository and org are trusted";
19
+ export const MAL_GIT_SOURCE_PINNED_DISPLAY = "⚠ Git source (SHA-pinned)";
20
+ export const MAL_GIT_SOURCE_FLOATING_DISPLAY = "⚠ Git source (floating ref)";
15
21
  export const EXCLUDED_DIRS = new Set([
16
22
  ".git",
17
23
  "node_modules",
@@ -83,6 +83,15 @@ export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
83
83
  const filename = `cve-lite-scan-${ts}.cdx.json`;
84
84
  const outputPath = path.join(process.cwd(), filename);
85
85
  const bom = buildCycloneDxBom(allPackages, findings, projectMeta, getCliVersion(), plan);
86
- fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
86
+ try {
87
+ fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
88
+ }
89
+ catch (err) {
90
+ try {
91
+ fs.rmSync(outputPath, { force: true });
92
+ }
93
+ catch { }
94
+ throw new Error(`Failed to write CycloneDX report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
95
+ }
87
96
  return filename;
88
97
  }
@@ -1,6 +1,6 @@
1
1
  import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
2
2
  import { chalk } from "../utils/chalk.js";
3
- import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE } from "../constants.js";
3
+ import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, } from "../constants.js";
4
4
  import { loadCache } from "../osv/cache.js";
5
5
  import { inferSeverity } from "../osv/severity.js";
6
6
  import { getPrimaryParent } from "../utils/finding.js";
@@ -27,6 +27,10 @@ export function formatRelationshipLabel(value) {
27
27
  return chalk.yellow(value);
28
28
  return chalk.gray(value);
29
29
  }
30
+ export function formatRelLabel(finding) {
31
+ const base = finding.relationship;
32
+ return finding.pkg.dev === true ? `${base} · dev` : base;
33
+ }
30
34
  export function formatAdvisorySourceLine(sourceLabel) {
31
35
  const match = sourceLabel.match(/^(.*) \((.*)\)$/);
32
36
  if (!match) {
@@ -87,6 +91,14 @@ export function getRecommendedAction(finding) {
87
91
  return `No parent dependency was identified for ${finding.pkg.name} in the lockfile. Run \`npm ls ${finding.pkg.name}\` (or your package manager equivalent) to find which package pulls it in.`;
88
92
  }
89
93
  export function summarizeRisk(finding) {
94
+ if (finding.maliciousUnverifiable) {
95
+ return MAL_PRIVATE_REGISTRY_MESSAGE;
96
+ }
97
+ if (finding.maliciousGitSource) {
98
+ return finding.maliciousGitSourcePinned
99
+ ? MAL_GIT_SOURCE_PINNED_MESSAGE
100
+ : MAL_GIT_SOURCE_FLOATING_MESSAGE;
101
+ }
90
102
  let risk = "";
91
103
  if (finding.severity === "critical" && finding.relationship === "direct") {
92
104
  risk = "Critical direct dependency. Prioritize this first because the project controls it directly.";
@@ -187,6 +199,7 @@ export function serializeFinding(finding, plan) {
187
199
  version: finding.pkg.version,
188
200
  severity: finding.severity,
189
201
  relationship: finding.relationship,
202
+ dev: finding.pkg.dev ?? false,
190
203
  firstFixedVersion: finding.firstFixedVersion,
191
204
  validatedFirstFixedVersion: finding.validatedFirstFixedVersion ?? null,
192
205
  fixVersionValidationNote: finding.fixVersionValidationNote ?? null,
@@ -201,6 +214,8 @@ export function serializeFinding(finding, plan) {
201
214
  dependencyPaths: finding.dependencyPaths,
202
215
  usage: finding.usage ?? null,
203
216
  maliciousUnverifiable: finding.maliciousUnverifiable ?? false,
217
+ maliciousGitSource: finding.maliciousGitSource ?? false,
218
+ maliciousGitSourcePinned: finding.maliciousGitSourcePinned ?? false,
204
219
  vulnerabilities: finding.vulnerabilities.map(v => ({
205
220
  id: v.id,
206
221
  aliases: v.aliases ?? [],
@@ -1,11 +1,19 @@
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 } from "./formatters.js";
4
+ import { serializeFinding, summarizeNextAction, summarizeRisk } from "./formatters.js";
5
5
  import { LOGO_BASE64 } from "./logo-base64.js";
6
6
  import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
7
7
  import { isMajorVersionBump } from "../utils/version.js";
8
8
  import { pluralize } from "../utils/string.js";
9
+ import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY } from "../constants.js";
10
+ export function serializeHtmlFinding(finding, plan) {
11
+ return {
12
+ ...serializeFinding(finding, plan),
13
+ riskSummary: summarizeRisk(finding),
14
+ nextAction: summarizeNextAction(finding),
15
+ };
16
+ }
9
17
  export function buildReportData(params) {
10
18
  return {
11
19
  projectPath: params.projectPath,
@@ -14,7 +22,7 @@ export function buildReportData(params) {
14
22
  packageManager: params.packageManager,
15
23
  lockfileSource: params.lockfileSource,
16
24
  packageCount: params.packageCount,
17
- findings: params.findings.map(finding => serializeFinding(finding, params.suggestedFixCommands)),
25
+ findings: params.findings.map(finding => serializeHtmlFinding(finding, params.suggestedFixCommands)),
18
26
  suggestedFixCommands: params.suggestedFixCommands,
19
27
  notes: params.notes,
20
28
  warnings: params.warnings,
@@ -98,10 +106,12 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
98
106
  .sev-badge.low{background:#388bfd22;color:#388bfd;border:1px solid #388bfd66}
99
107
  .sev-badge.unknown{background:#8b949e22;color:#8b949e;border:1px solid #8b949e66}
100
108
  .badge-warning{display:inline-block;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;padding:2px 8px;border-radius:4px;background:#e3b34122;color:#e3b341;border:1px solid #e3b34166}
109
+ .badge-git-source{background:#fb8c0022;color:#fb8c00;border:1px solid #fb8c0055;border-radius:4px;font-size:11px;padding:2px 6px}
101
110
  .rel-badge{font-size:11px;padding:2px 7px;border-radius:4px}
102
111
  .rel-badge.direct{color:#3fb950;background:#3fb95022}
103
112
  .rel-badge.transitive{color:#e3b341;background:#e3b34122}
104
113
  .rel-badge.unknown{color:#8b949e;background:#8b949e22}
114
+ .rel-badge.dev{color:#a371f7;background:#6e40c922;border:1px solid #6e40c955}
105
115
  .cve-link{font-size:11px;color:#58a6ff;font-family:monospace;text-decoration:none;border-bottom:1px dotted #58a6ff66}
106
116
  .cve-link:hover{color:#79c0ff}
107
117
  .fix-hint{font-size:11px;color:#3fb950;font-family:monospace}
@@ -114,6 +124,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
114
124
  .expanded-inner{padding:16px 20px 20px 48px;display:flex;gap:32px}
115
125
  .detail-col{flex:1}
116
126
  .detail-col h4{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:#8b949e;margin-bottom:8px}
127
+ .detail-col h4.detail-subheading{margin-top:14px}
117
128
  .detail-col p{font-size:12px;color:#8b949e;line-height:1.6}
118
129
  .dep-path{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
119
130
  .dep-node{font-size:11px;font-family:monospace;background:#161b22;border:1px solid #30363d;border-radius:4px;padding:2px 8px;color:#e6edf3}
@@ -394,6 +405,12 @@ function advisoryLink(id) {
394
405
  }
395
406
  return `<a class="cve-link" href="https://osv.dev/vulnerability/${escapeHtml(id)}" target="_blank">${escapeHtml(id)}</a>`;
396
407
  }
408
+ function renderRelBadge(finding) {
409
+ if (finding.dev) {
410
+ return `<span class="rel-badge dev">${escapeHtml(finding.relationship)} · dev</span>`;
411
+ }
412
+ return `<span class="rel-badge ${escapeHtml(finding.relationship)}">${escapeHtml(finding.relationship)}</span>`;
413
+ }
397
414
  export function renderFindingRow(finding, idx, skippedKeys) {
398
415
  const cveLinks = finding.cves.length > 0
399
416
  ? finding.cves.map(advisoryLink).join(", ")
@@ -407,9 +424,13 @@ export function renderFindingRow(finding, idx, skippedKeys) {
407
424
  ? `<span class="fix-hint">${escapeHtml(fixVersion)}</span>`
408
425
  : isMalicious && finding.maliciousUnverifiable
409
426
  ? `<span class="badge badge-warning" title="MAL- advisory found but package resolved from a private registry - may not apply to your artifact">Unverifiable (private source)</span>`
410
- : isMalicious
411
- ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
412
- : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
427
+ : isMalicious && finding.maliciousGitSource && finding.maliciousGitSourcePinned
428
+ ? `<span class="badge badge-git-source" title="MAL- advisory found but package resolves from a git source pinned to a commit SHA — verify the repository and org are trusted">${escapeHtml(MAL_GIT_SOURCE_PINNED_DISPLAY)}</span>`
429
+ : isMalicious && finding.maliciousGitSource
430
+ ? `<span class="badge badge-git-source" title="MAL- advisory found but package resolves from a git source with a floating reference — verify the repository, org, and ref are safe">${escapeHtml(MAL_GIT_SOURCE_FLOATING_DISPLAY)}</span>`
431
+ : isMalicious
432
+ ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
433
+ : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
413
434
  const depPathHtml = finding.dependencyPaths.length > 0
414
435
  ? finding.dependencyPaths[0].map((node, i, arr) => {
415
436
  const isLast = i === arr.length - 1;
@@ -432,7 +453,7 @@ export function renderFindingRow(finding, idx, skippedKeys) {
432
453
  <td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
433
454
  <td>${fixHtml}</td>
434
455
  <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
435
- <td><span class="rel-badge ${escapeHtml(finding.relationship)}">${escapeHtml(finding.relationship)}</span></td>
456
+ <td>${renderRelBadge(finding)}</td>
436
457
  <td>${cveLinks}</td>
437
458
  </tr>
438
459
  <tr id="detail-${idx}" class="detail-row">
@@ -450,6 +471,10 @@ export function renderFindingRow(finding, idx, skippedKeys) {
450
471
  <div class="detail-col">
451
472
  <h4>Recommended action</h4>
452
473
  ${recommendedActionHtml}
474
+ <h4 class="detail-subheading">Risk summary</h4>
475
+ <p>${escapeHtml(finding.riskSummary)}</p>
476
+ <h4 class="detail-subheading">Next action</h4>
477
+ <p>${escapeHtml(finding.nextAction)}</p>
453
478
  </div>
454
479
  </div>
455
480
  </td>
@@ -566,11 +591,28 @@ export function renderFixPlan(plan) {
566
591
  </div>`;
567
592
  }
568
593
  export async function writeHtmlReport(params) {
569
- fs.mkdirSync(params.outputDir, { recursive: true });
594
+ const dirExisted = fs.existsSync(params.outputDir);
595
+ try {
596
+ fs.mkdirSync(params.outputDir, { recursive: true });
597
+ }
598
+ catch (err) {
599
+ throw new Error(`Failed to create report directory ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
600
+ }
570
601
  const indexPath = path.join(params.outputDir, "index.html");
571
602
  const jsonPath = path.join(params.outputDir, "report.json");
572
- fs.writeFileSync(jsonPath, JSON.stringify(params.data, null, 2), "utf8");
573
- fs.writeFileSync(indexPath, renderHtmlReport(params.data), "utf8");
603
+ try {
604
+ fs.writeFileSync(jsonPath, JSON.stringify(params.data, null, 2), "utf8");
605
+ fs.writeFileSync(indexPath, renderHtmlReport(params.data), "utf8");
606
+ }
607
+ catch (err) {
608
+ if (!dirExisted) {
609
+ try {
610
+ fs.rmSync(params.outputDir, { recursive: true, force: true });
611
+ }
612
+ catch { }
613
+ }
614
+ throw new Error(`Failed to write HTML report to ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
615
+ }
574
616
  if (params.autoOpen) {
575
617
  openInBrowser(indexPath);
576
618
  }
@@ -1,9 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { REPORT_STYLES, escapeHtml, renderFindingRow, renderFixPlan, openInBrowser } from "./html-reporter.js";
3
+ import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, serializeHtmlFinding, } from "./html-reporter.js";
4
4
  import { LOGO_BASE64 } from "./logo-base64.js";
5
5
  import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
6
- import { serializeFinding } from "./formatters.js";
7
6
  import { pluralize } from "../utils/string.js";
8
7
  function summaryCounts(results) {
9
8
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
@@ -97,7 +96,7 @@ export async function writeMultiFolderHtmlReport(params) {
97
96
  const totalCVEs = params.results.reduce((sum, r) => sum + r.sorted.reduce((s, f) => s + f.cveAliases.length, 0), 0);
98
97
  const folderCount = params.results.length;
99
98
  // 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)));
99
+ const allSerialized = params.results.map(r => r.sorted.map(f => serializeHtmlFinding(f, r.suggestedFixCommands)));
101
100
  // Compact per-folder findings for JavaScript (only fields needed for filter/sort/search)
102
101
  const folderFindingsJson = JSON.stringify(allSerialized.map(findings => findings.map(f => ({
103
102
  package: f.package,
@@ -2,10 +2,10 @@ 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 } from "./formatters.js";
5
+ import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel, formatRelLabel } from "./formatters.js";
6
6
  import { pluralize } from "../utils/string.js";
7
7
  import { selectFindingsForCompact } from "./finding-display.js";
8
- import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE } from "../constants.js";
8
+ 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";
9
9
  export function printSummary(findings, packageCount, scanInput) {
10
10
  if (findings.length === 0) {
11
11
  if (scanInput.mode === "manifest-fallback") {
@@ -168,6 +168,9 @@ export function printTable(findings, threshold, skippedKeys) {
168
168
  else if (f.maliciousUnverifiable) {
169
169
  fixedDisplay = chalk.yellow("⚠ Unverifiable (private source)");
170
170
  }
171
+ else if (f.maliciousGitSource) {
172
+ fixedDisplay = chalk.yellow(f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_DISPLAY : MAL_GIT_SOURCE_FLOATING_DISPLAY);
173
+ }
171
174
  else if (f.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
172
175
  fixedDisplay = chalk.yellow("⚠ Malicious");
173
176
  }
@@ -178,7 +181,7 @@ export function printTable(findings, threshold, skippedKeys) {
178
181
  f.pkg.name,
179
182
  f.pkg.version,
180
183
  f.severity,
181
- f.relationship,
184
+ formatRelLabel(f),
182
185
  usageText,
183
186
  fixedDisplay,
184
187
  f.vulnerabilities.map(v => v.id).join(", ")
@@ -224,6 +227,11 @@ export function printTable(findings, threshold, skippedKeys) {
224
227
  if (f.maliciousUnverifiable) {
225
228
  console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${action}`));
226
229
  }
230
+ else if (f.maliciousGitSource) {
231
+ const msg = f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_MESSAGE : MAL_GIT_SOURCE_FLOATING_MESSAGE;
232
+ const url = f.pkg.resolvedUrl ? ` (${f.pkg.resolvedUrl})` : "";
233
+ console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version}${url} - ${msg}`));
234
+ }
227
235
  else {
228
236
  console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} - ${action}`));
229
237
  }
@@ -316,9 +324,9 @@ export function printCompactOutput(findings, scanInput, options) {
316
324
  for (const finding of urgentFindings) {
317
325
  const sevLabel = finding.severity.toUpperCase().padEnd(8);
318
326
  const typeLabel = finding.relationship === "direct"
319
- ? "Direct dependency"
327
+ ? `Direct dependency${finding.pkg.dev === true ? " · dev" : ""}`
320
328
  : finding.relationship === "transitive"
321
- ? "Transitive dependency"
329
+ ? `Transitive dependency${finding.pkg.dev === true ? " · dev" : ""}`
322
330
  : "Unknown dependency";
323
331
  let usageContext = "";
324
332
  if (finding.usage) {
@@ -336,6 +344,10 @@ export function printCompactOutput(findings, scanInput, options) {
336
344
  if (finding.maliciousUnverifiable) {
337
345
  console.log(` ${chalk.yellow(`⚠ Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE}`)}`);
338
346
  }
347
+ else if (finding.maliciousGitSource) {
348
+ const url = finding.pkg.resolvedUrl ? ` Source: ${finding.pkg.resolvedUrl}` : "";
349
+ console.log(` ${chalk.yellow(`⚠ ${MAL_GIT_SOURCE_COMPACT_MESSAGE}${url}`)}`);
350
+ }
339
351
  else {
340
352
  const action = finding.relationship === "direct"
341
353
  ? "Remove this package from your dependencies immediately."
@@ -447,6 +459,9 @@ export function printCompactOutput(findings, scanInput, options) {
447
459
  if (f.maliciousUnverifiable) {
448
460
  console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE}`));
449
461
  }
462
+ else if (f.maliciousGitSource) {
463
+ console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Git source - ${MAL_GIT_SOURCE_LEGEND_MESSAGE}`));
464
+ }
450
465
  else {
451
466
  const action = f.relationship === "direct"
452
467
  ? "Remove it from your dependencies immediately."
@@ -81,6 +81,15 @@ export function writeSarifReport(findings, lockfileUri, plan) {
81
81
  const filename = `cve-lite-scan-${ts}.sarif`;
82
82
  const outputPath = path.join(process.cwd(), filename);
83
83
  const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan);
84
- fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
84
+ try {
85
+ fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
86
+ }
87
+ catch (err) {
88
+ try {
89
+ fs.rmSync(outputPath, { force: true });
90
+ }
91
+ catch { }
92
+ throw new Error(`Failed to write SARIF report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
93
+ }
85
94
  return filename;
86
95
  }
@@ -32,8 +32,9 @@ function extractChildDependencyNames(depMeta) {
32
32
  function collectBunPaths(rootDepNames, childDepsByPackageName, map, packageNameToVersion) {
33
33
  const queue = rootDepNames.map(name => ({ name, path: ["project"] }));
34
34
  const visitedStates = new Set();
35
- while (queue.length > 0) {
36
- const current = queue.shift();
35
+ let head = 0;
36
+ while (head < queue.length) {
37
+ const current = queue[head++];
37
38
  const nextPath = [...current.path, current.name];
38
39
  const version = packageNameToVersion.get(current.name);
39
40
  const stateKey = `${current.name}@${version ?? ""}>${nextPath.join(">")}`;
@@ -120,12 +121,14 @@ export function loadFromBunLock(filePath, prodOnly) {
120
121
  const dev = devNames.has(pkgName) && !prodNames.has(pkgName);
121
122
  if (prodOnly && dev)
122
123
  continue;
124
+ const resolvedUrl = typeof entry[1] === "string" && entry[1] !== "" ? entry[1] : undefined;
123
125
  upsertPackage(map, {
124
126
  name,
125
127
  version,
126
128
  ecosystem: "npm",
127
129
  dev,
128
130
  paths: [],
131
+ resolvedUrl,
129
132
  });
130
133
  }
131
134
  collectBunPaths(rootDepNames, childDepsByPackageName, map, packageNameToVersion);
@@ -1,7 +1,7 @@
1
1
  import fs from "node:fs";
2
2
  import YAML from "yaml";
3
3
  import { looksLikeVersion, normalizeRawVersion } from "../utils/version.js";
4
- import { upsertPackage } from "./utils.js";
4
+ import { upsertPackage, markDevPackages } from "./utils.js";
5
5
  import { uniquePathArrays } from "../utils/array.js";
6
6
  const MAX_PATHS_PER_PACKAGE = 5;
7
7
  const MAX_PATH_DEPTH = 10;
@@ -54,7 +54,8 @@ function loadLegacy(parsed, prodOnly) {
54
54
  const dev = !!meta?.dev;
55
55
  if (prodOnly && dev)
56
56
  continue;
57
- upsertPackage(map, { name: ref.name, version: ref.version, ecosystem: "npm", dev, paths: [] });
57
+ const resolvedUrl = meta?.resolution?.tarball;
58
+ upsertPackage(map, { name: ref.name, version: ref.version, ecosystem: "npm", dev, paths: [], resolvedUrl });
58
59
  }
59
60
  const rootDeps = [];
60
61
  for (const importer of Object.values(importers)) {
@@ -91,6 +92,16 @@ function loadV9(parsed, prodOnly) {
91
92
  const importers = parsed?.importers ?? {};
92
93
  const graph = new Map();
93
94
  const map = new Map();
95
+ const packagesMetaSection = parsed?.packages ?? {};
96
+ const resolutionUrls = new Map();
97
+ for (const [key, pkgMeta] of Object.entries(packagesMetaSection)) {
98
+ const ref = parsePnpmPackageKeyV9(String(key));
99
+ if (!ref)
100
+ continue;
101
+ const tarball = pkgMeta?.resolution?.tarball;
102
+ if (tarball)
103
+ resolutionUrls.set(ref.key, tarball);
104
+ }
94
105
  for (const [key, meta] of Object.entries(snapshotsSection)) {
95
106
  const ref = parsePnpmPackageKeyV9(String(key));
96
107
  if (!ref)
@@ -109,9 +120,10 @@ function loadV9(parsed, prodOnly) {
109
120
  const dev = !!meta?.dev;
110
121
  if (prodOnly && dev)
111
122
  continue;
112
- upsertPackage(map, { name: ref.name, version: ref.version, ecosystem: "npm", dev, paths: [] });
123
+ upsertPackage(map, { name: ref.name, version: ref.version, ecosystem: "npm", dev, paths: [], resolvedUrl: resolutionUrls.get(ref.key) });
113
124
  }
114
125
  const rootDeps = [];
126
+ const devDepNames = new Set();
115
127
  for (const importer of Object.values(importers)) {
116
128
  for (const depSectionName of ["dependencies", "optionalDependencies", "devDependencies"]) {
117
129
  if (prodOnly && depSectionName === "devDependencies")
@@ -120,6 +132,9 @@ function loadV9(parsed, prodOnly) {
120
132
  if (!depSection || typeof depSection !== "object")
121
133
  continue;
122
134
  for (const [depName, depRef] of Object.entries(depSection)) {
135
+ if (depSectionName === "devDependencies") {
136
+ devDepNames.add(String(depName));
137
+ }
123
138
  const resolved = normalizePnpmDepRefV9(String(depName), depRef);
124
139
  if (resolved) {
125
140
  rootDeps.push(resolved);
@@ -139,13 +154,15 @@ function loadV9(parsed, prodOnly) {
139
154
  }
140
155
  }
141
156
  collectPnpmPaths(rootDeps, graph, map, parsePnpmPackageKeyV9);
157
+ markDevPackages(map, devDepNames);
142
158
  return [...map.values()];
143
159
  }
144
160
  function collectPnpmPaths(rootDeps, graph, map, parsePackageKey) {
145
161
  const queue = rootDeps.map(dep => ({ key: dep, path: ["project"] }));
146
162
  const visitedStates = new Set();
147
- while (queue.length > 0) {
148
- const current = queue.shift();
163
+ let head = 0;
164
+ while (head < queue.length) {
165
+ const current = queue[head++];
149
166
  const ref = parsePackageKey(current.key);
150
167
  if (!ref)
151
168
  continue;
@@ -1,4 +1,19 @@
1
1
  import { uniquePathArrays } from "../utils/array.js";
2
+ export function markDevPackages(map, devDepNames) {
3
+ if (devDepNames.size === 0)
4
+ return;
5
+ for (const pkg of map.values()) {
6
+ const paths = pkg.paths ?? [];
7
+ if (paths.length === 0)
8
+ continue;
9
+ // A package is dev only if every known path starts from a devDependency root.
10
+ // path[1] is the root dep name (path[0] is always "project").
11
+ const allPathsFromDev = paths.every(p => p.length >= 2 && devDepNames.has(p[1]));
12
+ if (allPathsFromDev) {
13
+ pkg.dev = true;
14
+ }
15
+ }
16
+ }
2
17
  export function upsertPackage(map, candidate) {
3
18
  const key = `${candidate.name}@${candidate.version}`;
4
19
  const existing = map.get(key);
@@ -3,7 +3,7 @@ import path from "node:path";
3
3
  import { parse as parseYarnLock } from "yarn-lockfile";
4
4
  import { uniquePathArrays } from "../utils/array.js";
5
5
  import { normalizeRawVersion } from "../utils/version.js";
6
- import { upsertPackage } from "./utils.js";
6
+ import { upsertPackage, markDevPackages } from "./utils.js";
7
7
  const MAX_PATHS_PER_PACKAGE = 5;
8
8
  const MAX_PATH_DEPTH = 10;
9
9
  export function buildYarnWorkspaceMap(filePath) {
@@ -86,8 +86,9 @@ function parseYarnPackageKey(key) {
86
86
  function collectYarnPaths(rootDepKeys, graph, map) {
87
87
  const queue = rootDepKeys.map(key => ({ key, path: ["project"] }));
88
88
  const visitedStates = new Set();
89
- while (queue.length > 0) {
90
- const current = queue.shift();
89
+ let head = 0;
90
+ while (head < queue.length) {
91
+ const current = queue[head++];
91
92
  const ref = parseYarnPackageKey(current.key);
92
93
  if (!ref)
93
94
  continue;
@@ -117,8 +118,9 @@ function loadRootDepKeys(filePath, selectorToKey, map) {
117
118
  rootPkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
118
119
  }
119
120
  catch {
120
- return [];
121
+ return { keys: [], devDepNames: new Set() };
121
122
  }
123
+ const devDepNames = new Set(Object.keys(rootPkg.devDependencies ?? {}));
122
124
  const rootDepKeys = [];
123
125
  for (const depSection of ["dependencies", "optionalDependencies", "devDependencies"]) {
124
126
  const deps = rootPkg[depSection];
@@ -142,7 +144,7 @@ function loadRootDepKeys(filePath, selectorToKey, map) {
142
144
  }
143
145
  }
144
146
  }
145
- return rootDepKeys;
147
+ return { keys: rootDepKeys, devDepNames };
146
148
  }
147
149
  function parseBerryDependencies(block) {
148
150
  const dependencies = {};
@@ -212,8 +214,9 @@ function loadFromYarnBerryLock(content, filePath) {
212
214
  }
213
215
  graph.set(canonicalKey, [...depKeys]);
214
216
  }
215
- const rootDepKeys = loadRootDepKeys(filePath, selectorToKey, map);
217
+ const { keys: rootDepKeys, devDepNames } = loadRootDepKeys(filePath, selectorToKey, map);
216
218
  collectYarnPaths(rootDepKeys, graph, map);
219
+ markDevPackages(map, devDepNames);
217
220
  return [...map.values()];
218
221
  }
219
222
  function loadFromYarnClassicLock(parsed, filePath) {
@@ -234,7 +237,7 @@ function loadFromYarnClassicLock(parsed, filePath) {
234
237
  for (const selector of selectors) {
235
238
  selectorToKey.set(selector, canonicalKey);
236
239
  }
237
- upsertPackage(map, { name, version, ecosystem: "npm", paths: [] });
240
+ upsertPackage(map, { name, version, ecosystem: "npm", paths: [], resolvedUrl: meta?.resolved });
238
241
  }
239
242
  for (const [selectorKey, meta] of Object.entries(parsed.object)) {
240
243
  const version = meta?.version;
@@ -258,8 +261,9 @@ function loadFromYarnClassicLock(parsed, filePath) {
258
261
  }
259
262
  graph.set(canonicalKey, [...depKeys]);
260
263
  }
261
- const rootDepKeys = loadRootDepKeys(filePath, selectorToKey, map);
264
+ const { keys: rootDepKeys, devDepNames } = loadRootDepKeys(filePath, selectorToKey, map);
262
265
  collectYarnPaths(rootDepKeys, graph, map);
266
+ markDevPackages(map, devDepNames);
263
267
  return [...map.values()];
264
268
  }
265
269
  export function loadFromYarnLock(filePath) {
package/dist/scanner.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { chunk, unique, runWithConcurrency } from "./utils/array.js";
2
- import { isPrivateRegistrySource } from "./utils/advisory.js";
2
+ import { isPrivateRegistrySource, isGitSource, hasCommitShaPinning } from "./utils/advisory.js";
3
3
  import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "./utils/version.js";
4
4
  import { loadCache, saveCache, isEntryStale } from "./osv/cache.js";
5
5
  import { maxSeverity } from "./osv/severity.js";
@@ -9,7 +9,7 @@ import { LocalAdvisorySource } from "./advisory/local-advisory-source.js";
9
9
  import { LocalAdvisoryDatabase } from "./advisory/local-db.js";
10
10
  import { ADVISORY_DB_STALE_AFTER_MS, getDefaultAdvisoryDbPath } from "./advisory/osv-sync.js";
11
11
  import { resolveRecommendedParentUpgrade } from "./remediation/parent-upgrade.js";
12
- import { configureNpmRegistryDebug, resolveLowestKnownNonVulnerableVersion, resolvePublishedFixVersion, } from "./remediation/npm-registry.js";
12
+ import { configureNpmRegistryDebug, fetchPackument, resolveLowestKnownNonVulnerableVersion, resolvePublishedFixVersion, } from "./remediation/npm-registry.js";
13
13
  import { countBySeverity } from "./utils/severity.js";
14
14
  import { resolveNpmTransitiveRemediation, resolveTransitiveRemediationViaRegistry } from "./remediation/npm-transitive-resolution.js";
15
15
  import { loadNpmLockGraph } from "./parsers/npm-lock-graph.js";
@@ -142,25 +142,37 @@ export async function scanPackages(packages, batchSize, options, context, debugL
142
142
  const ids = [...idSet];
143
143
  const detailSpinner = createSpinner("Fetching vulnerability details...", options);
144
144
  try {
145
- for (let i = 0; i < ids.length; i++) {
146
- const id = ids[i];
147
- detailSpinner.update(`Fetching vulnerability details ${i + 1}/${ids.length}...`);
145
+ // cache.entries holds OsvVuln detail records. Unlike cache.queryEntries (which has a
146
+ // 30-minute staleness check applied earlier in this function), detail records have no
147
+ // expiry — they are considered valid for the lifetime of the cache file. The check below
148
+ // is therefore a simple presence check, not a staleness check. This is intentional and
149
+ // matches the original behaviour. Fetches run concurrently because there is no ordering
150
+ // dependency between CVE ID detail requests.
151
+ const uncachedIds = [];
152
+ for (const id of ids) {
148
153
  if (id in cache.entries) {
149
154
  const cached = cache.entries[id];
150
- if (cached) {
155
+ if (cached)
151
156
  vulnMap.set(id, cached);
152
- }
153
- continue;
154
- }
155
- try {
156
- const detail = await advisorySource.getVuln(id);
157
- vulnMap.set(id, detail);
158
- cache.entries[id] = detail;
159
157
  }
160
- catch (_error) {
161
- cache.entries[id] = null;
158
+ else {
159
+ uncachedIds.push(id);
162
160
  }
163
161
  }
162
+ // Fetch all uncached IDs concurrently
163
+ if (uncachedIds.length > 0) {
164
+ detailSpinner.update(`Fetching ${uncachedIds.length} vulnerability details...`);
165
+ await runWithConcurrency(uncachedIds, 10, async (id) => {
166
+ try {
167
+ const detail = await advisorySource.getVuln(id);
168
+ vulnMap.set(id, detail);
169
+ cache.entries[id] = detail;
170
+ }
171
+ catch {
172
+ cache.entries[id] = null;
173
+ }
174
+ });
175
+ }
164
176
  detailSpinner.succeed(`Loaded ${ids.length} vulnerability detail ${pluralize(ids.length, "record")}`);
165
177
  }
166
178
  catch (error) {
@@ -172,9 +184,7 @@ export async function scanPackages(packages, batchSize, options, context, debugL
172
184
  const ids = [...idSet];
173
185
  const detailSpinner = createSpinner("Loading local advisory details...", options);
174
186
  try {
175
- for (let i = 0; i < ids.length; i++) {
176
- const id = ids[i];
177
- detailSpinner.update(`Loading local advisory details ${i + 1}/${ids.length}...`);
187
+ await runWithConcurrency(ids, 10, async (id) => {
178
188
  try {
179
189
  const detail = await advisorySource.getVuln(id);
180
190
  vulnMap.set(id, detail);
@@ -182,7 +192,7 @@ export async function scanPackages(packages, batchSize, options, context, debugL
182
192
  catch {
183
193
  // ignore missing local records so scans remain resilient to partial DB state
184
194
  }
185
- }
195
+ });
186
196
  detailSpinner.succeed(`Loaded ${ids.length} local advisory detail ${pluralize(ids.length, "record")}`);
187
197
  }
188
198
  catch (error) {
@@ -219,9 +229,14 @@ export async function scanPackages(packages, batchSize, options, context, debugL
219
229
  };
220
230
  });
221
231
  for (const finding of findings) {
222
- if (finding.vulnerabilities.some(v => v.id.startsWith("MAL-")) &&
223
- isPrivateRegistrySource(finding.pkg)) {
224
- finding.maliciousUnverifiable = true;
232
+ if (finding.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
233
+ if (isGitSource(finding.pkg)) {
234
+ finding.maliciousGitSource = true;
235
+ finding.maliciousGitSourcePinned = hasCommitShaPinning(finding.pkg);
236
+ }
237
+ else if (isPrivateRegistrySource(finding.pkg)) {
238
+ finding.maliciousUnverifiable = true;
239
+ }
225
240
  }
226
241
  }
227
242
  const npmTransitiveGraph = context?.scanSource === "package-lock" && context.scanFilePath
@@ -297,6 +312,29 @@ export async function scanPackages(packages, batchSize, options, context, debugL
297
312
  updateAnalysisProgress("validating fix target for", `${finding.pkg.name}@${finding.pkg.version}`);
298
313
  }, log);
299
314
  }
315
+ // Pre-warm packument cache for all packages needed in the remediation loop.
316
+ // This converts N sequential registry round-trips into one concurrent burst,
317
+ // after which the loop runs entirely from the in-memory packument cache.
318
+ if (!offline) {
319
+ const packumentsToPrewarm = new Set();
320
+ for (const finding of findings) {
321
+ if (finding.relationship !== "transitive")
322
+ continue;
323
+ packumentsToPrewarm.add(finding.pkg.name);
324
+ const paths = finding.dependencyPaths;
325
+ if (paths.length > 0 && paths[0].length >= 2) {
326
+ packumentsToPrewarm.add(paths[0][paths[0].length - 2]);
327
+ }
328
+ }
329
+ if (packumentsToPrewarm.size > 0) {
330
+ await runWithConcurrency([...packumentsToPrewarm], 8, async (name) => {
331
+ try {
332
+ await fetchPackument(name);
333
+ }
334
+ catch { /* loop will handle missing packuments */ }
335
+ });
336
+ }
337
+ }
300
338
  for (const finding of findings) {
301
339
  if (finding.relationship !== "transitive")
302
340
  continue;
@@ -4,3 +4,20 @@ export function isPrivateRegistrySource(pkg) {
4
4
  pkg.resolvedUrl !== "" &&
5
5
  !pkg.resolvedUrl.startsWith(NPM_PUBLIC_REGISTRY));
6
6
  }
7
+ const GIT_SOURCE_PREFIXES = [
8
+ "https://codeload.github.com/",
9
+ "https://github.com/",
10
+ "https://gitlab.com/",
11
+ "https://bitbucket.org/",
12
+ "git+https://",
13
+ "git+ssh://",
14
+ "git://",
15
+ ];
16
+ export function isGitSource(pkg) {
17
+ return (pkg.resolvedUrl !== undefined &&
18
+ pkg.resolvedUrl !== "" &&
19
+ GIT_SOURCE_PREFIXES.some(prefix => pkg.resolvedUrl.startsWith(prefix)));
20
+ }
21
+ export function hasCommitShaPinning(pkg) {
22
+ return pkg.resolvedUrl !== undefined && /[0-9a-f]{40}/i.test(pkg.resolvedUrl);
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.21.0",
3
+ "version": "1.23.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": {
@@ -25,7 +25,7 @@
25
25
  "@types/node": "^24.0.0",
26
26
  "jest": "^30.3.0",
27
27
  "ts-jest": "^29.4.9",
28
- "tsx": "^4.19.2",
28
+ "tsx": "^4.22.0",
29
29
  "typescript": "^5.8.2"
30
30
  },
31
31
  "keywords": [
@@ -44,6 +44,14 @@
44
44
  "engines": {
45
45
  "node": ">=18"
46
46
  },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/OWASP/cve-lite-cli.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/OWASP/cve-lite-cli/issues"
53
+ },
54
+ "homepage": "https://github.com/OWASP/cve-lite-cli#readme",
47
55
  "files": [
48
56
  "dist",
49
57
  "README.md",