cve-lite-cli 1.15.0 → 1.17.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 +56 -12
- package/dist/cli/args.js +14 -0
- package/dist/cli/help.js +2 -0
- package/dist/index.js +32 -39
- package/dist/output/cyclonedx.js +88 -0
- package/dist/output/formatters.js +3 -0
- package/dist/output/html-reporter.js +3 -1
- package/dist/output/printers.js +13 -5
- package/dist/output/sarif.js +92 -0
- package/dist/output/write-outputs.js +54 -0
- package/dist/parsers/index.js +31 -2
- package/dist/utils/severity.js +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
|
|
26
26
|
<table>
|
|
27
27
|
<tr>
|
|
28
|
-
<td align="center" width="33%"><p
|
|
29
|
-
<td align="center" width="33%"><p
|
|
30
|
-
<td align="center" width="33%"><p
|
|
28
|
+
<td align="center" width="33%"><p>🏆</p><strong>OWASP Incubator Project</strong><br/><sub>Peer-reviewed by the org behind the OWASP Top 10 —<br/>the security standard followed by millions of developers</sub></td>
|
|
29
|
+
<td align="center" width="33%"><p>🎯</p><strong>Remediation-first</strong><br/><sub>Validated fix commands + parent-aware<br/>transitive guidance — not just CVE IDs</sub></td>
|
|
30
|
+
<td align="center" width="33%"><p>🔒</p><strong>Runs locally</strong><br/><sub>Nothing leaves your machine — not your<br/>code, not your dependency tree</sub></td>
|
|
31
31
|
</tr>
|
|
32
32
|
</table>
|
|
33
33
|
|
|
@@ -47,6 +47,23 @@
|
|
|
47
47
|
|
|
48
48
|
---
|
|
49
49
|
|
|
50
|
+
<div align="center">
|
|
51
|
+
|
|
52
|
+
**Package Managers**
|
|
53
|
+
|
|
54
|
+
<table border="0" cellspacing="0" cellpadding="12">
|
|
55
|
+
<tr>
|
|
56
|
+
<td align="center"><img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/npm/npm-original-wordmark.svg" width="48" height="48" alt="npm"/><br/><sub><b>npm</b></sub></td>
|
|
57
|
+
<td align="center"><img src="https://cdn.simpleicons.org/pnpm" width="48" height="48" alt="pnpm"/><br/><sub><b>pnpm</b></sub></td>
|
|
58
|
+
<td align="center"><img src="https://cdn.jsdelivr.net/gh/devicons/devicon@latest/icons/yarn/yarn-original.svg" width="48" height="48" alt="Yarn"/><br/><sub><b>Yarn</b></sub></td>
|
|
59
|
+
<td align="center"><img src="https://cdn.simpleicons.org/bun" width="48" height="48" alt="Bun"/><br/><sub><b>Bun</b></sub></td>
|
|
60
|
+
</tr>
|
|
61
|
+
</table>
|
|
62
|
+
|
|
63
|
+
</div>
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
50
67
|
## The problem with how security scanning works today
|
|
51
68
|
|
|
52
69
|
Most security tooling is designed around pipelines, not people.
|
|
@@ -89,7 +106,7 @@ No account. No configuration. No source code leaves your machine.
|
|
|
89
106
|
- **Offline advisory DB** — sync advisory data ahead of time and scan with zero runtime API calls, designed for enterprise and air-gapped environments
|
|
90
107
|
- **Interactive HTML report** — generate a self-contained dashboard with severity cards, a searchable findings table, and copy-ready fix commands (`--report`)
|
|
91
108
|
- **Auto-fix mode** — apply validated direct dependency fixes and rescan automatically (`--fix`)
|
|
92
|
-
- **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
|
|
109
|
+
- **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
|
|
93
110
|
- **Minimal footprint** — four runtime dependencies, intentionally kept small for a security tool
|
|
94
111
|
|
|
95
112
|
## What it looks like
|
|
@@ -132,7 +149,7 @@ CVE Lite CLI fits at every stage of the development workflow, not just CI.
|
|
|
132
149
|
|
|
133
150
|
**Local development** — run a scan before opening a PR. The default output is fast and minimal. `--verbose` adds the full fix plan with dependency paths and prioritized remediation commands. `--report` opens an interactive HTML dashboard.
|
|
134
151
|
|
|
135
|
-
**CI pipelines** — use `--fail-on high` to gate builds on severity. JSON output (`--json`) integrates with SIEM, dashboards, and custom automation. SARIF output
|
|
152
|
+
**CI pipelines** — use `--fail-on high` to gate builds on severity. JSON output (`--json`) integrates with SIEM, dashboards, and custom automation. SARIF output (`--sarif`) writes a SARIF 2.1.0 file for direct upload to GitHub Code Scanning — findings appear in the Security tab and annotate PRs.
|
|
136
153
|
|
|
137
154
|
**Restricted and enterprise environments** — sync the advisory database ahead of time with `cve-lite advisories sync`, then scan offline with `--offline`. No runtime outbound calls during the scan. Syncing ~217,065 advisory records completes in under 9 seconds.
|
|
138
155
|
|
|
@@ -143,14 +160,25 @@ CVE Lite CLI fits at every stage of the development workflow, not just CI.
|
|
|
143
160
|
with:
|
|
144
161
|
verbose: "true"
|
|
145
162
|
fail-on: high
|
|
163
|
+
sarif: "true"
|
|
164
|
+
|
|
165
|
+
- name: Upload to GitHub Code Scanning
|
|
166
|
+
uses: github/codeql-action/upload-sarif@v4
|
|
167
|
+
if: always()
|
|
168
|
+
with:
|
|
169
|
+
sarif_file: ${{ github.workspace }}
|
|
146
170
|
```
|
|
147
171
|
|
|
172
|
+
> **Note:** `if: always()` is required on the upload step. Without it, the upload is skipped when `--fail-on` exits non-zero — losing your findings in Code Scanning exactly when they matter most.
|
|
173
|
+
|
|
148
174
|
CVE Lite CLI scans its own dependencies in CI. See [`self-scan.yml`](https://github.com/OWASP/cve-lite-cli/blob/main/.github/workflows/self-scan.yml).
|
|
149
175
|
|
|
150
176
|
For full CI patterns including offline workflows, git hooks, and scripted automation, see the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration).
|
|
151
177
|
|
|
152
178
|
## How it compares
|
|
153
179
|
|
|
180
|
+
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; and a fully offline advisory DB for restricted environments.
|
|
181
|
+
|
|
154
182
|
| Capability | CVE Lite CLI | npm audit | OSV-Scanner | Snyk CLI | Socket CLI |
|
|
155
183
|
|---|:---:|:---:|:---:|:---:|:---:|
|
|
156
184
|
| JS/TS lockfile scanning | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
@@ -169,6 +197,9 @@ For full CI patterns including offline workflows, git hooks, and scripted automa
|
|
|
169
197
|
|
|
170
198
|
The transitive parent guidance is a key difference: CVE Lite CLI avoids recommending direct installs for packages that are only present transitively. For npm lockfiles, it can identify when `npm update <parent>` is enough to re-resolve a known non-vulnerable child within the current parent range, and when the parent package itself needs an upgrade.
|
|
171
199
|
|
|
200
|
+
### About Socket CLI
|
|
201
|
+
Socket provides deep supply-chain analysis (malware, typosquatting, maintainer risk) but requires a paid account for full features. CVE Lite CLI remains one of the few fully free, offline, and account-free options with strong transitive analysis.
|
|
202
|
+
|
|
172
203
|
For detailed per-tool analysis, see [Comparison with other tools](https://owasp.org/cve-lite-cli/docs/comparison).
|
|
173
204
|
|
|
174
205
|
## Real-world validation
|
|
@@ -178,14 +209,22 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
|
|
|
178
209
|
- [OWASP Juice Shop](https://owasp.org/cve-lite-cli/docs/case-studies/owasp-juice-shop) — scanning a deliberately vulnerable application with known dependency issues
|
|
179
210
|
- [NestJS](https://owasp.org/cve-lite-cli/docs/case-studies/nestjs) — working through a real transitive dependency remediation sequence across a widely-used Node.js framework
|
|
180
211
|
- [Analog](https://owasp.org/cve-lite-cli/docs/case-studies/analog) — scanning a modern pnpm v9 Angular monorepo (3,367 packages) with unexpected toolchain vulnerabilities
|
|
212
|
+
- [Ghost](https://owasp.org/cve-lite-cli/docs/case-studies/ghost) — 26 vulnerable packages across 4,447 resolved in a professionally maintained CMS — every one transitive, including a critical XSS in the library responsible for making user content safe
|
|
181
213
|
|
|
182
214
|
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
183
215
|
|
|
184
216
|
If you maintain an open-source JavaScript or TypeScript project and want CVE Lite CLI evaluated on it, open an issue and share the repository. Strong candidates may be turned into future public case studies.
|
|
185
217
|
|
|
218
|
+
## Press
|
|
219
|
+
|
|
220
|
+
- **[CVE Lite CLI: Open-source dependency vulnerability scanner](https://www.helpnetsecurity.com/2026/05/20/cve-lite-cli-open-source-dependency-vulnerability-scanner/)** — Help Net Security, May 2026
|
|
221
|
+
- **[Review of CVE Lite CLI](https://developmentcurated.com/testing-and-security/review-of-cve-lite-cli/)** — Development Curated (Sebastian Raiffen, IT Security Consultant), April 2026
|
|
222
|
+
|
|
186
223
|
## Recognized by OWASP
|
|
187
224
|
|
|
188
|
-
|
|
225
|
+
OWASP (Open Web Application Security Project) is the globally recognized nonprofit behind the security standards followed by millions of developers worldwide — most notably the [OWASP Top 10](https://owasp.org/www-project-top-ten/), the most widely cited web application security reference in the industry. Organizations from startups to Fortune 500 companies use OWASP guidelines as the foundation of their security programs.
|
|
226
|
+
|
|
227
|
+
CVE Lite CLI is an [OWASP Incubator Project](https://owasp.org/cve-lite-cli) — reviewed and accepted by the OWASP community as a vendor-neutral, open source security tool. Being part of OWASP means:
|
|
189
228
|
|
|
190
229
|
- **Peer-reviewed** by security professionals
|
|
191
230
|
- **Community-driven** development and governance
|
|
@@ -248,6 +287,9 @@ cve-lite /path/to/project --fail-on high
|
|
|
248
287
|
# JSON output
|
|
249
288
|
cve-lite /path/to/project --json
|
|
250
289
|
|
|
290
|
+
# SARIF output for GitHub Code Scanning and other SARIF-compatible tools
|
|
291
|
+
cve-lite /path/to/project --sarif
|
|
292
|
+
|
|
251
293
|
# Generate an HTML vulnerability dashboard (opens in browser automatically)
|
|
252
294
|
cve-lite /path/to/project --report
|
|
253
295
|
cve-lite /path/to/project --report ./my-report --no-open
|
|
@@ -353,12 +395,14 @@ See the [Offline Advisory DB guide](https://owasp.org/cve-lite-cli/docs/offline-
|
|
|
353
395
|
|
|
354
396
|
## Who uses it
|
|
355
397
|
|
|
356
|
-
CVE Lite CLI is a
|
|
398
|
+
CVE Lite CLI is the only free, OWASP-recognized vulnerability scanner purpose-built for JavaScript and TypeScript that combines validated fix commands, parent-aware transitive remediation, and offline scanning in a single lightweight CLI.
|
|
399
|
+
|
|
400
|
+
It is a good fit for:
|
|
357
401
|
|
|
358
|
-
- **Independent developers and OSS maintainers** — quick pre-release check without any platform overhead
|
|
359
|
-
- **Startups and small teams** — lightweight CI gate at no cost
|
|
360
|
-
- **Consultants** —
|
|
361
|
-
- **Enterprise teams with restricted networks** — offline advisory DB
|
|
402
|
+
- **Independent developers and OSS maintainers** — quick pre-release check without any platform overhead or cost
|
|
403
|
+
- **Startups and small teams** — lightweight CI gate at no cost, with fix commands ready to run immediately
|
|
404
|
+
- **Consultants** — scan a client project in seconds and hand over a concrete, copy-and-run remediation plan
|
|
405
|
+
- **Enterprise teams with restricted networks** — offline advisory DB removes the need for runtime outbound calls during scans
|
|
362
406
|
- **Teams running npm, pnpm, Yarn, and Bun** — unified scanning across all four package managers in one tool
|
|
363
407
|
|
|
364
408
|
See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration) for concrete patterns across these scenarios.
|
|
@@ -485,4 +529,4 @@ If CVE Lite CLI helps your release workflow, a [GitHub star](https://github.com/
|
|
|
485
529
|
|
|
486
530
|
## License
|
|
487
531
|
|
|
488
|
-
MIT
|
|
532
|
+
MIT — built in public and maintained as an OWASP Foundation Project by Sonu Kapoor.
|
package/dist/cli/args.js
CHANGED
|
@@ -174,6 +174,14 @@ export function parseArgs(argv) {
|
|
|
174
174
|
options.noCache = true;
|
|
175
175
|
continue;
|
|
176
176
|
}
|
|
177
|
+
if (arg === "--sarif") {
|
|
178
|
+
options.sarif = true;
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (arg === "--cdx") {
|
|
182
|
+
options.cdx = true;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
177
185
|
if (arg.startsWith("-"))
|
|
178
186
|
throw new Error(`Unknown option: ${arg}`);
|
|
179
187
|
if (!projectArg) {
|
|
@@ -182,5 +190,11 @@ export function parseArgs(argv) {
|
|
|
182
190
|
}
|
|
183
191
|
throw new Error(`Unexpected argument: ${arg}`);
|
|
184
192
|
}
|
|
193
|
+
if (options.sarif && options.report) {
|
|
194
|
+
throw new Error("cannot combine --sarif and --report");
|
|
195
|
+
}
|
|
196
|
+
if (options.cdx && options.report) {
|
|
197
|
+
throw new Error("cannot combine --cdx and --report");
|
|
198
|
+
}
|
|
185
199
|
return { command: "scan", options, projectArg };
|
|
186
200
|
}
|
package/dist/cli/help.js
CHANGED
|
@@ -33,6 +33,8 @@ export function printHelp() {
|
|
|
33
33
|
"Scan options:",
|
|
34
34
|
" --json Print JSON output",
|
|
35
35
|
" --report [dir] Generate an HTML report in [dir] (default: ./cve-report)",
|
|
36
|
+
" --sarif Write SARIF 2.1.0 output to a timestamped .sarif file",
|
|
37
|
+
" --cdx Write CycloneDX 1.4 SBOM to a timestamped .cdx.json file",
|
|
36
38
|
" --no-open Don't auto-open the report in the browser",
|
|
37
39
|
" --fix Apply validated direct dependency fixes and rescan",
|
|
38
40
|
" --osv-url <url> Use a custom OSV-compatible advisory endpoint",
|
package/dist/index.js
CHANGED
|
@@ -16,8 +16,9 @@ import { buildSuggestedFixCommandPlan } from "./remediation/fix-commands.js";
|
|
|
16
16
|
import { scanProjectForPackageUsage } from "./usage/scanner.js";
|
|
17
17
|
import { getCliVersion } from "./utils/version-info.js";
|
|
18
18
|
import { isLikelyBlockedAdvisoryRequestError } from "./utils/network.js";
|
|
19
|
-
import { logInfo, logWarn, printCacheSummary,
|
|
19
|
+
import { logInfo, logWarn, printCacheSummary, sortFindingsForOutput } from "./output/formatters.js";
|
|
20
20
|
import { buildReportData, writeHtmlReport } from "./output/html-reporter.js";
|
|
21
|
+
import { writeOutputs } from "./output/write-outputs.js";
|
|
21
22
|
import { printSummary, printActionSummary, printSuggestedFixCommands, printSuggestedFixCommandSkips, printCoverage, printSkippedDependencies, printTable, printFinalStatus, printCompactOutput } from "./output/printers.js";
|
|
22
23
|
import { installSkill } from "./skills/install.js";
|
|
23
24
|
let parsedArgs = null;
|
|
@@ -191,49 +192,40 @@ if (parsedArgs) {
|
|
|
191
192
|
remainingBySeverity: countBySeverity(scanState.sorted),
|
|
192
193
|
});
|
|
193
194
|
}
|
|
194
|
-
else
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
fs.writeFileSync(jsonOutputPath, JSON.stringify({
|
|
199
|
-
projectPath,
|
|
200
|
-
mode: scanInput.mode,
|
|
201
|
-
source: scanInput.source,
|
|
202
|
-
packageCount: packages.length,
|
|
203
|
-
findingCount: scanState.sorted.length,
|
|
195
|
+
else {
|
|
196
|
+
await writeOutputs(options, {
|
|
197
|
+
sorted: scanState.sorted,
|
|
198
|
+
allPackages: scanState.allPackages,
|
|
204
199
|
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
200
|
+
coverage: scanState.coverage,
|
|
201
|
+
minSeverity: scanState.minSeverity,
|
|
202
|
+
tableFindings: scanState.tableFindings,
|
|
203
|
+
}, scanInput, projectPath);
|
|
204
|
+
if (!(options.json || options.sarif || options.cdx) || options.verbose) {
|
|
205
|
+
const offline = !!options.offline || !!options.offlineDb;
|
|
206
|
+
if (options.verbose) {
|
|
207
|
+
printSummary(scanState.sorted, packages.length, scanInput);
|
|
208
|
+
printActionSummary(scanState.sorted);
|
|
209
|
+
printSuggestedFixCommands(scanState.sorted, scanInput, { offline });
|
|
210
|
+
printSuggestedFixCommandSkips(scanState.sorted, scanInput, { offline });
|
|
211
|
+
if (scanInput.skippedDependencies.length > 0) {
|
|
212
|
+
printSkippedDependencies(scanInput.skippedDependencies);
|
|
213
|
+
}
|
|
214
|
+
if (scanState.sorted.length > 0) {
|
|
215
|
+
if (scanState.tableFindings.length > 0) {
|
|
216
|
+
printTable(scanState.tableFindings, options.all ? null : scanState.minSeverity);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
logInfo(`No findings met the table threshold of ${scanState.minSeverity}. Re-run with --all to show everything.`, options);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
printCoverage([...scanInput.notes, ...scanState.coverage]);
|
|
223
|
+
printFinalStatus(scanState.sorted);
|
|
225
224
|
}
|
|
226
225
|
else {
|
|
227
|
-
|
|
226
|
+
printCompactOutput(scanState.sorted, scanInput, { offline, all: !!options.all });
|
|
228
227
|
}
|
|
229
228
|
}
|
|
230
|
-
printCoverage([...scanInput.notes, ...scanState.coverage]);
|
|
231
|
-
printFinalStatus(scanState.sorted);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
// Simplified output - cleaner, focused view
|
|
235
|
-
const offline = !!options.offline || !!options.offlineDb;
|
|
236
|
-
printCompactOutput(scanState.sorted, scanInput, { offline, all: !!options.all });
|
|
237
229
|
}
|
|
238
230
|
if (options.report) {
|
|
239
231
|
const outputDir = path.resolve(typeof options.report === "string" ? options.report : "./cve-report");
|
|
@@ -318,6 +310,7 @@ async function scanProject(params) {
|
|
|
318
310
|
minSeverity,
|
|
319
311
|
tableFindings,
|
|
320
312
|
suggestedFixCommands,
|
|
313
|
+
allPackages: params.scanInput.packages,
|
|
321
314
|
};
|
|
322
315
|
}
|
|
323
316
|
async function applyFixesIfRequested(params) {
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { randomUUID } from "node:crypto";
|
|
4
|
+
import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
|
|
5
|
+
import { getRecommendedAction } from "./formatters.js";
|
|
6
|
+
import { getCliVersion } from "../utils/version-info.js";
|
|
7
|
+
export function buildPurl(name, version) {
|
|
8
|
+
const encodedName = name.startsWith("@") ? `%40${name.slice(1)}` : name;
|
|
9
|
+
return `pkg:npm/${encodedName}@${version}`;
|
|
10
|
+
}
|
|
11
|
+
export function buildCycloneDxBom(allPackages, findings, projectMeta, version, plan = null) {
|
|
12
|
+
const components = allPackages.map(pkg => {
|
|
13
|
+
const purl = buildPurl(pkg.name, pkg.version);
|
|
14
|
+
return {
|
|
15
|
+
type: "library",
|
|
16
|
+
"bom-ref": purl,
|
|
17
|
+
name: pkg.name,
|
|
18
|
+
version: pkg.version,
|
|
19
|
+
purl,
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
// Deduplicate vulnerabilities by CVE ID — one entry per CVE with multiple affects
|
|
23
|
+
const vulnMap = new Map();
|
|
24
|
+
for (const finding of findings) {
|
|
25
|
+
const cveIds = finding.cveAliases.length > 0
|
|
26
|
+
? finding.cveAliases
|
|
27
|
+
: finding.vulnerabilities.map(v => v.id);
|
|
28
|
+
const purl = buildPurl(finding.pkg.name, finding.pkg.version);
|
|
29
|
+
for (const cveId of cveIds) {
|
|
30
|
+
const existing = vulnMap.get(cveId);
|
|
31
|
+
if (existing) {
|
|
32
|
+
existing.affects.push({ ref: purl });
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
// severity from first finding wins when the same CVE affects multiple packages
|
|
36
|
+
vulnMap.set(cveId, { finding, affects: [{ ref: purl }] });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const vulnerabilities = [];
|
|
41
|
+
for (const [cveId, { finding, affects }] of vulnMap) {
|
|
42
|
+
const runnableFixCommand = plan ? findSuggestedCommandForFinding(plan, finding) : null;
|
|
43
|
+
const recommendation = runnableFixCommand ?? getRecommendedAction(finding);
|
|
44
|
+
vulnerabilities.push({
|
|
45
|
+
id: cveId,
|
|
46
|
+
source: {
|
|
47
|
+
name: "OSV",
|
|
48
|
+
url: `https://osv.dev/vulnerability/${cveId}`,
|
|
49
|
+
},
|
|
50
|
+
ratings: [{ severity: finding.severity, method: "other" }],
|
|
51
|
+
affects,
|
|
52
|
+
recommendation,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
const metadata = {
|
|
56
|
+
timestamp: new Date().toISOString(),
|
|
57
|
+
tools: [
|
|
58
|
+
{ vendor: "OWASP", name: "CVE Lite CLI", version },
|
|
59
|
+
],
|
|
60
|
+
};
|
|
61
|
+
if (projectMeta && projectMeta.name) {
|
|
62
|
+
const metaComponent = {
|
|
63
|
+
type: "application",
|
|
64
|
+
name: projectMeta.name,
|
|
65
|
+
};
|
|
66
|
+
if (projectMeta.version) {
|
|
67
|
+
metaComponent.version = projectMeta.version;
|
|
68
|
+
}
|
|
69
|
+
metadata.component = metaComponent;
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
bomFormat: "CycloneDX",
|
|
73
|
+
specVersion: "1.4",
|
|
74
|
+
version: 1,
|
|
75
|
+
serialNumber: `urn:uuid:${randomUUID()}`,
|
|
76
|
+
metadata,
|
|
77
|
+
components,
|
|
78
|
+
vulnerabilities,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
|
|
82
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
83
|
+
const filename = `cve-lite-scan-${ts}.cdx.json`;
|
|
84
|
+
const outputPath = path.join(process.cwd(), filename);
|
|
85
|
+
const bom = buildCycloneDxBom(allPackages, findings, projectMeta, getCliVersion(), plan);
|
|
86
|
+
fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
|
|
87
|
+
return filename;
|
|
88
|
+
}
|
|
@@ -28,6 +28,7 @@ export function renderHtmlReport(data) {
|
|
|
28
28
|
if (sev in counts)
|
|
29
29
|
counts[sev]++;
|
|
30
30
|
}
|
|
31
|
+
const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
31
32
|
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
32
33
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
33
34
|
const findingRowsHtml = data.findings.map(renderFindingRow).join("\n");
|
|
@@ -211,7 +212,8 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
211
212
|
<div class="sev-card high"><span class="count">${counts.high}</span><span class="label">High</span></div>
|
|
212
213
|
<div class="sev-card medium"><span class="count">${counts.medium}</span><span class="label">Medium</span></div>
|
|
213
214
|
<div class="sev-card low"><span class="count">${counts.low}</span><span class="label">Low</span></div>
|
|
214
|
-
<div class="sev-card total"><span class="count">${data.findings.length}</span><span class="label">
|
|
215
|
+
<div class="sev-card total"><span class="count">${data.findings.length}</span><span class="label">Packages</span></div>
|
|
216
|
+
<div class="sev-card total"><span class="count">${totalCVEs}</span><span class="label">CVEs</span></div>
|
|
215
217
|
</div>
|
|
216
218
|
|
|
217
219
|
${fixPlanHtml}
|
package/dist/output/printers.js
CHANGED
|
@@ -2,7 +2,7 @@ import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
|
2
2
|
import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
3
3
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
4
4
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
5
|
-
import { formatSeverityLabel, formatRelationshipLabel } from "./formatters.js";
|
|
5
|
+
import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel } from "./formatters.js";
|
|
6
6
|
export function printSummary(findings, packageCount, scanInput) {
|
|
7
7
|
if (findings.length === 0) {
|
|
8
8
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -13,6 +13,9 @@ export function printSummary(findings, packageCount, scanInput) {
|
|
|
13
13
|
}
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
+
const totalCVEs = countUniqueAdvisories(findings);
|
|
17
|
+
const pkgLabel = findings.length === 1 ? "package" : "packages";
|
|
18
|
+
const cveLabel = totalCVEs === 1 ? "CVE" : "CVEs";
|
|
16
19
|
const counts = {
|
|
17
20
|
critical: findings.filter(f => f.severity === "critical").length,
|
|
18
21
|
high: findings.filter(f => f.severity === "high").length,
|
|
@@ -20,7 +23,7 @@ export function printSummary(findings, packageCount, scanInput) {
|
|
|
20
23
|
low: findings.filter(f => f.severity === "low").length,
|
|
21
24
|
unknown: findings.filter(f => f.severity === "unknown").length
|
|
22
25
|
};
|
|
23
|
-
console.log(chalk.redBright(`✗ Found ${findings.length}
|
|
26
|
+
console.log(chalk.redBright(`✗ Found ${findings.length} ${pkgLabel} (${totalCVEs} ${cveLabel}) with known OSV matches from ${scanInput.source}`));
|
|
24
27
|
console.log(renderSeverityTable(counts));
|
|
25
28
|
}
|
|
26
29
|
export function printActionSummary(findings) {
|
|
@@ -29,7 +32,7 @@ export function printActionSummary(findings) {
|
|
|
29
32
|
const direct = findings.filter(f => f.relationship === "direct").length;
|
|
30
33
|
const transitive = findings.filter(f => f.relationship === "transitive").length;
|
|
31
34
|
const unknown = findings.filter(f => f.relationship === "unknown").length;
|
|
32
|
-
const uniqueAdvisories =
|
|
35
|
+
const uniqueAdvisories = countUniqueAdvisories(findings);
|
|
33
36
|
const fixable = findings.filter(f => Boolean(f.firstFixedVersion)).length;
|
|
34
37
|
console.log("");
|
|
35
38
|
console.log(chalk.bold.cyan("Quick take"));
|
|
@@ -38,7 +41,7 @@ export function printActionSummary(findings) {
|
|
|
38
41
|
if (unknown > 0) {
|
|
39
42
|
console.log(`- ${chalk.magenta(String(unknown))} package${unknown === 1 ? "" : "s"} could not be clearly classified as direct or transitive.`);
|
|
40
43
|
}
|
|
41
|
-
console.log(`- ${chalk.blueBright(String(uniqueAdvisories))}
|
|
44
|
+
console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} CVE${uniqueAdvisories === 1 ? "" : "s"} matched overall.`);
|
|
42
45
|
console.log(`- ${chalk.blue(String(fixable))} package${fixable === 1 ? "" : "s"} include a fixed-version hint from OSV.`);
|
|
43
46
|
}
|
|
44
47
|
export function printSuggestedFixCommands(findings, scanInput, options) {
|
|
@@ -367,7 +370,12 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
367
370
|
parts.push(chalk.green(`${counts.low} low`));
|
|
368
371
|
if (counts.unknown > 0)
|
|
369
372
|
parts.push(chalk.gray(`${counts.unknown} unknown`));
|
|
370
|
-
|
|
373
|
+
const compactCVEs = countUniqueAdvisories(findings);
|
|
374
|
+
const compactPkgLabel = findings.length === 1 ? "package" : "packages";
|
|
375
|
+
const compactCveLabel = compactCVEs === 1 ? "CVE" : "CVEs";
|
|
376
|
+
console.log(`${chalk.whiteBright(String(findings.length))} ${compactPkgLabel}` +
|
|
377
|
+
chalk.gray(" · ") +
|
|
378
|
+
`${chalk.whiteBright(String(compactCVEs))} ${compactCveLabel}`);
|
|
371
379
|
console.log(parts.join(chalk.gray(" · ")));
|
|
372
380
|
console.log(`${chalk.cyan(String(direct))} ${chalk.white("direct")}` +
|
|
373
381
|
`${chalk.gray(" · ")}` +
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
|
|
4
|
+
import { getRecommendedAction } from "./formatters.js";
|
|
5
|
+
import { getCliVersion } from "../utils/version-info.js";
|
|
6
|
+
import { severityToSarifLevel } from "../utils/severity.js";
|
|
7
|
+
const SARIF_RULE_NAME = "VulnerableDependency";
|
|
8
|
+
const LOCKFILE_NAMES = {
|
|
9
|
+
"package-lock": "package-lock.json",
|
|
10
|
+
"npm-shrinkwrap": "npm-shrinkwrap.json",
|
|
11
|
+
"pnpm-lock": "pnpm-lock.yaml",
|
|
12
|
+
"yarn-lock": "yarn.lock",
|
|
13
|
+
"bun-lock": "bun.lockb",
|
|
14
|
+
"package-json": "package.json",
|
|
15
|
+
"unknown": "lockfile",
|
|
16
|
+
};
|
|
17
|
+
export function deriveLockfileUri(scanInput) {
|
|
18
|
+
if (scanInput.filePath)
|
|
19
|
+
return path.basename(scanInput.filePath);
|
|
20
|
+
return LOCKFILE_NAMES[scanInput.source] ?? "lockfile";
|
|
21
|
+
}
|
|
22
|
+
export function buildSarifOutput(findings, lockfileUri, version, plan) {
|
|
23
|
+
const ruleMap = new Map();
|
|
24
|
+
const results = [];
|
|
25
|
+
for (const finding of findings) {
|
|
26
|
+
const level = severityToSarifLevel(finding.severity);
|
|
27
|
+
const action = getRecommendedAction(finding);
|
|
28
|
+
const runnableFixCommand = plan ? findSuggestedCommandForFinding(plan, finding) : null;
|
|
29
|
+
const location = {
|
|
30
|
+
physicalLocation: {
|
|
31
|
+
artifactLocation: { uri: lockfileUri, uriBaseId: "%SRCROOT%" },
|
|
32
|
+
region: { startLine: 1 },
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
const ruleIds = finding.cveAliases.length > 0
|
|
36
|
+
? finding.cveAliases
|
|
37
|
+
: finding.vulnerabilities.map(v => v.id);
|
|
38
|
+
for (const ruleId of ruleIds) {
|
|
39
|
+
if (!ruleMap.has(ruleId)) {
|
|
40
|
+
ruleMap.set(ruleId, {
|
|
41
|
+
id: ruleId,
|
|
42
|
+
name: SARIF_RULE_NAME,
|
|
43
|
+
shortDescription: { text: ruleId },
|
|
44
|
+
fullDescription: { text: `Vulnerable dependency: ${ruleId}` },
|
|
45
|
+
helpUri: `https://osv.dev/vulnerability/${ruleId}`,
|
|
46
|
+
defaultConfiguration: { level },
|
|
47
|
+
properties: { tags: ["security", "dependency"] },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
const result = {
|
|
51
|
+
ruleId,
|
|
52
|
+
level,
|
|
53
|
+
message: {
|
|
54
|
+
text: `${finding.pkg.name}@${finding.pkg.version} is vulnerable (${finding.severity}). ${action}`,
|
|
55
|
+
},
|
|
56
|
+
locations: [location],
|
|
57
|
+
};
|
|
58
|
+
if (runnableFixCommand) {
|
|
59
|
+
result.fixes = [{ description: { text: runnableFixCommand }, artifactChanges: [] }];
|
|
60
|
+
}
|
|
61
|
+
results.push(result);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
$schema: "https://raw.githubusercontent.com/oasis-tcs/sarif-spec/master/Schemata/sarif-schema-2.1.0.json",
|
|
66
|
+
version: "2.1.0",
|
|
67
|
+
runs: [
|
|
68
|
+
{
|
|
69
|
+
tool: {
|
|
70
|
+
driver: {
|
|
71
|
+
name: "CVE Lite CLI",
|
|
72
|
+
version,
|
|
73
|
+
informationUri: "https://owasp.org/cve-lite-cli/",
|
|
74
|
+
rules: Array.from(ruleMap.values()),
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
results,
|
|
78
|
+
artifacts: [
|
|
79
|
+
{ location: { uri: lockfileUri, uriBaseId: "%SRCROOT%" } },
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export function writeSarifReport(findings, lockfileUri, plan) {
|
|
86
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
87
|
+
const filename = `cve-lite-scan-${ts}.sarif`;
|
|
88
|
+
const outputPath = path.join(process.cwd(), filename);
|
|
89
|
+
const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan);
|
|
90
|
+
fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
|
|
91
|
+
return filename;
|
|
92
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { chalk } from "../utils/chalk.js";
|
|
4
|
+
import { serializeFinding } from "./formatters.js";
|
|
5
|
+
import { writeSarifReport, deriveLockfileUri } from "./sarif.js";
|
|
6
|
+
import { writeCycloneDxReport } from "./cyclonedx.js";
|
|
7
|
+
function readProjectMeta(projectPath) {
|
|
8
|
+
try {
|
|
9
|
+
const pkgPath = path.join(projectPath, "package.json");
|
|
10
|
+
if (!fs.existsSync(pkgPath))
|
|
11
|
+
return null;
|
|
12
|
+
const raw = fs.readFileSync(pkgPath, "utf-8");
|
|
13
|
+
const parsed = JSON.parse(raw);
|
|
14
|
+
if (!parsed.name)
|
|
15
|
+
return null;
|
|
16
|
+
return {
|
|
17
|
+
name: typeof parsed.name === "string" ? parsed.name : undefined,
|
|
18
|
+
version: typeof parsed.version === "string" ? parsed.version : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function writeOutputs(options, scanState, scanInput, projectPath) {
|
|
26
|
+
if (options.json) {
|
|
27
|
+
const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
28
|
+
const jsonFilename = `cve-lite-scan-${ts}.json`;
|
|
29
|
+
const jsonOutputPath = path.join(process.cwd(), jsonFilename);
|
|
30
|
+
fs.writeFileSync(jsonOutputPath, JSON.stringify({
|
|
31
|
+
projectPath,
|
|
32
|
+
mode: scanInput.mode,
|
|
33
|
+
source: scanInput.source,
|
|
34
|
+
packageCount: scanInput.packages.length,
|
|
35
|
+
findingCount: scanState.sorted.length,
|
|
36
|
+
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
37
|
+
notes: [...scanInput.notes, ...scanState.coverage],
|
|
38
|
+
warnings: scanInput.warnings,
|
|
39
|
+
skippedDependencies: scanInput.skippedDependencies,
|
|
40
|
+
findings: scanState.sorted.map(finding => serializeFinding(finding, scanState.suggestedFixCommands)),
|
|
41
|
+
}, null, 2));
|
|
42
|
+
console.log(`${chalk.gray("JSON saved to")} ${chalk.cyan(jsonFilename)}`);
|
|
43
|
+
}
|
|
44
|
+
if (options.sarif) {
|
|
45
|
+
const lockfileUri = deriveLockfileUri(scanInput);
|
|
46
|
+
const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands);
|
|
47
|
+
console.log(`${chalk.gray("SARIF report written to")} ${chalk.cyan(sarifFilename)}`);
|
|
48
|
+
}
|
|
49
|
+
if (options.cdx) {
|
|
50
|
+
const projectMeta = readProjectMeta(projectPath);
|
|
51
|
+
const cdxFilename = writeCycloneDxReport(scanState.allPackages, scanState.sorted, scanState.suggestedFixCommands, projectMeta);
|
|
52
|
+
console.log(`${chalk.gray("CycloneDX BOM written to")} ${chalk.cyan(cdxFilename)}`);
|
|
53
|
+
}
|
|
54
|
+
}
|
package/dist/parsers/index.js
CHANGED
|
@@ -8,6 +8,7 @@ import { loadFromPnpmLock } from "./pnpm-lock.js";
|
|
|
8
8
|
import { loadFromYarnLock } from "./yarn-lock.js";
|
|
9
9
|
export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
10
10
|
const rootBunLock = path.join(projectRoot, "bun.lock");
|
|
11
|
+
const rootShrinkwrap = path.join(projectRoot, "npm-shrinkwrap.json");
|
|
11
12
|
const rootPackageLock = path.join(projectRoot, "package-lock.json");
|
|
12
13
|
const rootPnpmLock = path.join(projectRoot, "pnpm-lock.yaml");
|
|
13
14
|
const rootYarnLock = path.join(projectRoot, "yarn.lock");
|
|
@@ -25,6 +26,20 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
25
26
|
skippedDependencies: []
|
|
26
27
|
};
|
|
27
28
|
}
|
|
29
|
+
if (fs.existsSync(rootShrinkwrap)) {
|
|
30
|
+
return {
|
|
31
|
+
mode: "resolved-lockfile",
|
|
32
|
+
source: "npm-shrinkwrap",
|
|
33
|
+
filePath: rootShrinkwrap,
|
|
34
|
+
packages: loadFromPackageLock(rootShrinkwrap, prodOnly),
|
|
35
|
+
notes: [
|
|
36
|
+
"Scanned resolved dependency versions from npm-shrinkwrap.json.",
|
|
37
|
+
"Dependency paths are derived from lockfile package locations."
|
|
38
|
+
],
|
|
39
|
+
warnings: [],
|
|
40
|
+
skippedDependencies: []
|
|
41
|
+
};
|
|
42
|
+
}
|
|
28
43
|
if (fs.existsSync(rootPackageLock)) {
|
|
29
44
|
return {
|
|
30
45
|
mode: "resolved-lockfile",
|
|
@@ -67,7 +82,7 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
67
82
|
skippedDependencies: []
|
|
68
83
|
};
|
|
69
84
|
}
|
|
70
|
-
const discoveredLockfiles = findFiles(projectRoot, ["bun.lock", "package-lock.json", "pnpm-lock.yaml", "yarn.lock"], maxDepth);
|
|
85
|
+
const discoveredLockfiles = findFiles(projectRoot, ["bun.lock", "npm-shrinkwrap.json", "package-lock.json", "pnpm-lock.yaml", "yarn.lock"], maxDepth);
|
|
71
86
|
if (discoveredLockfiles.length > 0) {
|
|
72
87
|
const selected = chooseBestLockfile(discoveredLockfiles);
|
|
73
88
|
const selectedName = path.basename(selected);
|
|
@@ -85,6 +100,20 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
85
100
|
skippedDependencies: []
|
|
86
101
|
};
|
|
87
102
|
}
|
|
103
|
+
if (selectedName === "npm-shrinkwrap.json") {
|
|
104
|
+
return {
|
|
105
|
+
mode: "resolved-lockfile",
|
|
106
|
+
source: "npm-shrinkwrap",
|
|
107
|
+
filePath: selected,
|
|
108
|
+
packages: loadFromPackageLock(selected, prodOnly),
|
|
109
|
+
notes: [
|
|
110
|
+
`Scanned resolved dependency versions from ${relativeOrName(projectRoot, selected)}.`,
|
|
111
|
+
"Dependency paths are derived from lockfile package locations."
|
|
112
|
+
],
|
|
113
|
+
warnings: ["No supported lockfile was found at the repo root, so a nested lockfile was used instead."],
|
|
114
|
+
skippedDependencies: []
|
|
115
|
+
};
|
|
116
|
+
}
|
|
88
117
|
if (selectedName === "package-lock.json") {
|
|
89
118
|
return {
|
|
90
119
|
mode: "resolved-lockfile",
|
|
@@ -166,7 +195,7 @@ export function loadPackages(projectRoot, prodOnly, maxDepth) {
|
|
|
166
195
|
export function buildNoPackagesMessage(projectRoot) {
|
|
167
196
|
return [
|
|
168
197
|
"No scannable packages were found.",
|
|
169
|
-
"Supported inputs: bun.lock, package-lock.json, pnpm-lock.yaml, yarn.lock, or package.json with exact pinned versions.",
|
|
198
|
+
"Supported inputs: bun.lock, npm-shrinkwrap.json, package-lock.json, pnpm-lock.yaml, yarn.lock, or package.json with exact pinned versions.",
|
|
170
199
|
`Searched under: ${projectRoot}`
|
|
171
200
|
].join(" ");
|
|
172
201
|
}
|