cve-lite-cli 1.19.1 → 1.20.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 +25 -1
- package/dist/cli/args.js +18 -0
- package/dist/cli/help.js +13 -7
- package/dist/cli/validate.js +9 -0
- package/dist/constants.js +4 -0
- package/dist/index.js +35 -4
- package/dist/output/formatters.js +8 -1
- package/dist/output/html-reporter.js +45 -26
- package/dist/output/printers.js +48 -12
- package/dist/parsers/bun-lock.js +75 -5
- package/dist/parsers/index.js +17 -12
- package/dist/parsers/package-lock.js +2 -1
- package/dist/parsers/yarn-lock.js +174 -15
- package/dist/remediation/fix-commands.js +3 -2
- package/dist/remediation/npm-transitive-resolution.js +43 -4
- package/dist/scanner.js +19 -3
- package/dist/utils/advisory.js +6 -0
- package/dist/utils/create-pr.js +212 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,9 +213,17 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
|
|
|
213
213
|
- [Astro](https://owasp.org/cve-lite-cli/docs/case-studies/astro) — verified baseline scan of a modern pnpm monorepo (2,228 packages, 34 findings at revision `221bb4b`) with a critical transitive SDK chain and four generated fix command groups
|
|
214
214
|
- [Turborepo](https://owasp.org/cve-lite-cli/docs/case-studies/turborepo) — verified baseline scan of a build-system pnpm monorepo (1,776 packages, 13 findings at revision `c85d410`) with a critical no-fix sandbox beta, all-transitive risk, and zero auto-generated fix commands on this snapshot
|
|
215
215
|
- [Visual Studio Code](https://owasp.org/cve-lite-cli/docs/case-studies/vscode) — verified baseline scan of the VS Code root npm lockfile (1,374 packages, 9 findings at revision `bc678ca`) with two direct Anthropic SDK advisories, a high-severity gulp toolchain chain, and two generated fix command groups
|
|
216
|
+
- [Gatsby](https://owasp.org/cve-lite-cli/docs/case-studies/gatsby) — verified baseline scan of a Yarn Classic monorepo (3,568 packages, 128 findings at revision `1f38c85`) with five direct findings, critical transitive template-engine chains, and CVE Lite vs `yarn audit` deduplication
|
|
217
|
+
- [Vercel AI SDK](https://owasp.org/cve-lite-cli/docs/case-studies/vercel-ai-sdk) — verified baseline scan of the [vercel/ai](https://github.com/vercel/ai) pnpm monorepo (3,570 packages, 55 findings at revision `3215032`) with three direct findings (`next`, `turbo`) and five workspace-scoped fix command groups — distinct from the Turborepo snapshot
|
|
218
|
+
- [Mastra](https://owasp.org/cve-lite-cli/docs/case-studies/mastra) — verified baseline scan of an AI agent framework pnpm monorepo (4,555 packages, 64 findings at revision `e9d54b2`) with four direct findings, two command groups, and workspace-scoped `pnpm add --filter playground` fixes
|
|
219
|
+
- [Lit](https://owasp.org/cve-lite-cli/docs/case-studies/lit) — verified baseline scan of an npm workspaces monorepo (2,059 packages, 99 findings at revision `20afabd`) with three direct `rollup` majors and workspace-scoped upgrade commands (13 first-pass fixes, 4 command groups)
|
|
220
|
+
- [LangChain.js](https://owasp.org/cve-lite-cli/docs/case-studies/langchainjs) — verified baseline scan of a pnpm LLM-framework monorepo (2,174 packages, 13 findings at revision `1503c9b`) with a lean-graph profile, three high-severity findings with validated fix targets, and a malicious-package advisory on OpenSearch integration paths
|
|
221
|
+
- [OpenAI Agents SDK (JavaScript)](https://owasp.org/cve-lite-cli/docs/case-studies/openai-agents-js) — verified baseline scan of a pnpm AI-agent monorepo (1,683 packages, 31 findings at revision `f76fc19`) with 0 direct findings, MCP/Daytona parent clusters, and one generated `verdaccio` parent-upgrade command
|
|
222
|
+
- [n8n](https://owasp.org/cve-lite-cli/docs/case-studies/n8n) — verified baseline scan of a workflow automation pnpm monorepo (3,746 packages, 32 findings at revision `e2e0394`) with one direct `turbo` fix, four command groups, and email/editor transitive clusters
|
|
223
|
+
- [CamoFox Browser](https://owasp.org/cve-lite-cli/docs/case-studies/camofox-browser) — verified baseline scan of an AI agent browser automation npm graph (435 packages, 2 findings at revision `ce3a3b0`) with dual `qs` fix strategies — within-range `npm update qs` and parent `npm install express@4.22.2`
|
|
216
224
|
- [Storybook](https://owasp.org/cve-lite-cli/docs/case-studies/storybook) — verified baseline scan of a Yarn Berry monorepo (3,008 packages, 92 findings at revision `cc19ae1`) spanning cross-framework sandbox templates, five critical transitive chains, and one direct vite fix command
|
|
217
225
|
|
|
218
|
-
In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, and Storybook live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
|
|
226
|
+
In-repo lockfile fixtures for Astro, Turborepo, Visual Studio Code, Gatsby, Vercel AI SDK, Mastra, Lit, LangChain.js, OpenAI Agents JS, n8n, CamoFox Browser, and Storybook live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
|
|
219
227
|
|
|
220
228
|
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
221
229
|
|
|
@@ -540,6 +548,22 @@ This project follows a [Code of Conduct](https://github.com/OWASP/cve-lite-cli/b
|
|
|
540
548
|
|
|
541
549
|
If CVE Lite CLI helps your release workflow, a [GitHub star](https://github.com/OWASP/cve-lite-cli) helps more developers find it.
|
|
542
550
|
|
|
551
|
+
## Contributors
|
|
552
|
+
|
|
553
|
+
Thanks to everyone who helps improve CVE Lite CLI — issues, pull requests, documentation, case studies, and real-world lockfile feedback all count.
|
|
554
|
+
|
|
555
|
+
<p align="center">
|
|
556
|
+
<a href="https://github.com/OWASP/cve-lite-cli/graphs/contributors">
|
|
557
|
+
<img src="https://contrib.rocks/image?repo=OWASP/cve-lite-cli" alt="Contributors to OWASP/cve-lite-cli" />
|
|
558
|
+
</a>
|
|
559
|
+
</p>
|
|
560
|
+
|
|
561
|
+
<p align="center">
|
|
562
|
+
<sub>Avatar grid generated from the <a href="https://github.com/OWASP/cve-lite-cli/graphs/contributors">GitHub contributors graph</a> via <a href="https://contrib.rocks">contrib.rocks</a>.</sub>
|
|
563
|
+
</p>
|
|
564
|
+
|
|
565
|
+
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.
|
|
566
|
+
|
|
543
567
|
---
|
|
544
568
|
|
|
545
569
|
*Most tools tell you what's wrong. CVE Lite CLI tells you what to run.*
|
package/dist/cli/args.js
CHANGED
|
@@ -109,6 +109,24 @@ export function parseArgs(argv) {
|
|
|
109
109
|
options.fix = true;
|
|
110
110
|
continue;
|
|
111
111
|
}
|
|
112
|
+
if (arg === "--create-pr") {
|
|
113
|
+
options.createPr = true;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (arg === "--base") {
|
|
117
|
+
const val = argv[++i];
|
|
118
|
+
if (!val)
|
|
119
|
+
throw new Error("--base requires a branch name");
|
|
120
|
+
options.prBase = val;
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (arg.startsWith("--base=")) {
|
|
124
|
+
const val = arg.slice("--base=".length);
|
|
125
|
+
if (!val)
|
|
126
|
+
throw new Error("--base requires a branch name");
|
|
127
|
+
options.prBase = val;
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
112
130
|
if (arg === "--prod-only") {
|
|
113
131
|
options.prodOnly = true;
|
|
114
132
|
continue;
|
package/dist/cli/help.js
CHANGED
|
@@ -21,12 +21,6 @@ export function printBanner(options) {
|
|
|
21
21
|
export function printHelp() {
|
|
22
22
|
printBanner();
|
|
23
23
|
const lines = [
|
|
24
|
-
"cve-lite",
|
|
25
|
-
"",
|
|
26
|
-
"Fast local-first CVE scanner for JS/TS projects using lockfiles + OSV",
|
|
27
|
-
"",
|
|
28
|
-
`Version: ${CLI_VERSION}`,
|
|
29
|
-
"",
|
|
30
24
|
"Usage:",
|
|
31
25
|
" cve-lite [projectPath] [options]",
|
|
32
26
|
" cve-lite advisories sync [options]",
|
|
@@ -40,6 +34,8 @@ export function printHelp() {
|
|
|
40
34
|
" --cdx Write CycloneDX 1.4 SBOM to a timestamped .cdx.json file",
|
|
41
35
|
" --no-open Don't auto-open the report in the browser",
|
|
42
36
|
" --fix Apply validated direct dependency fixes and rescan",
|
|
37
|
+
" --create-pr After --fix, commit changes and open a GitHub pull request (requires gh)",
|
|
38
|
+
" --base <branch> Base branch for --create-pr (default: main)",
|
|
43
39
|
" --osv-url <url> Use a custom OSV-compatible advisory endpoint",
|
|
44
40
|
" --ca-cert <path> Path to a CA certificate file for corporate SSL proxies",
|
|
45
41
|
" --debug Write verbose runtime/network diagnostics to a timestamped log file",
|
|
@@ -69,7 +65,17 @@ export function printHelp() {
|
|
|
69
65
|
" config show Show current configuration",
|
|
70
66
|
"",
|
|
71
67
|
" -v, --version Show the CLI version",
|
|
72
|
-
" -h, --help Show this help message"
|
|
68
|
+
" -h, --help Show this help message",
|
|
69
|
+
"",
|
|
70
|
+
"Examples:",
|
|
71
|
+
" cve-lite . Scan the current directory",
|
|
72
|
+
" cve-lite . --verbose Full output with fix plan and findings table",
|
|
73
|
+
" cve-lite . --fail-on high Exit 1 if any high or critical findings are found",
|
|
74
|
+
" cve-lite . --json Write findings to a timestamped JSON file",
|
|
75
|
+
" cve-lite . --report Generate an interactive HTML report",
|
|
76
|
+
" cve-lite . --fix Apply validated direct dependency fixes and rescan",
|
|
77
|
+
" cve-lite . --offline Scan using the local advisory database (no network)",
|
|
78
|
+
" cve-lite advisories sync Sync the local advisory database"
|
|
73
79
|
];
|
|
74
80
|
console.log(lines.join("\n"));
|
|
75
81
|
}
|
package/dist/cli/validate.js
CHANGED
|
@@ -17,6 +17,15 @@ export function validateOptions(options) {
|
|
|
17
17
|
if (options.fix && options.json) {
|
|
18
18
|
throw new Error("--fix cannot be used with --json");
|
|
19
19
|
}
|
|
20
|
+
if (options.createPr && !options.fix) {
|
|
21
|
+
throw new Error("--create-pr requires --fix");
|
|
22
|
+
}
|
|
23
|
+
if (options.createPr && options.json) {
|
|
24
|
+
throw new Error("--create-pr cannot be used with --json");
|
|
25
|
+
}
|
|
26
|
+
if (options.prBase && !options.createPr) {
|
|
27
|
+
throw new Error("--base can only be used with --create-pr");
|
|
28
|
+
}
|
|
20
29
|
if (options.report && options.json) {
|
|
21
30
|
throw new Error("--report cannot be used with --json");
|
|
22
31
|
}
|
package/dist/constants.js
CHANGED
|
@@ -8,6 +8,10 @@ export const severityOrder = {
|
|
|
8
8
|
};
|
|
9
9
|
export const DEFAULT_BATCH_SIZE = 100;
|
|
10
10
|
export const DEFAULT_SEARCH_DEPTH = 4;
|
|
11
|
+
export const NPM_PUBLIC_REGISTRY = "https://registry.npmjs.org/";
|
|
12
|
+
export const MAL_PRIVATE_REGISTRY_MESSAGE = "This package has a MAL- advisory but resolved from a private registry - unverifiable whether this advisory applies to your artifact. Inspect the source manually.";
|
|
13
|
+
export const MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE = "MAL- advisory could not be confirmed for this artifact.";
|
|
14
|
+
export const MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE = "verify artifact source manually";
|
|
11
15
|
export const EXCLUDED_DIRS = new Set([
|
|
12
16
|
".git",
|
|
13
17
|
"node_modules",
|
package/dist/index.js
CHANGED
|
@@ -31,6 +31,7 @@ import { readDirectDependencyNames } from "./utils/package-json.js";
|
|
|
31
31
|
import { applyFixesIfRequested, printFixModeSummary, } from "./utils/fix-runner.js";
|
|
32
32
|
import { hasRootLockfile, findNestedLockfiles } from "./parsers/multi-package.js";
|
|
33
33
|
import { handleMultiFolderScan } from "./scan/multi-folder-scan.js";
|
|
34
|
+
import { createPullRequestForFixes, } from "./utils/create-pr.js";
|
|
34
35
|
let parsedArgs = null;
|
|
35
36
|
try {
|
|
36
37
|
parsedArgs = parseArgs(process.argv.slice(2));
|
|
@@ -142,7 +143,7 @@ if (parsedArgs) {
|
|
|
142
143
|
await handleMultiFolderScan({ projectRoot: projectPath, batchSize, options });
|
|
143
144
|
return;
|
|
144
145
|
}
|
|
145
|
-
let advisorySourceLine;
|
|
146
|
+
let advisorySourceLine = "";
|
|
146
147
|
let advisoryDbFreshnessLine = null;
|
|
147
148
|
let advisoryDbWarning = null;
|
|
148
149
|
try {
|
|
@@ -180,7 +181,9 @@ if (parsedArgs) {
|
|
|
180
181
|
if (options.offline || options.offlineDb) {
|
|
181
182
|
console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
|
|
182
183
|
}
|
|
183
|
-
|
|
184
|
+
if (advisorySourceLine) {
|
|
185
|
+
console.log(`${chalk.gray("Advisory source:")} ${formatAdvisorySourceLine(advisorySourceLine)}`);
|
|
186
|
+
}
|
|
184
187
|
if (advisoryDbFreshnessLine) {
|
|
185
188
|
console.log(`${chalk.gray("Advisory DB freshness:")} ${advisoryDbFreshnessLine}`);
|
|
186
189
|
}
|
|
@@ -222,7 +225,8 @@ if (parsedArgs) {
|
|
|
222
225
|
projectPath,
|
|
223
226
|
debugLog,
|
|
224
227
|
});
|
|
225
|
-
const
|
|
228
|
+
const findingsBeforeFixList = scanState.sorted;
|
|
229
|
+
const findingsBeforeFix = findingsBeforeFixList.length;
|
|
226
230
|
let fixResult = null;
|
|
227
231
|
if (options.fix) {
|
|
228
232
|
fixResult = await applyFixesIfRequested({
|
|
@@ -258,6 +262,32 @@ if (parsedArgs) {
|
|
|
258
262
|
findingsAfterFix: scanState.sorted.length,
|
|
259
263
|
remainingBySeverity: countBySeverity(scanState.sorted),
|
|
260
264
|
});
|
|
265
|
+
if (options.createPr && fixResult) {
|
|
266
|
+
if (fixResult.appliedFixCount === 0) {
|
|
267
|
+
logWarn("Skipping pull request creation: no direct fixes were applied.", options);
|
|
268
|
+
}
|
|
269
|
+
else {
|
|
270
|
+
console.log("");
|
|
271
|
+
console.log(chalk.bold.cyan("Creating pull request (--create-pr)"));
|
|
272
|
+
const prResult = await createPullRequestForFixes({
|
|
273
|
+
projectPath,
|
|
274
|
+
baseBranch: options.prBase ?? "main",
|
|
275
|
+
fixResult,
|
|
276
|
+
findingsBeforeFix: findingsBeforeFixList,
|
|
277
|
+
findingsAfterFix: scanState.sorted,
|
|
278
|
+
});
|
|
279
|
+
if (prResult.skipped) {
|
|
280
|
+
logWarn(prResult.skipReason ?? "Pull request was not created.", options);
|
|
281
|
+
}
|
|
282
|
+
else if (prResult.prUrl) {
|
|
283
|
+
console.log(`${chalk.gray("Pull request:")} ${chalk.cyan(prResult.prUrl)}`);
|
|
284
|
+
console.log(`${chalk.gray("Branch:")} ${chalk.cyan(prResult.branchName)}`);
|
|
285
|
+
}
|
|
286
|
+
else {
|
|
287
|
+
logWarn(`Branch ${prResult.branchName} was pushed, but no pull request URL was returned.`, options);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
261
291
|
}
|
|
262
292
|
else {
|
|
263
293
|
await writeOutputs(options, {
|
|
@@ -280,7 +310,8 @@ if (parsedArgs) {
|
|
|
280
310
|
}
|
|
281
311
|
if (scanState.sorted.length > 0) {
|
|
282
312
|
if (scanState.tableFindings.length > 0) {
|
|
283
|
-
|
|
313
|
+
const skippedKeys = new Set((scanState.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
|
|
314
|
+
printTable(scanState.tableFindings, options.all ? null : scanState.minSeverity, skippedKeys);
|
|
284
315
|
}
|
|
285
316
|
else {
|
|
286
317
|
logInfo(`No findings met the table threshold of ${scanState.minSeverity}. Re-run with --all to show everything.`, options);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
|
|
2
2
|
import { chalk } from "../utils/chalk.js";
|
|
3
|
-
import { severityOrder } from "../constants.js";
|
|
3
|
+
import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE } from "../constants.js";
|
|
4
4
|
import { loadCache } from "../osv/cache.js";
|
|
5
5
|
import { inferSeverity } from "../osv/severity.js";
|
|
6
6
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
@@ -40,6 +40,9 @@ function isMaliciousAdvisory(finding) {
|
|
|
40
40
|
}
|
|
41
41
|
export function getRecommendedAction(finding) {
|
|
42
42
|
if (isMaliciousAdvisory(finding)) {
|
|
43
|
+
if (finding.maliciousUnverifiable) {
|
|
44
|
+
return MAL_PRIVATE_REGISTRY_MESSAGE;
|
|
45
|
+
}
|
|
43
46
|
return finding.relationship === "direct"
|
|
44
47
|
? "This package has a malicious code advisory. Remove it from your dependencies."
|
|
45
48
|
: "This package has a malicious code advisory. Upgrade or remove the parent package that pulls it in.";
|
|
@@ -146,6 +149,9 @@ export function summarizeNextAction(finding) {
|
|
|
146
149
|
// line agrees with the fix-command table. See getRecommendedAction.
|
|
147
150
|
const directTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
148
151
|
if (isMaliciousAdvisory(finding)) {
|
|
152
|
+
if (finding.maliciousUnverifiable) {
|
|
153
|
+
return MAL_PRIVATE_REGISTRY_MESSAGE;
|
|
154
|
+
}
|
|
149
155
|
return finding.relationship === "direct"
|
|
150
156
|
? "This package has a malicious code advisory. Remove it from your dependencies."
|
|
151
157
|
: "This package has a malicious code advisory. Upgrade or remove the parent package that pulls it in.";
|
|
@@ -194,6 +200,7 @@ export function serializeFinding(finding, plan) {
|
|
|
194
200
|
cves: finding.cveAliases,
|
|
195
201
|
dependencyPaths: finding.dependencyPaths,
|
|
196
202
|
usage: finding.usage ?? null,
|
|
203
|
+
maliciousUnverifiable: finding.maliciousUnverifiable ?? false,
|
|
197
204
|
vulnerabilities: finding.vulnerabilities.map(v => ({
|
|
198
205
|
id: v.id,
|
|
199
206
|
aliases: v.aliases ?? [],
|
|
@@ -69,7 +69,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
69
69
|
.fix-cmd .cmd-meta{font-size:11px;color:#8b949e;white-space:nowrap}
|
|
70
70
|
.fix-cmd .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
|
|
71
71
|
.fix-cmd .copy-btn:hover{color:#e6edf3;background:#30363d}
|
|
72
|
-
.findings-section{margin:
|
|
72
|
+
.findings-section{margin:24px 32px 32px}
|
|
73
73
|
.findings-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px}
|
|
74
74
|
.findings-header h2{font-size:13px;font-weight:600;color:#e6edf3}
|
|
75
75
|
.filter-bar{display:flex;gap:6px}
|
|
@@ -97,6 +97,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
97
97
|
.sev-badge.medium{background:#e3b34122;color:#e3b341;border:1px solid #e3b34166}
|
|
98
98
|
.sev-badge.low{background:#388bfd22;color:#388bfd;border:1px solid #388bfd66}
|
|
99
99
|
.sev-badge.unknown{background:#8b949e22;color:#8b949e;border:1px solid #8b949e66}
|
|
100
|
+
.badge-warning{display:inline-block;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;padding:2px 8px;border-radius:4px;background:#e3b34122;color:#e3b341;border:1px solid #e3b34166}
|
|
100
101
|
.rel-badge{font-size:11px;padding:2px 7px;border-radius:4px}
|
|
101
102
|
.rel-badge.direct{color:#3fb950;background:#3fb95022}
|
|
102
103
|
.rel-badge.transitive{color:#e3b341;background:#e3b34122}
|
|
@@ -105,6 +106,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
105
106
|
.cve-link:hover{color:#79c0ff}
|
|
106
107
|
.fix-hint{font-size:11px;color:#3fb950;font-family:monospace}
|
|
107
108
|
.fix-hint.none{color:#e3b341}
|
|
109
|
+
.fix-hint.hint-only{color:#8b949e}
|
|
108
110
|
.expand-icon{color:#8b949e;font-size:10px}
|
|
109
111
|
.detail-row{background:#0d1117;border-top:1px solid #21262d;display:none}
|
|
110
112
|
.detail-row.visible{display:table-row}
|
|
@@ -122,7 +124,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
|
|
|
122
124
|
.fix-cmd-inline .copy-btn{font-size:11px;color:#8b949e;background:#21262d;border:1px solid #30363d;border-radius:4px;padding:3px 8px;cursor:pointer}
|
|
123
125
|
.fix-cmd-note{margin:4px 0 0;font-size:12px;color:#8b949e;font-style:italic;line-height:1.5}
|
|
124
126
|
.report-footer{margin:0 32px 32px;padding:12px 0;border-top:1px solid #21262d;display:flex;justify-content:space-between;font-size:11px;color:#8b949e}
|
|
125
|
-
.scan-notes{margin:
|
|
127
|
+
.scan-notes{margin:24px 32px 16px}
|
|
126
128
|
.scan-notes-toggle{display:flex;align-items:center;gap:6px;font-size:11px;color:#8b949e;background:none;border:none;cursor:pointer;padding:0}
|
|
127
129
|
.scan-notes-toggle:hover{color:#e6edf3}
|
|
128
130
|
.scan-notes-toggle .arrow{font-size:9px;transition:transform .15s}
|
|
@@ -156,7 +158,9 @@ export function renderHtmlReport(data) {
|
|
|
156
158
|
const totalCVEs = new Set(data.findings.flatMap(f => f.vulnerabilities.map(v => v.id))).size;
|
|
157
159
|
const noticesHtml = renderNotices(data.notes, data.warnings);
|
|
158
160
|
const fixPlanHtml = renderFixPlan(data.suggestedFixCommands);
|
|
159
|
-
const
|
|
161
|
+
const skippedKeys = new Set((data.suggestedFixCommands?.skipped ?? []).map(s => `${s.package}@${s.version}`));
|
|
162
|
+
const skippedSectionHtml = renderSkippedSection(data.suggestedFixCommands);
|
|
163
|
+
const findingRowsHtml = data.findings.map((f, i) => renderFindingRow(f, i, skippedKeys)).join("\n");
|
|
160
164
|
const dataJson = JSON.stringify(data)
|
|
161
165
|
.replace(/</g, "\\u003c")
|
|
162
166
|
.replace(/>/g, "\\u003e")
|
|
@@ -219,7 +223,6 @@ ${REPORT_STYLES}
|
|
|
219
223
|
</div>
|
|
220
224
|
|
|
221
225
|
${fixPlanHtml}
|
|
222
|
-
${noticesHtml}
|
|
223
226
|
|
|
224
227
|
<div class="findings-section">
|
|
225
228
|
<div class="findings-header">
|
|
@@ -232,6 +235,7 @@ ${noticesHtml}
|
|
|
232
235
|
<button class="filter-btn" onclick="setFilter('high',this)">High (${counts.high})</button>
|
|
233
236
|
<button class="filter-btn" onclick="setFilter('medium',this)">Medium (${counts.medium})</button>
|
|
234
237
|
<button class="filter-btn" onclick="setFilter('direct',this)">Direct only</button>
|
|
238
|
+
${skippedKeys.size > 0 ? `<button class="filter-btn" onclick="setFilter('skipped',this)">⊘ Skipped (${skippedKeys.size})</button>` : ""}
|
|
235
239
|
</div>
|
|
236
240
|
</div>
|
|
237
241
|
</div>
|
|
@@ -252,6 +256,7 @@ ${findingRowsHtml}
|
|
|
252
256
|
</tbody>
|
|
253
257
|
</table>
|
|
254
258
|
</div>
|
|
259
|
+
${noticesHtml}
|
|
255
260
|
|
|
256
261
|
<div class="report-footer">
|
|
257
262
|
<span>Generated by <strong>cve-lite v${escapeHtml(data.cliVersion)}</strong></span>
|
|
@@ -306,6 +311,7 @@ function applyFilters() {
|
|
|
306
311
|
else if (activeFilter === 'high') visible = f.severity === 'high';
|
|
307
312
|
else if (activeFilter === 'medium') visible = f.severity === 'medium';
|
|
308
313
|
else if (activeFilter === 'direct') visible = f.relationship === 'direct';
|
|
314
|
+
else if (activeFilter === 'skipped') visible = mainRow?.dataset?.skipped === '1';
|
|
309
315
|
if (visible && query) {
|
|
310
316
|
const ids = [...(f.cves || []), ...(f.vulnerabilities || []).map(v => v.id)].join(' ').toLowerCase();
|
|
311
317
|
visible = f.package.toLowerCase().includes(query) || f.version.toLowerCase().includes(query) || ids.includes(query);
|
|
@@ -388,18 +394,22 @@ function advisoryLink(id) {
|
|
|
388
394
|
}
|
|
389
395
|
return `<a class="cve-link" href="https://osv.dev/vulnerability/${escapeHtml(id)}" target="_blank">${escapeHtml(id)}</a>`;
|
|
390
396
|
}
|
|
391
|
-
export function renderFindingRow(finding, idx) {
|
|
397
|
+
export function renderFindingRow(finding, idx, skippedKeys) {
|
|
392
398
|
const cveLinks = finding.cves.length > 0
|
|
393
399
|
? finding.cves.map(advisoryLink).join(", ")
|
|
394
400
|
: finding.vulnerabilities.map(v => advisoryLink(v.id)).join(", ");
|
|
395
401
|
const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
|
|
396
|
-
const
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
402
|
+
const isSkipped = skippedKeys?.has(`${finding.package}@${finding.version}`);
|
|
403
|
+
const fixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
404
|
+
const fixHtml = isSkipped && fixVersion
|
|
405
|
+
? `<span class="fix-hint hint-only" title="Advisory hint only — no automated fix command was generated. See the Skipped findings section below for details.">${escapeHtml(fixVersion)} ⊘</span>`
|
|
406
|
+
: fixVersion
|
|
407
|
+
? `<span class="fix-hint">${escapeHtml(fixVersion)}</span>`
|
|
408
|
+
: isMalicious && finding.maliciousUnverifiable
|
|
409
|
+
? `<span class="badge badge-warning" title="MAL- advisory found but package resolved from a private registry - may not apply to your artifact">Unverifiable (private source)</span>`
|
|
410
|
+
: isMalicious
|
|
411
|
+
? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
|
|
412
|
+
: `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
|
|
403
413
|
const depPathHtml = finding.dependencyPaths.length > 0
|
|
404
414
|
? finding.dependencyPaths[0].map((node, i, arr) => {
|
|
405
415
|
const isLast = i === arr.length - 1;
|
|
@@ -417,7 +427,7 @@ export function renderFindingRow(finding, idx) {
|
|
|
417
427
|
const contextColHtml = finding.relationship === "transitive"
|
|
418
428
|
? renderTransitiveContextCol(finding)
|
|
419
429
|
: "";
|
|
420
|
-
return ` <tr id="row-${idx}" onclick="toggleRow(${idx})">
|
|
430
|
+
return ` <tr id="row-${idx}" data-skipped="${isSkipped ? '1' : '0'}" onclick="toggleRow(${idx})">
|
|
421
431
|
<td><span class="expand-icon" id="icon-${idx}">▶</span></td>
|
|
422
432
|
<td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
|
|
423
433
|
<td>${fixHtml}</td>
|
|
@@ -485,6 +495,26 @@ function renderNotices(notes, warnings) {
|
|
|
485
495
|
<div class="scan-notes-body"><ul>${items}</ul></div>
|
|
486
496
|
</div>`;
|
|
487
497
|
}
|
|
498
|
+
export function renderSkippedSection(plan) {
|
|
499
|
+
if (!plan || plan.skipped.length === 0)
|
|
500
|
+
return "";
|
|
501
|
+
const skippedRows = plan.skipped.map(s => `
|
|
502
|
+
<div class="skipped-row">
|
|
503
|
+
<span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
|
|
504
|
+
<span class="skipped-rel ${escapeHtml(s.relationship)}">${escapeHtml(s.relationship)}</span>
|
|
505
|
+
<span class="skipped-reason">${escapeHtml(s.reason)}</span>
|
|
506
|
+
</div>`).join("\n");
|
|
507
|
+
return `<div class="fix-plan">
|
|
508
|
+
<div class="fix-plan-header">
|
|
509
|
+
<h2><span class="icon">⊘</span> Skipped findings</h2>
|
|
510
|
+
<button class="skipped-toggle" onclick="toggleSkipped()">↑ collapse</button>
|
|
511
|
+
</div>
|
|
512
|
+
<div class="skipped-section open" id="skipped-section">
|
|
513
|
+
<div style="font-size:11px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:.4px;margin-bottom:4px">Why were these skipped?</div>
|
|
514
|
+
${skippedRows}
|
|
515
|
+
</div>
|
|
516
|
+
</div>`;
|
|
517
|
+
}
|
|
488
518
|
export function renderFixPlan(plan) {
|
|
489
519
|
if (!plan || plan.sections.length === 0)
|
|
490
520
|
return "";
|
|
@@ -519,19 +549,8 @@ export function renderFixPlan(plan) {
|
|
|
519
549
|
<button class="copy-btn" data-cmd="${escapeHtml(section.command)}">Copy</button>
|
|
520
550
|
</div>${targetsHtml}`;
|
|
521
551
|
}).join("\n");
|
|
522
|
-
const skippedRows = plan.skipped.map(s => `
|
|
523
|
-
<div class="skipped-row">
|
|
524
|
-
<span class="skipped-pkg">${escapeHtml(s.package)}@${escapeHtml(s.version)}</span>
|
|
525
|
-
<span class="skipped-rel ${escapeHtml(s.relationship)}">${escapeHtml(s.relationship)}</span>
|
|
526
|
-
<span class="skipped-reason">${escapeHtml(s.reason)}</span>
|
|
527
|
-
</div>`).join("\n");
|
|
528
|
-
const skippedSection = skippedCount > 0 ? `
|
|
529
|
-
<div class="skipped-section" id="skipped-section">
|
|
530
|
-
<div style="font-size:11px;font-weight:600;color:#8b949e;text-transform:uppercase;letter-spacing:.4px;margin-bottom:4px">Why were these skipped?</div>
|
|
531
|
-
${skippedRows}
|
|
532
|
-
</div>` : "";
|
|
533
552
|
const skippedBadgePart = skippedCount > 0
|
|
534
|
-
? ` · <
|
|
553
|
+
? ` · <span style="color:#8b949e">${skippedCount} skipped ⊘</span>`
|
|
535
554
|
: "";
|
|
536
555
|
const coverageText = plan.coveredFindingCount === plan.totalFindingCount
|
|
537
556
|
? `Running all commands should fix all ${plan.totalFindingCount} findings.`
|
|
@@ -542,7 +561,7 @@ export function renderFixPlan(plan) {
|
|
|
542
561
|
<span class="badge">${directCount} direct ${pluralize(directCount, "fix", "fixes")}${skippedBadgePart}</span>
|
|
543
562
|
</div>
|
|
544
563
|
<div class="fix-commands">${commandRows}
|
|
545
|
-
</div
|
|
564
|
+
</div>
|
|
546
565
|
<div style="padding:10px 18px;border-top:1px solid #21262d;font-size:11px;color:#8b949e">${coverageText}</div>
|
|
547
566
|
</div>`;
|
|
548
567
|
}
|
package/dist/output/printers.js
CHANGED
|
@@ -5,6 +5,7 @@ import { getPrimaryParent } from "../utils/finding.js";
|
|
|
5
5
|
import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel } from "./formatters.js";
|
|
6
6
|
import { pluralize } from "../utils/string.js";
|
|
7
7
|
import { selectFindingsForCompact } from "./finding-display.js";
|
|
8
|
+
import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE } from "../constants.js";
|
|
8
9
|
export function printSummary(findings, packageCount, scanInput) {
|
|
9
10
|
if (findings.length === 0) {
|
|
10
11
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -148,21 +149,38 @@ export function printSkippedDependencies(skipped) {
|
|
|
148
149
|
console.log(`${chalk.yellow("•")} ...and ${skipped.length - 10} more`);
|
|
149
150
|
}
|
|
150
151
|
}
|
|
151
|
-
export function printTable(findings, threshold) {
|
|
152
|
+
export function printTable(findings, threshold, skippedKeys) {
|
|
152
153
|
const headers = ["Package", "Version", "Severity", "Type", "Usage", "Fixed", "IDs"];
|
|
153
154
|
const rawRows = findings.map(f => {
|
|
154
155
|
let usageText = "n/a";
|
|
155
156
|
if (f.usage) {
|
|
156
157
|
usageText = f.usage.imported ? `${f.usage.files.length} file(s)` : "unused";
|
|
157
158
|
}
|
|
159
|
+
const isSkipped = skippedKeys?.has(`${f.pkg.name}@${f.pkg.version}`);
|
|
160
|
+
const fixVersion = f.validatedFirstFixedVersion ?? f.firstFixedVersion;
|
|
161
|
+
let fixedDisplay;
|
|
162
|
+
if (isSkipped && fixVersion) {
|
|
163
|
+
fixedDisplay = chalk.gray(`${fixVersion} ⊘`);
|
|
164
|
+
}
|
|
165
|
+
else if (fixVersion) {
|
|
166
|
+
fixedDisplay = fixVersion;
|
|
167
|
+
}
|
|
168
|
+
else if (f.maliciousUnverifiable) {
|
|
169
|
+
fixedDisplay = chalk.yellow("⚠ Unverifiable (private source)");
|
|
170
|
+
}
|
|
171
|
+
else if (f.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
|
|
172
|
+
fixedDisplay = chalk.yellow("⚠ Malicious");
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
fixedDisplay = chalk.yellow("⚠ no fix");
|
|
176
|
+
}
|
|
158
177
|
return [
|
|
159
178
|
f.pkg.name,
|
|
160
179
|
f.pkg.version,
|
|
161
180
|
f.severity,
|
|
162
181
|
f.relationship,
|
|
163
182
|
usageText,
|
|
164
|
-
|
|
165
|
-
(f.vulnerabilities.some(v => v.id.startsWith("MAL-")) ? chalk.yellow("⚠ Malicious") : chalk.yellow("⚠ no fix")),
|
|
183
|
+
fixedDisplay,
|
|
166
184
|
f.vulnerabilities.map(v => v.id).join(", ")
|
|
167
185
|
];
|
|
168
186
|
});
|
|
@@ -203,9 +221,17 @@ export function printTable(findings, threshold) {
|
|
|
203
221
|
const action = f.relationship === "direct"
|
|
204
222
|
? "Remove it from your dependencies immediately."
|
|
205
223
|
: "Upgrade or remove the parent package that pulls it in.";
|
|
206
|
-
|
|
224
|
+
if (f.maliciousUnverifiable) {
|
|
225
|
+
console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${action}`));
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} - ${action}`));
|
|
229
|
+
}
|
|
207
230
|
}
|
|
208
231
|
}
|
|
232
|
+
if (skippedKeys && skippedKeys.size > 0 && findings.some(f => skippedKeys.has(`${f.pkg.name}@${f.pkg.version}`))) {
|
|
233
|
+
console.log(chalk.gray("⊘ Advisory hint only — no automated fix command could be generated. Run --report to view detailed skip reasons."));
|
|
234
|
+
}
|
|
209
235
|
if (threshold) {
|
|
210
236
|
console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
|
|
211
237
|
}
|
|
@@ -307,10 +333,15 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
307
333
|
console.log(` ${typeLabel}${usageContext}`);
|
|
308
334
|
const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
|
|
309
335
|
if (isMalicious) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
336
|
+
if (finding.maliciousUnverifiable) {
|
|
337
|
+
console.log(` ${chalk.yellow(`⚠ Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE}`)}`);
|
|
338
|
+
}
|
|
339
|
+
else {
|
|
340
|
+
const action = finding.relationship === "direct"
|
|
341
|
+
? "Remove this package from your dependencies immediately."
|
|
342
|
+
: "Upgrade or remove the parent package that pulls it in.";
|
|
343
|
+
console.log(` ${chalk.red(`⚠ Malicious: ${action}`)}`);
|
|
344
|
+
}
|
|
314
345
|
}
|
|
315
346
|
else if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
316
347
|
console.log(` ${chalk.gray(`Fix: lockfile refresh — ${finding.recommendedNpmTransitiveRemediation.package} already permits a safe version`)}`);
|
|
@@ -413,10 +444,15 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
413
444
|
console.log("");
|
|
414
445
|
console.log(chalk.bold.red("⚠ Malicious package advisory:"));
|
|
415
446
|
for (const f of maliciousCompact) {
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
447
|
+
if (f.maliciousUnverifiable) {
|
|
448
|
+
console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE}`));
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
const action = f.relationship === "direct"
|
|
452
|
+
? "Remove it from your dependencies immediately."
|
|
453
|
+
: "Upgrade or remove the parent package that pulls it in.";
|
|
454
|
+
console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} - ${action}`));
|
|
455
|
+
}
|
|
420
456
|
}
|
|
421
457
|
}
|
|
422
458
|
if (options?.all) {
|