cve-lite-cli 1.39.0 โ†’ 1.40.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.
Files changed (39) hide show
  1. package/README.md +11 -11
  2. package/dist/cli/help.js +1 -0
  3. package/dist/constants.js +4 -3
  4. package/dist/osv/severity.js +1 -1
  5. package/dist/output/cyclonedx.js +1 -1
  6. package/dist/output/formatters.js +2 -2
  7. package/dist/output/html-reporter.js +14 -8
  8. package/dist/output/multi-folder-html-reporter.js +12 -8
  9. package/dist/output/override-findings-html.js +3 -6
  10. package/dist/output/override-findings-terminal.js +7 -12
  11. package/dist/output/override-fix-command.js +13 -0
  12. package/dist/output/printers.js +11 -7
  13. package/dist/output/sarif.js +39 -11
  14. package/dist/output/scan-json.js +26 -1
  15. package/dist/output/write-outputs.js +13 -1
  16. package/dist/overrides/parsing/registry.js +1 -1
  17. package/dist/parsers/pnpm-lock.js +23 -10
  18. package/dist/remediation/fix-commands.js +36 -7
  19. package/dist/remediation/npm-registry.js +56 -7
  20. package/dist/remediation/npm-transitive-resolution.js +11 -30
  21. package/dist/remediation/parent-candidate-resolver.js +65 -0
  22. package/dist/remediation/parent-upgrade.js +6 -37
  23. package/dist/scan/completeness.js +7 -7
  24. package/dist/scan/multi-folder-scan.js +28 -8
  25. package/dist/scan/override-audit.js +11 -1
  26. package/dist/scan/single-scan.js +85 -45
  27. package/dist/scanner.js +32 -9
  28. package/dist/skills/content.js +12 -12
  29. package/dist/utils/contextual-signals.js +1 -1
  30. package/dist/utils/effective-options.js +55 -0
  31. package/dist/utils/finding.js +1 -1
  32. package/dist/utils/fix-runner.js +3 -2
  33. package/dist/utils/network.js +1 -1
  34. package/dist/utils/registry-config.js +144 -0
  35. package/dist/utils/severity.js +8 -0
  36. package/dist/utils/validate-url.js +3 -3
  37. package/dist/utils/version.js +17 -1
  38. package/dist/utils/vuln.js +75 -0
  39. package/package.json +1 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  <div align="center">
14
14
  <a href="https://owasp.org/cve-lite-cli">
15
- <img src="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/logos-combined.svg" alt="CVE Lite CLI โ€” An OWASP Foundation Project" width="500"/>
15
+ <img src="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/logos-combined.svg" alt="CVE Lite CLI - An OWASP Foundation Project" width="500"/>
16
16
  </a>
17
17
 
18
18
  <h1>CVE Lite CLI</h1>
@@ -32,9 +32,9 @@
32
32
  <td align="center" width="33%">๐Ÿ”’</td>
33
33
  </tr>
34
34
  <tr>
35
- <td align="center" width="33%" valign="top"><strong>OWASP Lab Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10 โ€”<br/>the security standard followed by millions of developers</sub></td>
36
- <td align="center" width="33%" valign="top"><strong>Remediation-first</strong><br/><sub>Validated fix commands + parent-aware<br/>transitive guidance โ€” not just CVE IDs</sub></td>
37
- <td align="center" width="33%" valign="top"><strong>Runs locally</strong><br/><sub>Nothing leaves your machine โ€” not your<br/>code, not your dependency tree</sub></td>
35
+ <td align="center" width="33%" valign="top"><strong>OWASP Lab Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10:<br/>the security standard followed by millions of developers</sub></td>
36
+ <td align="center" width="33%" valign="top"><strong>Remediation-first</strong><br/><sub>Validated fix commands + parent-aware<br/>transitive guidance: not just CVE IDs</sub></td>
37
+ <td align="center" width="33%" valign="top"><strong>Runs locally</strong><br/><sub>Nothing leaves your machine: not your<br/>code, not your dependency tree</sub></td>
38
38
  </tr>
39
39
  </table>
40
40
 
@@ -121,7 +121,7 @@ npx cve-lite-cli /path/to/project
121
121
 
122
122
  No account. No configuration. No source code leaves your machine.
123
123
 
