cve-lite-cli 1.25.0 β 1.26.0-beta.1
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 +38 -13
- package/assets/OWASP_Logo_Black_TM.png +0 -0
- package/assets/logo-with-title-removebg-preview.png +0 -0
- package/dist/advisory/local-db.js +7 -1
- package/dist/advisory/osv-advisory-source.js +2 -1
- package/dist/cli/args.js +4 -0
- package/dist/cli/help.js +2 -1
- package/dist/cli/overrides.js +1 -1
- package/dist/cli/validate.js +9 -1
- package/dist/index.js +47 -16
- package/dist/osv/cache.js +5 -1
- package/dist/output/formatters.js +0 -15
- package/dist/output/html-reporter.js +11 -12
- package/dist/output/logos.js +18 -0
- package/dist/output/multi-folder-html-reporter.js +3 -4
- package/dist/output/override-findings-html.js +10 -4
- package/dist/output/override-findings-terminal.js +90 -21
- package/dist/output/printers.js +42 -16
- package/dist/parsers/pnpm-lock.js +46 -3
- package/dist/remediation/npm-registry.js +55 -73
- package/dist/scan/multi-folder-scan.js +13 -3
- package/dist/scanner.js +79 -59
- package/dist/utils/fix-runner.js +6 -0
- package/dist/utils/package-json.js +21 -0
- package/dist/utils/severity.js +16 -0
- package/dist/utils/validate-url.js +223 -0
- package/dist/utils/version.js +20 -2
- package/package.json +6 -2
- package/dist/learn/keypress.js +0 -50
- package/dist/learn/runner.js +0 -96
- package/dist/learn/scenario.js +0 -47
- package/dist/learn/session.js +0 -36
- package/dist/learn/types.js +0 -1
- package/dist/llm/client.js +0 -40
- package/dist/llm/config.js +0 -48
- package/dist/llm/explainer.js +0 -31
- package/dist/output/logo-base64.js +0 -1
- package/dist/output/owasp-logo-base64.js +0 -1
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
**π Officially recognized as an [OWASP Lab Project](https://owasp.org/cve-lite-cli)**
|
|
19
19
|
|
|
20
|
-
<p>Vulnerability scanning that
|
|
20
|
+
<p>Vulnerability scanning that starts in your terminal and fits cleanly into CI.<br/>Scan your lockfile, get copy-and-run fix commands, and ship clean code.</p>
|
|
21
21
|
|
|
22
22
|
<strong>Scan. Understand. Fix.</strong>
|
|
23
23
|
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
<a href="https://owasp.org/cve-lite-cli/docs/html-report">HTML Report</a> β’
|
|
41
41
|
<a href="https://owasp.org/cve-lite-cli/docs/comparison">Compare</a> β’
|
|
42
42
|
<a href="https://owasp.org/cve-lite-cli/docs/roadmap">Roadmap</a> β’
|
|
43
|
-
<a href="https://github.com/OWASP/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md">Contributing</a>
|
|
43
|
+
<a href="https://github.com/OWASP/cve-lite-cli/blob/main/src/docs/CONTRIBUTING.md">Contributing</a> β’
|
|
44
44
|
<a href="https://owasp.org/slack/invite">Join Slack</a>
|
|
45
45
|
</p>
|
|
46
46
|
</div>
|
|
@@ -106,7 +106,7 @@ No account. No configuration. No source code leaves your machine.
|
|
|
106
106
|
- **Offline advisory DB** β sync advisory data ahead of time and scan with zero runtime API calls, designed for enterprise and air-gapped environments
|
|
107
107
|
- **Interactive HTML report** β generate a self-contained dashboard with severity cards, a searchable findings table, and copy-ready fix commands (`--report`)
|
|
108
108
|
- **Auto-fix mode** β apply validated direct dependency fixes and rescan automatically (`--fix`)
|
|
109
|
-
- **Override hygiene checks** β audit npm/pnpm/yarn/bun `overrides` and `resolutions` for orphaned targets, floating tags, surpassed pins, ineffective nested overrides, and platform-binary coupling (
|
|
109
|
+
- **Override hygiene checks** β audit npm/pnpm/yarn/bun `overrides` and `resolutions` for orphaned targets, floating tags, surpassed pins, ineffective nested overrides, and platform-binary coupling (`--check-overrides`, rules `OA001`-`OA008`)
|
|
110
110
|
- **CI-ready** β `--fail-on high` exits non-zero on findings at or above a severity threshold; a first-party [GitHub Action](https://github.com/marketplace/actions/cve-lite-cli) is available on the Marketplace; `--sarif` writes SARIF 2.1.0 output for direct upload to GitHub Code Scanning; `--cdx` writes a CycloneDX 1.4 SBOM for Dependency-Track and compliance artifacts; `--json` integrates with SIEM tools and dashboards
|
|
111
111
|
- **Minimal footprint** β four runtime dependencies, intentionally kept small for a security tool
|
|
112
112
|
|
|
@@ -197,6 +197,7 @@ No other free tool combines all of the following: lockfile scanning across npm,
|
|
|
197
197
|
| SARIF / GitHub Code Scanning output | β
| β | β
| β
| β |
|
|
198
198
|
| JSON output | β
| β
| β
| β
| β
|
|
|
199
199
|
| Offline/local advisory DB | β
| β | β οΈ | β | β |
|
|
200
|
+
| Override hygiene auditing | β
| β | β | β | β |
|
|
200
201
|
|
|
201
202
|
<sub>β
= built-in strength Β· β οΈ = partial or workflow-dependent Β· β = not a core strength</sub>
|
|
202
203
|
|
|
@@ -240,6 +241,7 @@ If you maintain an open-source JavaScript or TypeScript project and want CVE Lit
|
|
|
240
241
|
|
|
241
242
|
## Press
|
|
242
243
|
|
|
244
|
+
- **[Sniff out stale AI override advice with this open source CLI](https://www.theregister.com/security/2026/06/23/sniff-out-stale-ai-override-advice-with-this-open-source-cli/5259853)** β The Register (Thomas Claburn, Senior Reporter), June 2026
|
|
243
245
|
- **[OWASP Adopts CVE Lite CLI to Boost Dependency Scanning](https://devops.com/owasp-adopts-cve-lite-cli-to-boost-dependency-scanning/)** β DevOps.com, May 2026
|
|
244
246
|
- **[CVE Lite CLI repΓ¨re les dΓ©pendances Γ risque](https://www.lemondeinformatique.fr/actualites/lire-cve-lite-cli-repere-les-dependances-a-risque-100270.html)** β Le Monde Informatique (France), May 2026
|
|
245
247
|
- **[Lieferketten-Angriff: 5.500 GitHub-Repos in 6 Stunden kompromittiert](https://www.ad-hoc-news.de/wissenschaft/lieferketten-angriff-5-500-github-repos-in-6-stunden-kompromittiert/69418833)** β ad-hoc-news (Germany), May 2026 (references CVE Lite CLI)
|
|
@@ -311,10 +313,10 @@ cve-lite /path/to/project --verbose
|
|
|
311
313
|
cve-lite /path/to/project --fix
|
|
312
314
|
|
|
313
315
|
# Audit override hygiene (OA001-OA008) across npm/pnpm/yarn/bun
|
|
314
|
-
cve-lite
|
|
316
|
+
cve-lite /path/to/project --check-overrides
|
|
315
317
|
|
|
316
318
|
# Audit and auto-clean stale or ineffective overrides
|
|
317
|
-
cve-lite
|
|
319
|
+
cve-lite /path/to/project --check-overrides --fix
|
|
318
320
|
|
|
319
321
|
# Production dependencies only (where supported by the lockfile)
|
|
320
322
|
cve-lite /path/to/project --prod-only
|
|
@@ -350,6 +352,9 @@ cve-lite /path/to/project --offline-db /path/to/advisories.db
|
|
|
350
352
|
# Use a custom advisory endpoint
|
|
351
353
|
cve-lite /path/to/project --osv-url https://security.company.internal/osv
|
|
352
354
|
|
|
355
|
+
# Allow custom endpoint to resolve to private/reserved IPs (for internal mirrors)
|
|
356
|
+
cve-lite /path/to/project --osv-url https://internal-mirror.company.local/osv --allow-private-osv-url
|
|
357
|
+
|
|
353
358
|
# Show version
|
|
354
359
|
cve-lite --version
|
|
355
360
|
|
|
@@ -391,7 +396,7 @@ For a deeper explanation of how the CLI chooses direct upgrades, parent upgrades
|
|
|
391
396
|
|
|
392
397
|
## Override hygiene (`overrides`)
|
|
393
398
|
|
|
394
|
-
`overrides` and `resolutions` are powerful, but they rot. A pin you added to dodge a CVE last year can outlive its target, drift behind upstream, or quietly stop taking effect after a refactor, leaving a vulnerable copy still nested under a parent dependency.
|
|
399
|
+
`overrides` and `resolutions` are powerful, but they rot. A pin you added to dodge a CVE last year can outlive its target, drift behind upstream, or quietly stop taking effect after a refactor, leaving a vulnerable copy still nested under a parent dependency. `--check-overrides` audits that hygiene across npm, pnpm, yarn, and bun, reporting eight classes of problem (`OA001`-`OA008`):
|
|
395
400
|
|
|
396
401
|
| Rule | What it catches |
|
|
397
402
|
|---|---|
|
|
@@ -406,27 +411,27 @@ For a deeper explanation of how the CLI chooses direct upgrades, parent upgrades
|
|
|
406
411
|
|
|
407
412
|
```bash
|
|
408
413
|
# Audit, severity-grouped terminal output
|
|
409
|
-
cve-lite
|
|
414
|
+
cve-lite /path/to/project --check-overrides
|
|
410
415
|
|
|
411
416
|
# Structured JSON findings
|
|
412
|
-
cve-lite
|
|
417
|
+
cve-lite /path/to/project --check-overrides --json
|
|
413
418
|
|
|
414
419
|
# Apply RFC 6902 patches for fixable findings
|
|
415
|
-
cve-lite
|
|
420
|
+
cve-lite /path/to/project --check-overrides --fix
|
|
416
421
|
|
|
417
422
|
# Scope a run (or a fix) to a single rule
|
|
418
|
-
cve-lite
|
|
423
|
+
cve-lite /path/to/project --check-overrides --rule OA001
|
|
419
424
|
|
|
420
425
|
# Enable the OA007 registry drift check (opt-in network)
|
|
421
|
-
cve-lite
|
|
426
|
+
cve-lite /path/to/project --check-overrides --check-network
|
|
422
427
|
|
|
423
428
|
# Stream an NDJSON change-control log of every detection and fix
|
|
424
|
-
cve-lite
|
|
429
|
+
cve-lite /path/to/project --check-overrides --audit-log ./override-audit.ndjson
|
|
425
430
|
```
|
|
426
431
|
|
|
427
432
|
`--fix` applies fixes as RFC 6902 patches to `package.json`. A chokepoint guard means a fix can only remove, repin, move, or relocate an existing override; it can never invent a new override key. Suggest-only findings (OA004 cross-major, OA005.d/.e, all of OA008) and "proposed" fixes (the OA006 relocate floor) carry no auto-applied patch and are surfaced as recommendations. `--fail-on <severity>` sets the minimum severity that makes the command exit non-zero (default: `critical`).
|
|
428
433
|
|
|
429
|
-
Full per-rule reference
|
|
434
|
+
For the full guide with diagrams, per-rule examples, and CI patterns, see the [Override Hygiene Auditing guide](https://owasp.org/cve-lite-cli/docs/override-hygiene). Full per-rule reference including OA005 sub-codes lives in [`docs/rules/`](docs/rules/README.md). For the programmatic API, see [`docs/api/overrides.md`](docs/api/overrides.md).
|
|
430
435
|
|
|
431
436
|
## AI assistant integration (`install-skill`)
|
|
432
437
|
|
|
@@ -496,6 +501,22 @@ See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/
|
|
|
496
501
|
|
|
497
502
|
Using CVE Lite CLI at your company or in your projects? [Share your use case in the community thread](https://github.com/OWASP/cve-lite-cli/discussions/481) - we'd love to hear about it.
|
|
498
503
|
|
|
504
|
+
## Community and adoption
|
|
505
|
+
|
|
506
|
+
CVE Lite CLI is used in production across organizations and independent developers in multiple countries. Confirmed users span government digital services, enterprise engineering platforms, open-source libraries, and security education.
|
|
507
|
+
|
|
508
|
+
Notable adopters include:
|
|
509
|
+
|
|
510
|
+
- **Moody's** (via Bitovi) - embedded in the shared CI/CD pipeline serving 600+ UI repositories
|
|
511
|
+
- **Discord** - evaluated by the Staff Product Security Engineering team
|
|
512
|
+
- **Vertica** - used by developers and SRE teams across projects
|
|
513
|
+
- **DINUM** (France) - integrated across four French government digital service repositories, including official AI training infrastructure for civil servants
|
|
514
|
+
- **DGAFP** (France) - Ministry for Civil Service, used as a pre-commit hook on a public-sector HR chatbot
|
|
515
|
+
- **Government of British Columbia** (Canada) - running as a required merge gate alongside Trivy at the Ministry of Citizens' Services
|
|
516
|
+
- **Valibot** and **Formish** - integrated as a GitHub Action and dev script with branch protection
|
|
517
|
+
|
|
518
|
+
For a full view of adoption evidence and press coverage, see [`docs/community/impact.md`](docs/community/impact.md).
|
|
519
|
+
|
|
499
520
|
## Current limitations
|
|
500
521
|
|
|
501
522
|
- does not detect malicious packages before they appear in advisory data
|
|
@@ -630,6 +651,10 @@ New here? See [CONTRIBUTING.md](https://github.com/OWASP/cve-lite-cli/blob/main/
|
|
|
630
651
|
|
|
631
652
|
---
|
|
632
653
|
|
|
654
|
+
**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.
|
|
655
|
+
|
|
656
|
+
---
|
|
657
|
+
|
|
633
658
|
*Most tools tell you what's wrong. CVE Lite CLI tells you what to run.*
|
|
634
659
|
|
|
635
660
|
## License
|
|
Binary file
|
|
Binary file
|
|
@@ -155,7 +155,13 @@ export class LocalAdvisoryDatabase {
|
|
|
155
155
|
const row = this.getVulnerabilityStatement.get(id);
|
|
156
156
|
if (!row)
|
|
157
157
|
return null;
|
|
158
|
-
|
|
158
|
+
try {
|
|
159
|
+
return JSON.parse(row.osv_json);
|
|
160
|
+
}
|
|
161
|
+
catch (error) {
|
|
162
|
+
console.warn(`Failed to parse advisory JSON for ${id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
159
165
|
}
|
|
160
166
|
findMatchingVulnerabilityIds(pkg) {
|
|
161
167
|
if (!looksLikeVersion(pkg.version)) {
|
|
@@ -41,6 +41,7 @@ export class OsvAdvisorySource {
|
|
|
41
41
|
"Content-Type": "application/json",
|
|
42
42
|
},
|
|
43
43
|
body: JSON.stringify(payload),
|
|
44
|
+
redirect: "error",
|
|
44
45
|
});
|
|
45
46
|
if (this.debugLog) {
|
|
46
47
|
this.debugLog("OSV response", {
|
|
@@ -89,7 +90,7 @@ export class OsvAdvisorySource {
|
|
|
89
90
|
headers: {},
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
const response = await fetch(requestUrl);
|
|
93
|
+
const response = await fetch(requestUrl, { redirect: "error" });
|
|
93
94
|
if (this.debugLog) {
|
|
94
95
|
this.debugLog("OSV response", {
|
|
95
96
|
method: "GET",
|
package/dist/cli/args.js
CHANGED
|
@@ -242,6 +242,10 @@ export function parseArgs(argv) {
|
|
|
242
242
|
options.osvUrl = arg.slice("--osv-url=".length);
|
|
243
243
|
continue;
|
|
244
244
|
}
|
|
245
|
+
if (arg === "--allow-private-osv-url") {
|
|
246
|
+
options.allowPrivateOsvUrl = true;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
245
249
|
if (arg === "--output") {
|
|
246
250
|
options.output = argv[++i];
|
|
247
251
|
continue;
|
package/dist/cli/help.js
CHANGED
|
@@ -38,7 +38,8 @@ export function printHelp() {
|
|
|
38
38
|
" --ratchet Save current findings as baseline or, if baseline exists, only fail on new findings",
|
|
39
39
|
" --create-pr After --fix, commit changes and open a GitHub pull request (requires gh)",
|
|
40
40
|
" --base <branch> Base branch for --create-pr (default: main)",
|
|
41
|
-
" --osv-url <url> Use a custom OSV-compatible advisory endpoint",
|
|
41
|
+
" --osv-url <url> Use a custom OSV-compatible advisory endpoint (HTTPS only)",
|
|
42
|
+
" --allow-private-osv-url Allow --osv-url to resolve to private/reserved IPs",
|
|
42
43
|
" --ca-cert <path> Path to a CA certificate file for corporate SSL proxies",
|
|
43
44
|
" --debug Write verbose runtime/network diagnostics to a timestamped log file",
|
|
44
45
|
" --verbose Show detailed output with fix plan, paths, and full table",
|
package/dist/cli/overrides.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolve } from "node:path";
|
|
|
2
2
|
import { buildOverrideContext, audit, applyFix } from "../overrides/index.js";
|
|
3
3
|
import { createAuditLog } from "../audit-log/index.js";
|
|
4
4
|
import { EXIT_OK, EXIT_FINDINGS, EXIT_ERROR } from "../types.js";
|
|
5
|
-
import { renderOverrideFindings } from "../output/
|
|
5
|
+
import { renderOverrideFindings } from "../output/override-findings-terminal.js";
|
|
6
6
|
export async function runOverrides({ projectArg, options, logger, auditLog: injectedAuditLog }) {
|
|
7
7
|
const projectPath = resolve(projectArg ?? ".");
|
|
8
8
|
const ownsAuditLog = !injectedAuditLog;
|
package/dist/cli/validate.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
import { validateCaCertFile } from "./config.js";
|
|
2
|
-
|
|
2
|
+
import { validateOsvUrl } from "../utils/validate-url.js";
|
|
3
|
+
export async function validateOptions(options) {
|
|
4
|
+
if (options.allowPrivateOsvUrl && !options.osvUrl) {
|
|
5
|
+
throw new Error("--allow-private-osv-url requires --osv-url");
|
|
6
|
+
}
|
|
3
7
|
if ((options.offline || options.offlineDb) && options.osvUrl) {
|
|
4
8
|
throw new Error("--offline/--offline-db cannot be used with --osv-url");
|
|
5
9
|
}
|
|
6
10
|
if (options.noCache && (options.offline || options.offlineDb)) {
|
|
7
11
|
throw new Error("--no-cache cannot be used with --offline or --offline-db");
|
|
8
12
|
}
|
|
13
|
+
let ssrfWarning;
|
|
9
14
|
if (options.osvUrl) {
|
|
10
15
|
try {
|
|
11
16
|
new URL(options.osvUrl);
|
|
@@ -13,6 +18,8 @@ export function validateOptions(options) {
|
|
|
13
18
|
catch {
|
|
14
19
|
throw new Error(`Invalid value for --osv-url: ${options.osvUrl}`);
|
|
15
20
|
}
|
|
21
|
+
// SSRF defense: validate scheme, IP, and allow-private flag
|
|
22
|
+
ssrfWarning = await validateOsvUrl(options.osvUrl, !!options.allowPrivateOsvUrl);
|
|
16
23
|
}
|
|
17
24
|
if (options.fix && options.json) {
|
|
18
25
|
throw new Error("--fix cannot be used with --json");
|
|
@@ -37,4 +44,5 @@ export function validateOptions(options) {
|
|
|
37
44
|
throw new Error(`--ca-cert: ${err instanceof Error ? err.message : String(err)}`);
|
|
38
45
|
}
|
|
39
46
|
}
|
|
47
|
+
return ssrfWarning;
|
|
40
48
|
}
|
package/dist/index.js
CHANGED
|
@@ -25,18 +25,18 @@ import { countBySeverity } from "./utils/severity.js";
|
|
|
25
25
|
import { buildReportData, writeHtmlReport } from "./output/html-reporter.js";
|
|
26
26
|
import { writeOutputs } from "./output/write-outputs.js";
|
|
27
27
|
import { selectFindingsForTable } from "./output/finding-display.js";
|
|
28
|
-
import {
|
|
28
|
+
import { printActionSummary, printCompactOutput, printCoverage, printFinalStatus, printOverrideHint, printSkippedDependencies, printSuggestedFixCommands, printSuggestedFixCommandSkips, printSummary, printTable, } from "./output/printers.js";
|
|
29
29
|
import { renderOverrideFindings } from "./output/override-findings-terminal.js";
|
|
30
30
|
import { installSkill } from "./skills/install.js";
|
|
31
31
|
import { readConfig, validateCaCertFile } from "./cli/config.js";
|
|
32
32
|
import { runConfigCommand } from "./cli/config-command.js";
|
|
33
|
-
import { readDirectDependencyNames } from "./utils/package-json.js";
|
|
34
|
-
import { applyFixesIfRequested, printFixModeSummary, } from "./utils/fix-runner.js";
|
|
33
|
+
import { readDirectDependencyNames, hasOverrideEntries } from "./utils/package-json.js";
|
|
34
|
+
import { applyFixesIfRequested, printFixModeSummary, writeFixResultJson, } from "./utils/fix-runner.js";
|
|
35
35
|
import { createAuditLog } from "./audit-log/index.js";
|
|
36
36
|
import { audit, buildOverrideContext } from "./overrides/index.js";
|
|
37
37
|
import { hasRootLockfile, findNestedLockfiles } from "./parsers/multi-package.js";
|
|
38
38
|
import { handleMultiFolderScan } from "./scan/multi-folder-scan.js";
|
|
39
|
-
import { createPullRequestForFixes, } from "./utils/create-pr.js";
|
|
39
|
+
import { collectAdvisoryIdsForPackage, createPullRequestForFixes, } from "./utils/create-pr.js";
|
|
40
40
|
import { readBaseline, writeBaseline, filterNewFindings, ratchetOutcome } from "./utils/baseline.js";
|
|
41
41
|
let parsedArgs = null;
|
|
42
42
|
try {
|
|
@@ -177,7 +177,9 @@ if (parsedArgs) {
|
|
|
177
177
|
auditLogHandle.close();
|
|
178
178
|
process.exit(exitCode);
|
|
179
179
|
}
|
|
180
|
-
validateOptions(options);
|
|
180
|
+
const validationWarning = await validateOptions(options);
|
|
181
|
+
if (validationWarning)
|
|
182
|
+
logWarn(validationWarning, options);
|
|
181
183
|
// Multi-folder mode: if no root lockfile and 2+ nested lockfiles exist,
|
|
182
184
|
// route to dedicated multi-folder handler instead of single-lockfile scan
|
|
183
185
|
const nestedLockfiles = findNestedLockfiles(projectPath, searchDepth);
|
|
@@ -433,6 +435,21 @@ if (parsedArgs) {
|
|
|
433
435
|
findingsAfterFix: scanState.sorted.length,
|
|
434
436
|
remainingBySeverity: countBySeverity(scanState.sorted),
|
|
435
437
|
});
|
|
438
|
+
// Write fix result JSON for Action-level PR creation.
|
|
439
|
+
// Written even when appliedFixCount is 0 so the Action can detect
|
|
440
|
+
// the nothing-to-fix case without parsing stdout.
|
|
441
|
+
const fixResultJson = {
|
|
442
|
+
appliedFixCount: fixResult?.appliedFixCount ?? 0,
|
|
443
|
+
findingsBeforeFix,
|
|
444
|
+
findingsAfterFix: scanState.sorted.length,
|
|
445
|
+
applied: (fixResult?.applied ?? []).map(entry => ({
|
|
446
|
+
package: entry.package,
|
|
447
|
+
from: entry.from,
|
|
448
|
+
to: entry.to,
|
|
449
|
+
advisories: collectAdvisoryIdsForPackage(findingsBeforeFixList, entry.package),
|
|
450
|
+
})),
|
|
451
|
+
};
|
|
452
|
+
writeFixResultJson(fixResultJson, projectPath);
|
|
436
453
|
if (options.createPr && fixResult) {
|
|
437
454
|
// Override hygiene fixes also land in package.json (staged by create-pr), so
|
|
438
455
|
// a PR is warranted when either CVE fixes or override fixes were applied.
|
|
@@ -542,10 +559,15 @@ if (parsedArgs) {
|
|
|
542
559
|
}, scanInput, projectPath);
|
|
543
560
|
if (!(options.json || options.sarif || options.cdx) || options.verbose) {
|
|
544
561
|
const offline = !!options.offline || !!options.offlineDb;
|
|
562
|
+
const showOverrideHint = !options.checkOverrides && !options.ratchet && hasOverrideEntries(projectPath);
|
|
545
563
|
if (options.verbose) {
|
|
564
|
+
const overrideCount = options.checkOverrides ? overrideFindings.length : 0;
|
|
546
565
|
printSummary(scanState.sorted, packages.length, scanInput);
|
|
547
|
-
|
|
548
|
-
|
|
566
|
+
const pmLabel = scanState.suggestedFixCommands
|
|
567
|
+
? `${chalk.cyan(scanState.suggestedFixCommands.packageManager)} ${chalk.gray(`(${scanState.suggestedFixCommands.sourceLabel})`)}`
|
|
568
|
+
: undefined;
|
|
569
|
+
printActionSummary(scanState.sorted, overrideCount, pmLabel);
|
|
570
|
+
printSuggestedFixCommands(scanState.sorted, scanInput, { offline, overrideCount });
|
|
549
571
|
printSuggestedFixCommandSkips(scanState.sorted, scanInput, { offline });
|
|
550
572
|
if (scanInput.skippedDependencies.length > 0) {
|
|
551
573
|
printSkippedDependencies(scanInput.skippedDependencies);
|
|
@@ -559,17 +581,24 @@ if (parsedArgs) {
|
|
|
559
581
|
logInfo(`No findings met the table threshold of ${scanState.minSeverity}. Re-run with --all to show everything.`, options);
|
|
560
582
|
}
|
|
561
583
|
}
|
|
584
|
+
if (options.checkOverrides && overrideFindings.length > 0) {
|
|
585
|
+
console.log(renderOverrideFindings(overrideFindings, { verbose: true }));
|
|
586
|
+
}
|
|
562
587
|
printCoverage([...scanInput.notes, ...scanState.coverage]);
|
|
563
|
-
printFinalStatus(scanState.sorted);
|
|
588
|
+
printFinalStatus(scanState.sorted, overrideCount);
|
|
589
|
+
if (showOverrideHint)
|
|
590
|
+
printOverrideHint();
|
|
564
591
|
}
|
|
565
592
|
else {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
593
|
+
const compactPmLabel = scanState.suggestedFixCommands
|
|
594
|
+
? `${chalk.cyan(scanState.suggestedFixCommands.packageManager)} ${chalk.gray(`(${scanState.suggestedFixCommands.sourceLabel})`)}`
|
|
595
|
+
: undefined;
|
|
596
|
+
printCompactOutput(scanState.sorted, scanInput, { offline, all: !!options.all, packageManager: compactPmLabel });
|
|
597
|
+
if (options.checkOverrides) {
|
|
598
|
+
console.log(renderOverrideFindings(overrideFindings, { verbose: false }));
|
|
599
|
+
}
|
|
600
|
+
if (showOverrideHint)
|
|
601
|
+
printOverrideHint();
|
|
573
602
|
}
|
|
574
603
|
}
|
|
575
604
|
}
|
|
@@ -617,7 +646,9 @@ if (parsedArgs) {
|
|
|
617
646
|
// unless --check-overrides (and non-ratchet), so this is a no-op otherwise.
|
|
618
647
|
const reachesFailOn = (f) => severityOrder[f.severity] >= severityOrder[failLevel];
|
|
619
648
|
const shouldFail = scanState.sorted.some(reachesFailOn) || overrideFindings.some(reachesFailOn);
|
|
620
|
-
|
|
649
|
+
// In fix mode, remaining transitive findings cannot be auto-fixed.
|
|
650
|
+
// Exiting non-zero would prevent the Action PR step from running.
|
|
651
|
+
const exitCode = shouldFail && !options.fix ? 1 : 0;
|
|
621
652
|
// Emit scan.finished event and close audit-log
|
|
622
653
|
auditLogHandle.emit({
|
|
623
654
|
ts: new Date().toISOString(),
|
package/dist/osv/cache.js
CHANGED
|
@@ -112,7 +112,11 @@ export function loadCache(cacheDirOverride, debugLog) {
|
|
|
112
112
|
export function saveCache(cache, cacheDirOverride, debugLog) {
|
|
113
113
|
const filePath = getCacheFilePath(cacheDirOverride);
|
|
114
114
|
cache.createdAt = new Date().toISOString();
|
|
115
|
-
|
|
115
|
+
// Compact JSON: indentation roughly doubles the on-disk cache size and adds
|
|
116
|
+
// significant serialization time for large caches (10K+ entries). `loadCache`
|
|
117
|
+
// reads via `JSON.parse` which handles both compact and pretty formats, so
|
|
118
|
+
// existing pretty-printed caches migrate transparently on the next save.
|
|
119
|
+
fs.writeFileSync(filePath, JSON.stringify(cache), "utf8");
|
|
116
120
|
if (debugLog) {
|
|
117
121
|
debugLog("Cache saved", {
|
|
118
122
|
path: filePath,
|
|
@@ -6,20 +6,6 @@ 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
|
-
export function formatSeverityLabel(severity) {
|
|
10
|
-
const lower = severity.toLowerCase();
|
|
11
|
-
if (lower === "critical")
|
|
12
|
-
return chalk.redBright(severity);
|
|
13
|
-
if (lower === "high")
|
|
14
|
-
return chalk.red(severity);
|
|
15
|
-
if (lower === "medium")
|
|
16
|
-
return chalk.yellow(severity);
|
|
17
|
-
if (lower === "low")
|
|
18
|
-
return chalk.blueBright(severity);
|
|
19
|
-
if (lower === "unknown")
|
|
20
|
-
return chalk.magenta(severity);
|
|
21
|
-
return severity;
|
|
22
|
-
}
|
|
23
9
|
export function formatRelationshipLabel(value) {
|
|
24
10
|
if (value.startsWith("direct"))
|
|
25
11
|
return chalk.green(value);
|
|
@@ -286,4 +272,3 @@ export function sortFindingsForOutput(findings) {
|
|
|
286
272
|
export function countUniqueAdvisories(findings) {
|
|
287
273
|
return new Set(findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
288
274
|
}
|
|
289
|
-
export { renderOverrideFindings } from "./override-findings-terminal.js";
|
|
@@ -2,8 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { spawn } from "node:child_process";
|
|
4
4
|
import { serializeFinding, summarizeNextAction, summarizeRisk, formatFixCommandWithPublishDates } from "./formatters.js";
|
|
5
|
-
import {
|
|
6
|
-
import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
|
|
5
|
+
import { loadLogoDataUri } from "./logos.js";
|
|
7
6
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
8
7
|
import { pluralize } from "../utils/string.js";
|
|
9
8
|
import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY } from "../constants.js";
|
|
@@ -168,13 +167,13 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
168
167
|
.override-hygiene table tbody tr{border-bottom:1px solid #21262d}
|
|
169
168
|
.override-hygiene table tbody tr:last-child{border-bottom:none}
|
|
170
169
|
.override-hygiene table tbody tr.severity-group{background:#1c2128}
|
|
171
|
-
.override-hygiene table tbody tr.severity-group th{font-weight:600;color:#e6edf3;padding:10px 14px}
|
|
170
|
+
.override-hygiene table tbody tr.severity-group th{font-weight:600;color:#e6edf3;padding:10px 14px;text-align:left}
|
|
172
171
|
.override-hygiene table tbody tr.finding td{padding:11px 14px;font-size:12px;color:#e6edf3;vertical-align:middle}
|
|
173
|
-
.override-hygiene table tbody tr.
|
|
174
|
-
.override-hygiene table tbody tr.
|
|
175
|
-
.override-hygiene table tbody tr.
|
|
176
|
-
.override-hygiene table tbody tr.
|
|
177
|
-
.override-hygiene table tbody tr.
|
|
172
|
+
.override-hygiene table tbody tr.critical{border-left:3px solid #f85149}
|
|
173
|
+
.override-hygiene table tbody tr.high{border-left:3px solid #fb8500}
|
|
174
|
+
.override-hygiene table tbody tr.medium{border-left:3px solid #e3b341}
|
|
175
|
+
.override-hygiene table tbody tr.low{border-left:3px solid #388bfd}
|
|
176
|
+
.override-hygiene table tbody tr.unknown{border-left:3px solid #8b949e}`;
|
|
178
177
|
export function renderHtmlReport(data) {
|
|
179
178
|
const projectName = path.basename(data.projectPath);
|
|
180
179
|
const scanDate = new Date(data.scannedAt).toLocaleString();
|
|
@@ -211,10 +210,10 @@ ${REPORT_STYLES}
|
|
|
211
210
|
<div class="report-header">
|
|
212
211
|
<div class="header-left">
|
|
213
212
|
<div class="header-logo-pair">
|
|
214
|
-
<img src="${
|
|
213
|
+
<img src="${loadLogoDataUri("cve-lite")}" alt="CVE Lite" class="header-logo" />
|
|
215
214
|
<span class="header-logo-plus">+</span>
|
|
216
215
|
<a href="https://owasp.org/cve-lite-cli/" target="_blank" rel="noopener" style="display:flex;align-items:center">
|
|
217
|
-
<img src="${
|
|
216
|
+
<img src="${loadLogoDataUri("owasp")}" alt="An OWASP Foundation Project" class="header-logo" />
|
|
218
217
|
</a>
|
|
219
218
|
</div>
|
|
220
219
|
<div class="header-divider"></div>
|
|
@@ -285,10 +284,10 @@ ${findingRowsHtml}
|
|
|
285
284
|
</tbody>
|
|
286
285
|
</table>
|
|
287
286
|
</div>
|
|
288
|
-
${noticesHtml}
|
|
289
|
-
|
|
290
287
|
${renderOverrideFindingsHtml(data.overrideFindings)}
|
|
291
288
|
|
|
289
|
+
${noticesHtml}
|
|
290
|
+
|
|
292
291
|
<div class="report-footer">
|
|
293
292
|
<span>Generated by <strong>cve-lite v${escapeHtml(data.cliVersion)}</strong></span>
|
|
294
293
|
<span>${escapeHtml(data.lockfileSource)} Β· ${data.findings.length} findings Β· ${data.packageCount} packages</span>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
const FILES = {
|
|
5
|
+
"cve-lite": "logo-with-title-removebg-preview.png",
|
|
6
|
+
"owasp": "OWASP_Logo_Black_TM.png",
|
|
7
|
+
};
|
|
8
|
+
const ASSET_DIR = path.join(fileURLToPath(new URL("../../assets/", import.meta.url)));
|
|
9
|
+
const cache = new Map();
|
|
10
|
+
export function loadLogoDataUri(name) {
|
|
11
|
+
const cached = cache.get(name);
|
|
12
|
+
if (cached)
|
|
13
|
+
return cached;
|
|
14
|
+
const buf = fs.readFileSync(path.join(ASSET_DIR, FILES[name]));
|
|
15
|
+
const uri = `data:image/png;base64,${buf.toString("base64")}`;
|
|
16
|
+
cache.set(name, uri);
|
|
17
|
+
return uri;
|
|
18
|
+
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, serializeHtmlFinding, } from "./html-reporter.js";
|
|
4
|
-
import {
|
|
5
|
-
import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
|
|
4
|
+
import { loadLogoDataUri } from "./logos.js";
|
|
6
5
|
import { pluralize } from "../utils/string.js";
|
|
7
6
|
function summaryCounts(results) {
|
|
8
7
|
const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
|
|
@@ -143,10 +142,10 @@ details[open] .folder-summary::before{transform:rotate(90deg)}
|
|
|
143
142
|
<div class="report-header">
|
|
144
143
|
<div class="header-left">
|
|
145
144
|
<div class="header-logo-pair">
|
|
146
|
-
<img src="${
|
|
145
|
+
<img src="${loadLogoDataUri("cve-lite")}" alt="CVE Lite" class="header-logo" />
|
|
147
146
|
<span class="header-logo-plus">+</span>
|
|
148
147
|
<a href="https://owasp.org/cve-lite-cli/" target="_blank" rel="noopener" style="display:flex;align-items:center">
|
|
149
|
-
<img src="${
|
|
148
|
+
<img src="${loadLogoDataUri("owasp")}" alt="An OWASP Foundation Project" class="header-logo" />
|
|
150
149
|
</a>
|
|
151
150
|
</div>
|
|
152
151
|
<div class="header-divider"></div>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { SEVERITY_ORDER } from "../utils/severity.js";
|
|
1
2
|
function esc(s) {
|
|
2
3
|
return s
|
|
3
4
|
.replace(/&/g, "&")
|
|
@@ -5,7 +6,6 @@ function esc(s) {
|
|
|
5
6
|
.replace(/>/g, ">")
|
|
6
7
|
.replace(/"/g, """);
|
|
7
8
|
}
|
|
8
|
-
const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
|
|
9
9
|
export function renderOverrideFindingsHtml(findings) {
|
|
10
10
|
// undefined = override hygiene was never requested -> render nothing, so a plain
|
|
11
11
|
// `cve-lite .` report shows no Override hygiene panel at all. An empty array =
|
|
@@ -31,13 +31,19 @@ export function renderOverrideFindingsHtml(findings) {
|
|
|
31
31
|
const bucket = grouped.get(sev) ?? [];
|
|
32
32
|
if (bucket.length === 0)
|
|
33
33
|
continue;
|
|
34
|
-
rows.push(` <tr class="severity-group"><th
|
|
34
|
+
rows.push(` <tr class="severity-group ${esc(sev)}"><th>${esc(sev.toUpperCase())} (${bucket.length})</th><td></td><td></td><td></td></tr>`);
|
|
35
35
|
for (const f of bucket) {
|
|
36
|
+
const location = f.location.jsonPath
|
|
37
|
+
? `${esc(f.location.file)} βΊ ${esc(f.location.jsonPath)}`
|
|
38
|
+
: esc(f.location.file);
|
|
39
|
+
const fixHtml = f.fix?.runnableCommand
|
|
40
|
+
? `<div class="fix-cmd-inline" style="margin-top:6px"><code>${esc(f.fix.runnableCommand)}</code><button class="copy-btn" data-cmd="${esc(f.fix.runnableCommand)}">Copy</button></div>`
|
|
41
|
+
: "";
|
|
36
42
|
rows.push(` <tr class="finding ${esc(f.severity)}">` +
|
|
37
43
|
`<td>${esc(f.ruleId)}</td>` +
|
|
38
44
|
`<td>${esc(f.package.name)}</td>` +
|
|
39
|
-
`<td>${
|
|
40
|
-
`<td>${esc(f.message)}</td>` +
|
|
45
|
+
`<td>${location}</td>` +
|
|
46
|
+
`<td>${esc(f.message)}${fixHtml}</td>` +
|
|
41
47
|
`</tr>`);
|
|
42
48
|
}
|
|
43
49
|
}
|