cve-lite-cli 1.19.1 → 1.19.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/README.md CHANGED
@@ -213,9 +213,16 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
213
213
  - [Astro](https://owasp.org/cve-lite-cli/docs/case-studies/astro) — verified baseline scan of a modern pnpm monorepo (2,228 packages, 34 findings at revision `221bb4b`) with a critical transitive SDK chain and four generated fix command groups
214
214
  - [Turborepo](https://owasp.org/cve-lite-cli/docs/case-studies/turborepo) — verified baseline scan of a build-system pnpm monorepo (1,776 packages, 13 findings at revision `c85d410`) with a critical no-fix sandbox beta, all-transitive risk, and zero auto-generated fix commands on this snapshot
215
215
  - [Visual Studio Code](https://owasp.org/cve-lite-cli/docs/case-studies/vscode) — verified baseline scan of the VS Code root npm lockfile (1,374 packages, 9 findings at revision `bc678ca`) with two direct Anthropic SDK advisories, a high-severity gulp toolchain chain, and two generated fix command groups
216
+ - [Gatsby](https://owasp.org/cve-lite-cli/docs/case-studies/gatsby) — verified baseline scan of a Yarn Classic monorepo (3,568 packages, 128 findings at revision `1f38c85`) with five direct findings, critical transitive template-engine chains, and CVE Lite vs `yarn audit` deduplication
217
+ - [Vercel AI SDK](https://owasp.org/cve-lite-cli/docs/case-studies/vercel-ai-sdk) — verified baseline scan of the [vercel/ai](https://github.com/vercel/ai) pnpm monorepo (3,570 packages, 55 findings at revision `3215032`) with three direct findings (`next`, `turbo`) and five workspace-scoped fix command groups — distinct from the Turborepo snapshot
218
+ - [Mastra](https://owasp.org/cve-lite-cli/docs/case-studies/mastra) — verified baseline scan of an AI agent framework pnpm monorepo (4,555 packages, 64 findings at revision `e9d54b2`) with four direct findings, two command groups, and workspace-scoped `pnpm add --filter playground` fixes
219
+ - [Lit](https://owasp.org/cve-lite-cli/docs/case-studies/lit) — verified baseline scan of an npm workspaces monorepo (2,059 packages, 99 findings at revision `20afabd`) with three direct `rollup` majors and workspace-scoped upgrade commands (13 first-pass fixes, 4 command groups)
220
+ - [LangChain.js](https://owasp.org/cve-lite-cli/docs/case-studies/langchainjs) — verified baseline scan of a pnpm LLM-framework monorepo (2,174 packages, 13 findings at revision `1503c9b`) with a lean-graph profile, three high-severity findings with validated fix targets, and a malicious-package advisory on OpenSearch integration paths
221
+ - [OpenAI Agents SDK (JavaScript)](https://owasp.org/cve-lite-cli/docs/case-studies/openai-agents-js) — verified baseline scan of a pnpm AI-agent monorepo (1,683 packages, 31 findings at revision `f76fc19`) with 0 direct findings, MCP/Daytona parent clusters, and one generated `verdaccio` parent-upgrade command
222
+ - [n8n](https://owasp.org/cve-lite-cli/docs/case-studies/n8n) — verified baseline scan of a workflow automation pnpm monorepo (3,746 packages, 32 findings at revision `e2e0394`) with one direct `turbo` fix, four command groups, and email/editor transitive clusters
216
223
  - [Storybook](https://owasp.org/cve-lite-cli/docs/case-studies/storybook) — verified baseline scan of a Yarn Berry monorepo (3,008 packages, 92 findings at revision `cc19ae1`) spanning cross-framework sandbox templates, five critical transitive chains, and one direct vite fix command
217
224
 
218
- In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, and Storybook live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
225
+ In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, and Storybook live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
219
226
 
220
227
  These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
221
228
 
@@ -540,6 +547,22 @@ This project follows a [Code of Conduct](https://github.com/OWASP/cve-lite-cli/b
540
547
 
541
548
  If CVE Lite CLI helps your release workflow, a [GitHub star](https://github.com/OWASP/cve-lite-cli) helps more developers find it.
542
549
 
550
+ ## Contributors
551
+
552
+ Thanks to everyone who helps improve CVE Lite CLI — issues, pull requests, documentation, case studies, and real-world lockfile feedback all count.
553
+
554
+ <p align="center">
555
+ <a href="https://github.com/OWASP/cve-lite-cli/graphs/contributors">
556
+ <img src="https://contrib.rocks/image?repo=OWASP/cve-lite-cli" alt="Contributors to OWASP/cve-lite-cli" />
557
+ </a>
558
+ </p>
559
+
560
+ <p align="center">
561
+ <sub>Avatar grid generated from the <a href="https://github.com/OWASP/cve-lite-cli/graphs/contributors">GitHub contributors graph</a> via <a href="https://contrib.rocks">contrib.rocks</a>.</sub>
562
+ </p>
563
+
564
+ New here? See [CONTRIBUTING.md](https://github.com/OWASP/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md) to get started, and review the [Code of Conduct](https://github.com/OWASP/cve-lite-cli/blob/main/CODE_OF_CONDUCT.md) before participating.
565
+
543
566
  ---
544
567
 
545
568
  *Most tools tell you what's wrong. CVE Lite CLI tells you what to run.*
package/dist/cli/help.js CHANGED
@@ -21,12 +21,6 @@ export function printBanner(options) {
21
21
  export function printHelp() {
22
22
  printBanner();
23
23
  const lines = [
24
- "cve-lite",
25
- "",
26
- "Fast local-first CVE scanner for JS/TS projects using lockfiles + OSV",
27
- "",
28
- `Version: ${CLI_VERSION}`,
29
- "",
30
24
  "Usage:",
31
25
  " cve-lite [projectPath] [options]",
32
26
  " cve-lite advisories sync [options]",
@@ -69,7 +63,17 @@ export function printHelp() {
69
63
  " config show Show current configuration",
70
64
  "",
71
65
  " -v, --version Show the CLI version",
72
- " -h, --help Show this help message"
66
+ " -h, --help Show this help message",
67
+ "",
68
+ "Examples:",
69
+ " cve-lite . Scan the current directory",
70
+ " cve-lite . --verbose Full output with fix plan and findings table",
71
+ " cve-lite . --fail-on high Exit 1 if any high or critical findings are found",
72
+ " cve-lite . --json Write findings to a timestamped JSON file",
73
+ " cve-lite . --report Generate an interactive HTML report",
74
+ " cve-lite . --fix Apply validated direct dependency fixes and rescan",
75
+ " cve-lite . --offline Scan using the local advisory database (no network)",
76
+ " cve-lite advisories sync Sync the local advisory database"
73
77
  ];
74
78
  console.log(lines.join("\n"));
75
79
  }
package/dist/index.js CHANGED
@@ -280,7 +280,8 @@ if (parsedArgs) {
280
280
  }
281
281
  if (scanState.sorted.length > 0) {
282
282
  if (scanState.tableFindings.length > 0) {
283
- printTable(scanState.tableFindings, options.all ? null : scanState.minSeverity);
283
+ const skippedKeys = new Set((scanState.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
284
+ printTable(scanState.tableFindings, options.all ? null : scanState.minSeverity, skippedKeys);
284
285
  }
285
286
  else {
286
287
  logInfo(`No findings met the table threshold of ${scanState.minSeverity}. Re-run with --all to show everything.`, options);
@@ -69,7 +69,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
69
69
  .fix-cmd .cmd-meta{font-size:11px;color:#8b949e;white-space:nowrap}
70
70
  .fix-cmd .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
71
71
  .fix-cmd .copy-btn:hover{color:#e6edf3;background:#30363d}
72
- .findings-section{margin:0 32px 32px}
72
+ .findings-section{margin:24px 32px 32px}
73
73
  .findings-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
74
74
  .findings-header h2{font-size:13px;font-weight:600;color:#e6edf3}
75
75
  .filter-bar{display:flex;gap:6px}
@@ -105,6 +105,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
105
105
  .cve-link:hover{color:#79c0ff}
106
106
  .fix-hint{font-size:11px;color:#3fb950;font-family:monospace}
107
107
  .fix-hint.none{color:#e3b341}
108
+ .fix-hint.hint-only{color:#8b949e}
108
109
  .expand-icon{color:#8b949e;font-size:10px}
109
110
  .detail-row{background:#0d1117;border-top:1px solid #21262d;display:none}
110
111
  .detail-row.visible{display:table-row}
@@ -122,7 +123,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
122
123
  .fix-cmd-inline .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
123
124
  .fix-cmd-note{margin:4px 0 0;font-size:12px;color:#8b949e;font-style:italic;line-height:1.5}
124
125
  .report-footer{margin:0 32px 32px;padding:12px 0;border-top:1px solid #21262d;display:flex;justify-content:space-between;font-size:11px;color:#8b949e}
125
- .scan-notes{margin:0 32px 16px}
126
+ .scan-notes{margin:24px 32px 16px}
126
127
  .scan-notes-toggle{display:flex;align-items:center;gap:6px;font-size:11px;color:#8b949e;background:none;border:none;cursor:pointer;padding:0}
127
128
  .scan-notes-toggle:hover{color:#e6edf3}
128
129
  .scan-notes-toggle .arrow{font-size:9px;transition:transform .15s}
@@ -156,7 +157,9 @@ export function renderHtmlReport(data) {
156
157
  const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
157
158
  const noticesHtml = renderNotices(data.notes, data.warnings);
158
159
  const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
159
- const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
160
+ const skippedKeys = new Set((data.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
161
+ const skippedSectionHtml = renderSkippedSection(data.suggestedFixCommands);
162
+ const findingRowsHtml = data.findings.map((f, i) => renderFindingRow(f, i, skippedKeys)).join("\n");
160
163
  const dataJson = JSON.stringify(data)
161
164
  .replace(/</g, "\\u003c")
162
165
  .replace(/>/g, "\\u003e")
@@ -219,7 +222,6 @@ ${REPORT_STYLES}
219
222
  </div>
220
223
 
221
224
  ${fixPlanHtml}
222
- ${noticesHtml}
223
225
 
224
226
  <div class="findings-section">
225
227
  <div class="findings-header">
@@ -232,6 +234,7 @@ ${noticesHtml}
232
234
  <button class="filter-btn" onclick="setFilter('high',this)">High (${counts.high})</button>
233
235
  <button class="filter-btn" onclick="setFilter('medium',this)">Medium (${counts.medium})</button>
234
236
  <button class="filter-btn" onclick="setFilter('direct',this)">Direct only</button>
237
+ ${skippedKeys.size > 0 ? `<button class="filter-btn" onclick="setFilter('skipped',this)">⊘ Skipped (${skippedKeys.size})</button>` : ""}
235
238
  </div>
236
239
  </div>
237
240
  </div>
@@ -252,6 +255,7 @@ ${findingRowsHtml}
252
255
  </tbody>
253
256
  </table>
254
257
  </div>
258
+ ${noticesHtml}
255
259
 
256
260
  <div class="report-footer">
257
261
  <span>Generated by <strong>cve-lite v${escapeHtml(data.cliVersion)}</strong></span>
@@ -306,6 +310,7 @@ function applyFilters() {
306
310
  else if (activeFilter === 'high') visible = f.severity === 'high';
307
311
  else if (activeFilter === 'medium') visible = f.severity === 'medium';
308
312
  else if (activeFilter === 'direct') visible = f.relationship === 'direct';
313
+ else if (activeFilter === 'skipped') visible = mainRow?.dataset?.skipped === '1';
309
314
  if (visible && query) {
310
315
  const ids = [...(f.cves || []), ...(f.vulnerabilities || []).map(v => v.id)].join(' ').toLowerCase();
311
316
  visible = f.package.toLowerCase().includes(query) || f.version.toLowerCase().includes(query) || ids.includes(query);
@@ -388,15 +393,17 @@ function advisoryLink(id) {
388
393
  }
389
394
  return `<a class="cve-link" href="https://osv.dev/vulnerability/${escapeHtml(id)}" target="_blank">${escapeHtml(id)}</a>`;
390
395
  }
391
- export function renderFindingRow(finding, idx) {
396
+ export function renderFindingRow(finding, idx, skippedKeys) {
392
397
  const cveLinks = finding.cves.length > 0
393
398
  ? finding.cves.map(advisoryLink).join(", ")
394
399
  : finding.vulnerabilities.map(v => advisoryLink(v.id)).join(", ");
395
400
  const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
396
- const fixHtml = finding.validatedFirstFixedVersion
397
- ? `<span class="fix-hint">${escapeHtml(finding.validatedFirstFixedVersion)}</span>`
398
- : finding.firstFixedVersion
399
- ? `<span class="fix-hint">${escapeHtml(finding.firstFixedVersion)}</span>`
401
+ const isSkipped = skippedKeys?.has(`${finding.package}@${finding.version}`);
402
+ const fixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
403
+ const fixHtml = isSkipped && fixVersion
404
+ ? `<span class="fix-hint hint-only" title="Advisory hint only — no automated fix command was generated. See the Skipped findings section below for details.">${escapeHtml(fixVersion)} ⊘</span>`
405
+ : fixVersion
406
+ ? `<span class="fix-hint">${escapeHtml(fixVersion)}</span>`
400
407
  : isMalicious
401
408
  ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
402
409
  : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
@@ -417,7 +424,7 @@ export function renderFindingRow(finding, idx) {
417
424
  const contextColHtml = finding.relationship === "transitive"
418
425
  ? renderTransitiveContextCol(finding)
419
426
  : "";
420
- return ` <tr id="row-${idx}" onclick="toggleRow(${idx})">
427
+ return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
421
428
  <td><span class="expand-icon" id="icon-${idx}">▶</span></td>
422
429
  <td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
423
430
  <td>${fixHtml}</td>
@@ -485,6 +492,26 @@ function renderNotices(notes, warnings) {
485
492
  <div class="scan-notes-body"><ul>${items}</ul></div>
486
493
  </div>`;
487
494
  }
495
+ export function renderSkippedSection(plan) {
496
+ if (!plan || plan.skipped.length === 0)
497
+ return "";
498
+ const skippedRows = plan.skipped.map(s => `
499
+ <div class="skipped-row">
500
+ <span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
501
+ <span class="skipped-rel ${escapeHtml(s.relationship)}">${escapeHtml(s.relationship)}</span>
502
+ <span class="skipped-reason">${escapeHtml(s.reason)}</span>
503
+ </div>`).join("\n");
504
+ return `<div class="fix-plan">
505
+ <div class="fix-plan-header">
506
+ <h2><span class="icon">⊘</span> Skipped findings</h2>
507
+ <button class="skipped-toggle" onclick="toggleSkipped()">↑ collapse</button>
508
+ </div>
509
+ <div class="skipped-section open" id="skipped-section">
510
+ <div style="font-size:11px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:.4px;margin-bottom:4px">Why were these skipped?</div>
511
+ ${skippedRows}
512
+ </div>
513
+ </div>`;
514
+ }
488
515
  export function renderFixPlan(plan) {
489
516
  if (!plan || plan.sections.length === 0)
490
517
  return "";
@@ -519,19 +546,8 @@ export function renderFixPlan(plan) {
519
546
  <button class="copy-btn" data-cmd="${escapeHtml(section.command)}">Copy</button>
520
547
  </div>${targetsHtml}`;
521
548
  }).join("\n");
522
- const skippedRows = plan.skipped.map(s => `
523
- <div class="skipped-row">
524
- <span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
525
- <span class="skipped-rel ${escapeHtml(s.relationship)}">${escapeHtml(s.relationship)}</span>
526
- <span class="skipped-reason">${escapeHtml(s.reason)}</span>
527
- </div>`).join("\n");
528
- const skippedSection = skippedCount > 0 ? `
529
- <div class="skipped-section" id="skipped-section">
530
- <div style="font-size:11px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:.4px;margin-bottom:4px">Why were these skipped?</div>
531
- ${skippedRows}
532
- </div>` : "";
533
549
  const skippedBadgePart = skippedCount > 0
534
- ? ` · <button class="skipped-toggle" onclick="toggleSkipped()">↓ ${skippedCount} skipped</button>`
550
+ ? ` · <span style="color:#8b949e">${skippedCount} skipped ⊘</span>`
535
551
  : "";
536
552
  const coverageText = plan.coveredFindingCount === plan.totalFindingCount
537
553
  ? `Running all commands should fix all ${plan.totalFindingCount} findings.`
@@ -542,7 +558,7 @@ export function renderFixPlan(plan) {
542
558
  <span class="badge">${directCount} direct ${pluralize(directCount, "fix", "fixes")}${skippedBadgePart}</span>
543
559
  </div>
544
560
  <div class="fix-commands">${commandRows}
545
- </div>${skippedSection}
561
+ </div>
546
562
  <div style="padding:10px 18px;border-top:1px solid #21262d;font-size:11px;color:#8b949e">${coverageText}</div>
547
563
  </div>`;
548
564
  }
@@ -148,21 +148,27 @@ export function printSkippedDependencies(skipped) {
148
148
  console.log(`${chalk.yellow("•")} ...and ${skipped.length - 10} more`);
149
149
  }
150
150
  }
151
- export function printTable(findings, threshold) {
151
+ export function printTable(findings, threshold, skippedKeys) {
152
152
  const headers = ["Package", "Version", "Severity", "Type", "Usage", "Fixed", "IDs"];
153
153
  const rawRows = findings.map(f => {
154
154
  let usageText = "n/a";
155
155
  if (f.usage) {
156
156
  usageText = f.usage.imported ? `${f.usage.files.length} file(s)` : "unused";
157
157
  }
158
+ const isSkipped = skippedKeys?.has(`${f.pkg.name}@${f.pkg.version}`);
159
+ const fixVersion = f.validatedFirstFixedVersion ?? f.firstFixedVersion;
160
+ const fixedDisplay = isSkipped && fixVersion
161
+ ? chalk.gray(`${fixVersion} ⊘`)
162
+ : fixVersion
163
+ ? fixVersion
164
+ : f.vulnerabilities.some(v => v.id.startsWith("MAL-")) ? chalk.yellow("⚠ Malicious") : chalk.yellow("⚠ no fix");
158
165
  return [
159
166
  f.pkg.name,
160
167
  f.pkg.version,
161
168
  f.severity,
162
169
  f.relationship,
163
170
  usageText,
164
- (f.validatedFirstFixedVersion ?? f.firstFixedVersion) ??
165
- (f.vulnerabilities.some(v => v.id.startsWith("MAL-")) ? chalk.yellow("⚠ Malicious") : chalk.yellow("⚠ no fix")),
171
+ fixedDisplay,
166
172
  f.vulnerabilities.map(v => v.id).join(", ")
167
173
  ];
168
174
  });
@@ -206,6 +212,9 @@ export function printTable(findings, threshold) {
206
212
  console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} — ${action}`));
207
213
  }
208
214
  }
215
+ if (skippedKeys && skippedKeys.size > 0 && findings.some(f => skippedKeys.has(`${f.pkg.name}@${f.pkg.version}`))) {
216
+ console.log(chalk.gray("⊘ Advisory hint only — no automated fix command could be generated. Run --report to view detailed skip reasons."));
217
+ }
209
218
  if (threshold) {
210
219
  console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
211
220
  }
@@ -76,7 +76,7 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
76
76
  packages: loadFromYarnLock(rootYarnLock),
77
77
  notes: [
78
78
  "Scanned resolved dependency versions from yarn.lock.",
79
- "Dependency path reconstruction is limited for Yarn Classic lockfiles in this MVP."
79
+ "Dependency path reconstruction is limited for Yarn Classic lockfiles — transitive paths may appear as direct."
80
80
  ],
81
81
  warnings: [],
82
82
  skippedDependencies: []
@@ -94,9 +94,10 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
94
94
  packages: loadFromBunLock(selected, prodOnly),
95
95
  notes: [
96
96
  `Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
97
- "Dependency paths are approximated from the workspace dependency manifest."
97
+ "Dependency paths are approximated from the workspace dependency manifest.",
98
+ "No supported lockfile was found at the repo root — a nested lockfile was used instead."
98
99
  ],
99
- warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
100
+ warnings: [],
100
101
  skippedDependencies: []
101
102
  };
102
103
  }
@@ -108,9 +109,10 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
108
109
  packages: loadFromPackageLock(selected, prodOnly),
109
110
  notes: [
110
111
  `Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
111
- "Dependency paths are derived from lockfile package locations."
112
+ "Dependency paths are derived from lockfile package locations.",
113
+ "No supported lockfile was found at the repo root — a nested lockfile was used instead."
112
114
  ],
113
- warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
115
+ warnings: [],
114
116
  skippedDependencies: []
115
117
  };
116
118
  }
@@ -122,9 +124,10 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
122
124
  packages: loadFromPackageLock(selected, prodOnly),
123
125
  notes: [
124
126
  `Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
125
- "Dependency paths are derived from lockfile package locations."
127
+ "Dependency paths are derived from lockfile package locations.",
128
+ "No supported lockfile was found at the repo root — a nested lockfile was used instead."
126
129
  ],
127
- warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
130
+ warnings: [],
128
131
  skippedDependencies: []
129
132
  };
130
133
  }
@@ -136,9 +139,10 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
136
139
  packages: loadFromPnpmLock(selected, prodOnly),
137
140
  notes: [
138
141
  `Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
139
- "Dependency paths are approximated from importer relationships and package snapshots."
142
+ "Dependency paths are approximated from importer relationships and package snapshots.",
143
+ "No supported lockfile was found at the repo root — a nested lockfile was used instead."
140
144
  ],
141
- warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
145
+ warnings: [],
142
146
  skippedDependencies: []
143
147
  };
144
148
  }
@@ -149,9 +153,10 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
149
153
  packages: loadFromYarnLock(selected),
150
154
  notes: [
151
155
  `Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
152
- "Dependency path reconstruction is limited for Yarn Classic lockfiles in this MVP."
156
+ "Dependency path reconstruction is limited for Yarn Classic lockfiles — transitive paths may appear as direct.",
157
+ "No supported lockfile was found at the repo root — a nested lockfile was used instead."
153
158
  ],
154
- warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
159
+ warnings: [],
155
160
  skippedDependencies: []
156
161
  };
157
162
  }
@@ -260,8 +260,9 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
260
260
  }
261
261
  const primaryParent = getPrimaryParent(finding);
262
262
  if (finding.relationship === "transitive" && primaryParent) {
263
- const fixClause = finding.firstFixedVersion
264
- ? ` — check for a release that resolves ${finding.pkg.name} to ${finding.firstFixedVersion}+`
263
+ const fixHint = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
264
+ const fixClause = fixHint
265
+ ? ` — check for a release that resolves ${finding.pkg.name} to ${fixHint}+`
265
266
  : "";
266
267
  skippedByKey.set(`${finding.relationship}:${finding.pkg.name}@${finding.pkg.version}`, {
267
268
  package: finding.pkg.name,
package/dist/scanner.js CHANGED
@@ -490,8 +490,17 @@ function isAdvisoryDbStale(metadata) {
490
490
  return Date.now() - timestamp > ADVISORY_DB_STALE_AFTER_MS;
491
491
  }
492
492
  function classifyRelationship(paths, packageName, directDependencyNames) {
493
- if (packageName && directDependencyNames?.has(packageName))
494
- return "direct";
493
+ if (packageName && directDependencyNames?.has(packageName)) {
494
+ // The package name is declared as a direct dependency. But when multiple versions
495
+ // of the same package are installed (one direct, one transitive), the name alone
496
+ // is not enough — we need to verify this specific installed version is the direct
497
+ // one. A direct install always has at least one path of length 2 (["project", name]).
498
+ // If all paths are longer, this is a different (transitive) version of the package.
499
+ if (paths.length === 0)
500
+ return "direct"; // no path data — trust the name
501
+ const hasDirectPath = paths.some(p => p.length <= 2);
502
+ return hasDirectPath ? "direct" : "transitive";
503
+ }
495
504
  if (paths.length === 0)
496
505
  return "unknown";
497
506
  if (directDependencyNames)
@@ -521,7 +530,7 @@ function findFirstFixedVersion(vulns) {
521
530
  }
522
531
  export function buildCoverageNotes(scanInput, offline) {
523
532
  const notes = [
524
- "This MVP checks package versions against OSV advisories. It does not prove exploitability or runtime reachability.",
533
+ "CVE Lite CLI checks package versions against OSV advisories. It does not prove exploitability or runtime reachability.",
525
534
  "Installed node_modules contents are not verified in this scan.",
526
535
  "Container images, binaries, secrets, and IaC files are not scanned.",
527
536
  "Monorepo workspace boundaries are only partially modeled in this version.",
@@ -0,0 +1,212 @@
1
+ import { spawn } from "node:child_process";
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import { severityOrder } from "../constants.js";
5
+ import { normalizeSeverity } from "../osv/severity.js";
6
+ import { pluralize } from "./string.js";
7
+ const DEPENDENCY_FILES_TO_STAGE = [
8
+ "package.json",
9
+ "package-lock.json",
10
+ "yarn.lock",
11
+ "pnpm-lock.yaml",
12
+ "bun.lock",
13
+ "npm-shrinkwrap.json",
14
+ ];
15
+ export function findingsMeetFailOnThreshold(findings, failOn) {
16
+ const failLevel = normalizeSeverity(failOn);
17
+ return findings.some(finding => severityOrder[finding.severity] >= severityOrder[failLevel]);
18
+ }
19
+ export function defaultFixBranchName(date = new Date()) {
20
+ const year = date.getUTCFullYear();
21
+ const month = String(date.getUTCMonth() + 1).padStart(2, "0");
22
+ const day = String(date.getUTCDate()).padStart(2, "0");
23
+ return `cve-lite/fix-${year}-${month}-${day}`;
24
+ }
25
+ export function buildPullRequestTitle(appliedCount, packageNames) {
26
+ const pkgList = packageNames.length <= 3
27
+ ? packageNames.join(", ")
28
+ : `${packageNames.slice(0, 2).join(", ")} +${packageNames.length - 2} more`;
29
+ return `[CVE-Lite-CLI] fix: upgrade ${pkgList} (${appliedCount} ${pluralize(appliedCount, "vulnerability", "vulnerabilities")} resolved)`;
30
+ }
31
+ export function collectAdvisoryIdsForPackage(findings, packageName) {
32
+ const ids = new Set();
33
+ for (const finding of findings) {
34
+ if (finding.pkg.name !== packageName)
35
+ continue;
36
+ for (const vuln of finding.vulnerabilities) {
37
+ ids.add(vuln.id);
38
+ for (const alias of vuln.aliases ?? []) {
39
+ if (alias.startsWith("CVE-")) {
40
+ ids.add(alias);
41
+ }
42
+ }
43
+ }
44
+ }
45
+ return [...ids].sort();
46
+ }
47
+ export function buildPullRequestBody(params) {
48
+ const lines = [
49
+ "## Summary",
50
+ "",
51
+ "Automated security fixes applied by [CVE Lite CLI](https://github.com/OWASP/cve-lite-cli) using OSV-validated target versions.",
52
+ "",
53
+ "## Fixed packages",
54
+ "",
55
+ ];
56
+ for (const item of params.fixResult.applied) {
57
+ const advisoryIds = collectAdvisoryIdsForPackage(params.findingsBeforeFix, item.package);
58
+ const advisoryText = advisoryIds.length > 0 ? advisoryIds.join(", ") : "n/a";
59
+ lines.push(`- **${item.package}**: \`${item.from}\` → \`${item.to}\``);
60
+ lines.push(` - Advisories: ${advisoryText}`);
61
+ }
62
+ lines.push("", "## Scan results", "", `- Findings before fix: **${params.findingsBeforeFix.length}**`, `- Findings after fix: **${params.findingsAfterFix.length}**`, "", "## Notes", "", "- Only validated **direct** dependency upgrades are included in this PR.", "- Transitive vulnerabilities may still require parent package upgrades or upstream releases.");
63
+ return lines.join("\n");
64
+ }
65
+ async function runCommand(command, args, cwd) {
66
+ return await new Promise(resolve => {
67
+ let stdout = "";
68
+ let stderr = "";
69
+ const child = spawn(command, args, {
70
+ cwd,
71
+ stdio: ["ignore", "pipe", "pipe"],
72
+ });
73
+ child.stdout?.on("data", chunk => {
74
+ stdout += String(chunk);
75
+ });
76
+ child.stderr?.on("data", chunk => {
77
+ stderr += String(chunk);
78
+ });
79
+ child.on("error", error => {
80
+ resolve({ stdout, stderr, status: null, error });
81
+ });
82
+ child.on("close", code => {
83
+ resolve({ stdout, stderr, status: code, error: null });
84
+ });
85
+ });
86
+ }
87
+ async function assertGitRepository(projectPath) {
88
+ const result = await runCommand("git", ["rev-parse", "--is-inside-work-tree"], projectPath);
89
+ if (result.error || result.status !== 0 || result.stdout.trim() !== "true") {
90
+ throw new Error("--create-pr requires a git repository. Run this command from your project root.");
91
+ }
92
+ }
93
+ async function assertGhAvailable() {
94
+ const version = await runCommand("gh", ["--version"], process.cwd());
95
+ if (version.error || version.status !== 0) {
96
+ throw new Error("--create-pr requires the GitHub CLI (gh). Install it from https://cli.github.com/ or set GITHUB_TOKEN and ensure gh is on PATH.");
97
+ }
98
+ const auth = await runCommand("gh", ["auth", "status"], process.cwd());
99
+ if (auth.status !== 0 && !process.env.GITHUB_TOKEN) {
100
+ throw new Error("--create-pr requires GitHub authentication. Run `gh auth login` or set the GITHUB_TOKEN environment variable.");
101
+ }
102
+ }
103
+ async function hasAnyChanges(projectPath) {
104
+ const status = await runCommand("git", ["status", "--porcelain"], projectPath);
105
+ if (status.error || status.status !== 0) {
106
+ throw new Error(`Failed to inspect git status: ${status.stderr.trim() || status.error?.message || "unknown error"}`);
107
+ }
108
+ return status.stdout.trim().length > 0;
109
+ }
110
+ export async function stageDependencyFilesOnly(projectPath) {
111
+ for (const filePath of DEPENDENCY_FILES_TO_STAGE) {
112
+ if (!fs.existsSync(path.join(projectPath, filePath))) {
113
+ continue;
114
+ }
115
+ const add = await runCommand("git", ["add", "--", filePath], projectPath);
116
+ if (add.error || add.status !== 0) {
117
+ throw new Error(`Failed to stage dependency file ${filePath}: ${add.stderr.trim() || add.error?.message || "unknown error"}`);
118
+ }
119
+ }
120
+ }
121
+ export async function hasStagedDependencyChanges(projectPath) {
122
+ const diff = await runCommand("git", ["diff", "--cached", "--name-only"], projectPath);
123
+ if (diff.error || diff.status !== 0) {
124
+ throw new Error(`Failed to inspect staged changes: ${diff.stderr.trim() || diff.error?.message || "unknown error"}`);
125
+ }
126
+ const stagedFiles = diff.stdout
127
+ .split("\n")
128
+ .map(line => line.trim())
129
+ .filter(Boolean);
130
+ return stagedFiles.some(filePath => DEPENDENCY_FILES_TO_STAGE.some(target => filePath === target || filePath.endsWith(`/${target}`)));
131
+ }
132
+ async function branchExists(projectPath, branchName) {
133
+ const result = await runCommand("git", ["rev-parse", "--verify", branchName], projectPath);
134
+ return result.status === 0;
135
+ }
136
+ export async function selectAvailableBranchName(projectPath, baseName) {
137
+ if (!(await branchExists(projectPath, baseName))) {
138
+ return baseName;
139
+ }
140
+ for (let suffix = 2; suffix <= 99; suffix++) {
141
+ const candidate = `${baseName}-${suffix}`;
142
+ if (!(await branchExists(projectPath, candidate))) {
143
+ return candidate;
144
+ }
145
+ }
146
+ throw new Error(`Failed to allocate a unique branch name based on ${baseName}`);
147
+ }
148
+ function extractPullRequestUrl(output) {
149
+ const match = output.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);
150
+ return match?.[0] ?? null;
151
+ }
152
+ export async function createPullRequestForFixes(params) {
153
+ const baseBranchName = defaultFixBranchName();
154
+ if (params.fixResult.appliedFixCount === 0) {
155
+ return {
156
+ branchName: baseBranchName,
157
+ prUrl: null,
158
+ skipped: true,
159
+ skipReason: "No direct dependency fixes were applied, so no pull request was created.",
160
+ };
161
+ }
162
+ await assertGitRepository(params.projectPath);
163
+ await assertGhAvailable();
164
+ if (!(await hasAnyChanges(params.projectPath))) {
165
+ return {
166
+ branchName: baseBranchName,
167
+ prUrl: null,
168
+ skipped: true,
169
+ skipReason: "No lockfile or manifest changes were detected after applying fixes.",
170
+ };
171
+ }
172
+ const packageNames = params.fixResult.applied.map(a => a.package);
173
+ const title = buildPullRequestTitle(params.fixResult.appliedFixCount, packageNames);
174
+ const body = buildPullRequestBody({
175
+ fixResult: params.fixResult,
176
+ findingsBeforeFix: params.findingsBeforeFix,
177
+ findingsAfterFix: params.findingsAfterFix,
178
+ });
179
+ await stageDependencyFilesOnly(params.projectPath);
180
+ if (!(await hasStagedDependencyChanges(params.projectPath))) {
181
+ return {
182
+ branchName: baseBranchName,
183
+ prUrl: null,
184
+ skipped: true,
185
+ skipReason: "No dependency manifest or lockfile changes were detected after applying fixes.",
186
+ };
187
+ }
188
+ const branchName = await selectAvailableBranchName(params.projectPath, baseBranchName);
189
+ const checkout = await runCommand("git", ["checkout", "-b", branchName], params.projectPath);
190
+ if (checkout.error || checkout.status !== 0) {
191
+ const message = checkout.stderr.trim() || checkout.error?.message || "unknown error";
192
+ throw new Error(`Failed to create branch ${branchName}: ${message}`);
193
+ }
194
+ const commit = await runCommand("git", ["commit", "-m", title], params.projectPath);
195
+ if (commit.error || commit.status !== 0) {
196
+ throw new Error(`Failed to commit dependency changes: ${commit.stderr.trim() || commit.error?.message || "unknown error"}`);
197
+ }
198
+ const push = await runCommand("git", ["push", "-u", "origin", branchName], params.projectPath);
199
+ if (push.error || push.status !== 0) {
200
+ throw new Error(`Failed to push branch ${branchName}: ${push.stderr.trim() || push.error?.message || "unknown error"}`);
201
+ }
202
+ const create = await runCommand("gh", ["pr", "create", "--base", params.baseBranch, "--head", branchName, "--title", title, "--body", body], params.projectPath);
203
+ if (create.error || create.status !== 0) {
204
+ throw new Error(`Failed to open pull request: ${create.stderr.trim() || create.error?.message || "unknown error"}`);
205
+ }
206
+ const prUrl = extractPullRequestUrl(`${create.stdout}\n${create.stderr}`);
207
+ return {
208
+ branchName,
209
+ prUrl,
210
+ skipped: false,
211
+ };
212
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.19.1",
3
+ "version": "1.19.2",
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": {