124
- > **Note:** CVE Lite CLI includes [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3), a native SQLite binding used for the [local advisory database](https://owasp.org/cve-lite-cli/docs/offline-advisory-db). During installation, npm may download a prebuilt binary or compile one from source. This can produce extra console output โ€” it is expected and is not CVE Lite CLI itself running an install script. See [Dependency footprint](#dependency-footprint) for details.
124
+ > **Note:** CVE Lite CLI includes [`better-sqlite3`](https://github.com/WiseLibs/better-sqlite3), a native SQLite binding used for the [local advisory database](https://owasp.org/cve-lite-cli/docs/offline-advisory-db). During installation, npm may download a prebuilt binary or compile one from source. This can produce extra console output: it is expected and is not CVE Lite CLI itself running an install script. See [Dependency footprint](#dependency-footprint) for details.
125
125
 
126
126
  ## Usage
127
127
 
@@ -233,7 +233,7 @@ For the full guide, see the [Release Cooldown Awareness guide](https://owasp.org
233
233
  </table>
234
234
 
235
235
  <details>
236
- <summary>Verbose terminal output โ€” includes the full fix plan</summary>
236
+ <summary>Verbose terminal output: includes the full fix plan</summary>
237
237
  <p align="center">
238
238
  <a href="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/verbose-output-1.png"><img src="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/verbose-output-1.png" alt="Verbose output part 1" width="280"/></a>
239
239
  <a href="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/verbose-output-2.png"><img src="https://raw.githubusercontent.com/OWASP/cve-lite-cli/main/assets/verbose-output-2.png" alt="Verbose output part 2" width="280"/></a>
@@ -245,7 +245,7 @@ For the full guide, see the [Release Cooldown Awareness guide](https://owasp.org
245
245
 
246
246
  Most security tooling is built around pipelines, not developers. Dependabot opens PRs you'll get to eventually. CI scanners block merges after the fact. Dashboards surface lists of CVE IDs with no clear path to fixing them. Developers learn to ignore it.
247
247
 
248
- CVE Lite CLI is built for the moment before you push. It reads your lockfile locally, queries [OSV](https://osv.dev) and the npm registry advisory API, and produces copy-and-run `npm install`, `pnpm add`, `yarn add`, or `bun add` commands โ€” not a list of identifiers. You see which packages are direct versus transitive, get parent-aware upgrade guidance, and can scan offline in restricted environments.
248
+ CVE Lite CLI is built for the moment before you push. It reads your lockfile locally, queries [OSV](https://osv.dev) and the npm registry advisory API, and produces copy-and-run `npm install`, `pnpm add`, `yarn add`, or `bun add` commands, not a list of identifiers. You see which packages are direct versus transitive, get parent-aware upgrade guidance, and can scan offline in restricted environments.
249
249
 
250
250
  The closer a security tool is to a developer's natural workflow, the more likely it is to be used.
251
251
 
@@ -278,7 +278,7 @@ No other free tool combines all of the following: lockfile scanning across npm,
278
278
 
279
279
  <sub>โœ… = built-in strength ยท โš ๏ธ = partial or workflow-dependent ยท โŒ = not a core strength</sub>
280
280
 
281
- The transitive parent guidance is a key difference: CVE Lite CLI avoids recommending direct installs for packages that are only present transitively. For npm lockfiles, it can identify when `npm update <parent>` is enough to re-resolve a known non-vulnerable child within the current parent range, and when the parent package itself needs an upgrade.
281
+ The transitive parent guidance is a key difference: CVE Lite CLI avoids recommending direct installs for packages that are only present transitively. For npm lockfiles, it can identify when `npm update <child>` is enough to refresh a known non-vulnerable child within the current parent range, and when the parent package itself needs an upgrade.
282
282
 
283
283
  For detailed per-tool analysis, see [Comparison with other tools](https://owasp.org/cve-lite-cli/docs/comparison).
284
284
 
@@ -405,12 +405,12 @@ This is intentional. Because CVE Lite CLI is a security-oriented tool, runtime d
405
405
 
406
406
  Because it includes compiled C/C++ code, npm must run an install script when installing `better-sqlite3`. During installation:
407
407
 
408
- - **Prebuilt binary available:** `prebuild-install` downloads a prebuilt binary for your platform โ€” fast, though npm may still print a deprecation warning for `prebuild-install` itself ([#519](https://github.com/OWASP/cve-lite-cli/issues/519)).
408
+ - **Prebuilt binary available:** `prebuild-install` downloads a prebuilt binary for your platform: fast, though npm may still print a deprecation warning for `prebuild-install` itself ([#519](https://github.com/OWASP/cve-lite-cli/issues/519)).
409
409
  - **No prebuilt available:** the package falls back to compiling from source using `node-gyp`, which requires a C/C++ toolchain and produces more console output.
410
410
 
411
- This install step belongs to `better-sqlite3`, not to CVE Lite CLI โ€” the project itself does not define any `preinstall`, `install`, or `postinstall` hooks.
411
+ This install step belongs to `better-sqlite3`, not to CVE Lite CLI: the project itself does not define any `preinstall`, `install`, or `postinstall` hooks.
412
412
 
413
- **npm install-script permissions:** Depending on your npm version and configuration, npm may prompt you to approve the install script before it runs. This is an npm security feature. Online scanning works even when the install script is blocked โ€” the native binding is loaded lazily and only used by `--offline`, `--offline-db`, `cve-lite advisories sync`, and `cve-lite advisories init`. If you use any of those features, the `better-sqlite3` install script must be allowed to complete.
413
+ **npm install-script permissions:** Depending on your npm version and configuration, npm may prompt you to approve the install script before it runs. This is an npm security feature. Online scanning works even when the install script is blocked: the native binding is loaded lazily and only used by `--offline`, `--offline-db`, `cve-lite advisories sync`, and `cve-lite advisories init`. If you use any of those features, the `better-sqlite3` install script must be allowed to complete.
414
414
 
415
415
  **npx behavior:** When using `npx cve-lite-cli`, a quiet run does not necessarily mean the install script was skipped. If npm's cache already contains the required prebuilt binary, installation is silent. On a cold cache, the same native install step runs.
416
416
 
package/dist/cli/help.js CHANGED
@@ -41,6 +41,7 @@ export function printHelp() {
41
41
  " --no-open Don't auto-open the report in the browser",
42
42
  " --fix Apply validated direct dependency fixes and rescan",
43
43
  " --ratchet Save current findings as baseline or, if baseline exists, only fail on new findings",
44
+ " (the run that saves a baseline still gates on --fail-on)",
44
45
  " --create-pr After --fix, commit changes and open a GitHub pull request (requires gh)",
45
46
  " --base <branch> Base branch for --create-pr (default: main)",
46
47
  " --osv-url <url> Use a custom OSV-compatible advisory endpoint (HTTPS only)",
package/dist/constants.js CHANGED
@@ -6,6 +6,7 @@ export const severityOrder = {
6
6
  critical: 4,
7
7
  unknown: 1
8
8
  };
9
+ export const RATCHET_BASELINE_COMMIT_HINT = "to accept the existing debt; until then --ratchet gates like --fail-on.";
9
10
  export const DEFAULT_BATCH_SIZE = 100;
10
11
  export const DEFAULT_SEARCH_DEPTH = 4;
11
12
  export const CACHE_TTL_MS = 30 * 60 * 1000; // 30 minutes
@@ -13,9 +14,9 @@ export const NPM_PUBLIC_REGISTRY = "https://registry.npmjs.org/";
13
14
  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.";
14
15
  export const MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE = "MAL- advisory could not be confirmed for this artifact.";
15
16
  export const MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE = "verify artifact source manually";
16
- 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.";
17
- 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.";
18
- export const MAL_GIT_SOURCE_COMPACT_MESSAGE = "Git source โ€” verify repository and org are trusted.";
17
+ 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.";
18
+ 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.";
19
+ export const MAL_GIT_SOURCE_COMPACT_MESSAGE = "Git source: verify repository and org are trusted.";
19
20
  export const MAL_GIT_SOURCE_LEGEND_MESSAGE = "verify repository and org are trusted";
20
21
  export const MAL_GIT_SOURCE_PINNED_DISPLAY = "โš  Git source (SHA-pinned)";
21
22
  export const MAL_GIT_SOURCE_FLOATING_DISPLAY = "โš  Git source (floating ref)";
@@ -30,7 +30,7 @@ export function inferSeverity(vuln) {
30
30
  function severityFromScore(score) {
31
31
  // CVSS vector strings (e.g. "CVSS:3.1/AV:N/...") are not numerical scores.
32
32
  // Extracting the first number would yield the CVSS version (3.1), not the base
33
- // score โ€” causing every CVSS_V3 advisory to be misclassified as "low".
33
+ // score - causing every CVSS_V3 advisory to be misclassified as "low".
34
34
  // Return unknown so the caller falls through to database_specific.severity.
35
35
  if (String(score).startsWith("CVSS:"))
36
36
  return "unknown";
@@ -16,7 +16,7 @@ export function buildCycloneDxBom(allPackages, findings, projectMeta, version, p
16
16
  purl,
17
17
  };
18
18
  });
19
- // Deduplicate vulnerabilities by CVE ID โ€” one entry per CVE with multiple affects
19
+ // Deduplicate vulnerabilities by CVE ID - one entry per CVE with multiple affects
20
20
  const vulnMap = new Map();
21
21
  for (const finding of findings) {
22
22
  const cveIds = finding.cveAliases.length > 0
@@ -65,7 +65,7 @@ export function getRecommendedAction(finding) {
65
65
  : "This package has a malicious code advisory. Upgrade or remove the parent package that pulls it in.";
66
66
  }
67
67
  // Prefer the registry-validated target over the raw advisory hint when
68
- // available โ€” they can disagree (the hint may not be published on npm or
68
+ // available - they can disagree (the hint may not be published on npm or
69
69
  // may itself be vulnerable), and the validated target is what the fix
70
70
  // command actually uses.
71
71
  const directTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
@@ -100,7 +100,7 @@ export function getRecommendedAction(finding) {
100
100
  // No parent identifiable: either dependencyPaths is empty, or the path is
101
101
  // a degenerate length-2 chain (project -> vulnerable, common when the
102
102
  // package is hoisted to top-level node_modules). The advice is the same
103
- // either way โ€” inspect the lockfile or run `<pm> ls` to find the parent.
103
+ // either way - inspect the lockfile or run `<pm> ls` to find the parent.
104
104
  if (directTarget) {
105
105
  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, then upgrade toward ${directTarget}+.`;
106
106
  }
@@ -26,6 +26,7 @@ export function buildReportData(params) {
26
26
  return {
27
27
  projectPath: params.projectPath,
28
28
  scannedAt: new Date().toISOString(),
29
+ ...(params.registry ? { registry: params.registry } : {}),
29
30
  cliVersion: params.cliVersion,
30
31
  packageManager: params.packageManager,
31
32
  lockfileSource: params.lockfileSource,
@@ -246,6 +247,11 @@ function embedJson(value) {
246
247
  export function renderHtmlReport(data, jsonPayload) {
247
248
  const projectName = path.basename(data.projectPath);
248
249
  const scanDate = new Date(data.scannedAt).toLocaleString();
250
+ // Only when configured, matching the terminal, so nothing new appears for a project
251
+ // installing from public npm.
252
+ const registryMeta = data.registry?.sourceFile
253
+ ? ` &nbsp;ยท&nbsp; registry: ${escapeHtml(data.registry.registry)}`
254
+ : "";
249
255
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
250
256
  for (const f of data.findings) {
251
257
  const sev = f.severity;
@@ -271,7 +277,7 @@ export function renderHtmlReport(data, jsonPayload) {
271
277
  <head>
272
278
  <meta charset="UTF-8">
273
279
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
274
- <title>CVE Lite โ€” ${escapeHtml(projectName)}</title>
280
+ <title>CVE Lite - ${escapeHtml(projectName)}</title>
275
281
  <style>
276
282
  ${REPORT_STYLES}
277
283
  </style>
@@ -291,7 +297,7 @@ ${REPORT_STYLES}
291
297
  <div class="header-divider"></div>
292
298
  <div class="header-project">
293
299
  <span class="project-name">${escapeHtml(projectName)}</span>
294
- <span class="project-meta">${escapeHtml(data.packageManager)} &nbsp;ยท&nbsp; ${escapeHtml(data.lockfileSource)} &nbsp;ยท&nbsp; ${escapeHtml(scanDate)}</span>
300
+ <span class="project-meta">${escapeHtml(data.packageManager)} &nbsp;ยท&nbsp; ${escapeHtml(data.lockfileSource)} &nbsp;ยท&nbsp; ${escapeHtml(scanDate)}${registryMeta}</span>
295
301
  </div>
296
302
  </div>
297
303
  <div class="header-right">
@@ -371,7 +377,7 @@ ${findingRowsHtml}
371
377
  </table>
372
378
  ${renderPriorityLegendHtml(data.findings)}
373
379
  </div>
374
- ${renderOverrideFindingsHtml(data.overrideFindings, data.projectPath, data.skippedOverrideRules)}
380
+ ${renderOverrideFindingsHtml(data.overrideFindings, undefined, data.skippedOverrideRules)}
375
381
  ${renderMaintenanceFindingsHtml(data.maintenanceFindings)}
376
382
  ${renderLicenseFindingsHtml(data.licenseFindings, { limitedToDirectOnly: data.licenseLimitedToDirectOnly })}
377
383
  ${skippedDepsHtml}
@@ -618,18 +624,18 @@ export function renderFindingRow(finding, idx, skippedKeys) {
618
624
  const unconfirmed = isUnconfirmedFix(finding);
619
625
  const fixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
620
626
  const fixHtml = (isSkipped || unconfirmed) && fixVersion
621
- ? `<span class="fix-hint hint-only" title="Advisory hint only โ€” a safe fix has not been confirmed.">${escapeHtml(fixVersion)} โŠ˜</span>`
627
+ ? `<span class="fix-hint hint-only" title="Advisory hint only: a safe fix has not been confirmed.">${escapeHtml(fixVersion)} โŠ˜</span>`
622
628
  : fixVersion
623
629
  ? `<span class="fix-hint">${escapeHtml(fixVersion)}</span>`
624
630
  : isMalicious && finding.maliciousUnverifiable
625
631
  ? `<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>`
626
632
  : isMalicious && finding.maliciousGitSource && finding.maliciousGitSourcePinned
627
- ? `<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>`
633
+ ? `<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>`
628
634
  : isMalicious && finding.maliciousGitSource
629
- ? `<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>`
635
+ ? `<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>`
630
636
  : isMalicious
631
- ? `<span class="fix-hint none" title="Malicious code advisory โ€” remove this package">โš  Malicious</span>`
632
- : `<span class="fix-hint none" title="No known fix โ€” consider replacing this package">โš  No fix</span>`;
637
+ ? `<span class="fix-hint none" title="Malicious code advisory: remove this package">โš  Malicious</span>`
638
+ : `<span class="fix-hint none" title="No known fix: consider replacing this package">โš  No fix</span>`;
633
639
  const depPaths = renderDependencyPathsHtml(finding);
634
640
  const description = finding.vulnerabilities[0]?.summary ?? "";
635
641
  const runnable = finding.runnableFixCommand ?? null;
@@ -56,7 +56,7 @@ function renderFolderNotices(coverage, warnings) {
56
56
  <div class="scan-notes-body"><ul>${items}</ul></div>
57
57
  </div>`;
58
58
  }
59
- function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRoot, includeOverrides, includeMaintenance, includeLicenses) {
59
+ function renderFolderSection(result, folderIdx, idxOffset, serialized, includeOverrides, includeMaintenance, includeLicenses) {
60
60
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0 };
61
61
  for (const f of result.sorted) {
62
62
  const sev = f.severity;
@@ -73,9 +73,8 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
73
73
  const findingRowsHtml = serialized.map((f, i) => renderFindingRow(f, idxOffset + i)).join("\n");
74
74
  const fixPlanHtml = renderFixPlan(result.suggestedFixCommands);
75
75
  const noticesHtml = renderFolderNotices(result.coverage, result.scanInput.warnings);
76
- const folderAbs = path.join(projectRoot, result.subfolder);
77
76
  const overrideHtml = includeOverrides
78
- ? renderOverrideFindingsHtml(result.overrideFindings, folderAbs, result.overrideSkipped)
77
+ ? renderOverrideFindingsHtml(result.overrideFindings, result.subfolder, result.overrideSkipped)
79
78
  : "";
80
79
  const maintenanceHtml = includeMaintenance
81
80
  ? renderMaintenanceFindingsHtml(result.maintenanceFindings)
@@ -178,7 +177,7 @@ export async function writeMultiFolderHtmlReport(params) {
178
177
  let idxOffset = 0;
179
178
  const folderSectionsHtml = params.results
180
179
  .map((r, fi) => {
181
- const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi], params.projectPath, params.includeOverrides, params.includeMaintenance, params.includeLicenses);
180
+ const html = renderFolderSection(r, fi, idxOffset, allSerialized[fi], params.includeOverrides, params.includeMaintenance, params.includeLicenses);
182
181
  idxOffset += r.sorted.length;
183
182
  return html;
184
183
  })
@@ -190,7 +189,7 @@ export async function writeMultiFolderHtmlReport(params) {
190
189
  <head>
191
190
  <meta charset="UTF-8">
192
191
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
193
- <title>CVE Lite โ€” ${escapeHtml(projectName)}</title>
192
+ <title>CVE Lite - ${escapeHtml(projectName)}</title>
194
193
  <style>
195
194
  ${REPORT_STYLES}
196
195
  .folder-section{margin:0 32px 16px;background:#161b22;border:1px solid #30363d;border-radius:8px;overflow:hidden}
@@ -387,9 +386,9 @@ document.addEventListener('click', function(e) {
387
386
  </script>
388
387
  </body>
389
388
  </html>`;
390
- // Same --json multi-folder shape, plus cliVersion for saved-artifact provenance
391
- // (scannedAt is already on the multi-folder payload) and per-finding
392
- // riskSummary/nextAction from serializeHtmlFinding.
389
+ // Same --json multi-folder shape, plus per-finding riskSummary/nextAction
390
+ // from serializeHtmlFinding. Saved-artifact provenance (cliVersion,
391
+ // scannedAt, effectiveOptions) comes from the builder (#1296).
393
392
  const jsonPayload = {
394
393
  ...buildMultiFolderScanJson({
395
394
  results: params.results,
@@ -397,7 +396,12 @@ document.addEventListener('click', function(e) {
397
396
  includeOverrides: params.includeOverrides,
398
397
  includeMaintenance: params.includeMaintenance,
399
398
  includeLicenses: params.includeLicenses,
399
+ provenance: params.options
400
+ ? { cliVersion: params.cliVersion, options: params.options }
401
+ : undefined,
400
402
  }),
403
+ // cliVersion was always attached here; keep it unconditional and add
404
+ // effectiveOptions alongside when options are available (#1296).
401
405
  cliVersion: params.cliVersion,
402
406
  findings: reportData.findings,
403
407
  };
@@ -1,7 +1,6 @@
1
- import { relative } from "node:path";
2
1
  import { groupSkippedByReason, skippedHeadline, skippedRuleCount } from "./skipped-override-rules.js";
3
2
  import { SEVERITY_ORDER } from "../utils/severity.js";
4
- import { OVERRIDES_COMMAND } from "../constants.js";
3
+ import { buildOverrideFixCommand } from "./override-fix-command.js";
5
4
  function esc(s) {
6
5
  return s
7
6
  .replace(/&/g, "&amp;")
@@ -29,7 +28,7 @@ ${items}
29
28
  </div>
30
29
  `;
31
30
  }
32
- export function renderOverrideFindingsHtml(findings, projectPath, skipped) {
31
+ export function renderOverrideFindingsHtml(findings, commandTarget, skipped) {
33
32
  // undefined = override hygiene was never requested -> render nothing, so a plain
34
33
  // `cve-lite .` report shows no Override hygiene panel at all. An empty array =
35
34
  // it ran and found nothing -> render the "no findings" reassurance.
@@ -49,10 +48,8 @@ ${skippedNoticeHtml(skipped)}</section>
49
48
  const location = f.location.jsonPath
50
49
  ? `${esc(f.location.file)} โ€บ ${esc(f.location.jsonPath)}`
51
50
  : esc(f.location.file);
52
- const relPath = projectPath ? relative(process.cwd(), projectPath) : "";
53
- const projectInfix = relPath && relPath !== "." ? ` ${relPath}` : "";
54
51
  const fixCommand = f.fix && f.fix.runnableCommand
55
- ? f.fix.runnableCommand.replace(OVERRIDES_COMMAND, `cve-lite${projectInfix} overrides`)
52
+ ? buildOverrideFixCommand(f.fix.runnableCommand, commandTarget)
56
53
  : null;
57
54
  const fixHtml = fixCommand
58
55
  ? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(fixCommand)}</code><button class="copy-btn" data-cmd="${esc(fixCommand)}">Copy</button></div>`
@@ -3,7 +3,7 @@ import { groupSkippedByReason, skippedHeadline, skippedRuleCount } from "./skipp
3
3
  import { chalk, stripAnsi } from "../utils/chalk.js";
4
4
  import { formatSeverityLabel, SEVERITY_ORDER } from "../utils/severity.js";
5
5
  import { pluralize } from "../utils/string.js";
6
- import { OVERRIDES_COMMAND } from "../constants.js";
6
+ import { buildOverrideFixCommand, overrideCommandTargetSuffix } from "./override-fix-command.js";
7
7
  const COL_RULE_MAX = 8;
8
8
  const COL_PKG_MAX = 30;
9
9
  const COL_MSG_MAX = 50;
@@ -27,6 +27,10 @@ export function renderOverrideFindings(findings, options) {
27
27
  : "โœ” No override hygiene issues found."));
28
28
  return lines.join("\n");
29
29
  }
30
+ // Printed in the shell that ran the scan, so a cwd-relative target is runnable.
31
+ const commandTarget = options?.projectPath
32
+ ? relative(process.cwd(), options.projectPath)
33
+ : "";
30
34
  const grouped = new Map();
31
35
  for (const sev of SEVERITY_ORDER)
32
36
  grouped.set(sev, []);
@@ -60,26 +64,17 @@ export function renderOverrideFindings(findings, options) {
60
64
  lines.push(hr("โ”œ", "โ”ผ", "โ”ค"));
61
65
  }
62
66
  lines.push(hr("โ””", "โ”ด", "โ”˜"));
63
- const relPath = options?.projectPath
64
- ? relative(process.cwd(), options.projectPath)
65
- : "";
66
- const projectInfix = relPath && relPath !== "." ? ` ${relPath}` : "";
67
67
  const seenRules = new Set();
68
68
  for (const f of sorted) {
69
69
  if (f.fix?.runnableCommand && !seenRules.has(f.ruleId)) {
70
70
  seenRules.add(f.ruleId);
71
- const cmd = projectInfix
72
- ? f.fix.runnableCommand.replace(OVERRIDES_COMMAND, `cve-lite${projectInfix} overrides`)
73
- : f.fix.runnableCommand;
71
+ const cmd = buildOverrideFixCommand(f.fix.runnableCommand, commandTarget);
74
72
  lines.push(chalk.bold.cyan(`> ${cmd}`));
75
73
  }
76
74
  }
77
75
  lines.push("");
78
76
  }
79
- const relPath = options?.projectPath
80
- ? relative(process.cwd(), options.projectPath)
81
- : "";
82
- const projectInfix = relPath && relPath !== "." ? ` ${relPath}` : "";
77
+ const projectInfix = overrideCommandTargetSuffix(commandTarget);
83
78
  const allFixableRules = new Set(findings.filter(f => f.fix?.runnableCommand).map(f => f.ruleId));
84
79
  if (allFixableRules.size >= 2) {
85
80
  const fixAllCmd = `cve-lite${projectInfix} overrides --fix`;
@@ -0,0 +1,13 @@
1
+ import { OVERRIDES_COMMAND } from "../constants.js";
2
+ // The folder a fix command targets, relative to the scanned project root
3
+ // ("packages/a"), or empty for the root itself. Never pass a cwd-relative or
4
+ // absolute path: the HTML report is opened from an unknown directory, so only a
5
+ // project-relative target stays runnable when it is copied out.
6
+ export function overrideCommandTargetSuffix(commandTarget) {
7
+ const normalized = commandTarget?.replace(/\\/g, "/");
8
+ return normalized && normalized !== "." ? ` ${normalized}` : "";
9
+ }
10
+ export function buildOverrideFixCommand(runnableCommand, commandTarget) {
11
+ const suffix = overrideCommandTargetSuffix(commandTarget);
12
+ return runnableCommand.replace(OVERRIDES_COMMAND, `cve-lite${suffix} overrides`);
13
+ }
@@ -128,11 +128,15 @@ export function printSuggestedFixCommandSkips(findings, scanInput, options) {
128
128
  const plan = buildSuggestedFixCommandPlan(findings, scanInput, options);
129
129
  if (!plan || plan.skipped.length === 0)
130
130
  return;
131
- const unpublishable = plan.skipped.filter(skipped => skipped.reason.includes("not published on npm"));
131
+ // Routed on the flag the resolver sets, never on the reason text. The reason is
132
+ // prose, it gets joined with other notes before it arrives here, and it changes
133
+ // whenever the message is reworded, all of which moves findings between these two
134
+ // sections without anything failing.
135
+ const unpublishable = plan.skipped.filter(skipped => skipped.advisoryHintUnavailable === true);
132
136
  // Only surface direct-dependency skips here. Transitive findings without an
133
137
  // auto-fix path are already covered by the fix plan step 2 ("Review these urgent
134
138
  // transitive issues"), so repeating them here creates confusing duplication.
135
- const remaining = plan.skipped.filter(skipped => !skipped.reason.includes("not published on npm") && skipped.relationship === "direct");
139
+ const remaining = plan.skipped.filter(skipped => skipped.advisoryHintUnavailable !== true && skipped.relationship === "direct");
136
140
  if (unpublishable.length > 0) {
137
141
  console.log("");
138
142
  console.log(chalk.gray("Unpublishable fixed-version hints:"));
@@ -483,7 +487,7 @@ export function printTable(findings, threshold, skippedKeys, plan) {
483
487
  if (findings.length > 0) {
484
488
  console.log("");
485
489
  console.log(chalk.bold("Prioritization signals (heuristic)"));
486
- console.log(chalk.gray("Triage hints only โ€” not exploitability or runtime reachability proofs."));
490
+ console.log(chalk.gray("Triage hints only: not exploitability or runtime reachability proofs."));
487
491
  for (const finding of findings) {
488
492
  const values = formatContextualSignalValues(computeContextualSignals(finding));
489
493
  console.log(chalk.gray(` ${finding.pkg.name}@${finding.pkg.version} ${values}`));
@@ -511,7 +515,7 @@ export function printTable(findings, threshold, skippedKeys, plan) {
511
515
  }
512
516
  }
513
517
  if (skippedKeys && skippedKeys.size > 0 && findings.some(f => skippedKeys.has(`${f.pkg.name}@${f.pkg.version}`))) {
514
- console.log(chalk.gray("โŠ˜ Advisory hint only โ€” no automated fix command could be generated. Run --report to view detailed skip reasons."));
518
+ console.log(chalk.gray("โŠ˜ Advisory hint only: no automated fix command could be generated. Run --report to view detailed skip reasons."));
515
519
  }
516
520
  if (threshold) {
517
521
  console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
@@ -743,8 +747,8 @@ export function printCompactOutput(findings, scanInput, options) {
743
747
  else {
744
748
  const parent = getPrimaryParent(finding);
745
749
  action = parent
746
- ? `Upgrade ${parent} โ€” check for release resolving ${finding.pkg.name} to ${displayFixVersion}+`
747
- : `No dependency path found โ€” inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
750
+ ? `Upgrade ${parent}: check for release resolving ${finding.pkg.name} to ${displayFixVersion}+`
751
+ : `No dependency path found: inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
748
752
  }
749
753
  console.log(` ${chalk.gray(`Fix: ${action}`)}`);
750
754
  }
@@ -757,7 +761,7 @@ export function printCompactOutput(findings, scanInput, options) {
757
761
  const parent = getPrimaryParent(finding);
758
762
  action = parent
759
763
  ? `Upgrade ${parent} to resolve ${finding.pkg.name}`
760
- : `No dependency path found โ€” inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
764
+ : `No dependency path found: inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
761
765
  }
762
766
  console.log(` ${chalk.gray(`Fix: ${action}`)}`);
763
767
  }
@@ -9,6 +9,22 @@ import { displayOutputPath } from "./output-dir.js";
9
9
  import { buildOverrideSarifComponent, buildOverrideSarifResults } from "./override-findings-sarif.js";
10
10
  import { buildMaintenanceSarifComponent, buildMaintenanceSarifResults } from "./maintenance-findings-sarif.js";
11
11
  import { buildLicenseSarifComponent, buildLicenseSarifResults } from "./license-findings-sarif.js";
12
+ /**
13
+ * Attribution leading the rule help, so an alert in Code Scanning is
14
+ * recognisably from this tool rather than from whichever scanner the reader
15
+ * assumed.
16
+ *
17
+ * โš  Deliberately a markdown link rather than the logo image the GitHub App
18
+ * puts on PR comments. This help text renders inside the ADOPTER's security
19
+ * dashboard, not ours, which makes an image the wrong shape twice over: it
20
+ * would be hot-linked from a moving branch, so renaming the asset later breaks
21
+ * the image in every historical alert they hold, and it would fetch 217KB from
22
+ * our repository every time one of their engineers opens an alert. A link
23
+ * carries the same attribution and costs them nothing.
24
+ */
25
+ const PROJECT_URL = "https://github.com/OWASP/cve-lite-cli";
26
+ const MARKDOWN_ATTRIBUTION = `Reported by [CVE Lite CLI](${PROJECT_URL})`;
27
+ const TEXT_ATTRIBUTION = `Reported by CVE Lite CLI - ${PROJECT_URL}`;
12
28
  const SARIF_SCHEMA = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
13
29
  const LOCKFILE_NAMES = {
14
30
  "package-lock": "package-lock.json",
@@ -44,7 +60,7 @@ function buildRuleHelp(vuln, depPath, action) {
44
60
  const rawCweIds = dbSpecific?.cwe_ids;
45
61
  const cweIds = Array.isArray(rawCweIds) ? rawCweIds : null;
46
62
  const range = extractAffectedRange(vuln);
47
- const textParts = [`Vulnerability: ${title}`];
63
+ const textParts = [TEXT_ATTRIBUTION, "", `Vulnerability: ${title}`];
48
64
  if (body)
49
65
  textParts.push("", body);
50
66
  if (cvssScore)
@@ -58,7 +74,7 @@ function buildRuleHelp(vuln, depPath, action) {
58
74
  if (depPath)
59
75
  textParts.push("", `Dependency path: ${depPath}`);
60
76
  textParts.push("", `Fix: ${action}`);
61
- const mdParts = [`## ${title}`];
77
+ const mdParts = [MARKDOWN_ATTRIBUTION, "", `## ${title}`];
62
78
  if (body)
63
79
  mdParts.push("", body);
64
80
  if (cvssScore)
@@ -91,16 +107,18 @@ function dedupeSkipped(skipped) {
91
107
  }
92
108
  return out;
93
109
  }
94
- export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings, licenseFindings,
95
- // NOTE: this parameter list is too long and wants an options object, tracked as #1244.
96
- // Kept positional here so #1222 does not also rewrite every call site. It is why the
97
- // new parameter sits last in both functions even though `writeSarifReport` already has
98
- // a defaulted `outputDir` ahead of it.
99
- overrideSkipped) {
110
+ export function buildSarifOutput(findings, lockfileUri, version, plan, options = {}) {
111
+ const { overrideFindings, maintenanceFindings, licenseFindings, overrideSkipped } = options;
112
+ // Accepted findings go through the SAME construction as actionable ones and differ only by
113
+ // carrying `suppressions`. Duplicating the loop instead is how the two would drift.
114
+ const taggedFindings = [
115
+ ...findings.map(finding => ({ finding, accepted: false })),
116
+ ...(options.acceptedFindings ?? []).map(finding => ({ finding, accepted: true })),
117
+ ];
100
118
  const ruleMap = new Map();
101
119
  const ruleIndexMap = new Map();
102
120
  const results = [];
103
- for (const finding of findings) {
121
+ for (const { finding, accepted } of taggedFindings) {
104
122
  const level = severityToSarifLevel(finding.severity);
105
123
  const action = getRecommendedAction(finding);
106
124
  // If the recommended fix for this finding lands on a version inside the
@@ -160,6 +178,14 @@ overrideSkipped) {
160
178
  ruleId,
161
179
  ruleIndex: ruleIndexMap.get(ruleId),
162
180
  kind: "open",
181
+ ...(accepted
182
+ ? {
183
+ suppressions: [{
184
+ kind: "external",
185
+ justification: "Accepted by the .cve-lite/baseline.json ratchet baseline.",
186
+ }],
187
+ }
188
+ : {}),
163
189
  level,
164
190
  message: {
165
191
  text: `${finding.pkg.name}@${finding.pkg.version} is vulnerable (${finding.severity}). ${action}`
@@ -249,11 +275,13 @@ overrideSkipped) {
249
275
  ],
250
276
  };
251
277
  }
252
- export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings, licenseFindings, outputDir = process.cwd(), overrideSkipped) {
278
+ export function writeSarifReport(findings, lockfileUri, plan, options = {}) {
279
+ const { outputDir: outputDirOption, ...sarifOptions } = options;
280
+ const outputDir = outputDirOption ?? process.cwd();
253
281
  const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
254
282
  const filename = `cve-lite-scan-${ts}.sarif`;
255
283
  const outputPath = path.join(outputDir, filename);
256
- const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings, licenseFindings, overrideSkipped);
284
+ const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, sarifOptions);
257
285
  try {
258
286
  fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
259
287
  }
@@ -3,6 +3,7 @@ import { overrideFindingsToJson } from "./override-findings-json.js";
3
3
  import { maintenanceFindingsToJson } from "./maintenance-findings-json.js";
4
4
  import { serializeLicenseFindings } from "./license-findings-json.js";
5
5
  import { aggregateMultiFolderCompleteness } from "../scan/completeness.js";
6
+ import { summarizeEffectiveOptions } from "../utils/effective-options.js";
6
7
  /**
7
8
  * Single-folder `--json` payload. HTML `report.json` reuses this so both
8
9
  * artifacts share one schema.
@@ -12,6 +13,9 @@ export function buildScanJson(input) {
12
13
  projectPath: input.projectPath,
13
14
  mode: input.scanInput.mode,
14
15
  source: input.scanInput.source,
16
+ ...(input.registry
17
+ ? { registry: { registry: input.registry.registry, sourceFile: input.registry.sourceFile } }
18
+ : {}),
15
19
  packageCount: input.scanInput.packages.length,
16
20
  findingCount: input.findings.length,
17
21
  status: (input.completeness.complete ? "ok" : "partial"),
@@ -22,6 +26,12 @@ export function buildScanJson(input) {
22
26
  warnings: input.scanInput.warnings,
23
27
  skippedDependencies: input.scanInput.skippedDependencies,
24
28
  findings: input.findings.map(finding => serializeFinding(finding, input.suggestedFixCommands)),
29
+ ...(input.acceptedFindings && input.acceptedFindings.length > 0
30
+ ? {
31
+ acceptedFindingCount: input.acceptedFindings.length,
32
+ acceptedFindings: input.acceptedFindings.map(finding => serializeFinding(finding, input.suggestedFixCommands)),
33
+ }
34
+ : {}),
25
35
  };
26
36
  const overridePayload = overrideFindingsToJson(input.overrideFindings ?? [], input.overrideSkipped);
27
37
  const maintenancePayload = maintenanceFindingsToJson(input.maintenanceFindings ?? []);
@@ -31,7 +41,15 @@ export function buildScanJson(input) {
31
41
  ...(input.licenseLimitedToDirectOnly ? { licenseLimitedToDirectOnly: true } : {}),
32
42
  }
33
43
  : {};
34
- return { ...payload, ...overridePayload, ...maintenancePayload, ...licensePayload };
44
+ // Provenance is additive only: nothing existing changes shape (#1296).
45
+ const provenancePayload = input.provenance
46
+ ? {
47
+ cliVersion: input.provenance.cliVersion,
48
+ scannedAt: new Date().toISOString(),
49
+ effectiveOptions: summarizeEffectiveOptions(input.provenance.options),
50
+ }
51
+ : {};
52
+ return { ...payload, ...overridePayload, ...maintenancePayload, ...licensePayload, ...provenancePayload };
35
53
  }
36
54
  /**
37
55
  * Multi-folder `--json` payload. HTML `report.json` reuses this so both
@@ -70,5 +88,12 @@ export function buildMultiFolderScanJson(params) {
70
88
  }
71
89
  : {}),
72
90
  scannedAt: new Date().toISOString(),
91
+ // Provenance is additive only: nothing existing changes shape (#1296).
92
+ ...(params.provenance
93
+ ? {
94
+ cliVersion: params.provenance.cliVersion,
95
+ effectiveOptions: summarizeEffectiveOptions(params.provenance.options),
96
+ }
97
+ : {}),
73
98
  };
74
99
  }