cve-lite-cli 1.28.0 → 1.29.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 +28 -3
- package/dist/cli/validate.js +6 -0
- package/dist/index.js +21 -5
- package/dist/maintenance/dm001-maintenance-risk.js +74 -15
- package/dist/maintenance/score.js +51 -0
- package/dist/output/formatters.js +2 -1
- package/dist/output/html-reporter.js +115 -2
- package/dist/output/maintenance-findings-html.js +4 -0
- package/dist/output/maintenance-findings-sarif.js +58 -0
- package/dist/output/maintenance-terminal.js +63 -5
- package/dist/output/multi-folder-html-reporter.js +61 -5
- package/dist/output/multi-folder-printer.js +11 -2
- package/dist/output/printers.js +76 -16
- package/dist/output/sarif.js +23 -7
- package/dist/output/write-outputs.js +4 -1
- package/dist/parsers/bun-lock.js +47 -7
- package/dist/parsers/npm-lock-graph.js +90 -12
- package/dist/parsers/pnpm-lock.js +42 -6
- package/dist/parsers/utils.js +0 -15
- package/dist/parsers/yarn-lock.js +140 -58
- package/dist/remediation/npm-registry.js +69 -52
- package/dist/scan/completeness.js +49 -0
- package/dist/scan/multi-folder-scan.js +167 -14
- package/dist/scanner.js +210 -155
- package/dist/usage/scanner.js +12 -2
- package/dist/utils/vuln.js +16 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -133,6 +133,24 @@ cve-lite /path/to/project --check-overrides # CVE scan + hygiene in one pass
|
|
|
133
133
|
|
|
134
134
|
For the full guide with per-rule examples and CI patterns, see the [Override Hygiene Auditing guide](https://owasp.org/cve-lite-cli/docs/override-hygiene).
|
|
135
135
|
|
|
136
|
+
## Maintenance risk (`--check-maintenance`)
|
|
137
|
+
|
|
138
|
+
A CVE scanner tells you a transitive package is vulnerable. It does not tell you *why you can't fix it* - often a direct dependency of yours pins it below the fix, and clearing it needs a breaking major upgrade the scanner never mentions. The DM001 rule surfaces exactly that, plus direct dependencies npm has marked deprecated.
|
|
139
|
+
|
|
140
|
+
| Signal | Severity | What it means |
|
|
141
|
+
|---|---|---|
|
|
142
|
+
| Constraint drag | high | A direct dependency blocks a transitive CVE fix behind a major-version upgrade |
|
|
143
|
+
| Deprecated on npm | medium | A direct dependency is deprecated - no fix is coming through a normal update |
|
|
144
|
+
|
|
145
|
+
Packages that have not published in years get a `Last release` context line; release age is informational, not a severity signal on its own.
|
|
146
|
+
|
|
147
|
+
```bash
|
|
148
|
+
cve-lite /path/to/project --check-maintenance # CVE scan + maintenance risk
|
|
149
|
+
cve-lite /path/to/project --check-maintenance --fail-on high
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
For the full guide, see the [Maintenance Risk Detection guide](https://owasp.org/cve-lite-cli/docs/maintenance-risk).
|
|
153
|
+
|
|
136
154
|
## Release cooldown awareness
|
|
137
155
|
|
|
138
156
|
Package managers added a release cooldown to skip the danger window right after a version is published, when a hijacked release is live but not yet caught (the `chalk`/`debug` compromise sat live for about two hours). CVE Lite CLI reads the cooldown your project already configures and warns when a recommended fix is newer than that window, so it never quietly pushes you onto a version your own package manager would refuse to install.
|
|
@@ -211,6 +229,7 @@ No other free tool combines all of the following: lockfile scanning across npm,
|
|
|
211
229
|
| JSON output | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
212
230
|
| Offline/local advisory DB | ✅ | ❌ | ⚠️ | ❌ | ❌ |
|
|
213
231
|
| Override hygiene auditing | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
232
|
+
| Maintenance-risk detection (CVE-fix drag) | ✅ | ❌ | ❌ | ❌ | ❌ |
|
|
214
233
|
|
|
215
234
|
<sub>✅ = built-in strength · ⚠️ = partial or workflow-dependent · ❌ = not a core strength</sub>
|
|
216
235
|
|
|
@@ -238,7 +257,7 @@ jobs:
|
|
|
238
257
|
fix:
|
|
239
258
|
runs-on: ubuntu-latest
|
|
240
259
|
steps:
|
|
241
|
-
- uses: actions/checkout@
|
|
260
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
242
261
|
with:
|
|
243
262
|
ref: ${{ github.event.repository.default_branch }}
|
|
244
263
|
- uses: OWASP/cve-lite-cli@v1
|
|
@@ -350,7 +369,7 @@ gh attestation verify cve-lite-cli-X.Y.Z.tgz --repo OWASP/cve-lite-cli
|
|
|
350
369
|
npm audit signatures
|
|
351
370
|
```
|
|
352
371
|
|
|
353
|
-
For full details, fingerprints, and the project's threat model, see [SECURITY.md](https://github.com/OWASP/cve-lite-cli/blob/main/
|
|
372
|
+
For full details, fingerprints, and the project's threat model, see [SECURITY.md](https://github.com/OWASP/cve-lite-cli/blob/main/SECURITY.md) and the [Security Assurance Case](https://owasp.org/cve-lite-cli/docs/security-assurance-case).
|
|
354
373
|
|
|
355
374
|
For governance details - roles, decision-making, and dispute resolution - see [CONTRIBUTING.md](https://github.com/OWASP/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md).
|
|
356
375
|
|
|
@@ -378,7 +397,7 @@ Helpful feedback includes reproducible bug reports, real-world lockfile edge cas
|
|
|
378
397
|
|
|
379
398
|
Using CVE Lite CLI at your company or in your projects? [Share your use case in the community thread](https://github.com/OWASP/cve-lite-cli/discussions/481).
|
|
380
399
|
|
|
381
|
-
For security-related reporting: [SECURITY.md](https://github.com/OWASP/cve-lite-cli/blob/main/
|
|
400
|
+
For security-related reporting: [SECURITY.md](https://github.com/OWASP/cve-lite-cli/blob/main/SECURITY.md)
|
|
382
401
|
|
|
383
402
|
This project follows a [Code of Conduct](https://github.com/OWASP/cve-lite-cli/blob/main/CODE_OF_CONDUCT.md). Please review it before participating.
|
|
384
403
|
|
|
@@ -400,6 +419,12 @@ Thanks to everyone who helps improve CVE Lite CLI - issues, pull requests, docum
|
|
|
400
419
|
|
|
401
420
|
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.
|
|
402
421
|
|
|
422
|
+
## Sponsors
|
|
423
|
+
|
|
424
|
+
Thank you to those who sponsor CVE Lite CLI and help keep it maintained:
|
|
425
|
+
|
|
426
|
+
- [Arkadii Yakovets](https://github.com/arkid15r)
|
|
427
|
+
|
|
403
428
|
---
|
|
404
429
|
|
|
405
430
|
**Maintainer note:** CVE Lite CLI is an OWASP Lab Project maintained by [Sonu Kapoor](https://github.com/sonukapoor). The goal is to build a tool the security and developer community trusts and returns to - not a product that requires vendor lock-in or a dashboard to be useful. If you find a real-world lockfile edge case, a remediation gap, or a workflow that doesn't fit, open an issue. Real-world feedback from real projects is the most valuable input this project gets. See [CONTRIBUTING.md](https://github.com/OWASP/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md) for how to get involved.
|
package/dist/cli/validate.js
CHANGED
|
@@ -24,6 +24,12 @@ export async function validateOptions(options) {
|
|
|
24
24
|
if (options.fix && options.json) {
|
|
25
25
|
throw new Error("--fix cannot be used with --json");
|
|
26
26
|
}
|
|
27
|
+
if (options.fix && options.sarif) {
|
|
28
|
+
throw new Error("--fix cannot be used with --sarif");
|
|
29
|
+
}
|
|
30
|
+
if (options.fix && options.cdx) {
|
|
31
|
+
throw new Error("--fix cannot be used with --cdx");
|
|
32
|
+
}
|
|
27
33
|
if (options.createPr && !options.fix) {
|
|
28
34
|
throw new Error("--create-pr requires --fix");
|
|
29
35
|
}
|
package/dist/index.js
CHANGED
|
@@ -202,7 +202,13 @@ if (parsedArgs) {
|
|
|
202
202
|
// route to dedicated multi-folder handler instead of single-lockfile scan
|
|
203
203
|
const nestedLockfiles = findNestedLockfiles(projectPath, searchDepth);
|
|
204
204
|
if (!hasRootLockfile(projectPath) && nestedLockfiles.length >= 2) {
|
|
205
|
-
const exitCode = await handleMultiFolderScan({
|
|
205
|
+
const exitCode = await handleMultiFolderScan({
|
|
206
|
+
projectRoot: projectPath,
|
|
207
|
+
batchSize,
|
|
208
|
+
options,
|
|
209
|
+
fetchImpl: certFetch,
|
|
210
|
+
auditLog: auditLogHandle,
|
|
211
|
+
});
|
|
206
212
|
auditLogHandle.close();
|
|
207
213
|
process.exit(exitCode);
|
|
208
214
|
}
|
|
@@ -580,7 +586,9 @@ if (parsedArgs) {
|
|
|
580
586
|
// This point is unreached in --ratchet mode (which always exits above
|
|
581
587
|
// via process.exit), so packument fetches never run wastefully there.
|
|
582
588
|
if (options.checkMaintenance) {
|
|
583
|
-
|
|
589
|
+
const directNames = readDirectDependencyNames(projectPath, !!options.prodOnly);
|
|
590
|
+
const directDependencies = scanState.allPackages.filter(p => directNames?.has(p.name));
|
|
591
|
+
maintenanceFindings = await detectDM001(scanState.sorted, directDependencies, !!options.offline || !!options.offlineDb);
|
|
584
592
|
}
|
|
585
593
|
await writeOutputs(options, {
|
|
586
594
|
sorted: scanState.sorted,
|
|
@@ -589,6 +597,7 @@ if (parsedArgs) {
|
|
|
589
597
|
coverage: scanState.coverage,
|
|
590
598
|
minSeverity: scanState.minSeverity,
|
|
591
599
|
tableFindings: scanState.tableFindings,
|
|
600
|
+
completeness: scanState.completeness,
|
|
592
601
|
overrideFindings,
|
|
593
602
|
maintenanceFindings,
|
|
594
603
|
}, scanInput, projectPath);
|
|
@@ -623,7 +632,7 @@ if (parsedArgs) {
|
|
|
623
632
|
console.log("\n" + renderMaintenanceFindings(maintenanceFindings, { verbose: true }));
|
|
624
633
|
}
|
|
625
634
|
printCoverage([...scanInput.notes, ...scanState.coverage]);
|
|
626
|
-
printFinalStatus(scanState.sorted, overrideCount);
|
|
635
|
+
printFinalStatus(scanState.sorted, overrideCount, scanState.completeness);
|
|
627
636
|
if (showOverrideHint)
|
|
628
637
|
printOverrideHint();
|
|
629
638
|
}
|
|
@@ -631,7 +640,12 @@ if (parsedArgs) {
|
|
|
631
640
|
const compactPmLabel = scanState.suggestedFixCommands
|
|
632
641
|
? `${chalk.cyan(scanState.suggestedFixCommands.packageManager)} ${chalk.gray(`(${scanState.suggestedFixCommands.sourceLabel})`)}`
|
|
633
642
|
: undefined;
|
|
634
|
-
printCompactOutput(scanState.sorted, scanInput, {
|
|
643
|
+
printCompactOutput(scanState.sorted, scanInput, {
|
|
644
|
+
offline,
|
|
645
|
+
all: !!options.all,
|
|
646
|
+
packageManager: compactPmLabel,
|
|
647
|
+
completeness: scanState.completeness,
|
|
648
|
+
});
|
|
635
649
|
if (options.checkOverrides) {
|
|
636
650
|
console.log("\n" + renderOverrideFindings(overrideFindings, { verbose: false, projectPath }));
|
|
637
651
|
}
|
|
@@ -661,6 +675,7 @@ if (parsedArgs) {
|
|
|
661
675
|
overrideFindings: options.checkOverrides ? overrideFindings : undefined,
|
|
662
676
|
// Same undefined-vs-[] convention as overrideFindings above.
|
|
663
677
|
maintenanceFindings: options.checkMaintenance ? maintenanceFindings : undefined,
|
|
678
|
+
completeness: scanState.completeness,
|
|
664
679
|
});
|
|
665
680
|
const { reportPath } = await writeHtmlReport({
|
|
666
681
|
outputDir,
|
|
@@ -731,7 +746,7 @@ if (parsedArgs) {
|
|
|
731
746
|
}
|
|
732
747
|
async function scanProject(params) {
|
|
733
748
|
const directDependencyNames = readDirectDependencyNames(params.projectPath, !!params.options.prodOnly);
|
|
734
|
-
const findings = await scanPackages(params.scanInput.packages, params.batchSize, params.options, {
|
|
749
|
+
const { findings, completeness } = await scanPackages(params.scanInput.packages, params.batchSize, params.options, {
|
|
735
750
|
directDependencyNames,
|
|
736
751
|
scanSource: params.scanInput.source,
|
|
737
752
|
scanFilePath: params.scanInput.filePath,
|
|
@@ -789,5 +804,6 @@ async function scanProject(params) {
|
|
|
789
804
|
tableFindings,
|
|
790
805
|
suggestedFixCommands,
|
|
791
806
|
allPackages: params.scanInput.packages,
|
|
807
|
+
completeness,
|
|
792
808
|
};
|
|
793
809
|
}
|
|
@@ -1,9 +1,58 @@
|
|
|
1
1
|
import { fetchPackument } from "../remediation/npm-registry.js";
|
|
2
|
-
|
|
2
|
+
import { computeStaleness, scoreMaintenanceFinding } from "./score.js";
|
|
3
|
+
import { runWithConcurrency } from "../utils/array.js";
|
|
4
|
+
const SEVERITY_ORDER_MAP = { high: 0, medium: 1, low: 2 };
|
|
5
|
+
// Bounds concurrent packument fetches for the deprecated-only pass over direct
|
|
6
|
+
// dependencies so a large dependency tree does not fire hundreds of requests at once.
|
|
7
|
+
const DEPRECATED_CHECK_CONCURRENCY = 10;
|
|
3
8
|
function majorOf(version) {
|
|
4
9
|
return parseInt(version.split(".")[0] ?? "0", 10);
|
|
5
10
|
}
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Looks up the deprecation message on a packument's `latest` dist-tag version, if any.
|
|
13
|
+
* Deprecation is checked on `latest` (package-level abandonment signal), not the
|
|
14
|
+
* version actually installed.
|
|
15
|
+
*/
|
|
16
|
+
function deprecationMessageOf(packument) {
|
|
17
|
+
if (!packument) {
|
|
18
|
+
return "";
|
|
19
|
+
}
|
|
20
|
+
const latestVersion = packument["dist-tags"]?.latest ?? "";
|
|
21
|
+
if (!latestVersion) {
|
|
22
|
+
return "";
|
|
23
|
+
}
|
|
24
|
+
return packument.versions?.[latestVersion]?.deprecated ?? "";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Checks a single direct dependency (already known not to be a drag candidate) for
|
|
28
|
+
* npm-level deprecation and, if deprecated, builds a DM001 finding for it. Returns
|
|
29
|
+
* null when the dependency is not deprecated or the packument fetch fails.
|
|
30
|
+
*/
|
|
31
|
+
async function checkDeprecatedOnly(dep) {
|
|
32
|
+
let packument;
|
|
33
|
+
try {
|
|
34
|
+
packument = await fetchPackument(dep.name);
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
const deprecatedMsg = deprecationMessageOf(packument);
|
|
40
|
+
if (!deprecatedMsg) {
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
const staleness = computeStaleness(packument, new Date());
|
|
44
|
+
const severity = scoreMaintenanceFinding({ drag: false, deprecated: true }).severity;
|
|
45
|
+
return {
|
|
46
|
+
ruleId: "DM001",
|
|
47
|
+
severity,
|
|
48
|
+
package: { name: dep.name, version: dep.version },
|
|
49
|
+
drag: undefined,
|
|
50
|
+
deprecated: { message: deprecatedMsg },
|
|
51
|
+
staleness: staleness ?? undefined,
|
|
52
|
+
message: `Deprecated: ${deprecatedMsg}`,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export async function detectDM001(findings, directDependencies, isOffline) {
|
|
7
56
|
// Step 1: Collect drag candidates (transitive findings requiring a major-version parent bump)
|
|
8
57
|
const candidates = new Map();
|
|
9
58
|
for (const finding of findings) {
|
|
@@ -23,39 +72,49 @@ export async function detectDM001(findings, isOffline) {
|
|
|
23
72
|
cveId: finding.cveAliases[0] ?? finding.vulnerabilities[0]?.id ?? "",
|
|
24
73
|
});
|
|
25
74
|
}
|
|
26
|
-
|
|
27
|
-
return [];
|
|
28
|
-
// Step 2: Check deprecated status for each candidate (skip when offline)
|
|
75
|
+
// Step 2: Check deprecated status for each drag candidate (skip when offline)
|
|
29
76
|
const results = [];
|
|
30
77
|
for (const [parentName, candidate] of candidates) {
|
|
31
78
|
let deprecated;
|
|
79
|
+
let packument = null;
|
|
32
80
|
if (!isOffline) {
|
|
33
81
|
try {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
? (packument.versions?.[latestVersion]?.deprecated ?? "")
|
|
39
|
-
: "";
|
|
40
|
-
if (deprecatedMsg)
|
|
41
|
-
deprecated = { message: deprecatedMsg };
|
|
82
|
+
packument = await fetchPackument(parentName);
|
|
83
|
+
const deprecatedMsg = deprecationMessageOf(packument);
|
|
84
|
+
if (deprecatedMsg) {
|
|
85
|
+
deprecated = { message: deprecatedMsg };
|
|
42
86
|
}
|
|
43
87
|
}
|
|
44
88
|
catch {
|
|
45
|
-
// Network error - emit drag finding without deprecated signal
|
|
89
|
+
// Network error - emit drag finding without deprecated/staleness signal
|
|
90
|
+
packument = null;
|
|
46
91
|
}
|
|
47
92
|
}
|
|
93
|
+
const staleness = isOffline ? null : computeStaleness(packument, new Date());
|
|
94
|
+
const severity = scoreMaintenanceFinding({ drag: true, deprecated: !!deprecated }).severity;
|
|
48
95
|
const pkgList = candidate.dragSignals.map(d => d.constrainedPackage).join(", ");
|
|
49
96
|
const message = `Constrains ${pkgList} - blocks CVE fix requiring major upgrade`;
|
|
50
97
|
results.push({
|
|
51
98
|
ruleId: "DM001",
|
|
52
|
-
severity
|
|
99
|
+
severity,
|
|
53
100
|
package: { name: parentName, version: candidate.parentVersion },
|
|
54
101
|
drag: candidate.dragSignals,
|
|
55
102
|
deprecated,
|
|
103
|
+
staleness: staleness ?? undefined,
|
|
56
104
|
message,
|
|
57
105
|
});
|
|
58
106
|
}
|
|
107
|
+
// Step 3: Deprecated-only pass over direct dependencies not already covered by
|
|
108
|
+
// drag (package-level abandonment, independent of any CVE-driven parent upgrade).
|
|
109
|
+
if (!isOffline) {
|
|
110
|
+
const uncoveredDeps = directDependencies.filter(dep => !candidates.has(dep.name));
|
|
111
|
+
const deprecatedOnlyFindings = await runWithConcurrency(uncoveredDeps, DEPRECATED_CHECK_CONCURRENCY, checkDeprecatedOnly);
|
|
112
|
+
for (const finding of deprecatedOnlyFindings) {
|
|
113
|
+
if (finding) {
|
|
114
|
+
results.push(finding);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
59
118
|
return results.sort((a, b) => {
|
|
60
119
|
const sDiff = (SEVERITY_ORDER_MAP[a.severity] ?? 4) - (SEVERITY_ORDER_MAP[b.severity] ?? 4);
|
|
61
120
|
return sDiff !== 0 ? sDiff : a.package.name.localeCompare(b.package.name);
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Severity comes only from explicit maintainer signals: drag (a package holding a
|
|
2
|
+
// transitive dep below its CVE fix) and npm-deprecation. Release age is NOT a
|
|
3
|
+
// severity input - a stable, feature-complete package can be years old and fine;
|
|
4
|
+
// only an explicit signal reliably means "this will not get fixed". Staleness is
|
|
5
|
+
// surfaced as display context (see computeStaleness), never as a score.
|
|
6
|
+
export const DRAG_WEIGHT = 3;
|
|
7
|
+
export const DEPRECATED_WEIGHT = 2;
|
|
8
|
+
// A package is shown as stale (a "Last release: …" context line) only when its
|
|
9
|
+
// latest release is at least this old. This is a display threshold, not a
|
|
10
|
+
// severity threshold.
|
|
11
|
+
export const STALE_YEARS = 2;
|
|
12
|
+
const MS_PER_YEAR = 365.25 * 24 * 60 * 60 * 1000;
|
|
13
|
+
export function scoreMaintenanceFinding(signals) {
|
|
14
|
+
let score = 0;
|
|
15
|
+
if (signals.drag) {
|
|
16
|
+
score += DRAG_WEIGHT;
|
|
17
|
+
}
|
|
18
|
+
if (signals.deprecated) {
|
|
19
|
+
score += DEPRECATED_WEIGHT;
|
|
20
|
+
}
|
|
21
|
+
let severity;
|
|
22
|
+
if (score >= 3) {
|
|
23
|
+
severity = "high";
|
|
24
|
+
}
|
|
25
|
+
else if (score === 2) {
|
|
26
|
+
severity = "medium";
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
severity = "low";
|
|
30
|
+
}
|
|
31
|
+
return { score, severity };
|
|
32
|
+
}
|
|
33
|
+
// Returns a staleness signal ONLY when the latest release is at least STALE_YEARS
|
|
34
|
+
// old - a fresh package produces no signal (and no "Last release" line). This is
|
|
35
|
+
// context to help judge abandonment, not a severity input.
|
|
36
|
+
export function computeStaleness(packument, now) {
|
|
37
|
+
const latest = packument?.["dist-tags"]?.latest;
|
|
38
|
+
const lastPublish = latest ? packument?.time?.[latest] : undefined;
|
|
39
|
+
if (!lastPublish) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
const published = new Date(lastPublish);
|
|
43
|
+
if (Number.isNaN(published.getTime())) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
const ageYears = Math.floor((now.getTime() - published.getTime()) / MS_PER_YEAR);
|
|
47
|
+
if (ageYears < STALE_YEARS) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
return { lastPublish, ageYears };
|
|
51
|
+
}
|
|
@@ -6,6 +6,7 @@ import { inferSeverity } from "../osv/severity.js";
|
|
|
6
6
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
7
7
|
import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js";
|
|
8
8
|
import { pluralize } from "../utils/string.js";
|
|
9
|
+
import { hasMaliciousAdvisory } from "../utils/vuln.js";
|
|
9
10
|
export function formatRelationshipLabel(value) {
|
|
10
11
|
if (value.startsWith("direct"))
|
|
11
12
|
return chalk.green(value);
|
|
@@ -35,7 +36,7 @@ export function formatHintLines(lines) {
|
|
|
35
36
|
}
|
|
36
37
|
// MAL-* is the OSV prefix for malicious code advisories
|
|
37
38
|
function isMaliciousAdvisory(finding) {
|
|
38
|
-
return finding.vulnerabilities
|
|
39
|
+
return hasMaliciousAdvisory(finding.vulnerabilities);
|
|
39
40
|
}
|
|
40
41
|
export function getRecommendedAction(finding) {
|
|
41
42
|
if (isMaliciousAdvisory(finding)) {
|
|
@@ -5,10 +5,12 @@ import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandW
|
|
|
5
5
|
import { loadLogoDataUri } from "./logos.js";
|
|
6
6
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
7
7
|
import { pluralize } from "../utils/string.js";
|
|
8
|
-
import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY } from "../constants.js";
|
|
8
|
+
import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, severityOrder } from "../constants.js";
|
|
9
|
+
import { hasMaliciousAdvisory } from "../utils/vuln.js";
|
|
9
10
|
import { renderOverrideFindingsHtml } from "./override-findings-html.js";
|
|
10
11
|
import { renderMaintenanceFindingsHtml } from "./maintenance-findings-html.js";
|
|
11
12
|
import { UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
|
|
13
|
+
import { getCompletenessImpact } from "../scan/completeness.js";
|
|
12
14
|
export function serializeHtmlFinding(finding, plan) {
|
|
13
15
|
return {
|
|
14
16
|
...serializeFinding(finding, plan),
|
|
@@ -31,6 +33,7 @@ export function buildReportData(params) {
|
|
|
31
33
|
skippedDependencies: params.skippedDependencies,
|
|
32
34
|
overrideFindings: params.overrideFindings,
|
|
33
35
|
maintenanceFindings: params.maintenanceFindings,
|
|
36
|
+
completeness: params.completeness,
|
|
34
37
|
};
|
|
35
38
|
}
|
|
36
39
|
export const REPORT_STYLES = `:root{--bg:#0d1117;--surface:#161b22;--surface-hi:#1c2128;--input:#21262d;--border:#30363d;--border-sub:#21262d;--text:#e6edf3;--text-2:#8b949e;--text-3:#6b7280;--link:#58a6ff;--link-h:#79c0ff;--green:#3fb950;--logo-bg:#fff}
|
|
@@ -84,6 +87,15 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
|
|
|
84
87
|
.skipped-deps{padding:12px 18px;display:flex;flex-direction:column;gap:4px}
|
|
85
88
|
.skipped-deps .skipped-deps-hint{font-size:11px;color:var(--text-2);margin-bottom:4px}
|
|
86
89
|
.skipped-dep{font-size:11px;padding:5px 8px;border-radius:4px;background:var(--bg);border:1px solid var(--border-sub)}
|
|
90
|
+
.dup-pkgs{padding:12px 18px;display:flex;flex-direction:column;gap:10px}
|
|
91
|
+
.dup-pkgs .dup-pkgs-hint{font-size:11px;color:var(--text-2);margin-bottom:2px}
|
|
92
|
+
.dup-pkg{background:var(--bg);border:1px solid var(--border-sub);border-radius:6px;padding:8px 10px}
|
|
93
|
+
.dup-pkg-name{font-size:13px;font-weight:600;color:var(--text);display:flex;align-items:center;gap:8px;margin-bottom:6px}
|
|
94
|
+
.dup-count{font-size:11px;font-weight:500;color:var(--text-2);background:var(--input);border:1px solid var(--border);border-radius:10px;padding:1px 7px}
|
|
95
|
+
.dup-versions{display:flex;flex-direction:column;gap:4px}
|
|
96
|
+
.dup-version{display:flex;align-items:center;gap:8px;font-size:12px;color:var(--text-2)}
|
|
97
|
+
.dup-version .dup-ver{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;color:var(--text)}
|
|
98
|
+
.dup-version .dup-origin{color:var(--text-3)}
|
|
87
99
|
.fix-cmd{display:flex;align-items:center;gap:12px;background:var(--bg);border:1px solid var(--border);border-radius:6px;padding:10px 14px}
|
|
88
100
|
.fix-cmd .cmd-text{flex:1;font-family:'SF Mono','Cascadia Code','Fira Code',monospace;font-size:12px;color:var(--green)}
|
|
89
101
|
.fix-cmd .cmd-meta{font-size:11px;color:var(--text-2);white-space:nowrap}
|
|
@@ -166,6 +178,12 @@ button.header-link:hover{color:var(--link);border-color:var(--link)}
|
|
|
166
178
|
.fix-target-note{color:var(--text-3);font-style:italic;font-size:10px}
|
|
167
179
|
.fix-target-coverage{flex-basis:100%;color:var(--text-3);font-size:10px;line-height:1.45}
|
|
168
180
|
.chain-proof{font-size:0.78rem;color:var(--text-2);margin-left:6px;font-family:monospace}
|
|
181
|
+
.completeness-banner{margin:16px 32px 0;background:#e3b34111;border:1px solid #e3b34144;border-radius:8px;padding:14px 18px;display:flex;gap:14px;align-items:flex-start}
|
|
182
|
+
.completeness-banner-icon{font-size:22px;flex-shrink:0;line-height:1}
|
|
183
|
+
.completeness-banner-body strong{font-size:13px;color:var(--text);display:block;margin-bottom:4px}
|
|
184
|
+
.completeness-banner-body p{font-size:12px;color:var(--text-2);margin:0}
|
|
185
|
+
.completeness-banner-body ul{margin:8px 0 0;padding:0 0 0 18px;display:flex;flex-direction:column;gap:3px}
|
|
186
|
+
.completeness-banner-body li{font-size:11px;color:var(--text-2);line-height:1.5}
|
|
169
187
|
.break-badge{font-size:10px;font-weight:700;background:#fb850022;color:#fb8500;border:1px solid #fb850066;border-radius:4px;padding:1px 5px}
|
|
170
188
|
.tier-ok{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#3fb95022;color:#3fb950;border:1px solid #3fb95033;margin-bottom:6px}
|
|
171
189
|
.tier-warn{display:inline-flex;align-items:center;gap:4px;font-size:10px;padding:2px 8px;border-radius:4px;background:#e3b34122;color:#e3b341;border:1px solid #e3b34133;margin-bottom:6px}
|
|
@@ -199,10 +217,12 @@ export function renderHtmlReport(data) {
|
|
|
199
217
|
}
|
|
200
218
|
const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
201
219
|
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
220
|
+
const completenessBannerHtml = renderCompletenessBanner(data.completeness);
|
|
202
221
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
203
222
|
const skippedKeys = new Set((data.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
|
|
204
223
|
const skippedSectionHtml = renderSkippedSection(data.suggestedFixCommands);
|
|
205
224
|
const skippedDepsHtml = renderSkippedDependenciesSection(data.skippedDependencies);
|
|
225
|
+
const duplicatePackagesHtml = renderDuplicatePackagesSection(data.findings);
|
|
206
226
|
const findingRowsHtml = data.findings.map((f, i) => renderFindingRow(f, i, skippedKeys)).join("\n");
|
|
207
227
|
const dataJson = JSON.stringify(data)
|
|
208
228
|
.replace(/</g, "\\u003c")
|
|
@@ -270,7 +290,9 @@ ${REPORT_STYLES}
|
|
|
270
290
|
<div class="sev-card total"><span class="count">${totalCVEs}</span><span class="label">CVEs</span></div>
|
|
271
291
|
</div>
|
|
272
292
|
|
|
293
|
+
${completenessBannerHtml}
|
|
273
294
|
${fixPlanHtml}
|
|
295
|
+
${duplicatePackagesHtml}
|
|
274
296
|
|
|
275
297
|
<div class="findings-section">
|
|
276
298
|
<div class="findings-header">
|
|
@@ -465,7 +487,7 @@ export function renderFindingRow(finding, idx, skippedKeys) {
|
|
|
465
487
|
const cveLinks = finding.cves.length > 0
|
|
466
488
|
? finding.cves.map(advisoryLink).join(", ")
|
|
467
489
|
: finding.vulnerabilities.map(v => advisoryLink(v.id)).join(", ");
|
|
468
|
-
const isMalicious = finding.vulnerabilities
|
|
490
|
+
const isMalicious = hasMaliciousAdvisory(finding.vulnerabilities);
|
|
469
491
|
const isSkipped = skippedKeys?.has(`${finding.package}@${finding.version}`);
|
|
470
492
|
const fixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
471
493
|
const fixHtml = isSkipped && fixVersion
|
|
@@ -557,6 +579,33 @@ function renderTransitiveContextCol(finding) {
|
|
|
557
579
|
<p style="font-size:12px;color:var(--text-2);margin-top:4px">Run <code>npm ls ${escapeHtml(finding.package)}</code> to find which package pulls it in.</p>
|
|
558
580
|
</div>`;
|
|
559
581
|
}
|
|
582
|
+
export function renderCompletenessBanner(completeness) {
|
|
583
|
+
if (completeness == null || completeness.complete)
|
|
584
|
+
return "";
|
|
585
|
+
const { hasDetectionGap, hasRemediationGap } = getCompletenessImpact(completeness);
|
|
586
|
+
let bannerText;
|
|
587
|
+
if (hasDetectionGap && hasRemediationGap) {
|
|
588
|
+
bannerText = "Some vulnerability findings may be incomplete, and some remediation guidance may also be unavailable because the following issues occurred:";
|
|
589
|
+
}
|
|
590
|
+
else if (hasDetectionGap) {
|
|
591
|
+
bannerText = "Some vulnerability findings may be incomplete because the following issues occurred:";
|
|
592
|
+
}
|
|
593
|
+
else if (hasRemediationGap) {
|
|
594
|
+
bannerText = "Vulnerability findings are available, but remediation guidance may be incomplete because the following issues occurred:";
|
|
595
|
+
}
|
|
596
|
+
else {
|
|
597
|
+
bannerText = "The scan result may be incomplete because the following issues occurred:";
|
|
598
|
+
}
|
|
599
|
+
const diagRows = completeness.diagnostics.map(d => `<li class="diag-item ${escapeHtml(d.severity)} ${escapeHtml(d.impact)}">${escapeHtml(d.message)}</li>`).join("\n");
|
|
600
|
+
return `<div class="completeness-banner">
|
|
601
|
+
<div class="completeness-banner-icon">⚠</div>
|
|
602
|
+
<div class="completeness-banner-body">
|
|
603
|
+
<strong>Scan data is incomplete</strong>
|
|
604
|
+
<p>${bannerText}</p>
|
|
605
|
+
<ul>${diagRows}</ul>
|
|
606
|
+
</div>
|
|
607
|
+
</div>`;
|
|
608
|
+
}
|
|
560
609
|
function renderNotices(notes, warnings) {
|
|
561
610
|
if (notes.length === 0 && warnings.length === 0)
|
|
562
611
|
return "";
|
|
@@ -607,6 +656,70 @@ ${rows}
|
|
|
607
656
|
</div>
|
|
608
657
|
</div>`;
|
|
609
658
|
}
|
|
659
|
+
/**
|
|
660
|
+
* Groups vulnerable findings by package name and keeps only the packages that
|
|
661
|
+
* are installed at more than one version. This is the "same package, multiple
|
|
662
|
+
* versions" view: it shows where duplicate copies of a vulnerable package crept
|
|
663
|
+
* into the dependency tree so they can be consolidated onto one fixed version.
|
|
664
|
+
*/
|
|
665
|
+
export function collectDuplicatePackages(findings) {
|
|
666
|
+
const byName = new Map();
|
|
667
|
+
for (const finding of findings) {
|
|
668
|
+
let versions = byName.get(finding.package);
|
|
669
|
+
if (!versions) {
|
|
670
|
+
versions = new Map();
|
|
671
|
+
byName.set(finding.package, versions);
|
|
672
|
+
}
|
|
673
|
+
// First finding for a given version wins; a second advisory on the same
|
|
674
|
+
// install does not add a duplicate row.
|
|
675
|
+
if (!versions.has(finding.version))
|
|
676
|
+
versions.set(finding.version, finding);
|
|
677
|
+
}
|
|
678
|
+
const duplicates = [];
|
|
679
|
+
for (const [name, versions] of byName) {
|
|
680
|
+
if (versions.size > 1)
|
|
681
|
+
duplicates.push({ name, versions: [...versions.values()] });
|
|
682
|
+
}
|
|
683
|
+
// Most versions first, then alphabetical, so the output is stable.
|
|
684
|
+
duplicates.sort((a, b) => b.versions.length - a.versions.length || a.name.localeCompare(b.name));
|
|
685
|
+
return duplicates;
|
|
686
|
+
}
|
|
687
|
+
function duplicateOrigin(finding) {
|
|
688
|
+
if (finding.relationship === "direct")
|
|
689
|
+
return "direct dependency";
|
|
690
|
+
if (finding.primaryParent)
|
|
691
|
+
return `via ${finding.primaryParent}`;
|
|
692
|
+
return finding.relationship === "transitive" ? "transitive dependency" : "unknown origin";
|
|
693
|
+
}
|
|
694
|
+
export function renderDuplicatePackagesSection(findings) {
|
|
695
|
+
const duplicates = collectDuplicatePackages(findings);
|
|
696
|
+
if (duplicates.length === 0)
|
|
697
|
+
return "";
|
|
698
|
+
const cards = duplicates
|
|
699
|
+
.map(dup => {
|
|
700
|
+
const versionRows = [...dup.versions]
|
|
701
|
+
.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity] || a.version.localeCompare(b.version))
|
|
702
|
+
.map(f => ` <div class="dup-version"><span class="sev-badge ${escapeHtml(f.severity)}">${escapeHtml(f.severity)}</span><span class="dup-ver">${escapeHtml(f.version)}</span><span class="dup-origin">${escapeHtml(duplicateOrigin(f))}</span></div>`)
|
|
703
|
+
.join("\n");
|
|
704
|
+
return ` <div class="dup-pkg">
|
|
705
|
+
<div class="dup-pkg-name">${escapeHtml(dup.name)} <span class="dup-count">${dup.versions.length} versions</span></div>
|
|
706
|
+
<div class="dup-versions">
|
|
707
|
+
${versionRows}
|
|
708
|
+
</div>
|
|
709
|
+
</div>`;
|
|
710
|
+
})
|
|
711
|
+
.join("\n");
|
|
712
|
+
return `<div class="fix-plan">
|
|
713
|
+
<div class="fix-plan-header">
|
|
714
|
+
<h2><span class="icon">⧉</span> Duplicate package versions</h2>
|
|
715
|
+
<span class="badge">${duplicates.length} ${pluralize(duplicates.length, "package")}</span>
|
|
716
|
+
</div>
|
|
717
|
+
<div class="dup-pkgs">
|
|
718
|
+
<div class="dup-pkgs-hint">These vulnerable packages are installed at more than one version in this dependency tree. Consolidating each onto a single fixed version reduces how many places you have to patch.</div>
|
|
719
|
+
${cards}
|
|
720
|
+
</div>
|
|
721
|
+
</div>`;
|
|
722
|
+
}
|
|
610
723
|
export function renderFixPlan(plan) {
|
|
611
724
|
if (!plan || plan.sections.length === 0)
|
|
612
725
|
return "";
|
|
@@ -14,6 +14,10 @@ function detailHtml(finding) {
|
|
|
14
14
|
if (finding.deprecated) {
|
|
15
15
|
lines.push(`npm deprecated: ${esc(finding.deprecated.message)}`);
|
|
16
16
|
}
|
|
17
|
+
if (finding.staleness) {
|
|
18
|
+
const year = new Date(finding.staleness.lastPublish).getUTCFullYear();
|
|
19
|
+
lines.push(`Last release: ${year} (${finding.staleness.ageYears} years ago)`);
|
|
20
|
+
}
|
|
17
21
|
if (lines.length === 0)
|
|
18
22
|
lines.push(esc(finding.message));
|
|
19
23
|
return lines.join("<br>");
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getCliVersion } from "../utils/version-info.js";
|
|
2
|
+
import { severityToSarifLevel } from "../utils/severity.js";
|
|
3
|
+
import { sarifFingerprintHash } from "../utils/sarif.js";
|
|
4
|
+
const DM_RULES = [
|
|
5
|
+
{
|
|
6
|
+
id: "DM001",
|
|
7
|
+
name: "Dependency maintenance risk",
|
|
8
|
+
shortDescription: "Parent dependency constraints block transitive CVE fix",
|
|
9
|
+
helpUri: "https://owasp.org/cve-lite-cli/docs/maintenance-risk/dm001",
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
const DM_RULE_INDEX = new Map(DM_RULES.map((r, i) => [r.id, i]));
|
|
13
|
+
export function buildMaintenanceSarifComponent() {
|
|
14
|
+
return {
|
|
15
|
+
name: "cve-lite-cli-maintenance",
|
|
16
|
+
version: getCliVersion(),
|
|
17
|
+
informationUri: "https://github.com/OWASP/cve-lite-cli",
|
|
18
|
+
rules: DM_RULES.map(r => ({
|
|
19
|
+
id: r.id,
|
|
20
|
+
name: r.name,
|
|
21
|
+
shortDescription: { text: r.shortDescription },
|
|
22
|
+
helpUri: r.helpUri,
|
|
23
|
+
})),
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function buildMaintenanceSarifResults(findings, lockfileUri, toolComponentIndex = 0) {
|
|
27
|
+
return findings.map(f => {
|
|
28
|
+
const ruleIndex = DM_RULE_INDEX.get(f.ruleId);
|
|
29
|
+
if (ruleIndex === undefined) {
|
|
30
|
+
throw new Error(`DM_RULE_INDEX: unknown ruleId \"${f.ruleId}\" - add it to DM_RULES`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
ruleId: f.ruleId,
|
|
34
|
+
ruleIndex,
|
|
35
|
+
rule: { id: f.ruleId, toolComponent: { index: toolComponentIndex } },
|
|
36
|
+
kind: "open",
|
|
37
|
+
level: severityToSarifLevel(f.severity),
|
|
38
|
+
message: { text: f.message },
|
|
39
|
+
locations: [
|
|
40
|
+
{
|
|
41
|
+
physicalLocation: {
|
|
42
|
+
artifactLocation: { uri: lockfileUri, uriBaseId: "%SRCROOT%" },
|
|
43
|
+
region: { startLine: 1 },
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
partialFingerprints: {
|
|
48
|
+
primaryLocationLineHash: sarifFingerprintHash(`${f.ruleId}:${f.package.name}:${f.package.version}`),
|
|
49
|
+
},
|
|
50
|
+
properties: {
|
|
51
|
+
package: f.package.name,
|
|
52
|
+
version: f.package.version,
|
|
53
|
+
severity: f.severity,
|
|
54
|
+
...(f.staleness ? { lastPublish: f.staleness.lastPublish, ageYears: f.staleness.ageYears } : {}),
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
}
|