cve-lite-cli 1.32.0 → 1.34.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 +7 -3
- package/dist/advisory/local-db.js +31 -2
- package/dist/advisory/osv-advisory-source.js +3 -0
- package/dist/cli/args.js +41 -2
- package/dist/cli/help.js +3 -1
- package/dist/cli/validate.js +6 -2
- package/dist/index.js +1 -1
- package/dist/output/cyclonedx.js +16 -24
- package/dist/output/formatters.js +16 -0
- package/dist/output/html-reporter.js +84 -11
- package/dist/output/multi-folder-html-reporter.js +7 -3
- package/dist/output/printers.js +42 -9
- package/dist/output/sbom-dependency-edges.js +76 -0
- package/dist/output/sbom-file.js +27 -0
- package/dist/output/spdx.js +293 -0
- package/dist/output/write-outputs.js +18 -3
- package/dist/parsers/package-lock.js +11 -1
- package/dist/parsers/utils.js +3 -0
- package/dist/remediation/npm-registry.js +8 -2
- package/dist/scan/completeness.js +1 -0
- package/dist/scanner.js +62 -7
- package/dist/types.js +1 -1
- package/dist/utils/priority-signal.js +40 -0
- package/dist/utils/purl.js +10 -0
- package/dist/utils/sbom-format.js +12 -0
- package/dist/utils/version.js +74 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
*Most tools tell you what's wrong. CVE Lite CLI tells you what to run.*
|
|
3
2
|
|
|
4
3
|
[](https://owasp.org/cve-lite-cli)
|
|
@@ -95,6 +94,7 @@ cve-lite /path/to/project --fix # apply validated direct fixes and r
|
|
|
95
94
|
cve-lite /path/to/project --fail-on high # exit non-zero on high severity and above
|
|
96
95
|
cve-lite /path/to/project --json # JSON output
|
|
97
96
|
cve-lite /path/to/project --sarif # SARIF output for GitHub Code Scanning
|
|
97
|
+
cve-lite /path/to/project --sbom spdx # SPDX 2.3 SBOM (also: --sbom cyclonedx)
|
|
98
98
|
cve-lite /path/to/project --report # interactive HTML dashboard
|
|
99
99
|
cve-lite /path/to/project --check-overrides # audit override hygiene alongside the CVE scan
|
|
100
100
|
cve-lite /path/to/project --check-maintenance # flag CVE-blocking version drag and npm-deprecated direct deps
|
|
@@ -210,7 +210,7 @@ The closer a security tool is to a developer's natural workflow, the more likely
|
|
|
210
210
|
|
|
211
211
|
## How it compares
|
|
212
212
|
|
|
213
|
-
No other free tool combines all of the following: lockfile scanning across npm, pnpm, Yarn, and Bun; parent-aware transitive remediation that tells you which package to upgrade (not just which one is vulnerable); fix version validation before suggesting an upgrade; a fully offline advisory DB for restricted environments;
|
|
213
|
+
No other free tool combines all of the following: lockfile scanning across npm, pnpm, Yarn, and Bun; parent-aware transitive remediation that tells you which package to upgrade (not just which one is vulnerable); fix version validation before suggesting an upgrade; a fully offline advisory DB for restricted environments; CVE + license compliance scanning in a single pass; SBOM output in both CycloneDX and SPDX with the vulnerability findings attached rather than as a separate inventory step; and an EPSS priority signal that combines CVSS severity with exploitation likelihood into four actionable tiers.
|
|
214
214
|
|
|
215
215
|
| Capability | CVE Lite CLI | npm audit | OSV-Scanner | Snyk CLI | Socket CLI |
|
|
216
216
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
@@ -228,10 +228,12 @@ No other free tool combines all of the following: lockfile scanning across npm,
|
|
|
228
228
|
| [Interactive HTML report](https://owasp.org/cve-lite-cli/docs/html-report) | ✅ | ❌ | ❌ | ✅ | ❌ |
|
|
229
229
|
| [SARIF / GitHub Code Scanning output](https://owasp.org/cve-lite-cli/docs/sarif) | ✅ | ❌ | ✅ | ✅ | ❌ |
|
|
230
230
|
| [JSON output](https://owasp.org/cve-lite-cli/docs/cli-reference#output-options) | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
231
|
+
| [SBOM output with findings attached (CycloneDX + SPDX)](https://owasp.org/cve-lite-cli/docs/spdx) | ✅ | ❌ | ❌ | ⚠️ | ⚠️ |
|
|
231
232
|
| [Offline/local advisory DB](https://owasp.org/cve-lite-cli/docs/offline-advisory-db) | ✅ | ❌ | ⚠️ | ❌ | ❌ |
|
|
232
233
|
| [Override hygiene auditing](https://owasp.org/cve-lite-cli/docs/override-hygiene) | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
233
234
|
| [Maintenance-risk detection (CVE-fix drag)](https://owasp.org/cve-lite-cli/docs/maintenance-risk) | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
234
235
|
| [License compliance scanning (copyleft / unknown)](https://owasp.org/cve-lite-cli/docs/cli-reference#license-scanning-options) | ✅ | ❌ | ❌ | ⚠️ | ⚠️ |
|
|
236
|
+
| [Priority signal: CVSS severity × EPSS exploitation likelihood](https://owasp.org/cve-lite-cli/docs/cli-reference#epss-priority-signal) | ✅ | ❌ | ❌ | ⚠️ | ❌ |
|
|
235
237
|
|
|
236
238
|
<sub>✅ = built-in strength · ⚠️ = partial or workflow-dependent · ❌ = not a core strength</sub>
|
|
237
239
|
|
|
@@ -362,6 +364,8 @@ This is intentional. Because CVE Lite CLI is a security-oriented tool, runtime d
|
|
|
362
364
|
- [Parser Coverage guide](https://owasp.org/cve-lite-cli/docs/parser-coverage) - supported lockfile formats, selection priority, `package.json` fallback, monorepos, private registries
|
|
363
365
|
- [Remediation Strategy guide](https://owasp.org/cve-lite-cli/docs/remediation-strategy) - how CVE Lite CLI chooses upgrade targets and parent update paths
|
|
364
366
|
- [Release Cooldown Awareness guide](https://owasp.org/cve-lite-cli/docs/release-cooldown) - how CVE Lite CLI reads your package manager's cooldown and warns on fix versions newer than the window you trust
|
|
367
|
+
- [SPDX SBOM guide](https://owasp.org/cve-lite-cli/docs/spdx) - SPDX 2.3 output, how findings are attached, NTIA minimum elements, and inventory-only mode
|
|
368
|
+
- [CycloneDX SBOM guide](https://owasp.org/cve-lite-cli/docs/cyclonedx) - CycloneDX 1.6 output and Dependency-Track integration
|
|
365
369
|
|
|
366
370
|
## Security and verification
|
|
367
371
|
|
|
@@ -436,4 +440,4 @@ Thank you to those who sponsor CVE Lite CLI and help keep it maintained:
|
|
|
436
440
|
|
|
437
441
|
## License
|
|
438
442
|
|
|
439
|
-
MIT - built in public and maintained as an OWASP Foundation Project by Sonu Kapoor.
|
|
443
|
+
MIT - built in public and maintained as an OWASP Foundation Project by Sonu Kapoor.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import Database from "better-sqlite3";
|
|
4
|
-
import { compareVersions, looksLikeVersion } from "../utils/version.js";
|
|
4
|
+
import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "../utils/version.js";
|
|
5
5
|
const SCHEMA_SQL = `
|
|
6
6
|
CREATE TABLE IF NOT EXISTS advisories (
|
|
7
7
|
id TEXT PRIMARY KEY,
|
|
@@ -177,11 +177,40 @@ export class LocalAdvisoryDatabase {
|
|
|
177
177
|
return [...ids];
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
+
/**
|
|
181
|
+
* The release core of a version, with any pre-release and build metadata
|
|
182
|
+
* stripped: `1.2.0-beta.1+exp` becomes `1.2.0`.
|
|
183
|
+
*/
|
|
184
|
+
function releaseCore(version) {
|
|
185
|
+
return version.split("+")[0].split("-")[0];
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Whether `version` is at or above an advisory's `introduced` bound.
|
|
189
|
+
*
|
|
190
|
+
* Plain semver precedence puts a pre-release below its release, so
|
|
191
|
+
* `1.2.0-beta.1` sorts below an `introduced` of `1.2.0` and would fall outside
|
|
192
|
+
* the range the advisory declared. In practice a `1.2.0-beta.1` build is a
|
|
193
|
+
* pre-release *of* `1.2.0` and carries whatever was introduced there, so
|
|
194
|
+
* excluding it is a false negative.
|
|
195
|
+
*
|
|
196
|
+
* The relaxation cannot widen a pre-release lower bound, which matters because
|
|
197
|
+
* OSV declares plenty of them: 64 of 352 sampled `introduced` events, with
|
|
198
|
+
* Next.js using values like `15.0.1-canary.0` routinely. Those are deliberate
|
|
199
|
+
* canary boundaries and must keep comparing exactly, or we would pull in
|
|
200
|
+
* earlier canaries the advisory explicitly excluded and trade this false
|
|
201
|
+
* negative for a false positive. No guard is needed for that: a release core
|
|
202
|
+
* never contains "-", so it can never equal a pre-release `introduced`.
|
|
203
|
+
*/
|
|
204
|
+
function versionAtOrAboveIntroduced(version, introduced) {
|
|
205
|
+
if (compareVersions(version, introduced) >= 0)
|
|
206
|
+
return true;
|
|
207
|
+
return isPreReleaseVersion(version) && releaseCore(version) === introduced;
|
|
208
|
+
}
|
|
180
209
|
function versionMatchesRange(version, row) {
|
|
181
210
|
const introduced = row.introduced;
|
|
182
211
|
const fixed = row.fixed;
|
|
183
212
|
const lastAffected = row.last_affected;
|
|
184
|
-
if (introduced && introduced !== "0" &&
|
|
213
|
+
if (introduced && introduced !== "0" && !versionAtOrAboveIntroduced(version, introduced)) {
|
|
185
214
|
return false;
|
|
186
215
|
}
|
|
187
216
|
if (fixed && compareVersions(version, fixed) >= 0) {
|
|
@@ -62,6 +62,9 @@ export class OsvAdvisorySource {
|
|
|
62
62
|
if (!Array.isArray(data?.results)) {
|
|
63
63
|
throw new Error('OSV batch query returned a 200 response with no "results" array');
|
|
64
64
|
}
|
|
65
|
+
if (data.results.length !== packages.length) {
|
|
66
|
+
throw new Error(`OSV batch query returned ${data.results.length} result(s) for ${packages.length} quer(ies) - response length mismatch`);
|
|
67
|
+
}
|
|
65
68
|
return data.results.map((r, i) => ({
|
|
66
69
|
package: packages[i].name,
|
|
67
70
|
version: packages[i].version,
|
package/dist/cli/args.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
import { ConfigAction, ConfigKey } from "./config.js";
|
|
2
|
+
/**
|
|
3
|
+
* Accepted `--sbom` values. `spdx2.3` is an explicit alias for the version we
|
|
4
|
+
* emit today, so a future `spdx3` can be added without changing what a plain
|
|
5
|
+
* `spdx` means for anyone already using it in CI.
|
|
6
|
+
*/
|
|
7
|
+
const SBOM_FORMAT_ALIASES = {
|
|
8
|
+
cyclonedx: "cyclonedx",
|
|
9
|
+
spdx: "spdx",
|
|
10
|
+
"spdx2.3": "spdx",
|
|
11
|
+
};
|
|
12
|
+
function parseSbomFormat(value) {
|
|
13
|
+
const valid = Object.keys(SBOM_FORMAT_ALIASES).join(", ");
|
|
14
|
+
if (value === undefined || value.startsWith("-")) {
|
|
15
|
+
throw new Error(`--sbom requires a format. Valid formats: ${valid}.`);
|
|
16
|
+
}
|
|
17
|
+
const format = SBOM_FORMAT_ALIASES[value.toLowerCase()];
|
|
18
|
+
if (!format) {
|
|
19
|
+
throw new Error(`Unknown --sbom format "${value}". Valid formats: ${valid}.`);
|
|
20
|
+
}
|
|
21
|
+
return format;
|
|
22
|
+
}
|
|
2
23
|
export function parseArgs(argv) {
|
|
3
24
|
// Normalize "cve-lite <path> overrides [flags]" to "cve-lite overrides <path> [flags]"
|
|
4
25
|
// so both orderings work. Only reorder when "overrides" is a bare positional (not argv[0]).
|
|
@@ -351,7 +372,21 @@ export function parseArgs(argv) {
|
|
|
351
372
|
continue;
|
|
352
373
|
}
|
|
353
374
|
if (arg === "--cdx") {
|
|
375
|
+
// Permanent alias. --cdx shipped before --sbom existed and stays supported.
|
|
354
376
|
options.cdx = true;
|
|
377
|
+
options.sbom = "cyclonedx";
|
|
378
|
+
continue;
|
|
379
|
+
}
|
|
380
|
+
if (arg === "--sbom") {
|
|
381
|
+
options.sbom = parseSbomFormat(argv[++i]);
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (arg.startsWith("--sbom=")) {
|
|
385
|
+
options.sbom = parseSbomFormat(arg.slice("--sbom=".length));
|
|
386
|
+
continue;
|
|
387
|
+
}
|
|
388
|
+
if (arg === "--sbom-inventory-only") {
|
|
389
|
+
options.sbomInventoryOnly = true;
|
|
355
390
|
continue;
|
|
356
391
|
}
|
|
357
392
|
if (arg === "--audit-log") {
|
|
@@ -399,8 +434,12 @@ export function parseArgs(argv) {
|
|
|
399
434
|
}
|
|
400
435
|
throw new Error(`Unexpected argument: ${arg}`);
|
|
401
436
|
}
|
|
402
|
-
if (options.
|
|
403
|
-
|
|
437
|
+
if (options.sbom && options.report) {
|
|
438
|
+
const flag = options.cdx ? "--cdx" : "--sbom";
|
|
439
|
+
throw new Error(`cannot combine ${flag} and --report`);
|
|
440
|
+
}
|
|
441
|
+
if (options.sbomInventoryOnly && !options.sbom) {
|
|
442
|
+
throw new Error("--sbom-inventory-only only applies to SBOM output. Add --sbom <format>, or drop --sbom-inventory-only.");
|
|
404
443
|
}
|
|
405
444
|
return { command: "scan", options, projectArg };
|
|
406
445
|
}
|
package/dist/cli/help.js
CHANGED
|
@@ -34,7 +34,9 @@ export function printHelp() {
|
|
|
34
34
|
" --json Save scan results to a timestamped JSON file",
|
|
35
35
|
" --report [dir] Generate an HTML report in [dir] (default: ./cve-report)",
|
|
36
36
|
" --sarif Write SARIF 2.1.0 output to a timestamped .sarif file",
|
|
37
|
-
" --
|
|
37
|
+
" --sbom <format> Write an SBOM: cyclonedx (1.6) or spdx (2.3), to a timestamped file",
|
|
38
|
+
" --sbom-inventory-only Omit the vulnerability overlay from --sbom, leaving a pure inventory",
|
|
39
|
+
" --cdx Alias for --sbom cyclonedx",
|
|
38
40
|
" --no-open Don't auto-open the report in the browser",
|
|
39
41
|
" --fix Apply validated direct dependency fixes and rescan",
|
|
40
42
|
" --ratchet Save current findings as baseline or, if baseline exists, only fail on new findings",
|
package/dist/cli/validate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { validateCaCertFile } from "./config.js";
|
|
2
2
|
import { validateOsvUrl } from "../utils/validate-url.js";
|
|
3
|
+
import { resolveSbomFormat } from "../utils/sbom-format.js";
|
|
3
4
|
export async function validateOptions(options) {
|
|
4
5
|
if (options.allowPrivateOsvUrl && !options.osvUrl) {
|
|
5
6
|
throw new Error("--allow-private-osv-url requires --osv-url. Provide a custom OSV endpoint with --osv-url, or remove --allow-private-osv-url.");
|
|
@@ -30,8 +31,11 @@ export async function validateOptions(options) {
|
|
|
30
31
|
if (options.fix && options.sarif) {
|
|
31
32
|
throw new Error("--fix cannot be used with --sarif. Use --fix to apply validated fixes and rescan, or --sarif to save scan results as SARIF, not both.");
|
|
32
33
|
}
|
|
33
|
-
if (options.fix && options
|
|
34
|
-
|
|
34
|
+
if (options.fix && resolveSbomFormat(options)) {
|
|
35
|
+
// Name the flag the user actually typed: --cdx is an alias for --sbom cyclonedx.
|
|
36
|
+
const flag = options.cdx ? "--cdx" : "--sbom";
|
|
37
|
+
const what = options.cdx ? "a CycloneDX SBOM" : "an SBOM";
|
|
38
|
+
throw new Error(`--fix cannot be used with ${flag}. Use --fix to apply validated fixes and rescan, or ${flag} to save ${what}, not both.`);
|
|
35
39
|
}
|
|
36
40
|
if (options.createPr && !options.fix) {
|
|
37
41
|
throw new Error("--create-pr requires --fix. Add --fix to apply validated fixes before opening a pull request, or remove --create-pr.");
|
package/dist/index.js
CHANGED
|
@@ -646,7 +646,7 @@ if (parsedArgs) {
|
|
|
646
646
|
licenseFindings,
|
|
647
647
|
licenseLimitedToDirectOnly,
|
|
648
648
|
}, scanInput, projectPath);
|
|
649
|
-
if (!(options.json || options.sarif || options.
|
|
649
|
+
if (!(options.json || options.sarif || options.sbom) || options.verbose) {
|
|
650
650
|
const offline = !!options.offline || !!options.offlineDb;
|
|
651
651
|
const showOverrideHint = !options.checkOverrides && !options.ratchet && hasOverrideEntries(projectPath);
|
|
652
652
|
if (options.verbose) {
|
package/dist/output/cyclonedx.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import fs from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
1
|
import { randomUUID } from "node:crypto";
|
|
4
2
|
import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
|
|
5
3
|
import { getRecommendedAction } from "./formatters.js";
|
|
6
4
|
import { getCliVersion } from "../utils/version-info.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
5
|
+
import { buildPurl } from "../utils/purl.js";
|
|
6
|
+
import { sbomTimestamp, writeSbomFile } from "./sbom-file.js";
|
|
7
|
+
export { buildPurl };
|
|
11
8
|
export function buildCycloneDxBom(allPackages, findings, projectMeta, version, plan = null) {
|
|
12
9
|
const components = allPackages.map(pkg => {
|
|
13
10
|
const purl = buildPurl(pkg.name, pkg.version);
|
|
@@ -54,9 +51,16 @@ export function buildCycloneDxBom(allPackages, findings, projectMeta, version, p
|
|
|
54
51
|
}
|
|
55
52
|
const metadata = {
|
|
56
53
|
timestamp: new Date().toISOString(),
|
|
57
|
-
tools:
|
|
58
|
-
|
|
59
|
-
|
|
54
|
+
tools: {
|
|
55
|
+
components: [
|
|
56
|
+
{
|
|
57
|
+
type: "application",
|
|
58
|
+
name: "CVE Lite CLI",
|
|
59
|
+
version,
|
|
60
|
+
publisher: "OWASP",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
},
|
|
60
64
|
};
|
|
61
65
|
if (projectMeta && projectMeta.name) {
|
|
62
66
|
const metaComponent = {
|
|
@@ -70,7 +74,7 @@ export function buildCycloneDxBom(allPackages, findings, projectMeta, version, p
|
|
|
70
74
|
}
|
|
71
75
|
return {
|
|
72
76
|
bomFormat: "CycloneDX",
|
|
73
|
-
specVersion: "1.
|
|
77
|
+
specVersion: "1.6",
|
|
74
78
|
version: 1,
|
|
75
79
|
serialNumber: `urn:uuid:${randomUUID()}`,
|
|
76
80
|
metadata,
|
|
@@ -79,19 +83,7 @@ export function buildCycloneDxBom(allPackages, findings, projectMeta, version, p
|
|
|
79
83
|
};
|
|
80
84
|
}
|
|
81
85
|
export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
|
|
82
|
-
const
|
|
83
|
-
const filename = `cve-lite-scan-${ts}.cdx.json`;
|
|
84
|
-
const outputPath = path.join(process.cwd(), filename);
|
|
86
|
+
const filename = `cve-lite-scan-${sbomTimestamp()}.cdx.json`;
|
|
85
87
|
const bom = buildCycloneDxBom(allPackages, findings, projectMeta, getCliVersion(), plan);
|
|
86
|
-
|
|
87
|
-
fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
|
|
88
|
-
}
|
|
89
|
-
catch (err) {
|
|
90
|
-
try {
|
|
91
|
-
fs.rmSync(outputPath, { force: true });
|
|
92
|
-
}
|
|
93
|
-
catch { /* best-effort cleanup */ }
|
|
94
|
-
throw new Error(`Failed to write CycloneDX report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
|
|
95
|
-
}
|
|
96
|
-
return filename;
|
|
88
|
+
return writeSbomFile(filename, bom, "CycloneDX report");
|
|
97
89
|
}
|
|
@@ -7,6 +7,7 @@ import { getPrimaryParent, getRootDependencies } from "../utils/finding.js";
|
|
|
7
7
|
import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js";
|
|
8
8
|
import { pluralize } from "../utils/string.js";
|
|
9
9
|
import { hasMaliciousAdvisory } from "../utils/vuln.js";
|
|
10
|
+
import { computePrioritySignal } from "../utils/priority-signal.js";
|
|
10
11
|
export function formatRelationshipLabel(value) {
|
|
11
12
|
if (value.startsWith("direct"))
|
|
12
13
|
return chalk.green(value);
|
|
@@ -242,6 +243,7 @@ export function serializeFinding(finding, plan) {
|
|
|
242
243
|
recommendedNpmTransitiveRemediation: finding.recommendedNpmTransitiveRemediation ?? null,
|
|
243
244
|
cves: finding.cveAliases,
|
|
244
245
|
epssScores: finding.epssScores ?? null,
|
|
246
|
+
prioritySignal: computePrioritySignal(finding.severity, finding.epssScores) ?? null,
|
|
245
247
|
dependencyPaths: finding.dependencyPaths,
|
|
246
248
|
usage: finding.usage ?? null,
|
|
247
249
|
maliciousUnverifiable: finding.maliciousUnverifiable ?? false,
|
|
@@ -253,6 +255,7 @@ export function serializeFinding(finding, plan) {
|
|
|
253
255
|
aliases: v.aliases ?? [],
|
|
254
256
|
summary: v.summary ?? "",
|
|
255
257
|
severity: inferSeverity(v),
|
|
258
|
+
cvssScore: (v.severity ?? []).find(s => s.type?.startsWith("CVSS"))?.score ?? null,
|
|
256
259
|
})),
|
|
257
260
|
};
|
|
258
261
|
}
|
|
@@ -300,3 +303,16 @@ export function sortFindingsForOutput(findings) {
|
|
|
300
303
|
export function countUniqueAdvisories(findings) {
|
|
301
304
|
return new Set(findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
302
305
|
}
|
|
306
|
+
export function countProdFindings(findings) {
|
|
307
|
+
const devFlagAvailable = findings.some(f => f.pkg.dev !== undefined);
|
|
308
|
+
if (!devFlagAvailable)
|
|
309
|
+
return null;
|
|
310
|
+
const devTotal = findings.filter(f => f.pkg.dev === true).length;
|
|
311
|
+
if (devTotal === 0)
|
|
312
|
+
return null;
|
|
313
|
+
return {
|
|
314
|
+
prodTotal: findings.length - devTotal,
|
|
315
|
+
devTotal,
|
|
316
|
+
total: findings.length,
|
|
317
|
+
};
|
|
318
|
+
}
|
|
@@ -10,6 +10,7 @@ import { hasMaliciousAdvisory } from "../utils/vuln.js";
|
|
|
10
10
|
import { renderOverrideFindingsHtml } from "./override-findings-html.js";
|
|
11
11
|
import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
|
|
12
12
|
import { renderLicenseFindingsHtml } from "./license-findings-html.js";
|
|
13
|
+
import { PRIORITY_SIGNAL_LABELS, PRIORITY_SIGNAL_DESCRIPTIONS, PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS } from "../utils/priority-signal.js";
|
|
13
14
|
import { UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
|
|
14
15
|
import { getCompletenessImpact } from "../scan/completeness.js";
|
|
15
16
|
export function serializeHtmlFinding(finding, plan) {
|
|
@@ -210,7 +211,20 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
|
|
|
210
211
|
.maintenance-risk table tbody tr{border-bottom:1px solid var(--border-sub)}
|
|
211
212
|
.maintenance-risk table tbody tr:last-child{border-bottom:none}
|
|
212
213
|
.maintenance-risk table tbody tr:hover{background:var(--surface)}
|
|
213
|
-
.maintenance-risk table tbody td{padding:11px 14px;font-size:13px;color:var(--text);vertical-align:middle}
|
|
214
|
+
.maintenance-risk table tbody td{padding:11px 14px;font-size:13px;color:var(--text);vertical-align:middle}
|
|
215
|
+
.priority-badge{display:inline-flex;align-items:center;gap:4px;font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.4px;padding:2px 7px;border-radius:4px;white-space:nowrap}
|
|
216
|
+
.priority-badge.fix-now{background:#f8514922;color:#f85149;border:1px solid #f8514966}
|
|
217
|
+
.priority-badge.fix-soon{background:#fb850022;color:#fb8500;border:1px solid #fb850066}
|
|
218
|
+
.priority-badge.monitor{background:#388bfd22;color:#388bfd;border:1px solid #388bfd66}
|
|
219
|
+
.priority-badge.low-priority{background:#8b949e22;color:#8b949e;border:1px solid #8b949e66}
|
|
220
|
+
.priority-none{font-size:11px;color:var(--text-3)}
|
|
221
|
+
.epss-val{font-size:11px;color:var(--text-2);font-family:monospace;white-space:nowrap;cursor:help;border-bottom:1px dotted var(--text-3)}
|
|
222
|
+
.epss-val.hot{color:#a371f7;border-bottom-color:#a371f7}
|
|
223
|
+
.priority-legend{background:var(--surface);border:1px solid var(--border);border-radius:8px;padding:14px 18px;margin:16px 0 24px}
|
|
224
|
+
.priority-legend h4{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:var(--text-2);margin-bottom:12px}
|
|
225
|
+
.priority-legend-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:10px}
|
|
226
|
+
.priority-legend-item{display:flex;align-items:flex-start;gap:10px;font-size:12px;color:var(--text-2);line-height:1.5}
|
|
227
|
+
.sev-dev-note{text-align:center;font-size:12px;color:var(--text-2);margin:-12px 0 16px;padding:0 32px}`;
|
|
214
228
|
export function renderHtmlReport(data) {
|
|
215
229
|
const projectName = path.basename(data.projectPath);
|
|
216
230
|
const scanDate = new Date(data.scannedAt).toLocaleString();
|
|
@@ -221,6 +235,10 @@ export function renderHtmlReport(data) {
|
|
|
221
235
|
counts[sev]++;
|
|
222
236
|
}
|
|
223
237
|
const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
238
|
+
const devTotal = data.findings.filter(f => f.dev === true).length;
|
|
239
|
+
const devNoteHtml = devTotal > 0
|
|
240
|
+
? `<div class="sev-dev-note">${data.findings.length - devTotal} of ${data.findings.length} findings in prod dependencies</div>`
|
|
241
|
+
: "";
|
|
224
242
|
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
225
243
|
const completenessBannerHtml = renderCompletenessBanner(data.completeness);
|
|
226
244
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
@@ -294,6 +312,7 @@ ${REPORT_STYLES}
|
|
|
294
312
|
<div class="sev-card total"><span class="count">${data.findings.length}</span><span class="label">Packages</span></div>
|
|
295
313
|
<div class="sev-card total"><span class="count">${totalCVEs}</span><span class="label">CVEs</span></div>
|
|
296
314
|
</div>
|
|
315
|
+
${devNoteHtml}
|
|
297
316
|
|
|
298
317
|
${completenessBannerHtml}
|
|
299
318
|
${fixPlanHtml}
|
|
@@ -321,16 +340,19 @@ ${duplicatePackagesHtml}
|
|
|
321
340
|
<th onclick="sortBy('package')">Package <span class="sort-arrow">↕</span></th>
|
|
322
341
|
<th>Fix available</th>
|
|
323
342
|
<th onclick="sortBy('severity')" class="sorted">Severity <span class="sort-arrow" style="color:var(--link)">↓</span></th>
|
|
324
|
-
<th
|
|
343
|
+
<th title="Exploit Prediction Scoring System - likelihood of exploitation in the next 30 days, relative to all CVEs (FIRST.org)">EPSS</th>
|
|
344
|
+
<th>EPSS Priority</th>
|
|
345
|
+
<th onclick="sortBy('relationship')" style="min-width:130px">Type <span class="sort-arrow">↕</span></th>
|
|
325
346
|
<th>Root</th>
|
|
326
347
|
<th>CVE / Advisory</th>
|
|
327
348
|
</tr>
|
|
328
349
|
</thead>
|
|
329
350
|
<tbody id="findings-tbody">
|
|
330
351
|
${findingRowsHtml}
|
|
331
|
-
<tr id="no-results-row" style="display:none"><td colspan="
|
|
352
|
+
<tr id="no-results-row" style="display:none"><td colspan="9" class="no-results">No findings match your search.</td></tr>
|
|
332
353
|
</tbody>
|
|
333
354
|
</table>
|
|
355
|
+
${renderPriorityLegendHtml(data.findings)}
|
|
334
356
|
</div>
|
|
335
357
|
${renderOverrideFindingsHtml(data.overrideFindings, data.projectPath)}
|
|
336
358
|
${renderMaintenanceFindingsHtml(data.maintenanceFindings)}
|
|
@@ -489,15 +511,62 @@ function renderRelBadge(finding) {
|
|
|
489
511
|
}
|
|
490
512
|
return `<span class="rel-badge ${escapeHtml(finding.relationship)}">${escapeHtml(finding.relationship)}</span>`;
|
|
491
513
|
}
|
|
492
|
-
function
|
|
493
|
-
if (!
|
|
514
|
+
function renderPrioritySignalDetailHtml(priority, epssScores) {
|
|
515
|
+
if (!priority)
|
|
516
|
+
return "";
|
|
517
|
+
const label = PRIORITY_SIGNAL_LABELS[priority];
|
|
518
|
+
const desc = PRIORITY_SIGNAL_DESCRIPTIONS[priority];
|
|
519
|
+
const cssClass = priority.replace(/_/g, "-");
|
|
520
|
+
let epssLine = "";
|
|
521
|
+
if (epssScores && epssScores.length > 0) {
|
|
522
|
+
const best = epssScores.slice().sort((a, b) => b.percentile - a.percentile)[0];
|
|
523
|
+
const top = (1 - best.percentile) * 100;
|
|
524
|
+
const topStr = top < 0.01 ? "<0.01" : top < 1 ? top.toFixed(2) : top.toFixed(1);
|
|
525
|
+
epssLine = `<p style="font-size:12px;color:var(--text-3);margin-top:4px">${escapeHtml(best.cve)} - top ${topStr}% exploitation likelihood (EPSS: ${(best.epss * 100).toFixed(2)}%)</p>`;
|
|
526
|
+
}
|
|
527
|
+
return `<h4 class="detail-subheading">EPSS Priority Signal</h4>
|
|
528
|
+
<p><span class="priority-badge ${escapeHtml(cssClass)}">${escapeHtml(label)}</span> ${escapeHtml(desc)}</p>
|
|
529
|
+
${epssLine}`;
|
|
530
|
+
}
|
|
531
|
+
export function renderPriorityLegendHtml(findings) {
|
|
532
|
+
const hasEpss = findings.some(f => f.epssScores && f.epssScores.length > 0);
|
|
533
|
+
if (!hasEpss)
|
|
494
534
|
return "";
|
|
495
|
-
const
|
|
496
|
-
|
|
535
|
+
const items = [
|
|
536
|
+
{ signal: "fix_now", label: PRIORITY_SIGNAL_LABELS.fix_now, desc: PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS.fix_now },
|
|
537
|
+
{ signal: "fix_soon", label: PRIORITY_SIGNAL_LABELS.fix_soon, desc: PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS.fix_soon },
|
|
538
|
+
{ signal: "monitor", label: PRIORITY_SIGNAL_LABELS.monitor, desc: PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS.monitor },
|
|
539
|
+
{ signal: "low_priority", label: PRIORITY_SIGNAL_LABELS.low_priority, desc: PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS.low_priority },
|
|
540
|
+
];
|
|
541
|
+
const itemsHtml = items.map(({ signal, label, desc }) => {
|
|
542
|
+
const cssClass = signal.replace(/_/g, "-");
|
|
543
|
+
return `<div class="priority-legend-item"><span class="priority-badge ${escapeHtml(cssClass)}">${escapeHtml(label)}</span><span>${escapeHtml(desc)}</span></div>`;
|
|
544
|
+
}).join("\n");
|
|
545
|
+
return `<div class="priority-legend">
|
|
546
|
+
<h4>Priority Signal - severity x exploitation likelihood</h4>
|
|
547
|
+
<div class="priority-legend-grid">
|
|
548
|
+
${itemsHtml}
|
|
549
|
+
</div>
|
|
550
|
+
<p style="margin-top:10px;font-size:11px;color:var(--text-3)">EPSS = Exploit Prediction Scoring System (FIRST.org). "top X%" = this CVE is among the X% most likely to be exploited across all published CVEs. "-" is shown in the EPSS and EPSS Priority columns when EPSS data is unavailable for a finding.</p>
|
|
551
|
+
</div>`;
|
|
552
|
+
}
|
|
553
|
+
function renderEpssColumnHtml(epssScores) {
|
|
554
|
+
if (!epssScores || epssScores.length === 0)
|
|
555
|
+
return `<span class="priority-none">-</span>`;
|
|
556
|
+
const best = epssScores.slice().sort((a, b) => b.percentile - a.percentile)[0];
|
|
497
557
|
const top = (1 - best.percentile) * 100;
|
|
498
558
|
const topStr = top < 0.01 ? "<0.01" : top < 1 ? top.toFixed(2) : top.toFixed(1);
|
|
499
|
-
|
|
500
|
-
|
|
559
|
+
const isHot = best.percentile >= 0.90;
|
|
560
|
+
const hotClass = isHot ? " hot" : "";
|
|
561
|
+
const tooltip = `This CVE is more likely to be exploited than ${(best.percentile * 100).toFixed(0)}% of all published CVEs (EPSS score: ${(best.epss * 100).toFixed(2)}%)`;
|
|
562
|
+
return `<span class="epss-val${hotClass}" title="${escapeHtml(tooltip)}">top ${topStr}%</span>`;
|
|
563
|
+
}
|
|
564
|
+
function renderPriorityColumnHtml(priority) {
|
|
565
|
+
if (!priority)
|
|
566
|
+
return `<span class="priority-none">-</span>`;
|
|
567
|
+
const label = PRIORITY_SIGNAL_LABELS[priority];
|
|
568
|
+
const cssClass = priority.replace(/_/g, "-");
|
|
569
|
+
return `<span class="priority-badge ${escapeHtml(cssClass)}">${escapeHtml(label)}</span>`;
|
|
501
570
|
}
|
|
502
571
|
export function renderFindingRow(finding, idx, skippedKeys) {
|
|
503
572
|
const cveLinks = finding.cves.length > 0
|
|
@@ -539,17 +608,21 @@ export function renderFindingRow(finding, idx, skippedKeys) {
|
|
|
539
608
|
const rootDepsHtml = finding.rootDependencies.length > 0
|
|
540
609
|
? finding.rootDependencies.map(name => `<span class="root-dep">${escapeHtml(name)}</span>`).join(", ")
|
|
541
610
|
: `<span class="root-dep-none">-</span>`;
|
|
611
|
+
const epssHtml = renderEpssColumnHtml(finding.epssScores);
|
|
612
|
+
const priorityHtml = renderPriorityColumnHtml(finding.prioritySignal);
|
|
542
613
|
return `<tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
|
|
543
614
|
<td><span class="expand-icon" id="icon-${idx}">▶</span></td>
|
|
544
615
|
<td><div class="pkg-name"><a href="https://www.npmjs.com/package/${encodeURIComponent(finding.package)}" target="_blank" rel="noopener noreferrer">${escapeHtml(finding.package)}</a></div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
|
|
545
616
|
<td>${fixHtml}</td>
|
|
546
617
|
<td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
|
|
618
|
+
<td>${epssHtml}</td>
|
|
619
|
+
<td>${priorityHtml}</td>
|
|
547
620
|
<td>${renderRelBadge(finding)}</td>
|
|
548
621
|
<td>${rootDepsHtml}</td>
|
|
549
622
|
<td>${cveLinks}</td>
|
|
550
623
|
</tr>
|
|
551
624
|
<tr id="detail-${idx}" class="detail-row">
|
|
552
|
-
<td colspan="
|
|
625
|
+
<td colspan="9">
|
|
553
626
|
<div class="expanded-inner">
|
|
554
627
|
<div class="detail-col" style="max-width:320px">
|
|
555
628
|
<h4>Description</h4>
|
|
@@ -567,7 +640,7 @@ export function renderFindingRow(finding, idx, skippedKeys) {
|
|
|
567
640
|
<p>${escapeHtml(finding.riskSummary)}</p>
|
|
568
641
|
<h4 class="detail-subheading">Next action</h4>
|
|
569
642
|
<p>${escapeHtml(finding.nextAction)}</p>
|
|
570
|
-
${
|
|
643
|
+
${renderPrioritySignalDetailHtml(finding.prioritySignal, finding.epssScores)}
|
|
571
644
|
</div>
|
|
572
645
|
</div>
|
|
573
646
|
</td>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { aggregateMultiFolderCompleteness } from "../scan/completeness.js";
|
|
4
|
-
import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, renderCompletenessBanner, serializeHtmlFinding, } from "./html-reporter.js";
|
|
4
|
+
import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, renderCompletenessBanner, serializeHtmlFinding, renderPriorityLegendHtml, } from "./html-reporter.js";
|
|
5
5
|
import { renderOverrideFindingsHtml } from "./override-findings-html.js";
|
|
6
6
|
import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
|
|
7
7
|
import { renderLicenseFindingsHtml } from "./license-findings-html.js";
|
|
@@ -79,7 +79,7 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
|
|
|
79
79
|
? renderLicenseFindingsHtml(result.licenseFindings, { limitedToDirectOnly: result.licenseLimitedToDirectOnly })
|
|
80
80
|
: "";
|
|
81
81
|
const emptyRow = result.sorted.length === 0
|
|
82
|
-
? `<tr><td colspan="
|
|
82
|
+
? `<tr><td colspan="9" style="text-align:center;padding:24px;color:#8b949e">No findings</td></tr>`
|
|
83
83
|
: "";
|
|
84
84
|
return `
|
|
85
85
|
<details class="folder-section"${isOpen ? " open" : ""}>
|
|
@@ -114,6 +114,8 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
|
|
|
114
114
|
<th onclick="sortBy('package',${fi})">Package <span class="sort-arrow">↕</span></th>
|
|
115
115
|
<th>Fix available</th>
|
|
116
116
|
<th onclick="sortBy('severity',${fi})" class="sorted">Severity <span class="sort-arrow" style="color:#58a6ff">↓</span></th>
|
|
117
|
+
<th title="Exploit Prediction Scoring System - likelihood of exploitation in the next 30 days, relative to all CVEs (FIRST.org)">EPSS</th>
|
|
118
|
+
<th>EPSS Priority</th>
|
|
117
119
|
<th onclick="sortBy('relationship',${fi})">Type <span class="sort-arrow">↕</span></th>
|
|
118
120
|
<th>Root</th>
|
|
119
121
|
<th>CVE / Advisory</th>
|
|
@@ -121,7 +123,7 @@ function renderFolderSection(result, folderIdx, idxOffset, serialized, projectRo
|
|
|
121
123
|
</thead>
|
|
122
124
|
<tbody id="findings-tbody-${fi}" data-offset="${idxOffset}">
|
|
123
125
|
${emptyRow}${findingRowsHtml}
|
|
124
|
-
<tr id="no-results-row-${fi}" style="display:none"><td colspan="
|
|
126
|
+
<tr id="no-results-row-${fi}" style="display:none"><td colspan="9" class="no-results">No findings match your search.</td></tr>
|
|
125
127
|
</tbody>
|
|
126
128
|
</table>
|
|
127
129
|
</div>
|
|
@@ -239,6 +241,8 @@ ${aggregateBannerHtml}
|
|
|
239
241
|
|
|
240
242
|
${folderSectionsHtml}
|
|
241
243
|
|
|
244
|
+
${renderPriorityLegendHtml(reportData.findings)}
|
|
245
|
+
|
|
242
246
|
<div class="report-footer">
|
|
243
247
|
<span>Generated by <strong>cve-lite v${escapeHtml(params.cliVersion)}</strong></span>
|
|
244
248
|
<span>${folderCount} ${pluralize(folderCount, "folder")} · ${totalFindings} findings · ${totalCVEs} CVEs</span>
|