cve-lite-cli 1.18.0 → 1.18.2
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 +15 -0
- package/dist/advisory/local-advisory-source.js +1 -1
- package/dist/advisory/osv-advisory-source.js +83 -13
- package/dist/advisory/osv-sync.js +3 -2
- package/dist/cli/args.js +52 -0
- package/dist/cli/config-command.js +40 -0
- package/dist/cli/config.js +66 -0
- package/dist/cli/help.js +7 -0
- package/dist/cli/validate.js +9 -0
- package/dist/index.js +112 -130
- package/dist/learn/keypress.js +50 -0
- package/dist/learn/runner.js +96 -0
- package/dist/learn/scenario.js +47 -0
- package/dist/learn/session.js +36 -0
- package/dist/learn/types.js +1 -0
- package/dist/osv/cache.js +46 -7
- package/dist/output/debug.js +38 -0
- package/dist/output/finding-display.js +30 -0
- package/dist/output/formatters.js +4 -3
- package/dist/output/html-reporter.js +3 -2
- package/dist/output/multi-folder-html-reporter.js +323 -0
- package/dist/output/multi-folder-printer.js +46 -0
- package/dist/output/printers.js +16 -15
- package/dist/output/sarif.js +3 -9
- package/dist/output/spinner.js +1 -1
- package/dist/parsers/multi-package.js +58 -0
- package/dist/parsers/pnpm-lock.js +4 -0
- package/dist/parsers/yarn-lock.js +60 -0
- package/dist/remediation/fix-commands.js +127 -6
- package/dist/remediation/npm-registry.js +44 -1
- package/dist/remediation/parent-upgrade.js +14 -8
- package/dist/scan/multi-folder-scan.js +97 -0
- package/dist/scanner.js +100 -21
- package/dist/utils/fix-runner.js +131 -0
- package/dist/utils/network.js +18 -4
- package/dist/utils/string.js +3 -0
- package/dist/utils/time.js +4 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -210,6 +210,12 @@ CVE Lite CLI has been evaluated against real open-source projects to verify that
|
|
|
210
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
|
|
211
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
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
|
|
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
|
+
- [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
|
+
- [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
|
+
- [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
|
+
|
|
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.
|
|
213
219
|
|
|
214
220
|
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
215
221
|
|
|
@@ -217,8 +223,15 @@ If you maintain an open-source JavaScript or TypeScript project and want CVE Lit
|
|
|
217
223
|
|
|
218
224
|
## Press
|
|
219
225
|
|
|
226
|
+
- **[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
|
|
227
|
+
- **[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
|
|
228
|
+
- **[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)
|
|
229
|
+
- **[AIがコーディングを加速する中、CVE Lite CLIはセキュリティを意図的にAI無しに保つ](https://blackhatnews.tokyo/archives/104903)** — TokyoBlackHatNews (Japan), May 2026
|
|
230
|
+
- **[The postcss That Would Not Die, and How CVE Lite Ended My Override Grind](https://labs.hexaxia.tech/blog/hexops-cve-lite-integration/)** — Hexaxia Labs (Aaron Lamb), May 2026
|
|
220
231
|
- **[As AI speeds coding, CVE Lite CLI keeps security deliberately AI-free](https://www.csoonline.com/article/4176701/as-ai-speeds-coding-cve-lite-cli-keeps-security-deliberately-ai-free.html)** — CSO Online (Shweta Sharma), May 2026
|
|
232
|
+
- **[CVE Lite CLI: The Dependency Scanner That Actually Tells You What to Run](https://medium.com/@techlatest.net/cve-lite-cli-the-dependency-scanner-that-actually-tells-you-what-to-run-not-just-whats-broken-f6b518199981)** — Medium (TechLatest.Net), May 2026
|
|
221
233
|
- **[AI Security Is Changing Fast — These 6 Open-Source Tools Prove It](https://medium.com/@techlatest.net/ai-security-is-changing-fast-these-6-open-source-tools-prove-it-5c5c9081cff7)** — Medium (TechLatest.Net), May 2026
|
|
234
|
+
- **[Hottest cybersecurity open-source tools of the month: May 2026](https://www.helpnetsecurity.com/2026/05/28/hottest-cybersecurity-open-source-tools-of-the-month-may-2026/)** — Help Net Security Monthly Roundup, May 2026
|
|
222
235
|
- **[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
|
|
223
236
|
- **[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
|
|
224
237
|
|
|
@@ -409,6 +422,8 @@ It is a good fit for:
|
|
|
409
422
|
|
|
410
423
|
See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration) for concrete patterns across these scenarios.
|
|
411
424
|
|
|
425
|
+
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.
|
|
426
|
+
|
|
412
427
|
## Current limitations
|
|
413
428
|
|
|
414
429
|
- does not detect malicious packages before they appear in advisory data
|
|
@@ -1,26 +1,57 @@
|
|
|
1
1
|
import { extractErrorMessage } from "../utils/network.js";
|
|
2
2
|
export class OsvAdvisorySource {
|
|
3
3
|
baseUrl;
|
|
4
|
-
|
|
4
|
+
debugLog;
|
|
5
|
+
constructor(baseUrl = "https://api.osv.dev", debugLog) {
|
|
5
6
|
this.baseUrl = baseUrl;
|
|
7
|
+
this.debugLog = debugLog;
|
|
6
8
|
}
|
|
7
|
-
async queryBatch(packages) {
|
|
9
|
+
async queryBatch(packages, meta) {
|
|
10
|
+
const requestUrl = `${this.baseUrl}/v1/querybatch`;
|
|
11
|
+
const payload = {
|
|
12
|
+
queries: packages.map(p => ({
|
|
13
|
+
package: {
|
|
14
|
+
ecosystem: p.ecosystem,
|
|
15
|
+
name: p.name,
|
|
16
|
+
},
|
|
17
|
+
version: p.version,
|
|
18
|
+
})),
|
|
19
|
+
};
|
|
20
|
+
const startedAt = this.debugLog ? Date.now() : 0;
|
|
8
21
|
try {
|
|
9
|
-
|
|
22
|
+
if (this.debugLog) {
|
|
23
|
+
this.debugLog("OSV request", {
|
|
24
|
+
batchId: meta?.batchId ?? null,
|
|
25
|
+
method: "POST",
|
|
26
|
+
url: requestUrl,
|
|
27
|
+
headers: {
|
|
28
|
+
"Content-Type": "application/json",
|
|
29
|
+
},
|
|
30
|
+
queryCount: packages.length,
|
|
31
|
+
sample: packages.slice(0, 3).map(p => ({
|
|
32
|
+
ecosystem: p.ecosystem,
|
|
33
|
+
name: p.name,
|
|
34
|
+
version: p.version,
|
|
35
|
+
})),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const response = await fetch(requestUrl, {
|
|
10
39
|
method: "POST",
|
|
11
40
|
headers: {
|
|
12
41
|
"Content-Type": "application/json",
|
|
13
42
|
},
|
|
14
|
-
body: JSON.stringify(
|
|
15
|
-
queries: packages.map(p => ({
|
|
16
|
-
package: {
|
|
17
|
-
ecosystem: p.ecosystem,
|
|
18
|
-
name: p.name,
|
|
19
|
-
},
|
|
20
|
-
version: p.version,
|
|
21
|
-
})),
|
|
22
|
-
}),
|
|
43
|
+
body: JSON.stringify(payload),
|
|
23
44
|
});
|
|
45
|
+
if (this.debugLog) {
|
|
46
|
+
this.debugLog("OSV response", {
|
|
47
|
+
batchId: meta?.batchId ?? null,
|
|
48
|
+
method: "POST",
|
|
49
|
+
url: requestUrl,
|
|
50
|
+
status: response.status,
|
|
51
|
+
statusText: response.statusText,
|
|
52
|
+
durationMs: Date.now() - startedAt,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
24
55
|
if (!response.ok) {
|
|
25
56
|
throw new Error(`OSV batch query failed: ${response.status} ${response.statusText}`);
|
|
26
57
|
}
|
|
@@ -32,19 +63,58 @@ export class OsvAdvisorySource {
|
|
|
32
63
|
}));
|
|
33
64
|
}
|
|
34
65
|
catch (error) {
|
|
66
|
+
if (this.debugLog) {
|
|
67
|
+
this.debugLog("OSV request failed", {
|
|
68
|
+
batchId: meta?.batchId ?? null,
|
|
69
|
+
method: "POST",
|
|
70
|
+
url: requestUrl,
|
|
71
|
+
durationMs: Date.now() - startedAt,
|
|
72
|
+
error: error instanceof Error
|
|
73
|
+
? { message: error.message, stack: error.stack }
|
|
74
|
+
: String(error),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
35
77
|
const message = extractErrorMessage(error);
|
|
36
78
|
throw new Error(`OSV batch query failed for ${this.baseUrl}: ${message}`);
|
|
37
79
|
}
|
|
38
80
|
}
|
|
39
81
|
async getVuln(id) {
|
|
82
|
+
const requestUrl = `${this.baseUrl}/v1/vulns/${encodeURIComponent(id)}`;
|
|
83
|
+
const startedAt = this.debugLog ? Date.now() : 0;
|
|
40
84
|
try {
|
|
41
|
-
|
|
85
|
+
if (this.debugLog) {
|
|
86
|
+
this.debugLog("OSV request", {
|
|
87
|
+
method: "GET",
|
|
88
|
+
url: requestUrl,
|
|
89
|
+
headers: {},
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
const response = await fetch(requestUrl);
|
|
93
|
+
if (this.debugLog) {
|
|
94
|
+
this.debugLog("OSV response", {
|
|
95
|
+
method: "GET",
|
|
96
|
+
url: requestUrl,
|
|
97
|
+
status: response.status,
|
|
98
|
+
statusText: response.statusText,
|
|
99
|
+
durationMs: Date.now() - startedAt,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
42
102
|
if (!response.ok) {
|
|
43
103
|
throw new Error(`OSV vuln fetch failed for ${id}: ${response.status} ${response.statusText}`);
|
|
44
104
|
}
|
|
45
105
|
return response.json();
|
|
46
106
|
}
|
|
47
107
|
catch (error) {
|
|
108
|
+
if (this.debugLog) {
|
|
109
|
+
this.debugLog("OSV request failed", {
|
|
110
|
+
method: "GET",
|
|
111
|
+
url: requestUrl,
|
|
112
|
+
durationMs: Date.now() - startedAt,
|
|
113
|
+
error: error instanceof Error
|
|
114
|
+
? { message: error.message, stack: error.stack }
|
|
115
|
+
: String(error),
|
|
116
|
+
});
|
|
117
|
+
}
|
|
48
118
|
const message = extractErrorMessage(error);
|
|
49
119
|
throw new Error(`OSV vuln fetch failed for ${id} via ${this.baseUrl}: ${message}`);
|
|
50
120
|
}
|
|
@@ -3,6 +3,7 @@ import os from "node:os";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { unzipSync } from "fflate";
|
|
5
5
|
import { LocalAdvisoryDatabase } from "./local-db.js";
|
|
6
|
+
import { pluralize } from "../utils/string.js";
|
|
6
7
|
const DEFAULT_OSV_NPM_DUMP_URL = "https://storage.googleapis.com/osv-vulnerabilities/npm/all.zip";
|
|
7
8
|
export const ADVISORY_DB_STALE_AFTER_MS = 7 * 24 * 60 * 60 * 1000;
|
|
8
9
|
export function getDefaultAdvisoryDbPath(outputPath) {
|
|
@@ -61,7 +62,7 @@ export async function syncOsvAdvisories(options = {}) {
|
|
|
61
62
|
phase: "extract",
|
|
62
63
|
totalEntries: Object.keys(archiveEntries).length,
|
|
63
64
|
advisoryEntries: advisoryEntries.length,
|
|
64
|
-
message: `Archive loaded. Processing ${advisoryEntries.length} advisory
|
|
65
|
+
message: `Archive loaded. Processing ${advisoryEntries.length} advisory ${pluralize(advisoryEntries.length, "record")}`,
|
|
65
66
|
});
|
|
66
67
|
await yieldToEventLoop();
|
|
67
68
|
const db = new LocalAdvisoryDatabase(dbPath);
|
|
@@ -104,7 +105,7 @@ export async function syncOsvAdvisories(options = {}) {
|
|
|
104
105
|
phase: "complete",
|
|
105
106
|
advisoryCount,
|
|
106
107
|
dbPath,
|
|
107
|
-
message: `Sync complete. Stored ${advisoryCount} advisory
|
|
108
|
+
message: `Sync complete. Stored ${advisoryCount} advisory ${pluralize(advisoryCount, "record")} in ${dbPath}`,
|
|
108
109
|
});
|
|
109
110
|
return { advisoryCount, dbPath, sourceUrl };
|
|
110
111
|
}
|
package/dist/cli/args.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigAction, ConfigKey } from "./config.js";
|
|
1
2
|
export function parseArgs(argv) {
|
|
2
3
|
const options = {
|
|
3
4
|
failOn: "critical",
|
|
@@ -24,6 +25,20 @@ export function parseArgs(argv) {
|
|
|
24
25
|
options.output = arg.slice("--output=".length);
|
|
25
26
|
continue;
|
|
26
27
|
}
|
|
28
|
+
if (arg === "--ca-cert") {
|
|
29
|
+
const val = argv[++i];
|
|
30
|
+
if (!val)
|
|
31
|
+
throw new Error("--ca-cert requires a path argument");
|
|
32
|
+
options.caCert = val;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if (arg.startsWith("--ca-cert=")) {
|
|
36
|
+
const val = arg.slice("--ca-cert=".length);
|
|
37
|
+
if (!val)
|
|
38
|
+
throw new Error("--ca-cert requires a path argument");
|
|
39
|
+
options.caCert = val;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
27
42
|
if (arg.startsWith("-")) {
|
|
28
43
|
throw new Error(`Unknown option: ${arg}`);
|
|
29
44
|
}
|
|
@@ -45,6 +60,28 @@ export function parseArgs(argv) {
|
|
|
45
60
|
}
|
|
46
61
|
return { command: "install-skill", options };
|
|
47
62
|
}
|
|
63
|
+
if (argv[0] === "config") {
|
|
64
|
+
const sub = argv[1];
|
|
65
|
+
if (sub === ConfigAction.Show) {
|
|
66
|
+
return { command: "config", options, configSubcommand: { action: ConfigAction.Show } };
|
|
67
|
+
}
|
|
68
|
+
if (sub === ConfigAction.Set) {
|
|
69
|
+
const key = argv[2];
|
|
70
|
+
const value = argv[3];
|
|
71
|
+
if (key !== ConfigKey.CaCert)
|
|
72
|
+
throw new Error(`Unknown config key: ${key ?? "(none)"}. Valid keys: ${ConfigKey.CaCert}`);
|
|
73
|
+
if (!value)
|
|
74
|
+
throw new Error(`cve-lite config set ${ConfigKey.CaCert} requires a path argument`);
|
|
75
|
+
return { command: "config", options, configSubcommand: { action: ConfigAction.Set, key: ConfigKey.CaCert, value } };
|
|
76
|
+
}
|
|
77
|
+
if (sub === ConfigAction.Unset) {
|
|
78
|
+
const key = argv[2];
|
|
79
|
+
if (key !== ConfigKey.CaCert)
|
|
80
|
+
throw new Error(`Unknown config key: ${key ?? "(none)"}. Valid keys: ${ConfigKey.CaCert}`);
|
|
81
|
+
return { command: "config", options, configSubcommand: { action: ConfigAction.Unset, key: ConfigKey.CaCert } };
|
|
82
|
+
}
|
|
83
|
+
throw new Error(`Unknown config subcommand: ${sub ?? "(none)"}. Use: ${ConfigAction.Set}, ${ConfigAction.Unset}, ${ConfigAction.Show}`);
|
|
84
|
+
}
|
|
48
85
|
let projectArg;
|
|
49
86
|
for (let i = 0; i < argv.length; i++) {
|
|
50
87
|
const arg = argv[i];
|
|
@@ -60,6 +97,10 @@ export function parseArgs(argv) {
|
|
|
60
97
|
options.json = true;
|
|
61
98
|
continue;
|
|
62
99
|
}
|
|
100
|
+
if (arg === "--debug") {
|
|
101
|
+
options.debug = true;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
63
104
|
if (arg === "--verbose") {
|
|
64
105
|
options.verbose = true;
|
|
65
106
|
continue;
|
|
@@ -176,6 +217,17 @@ export function parseArgs(argv) {
|
|
|
176
217
|
options.noCache = true;
|
|
177
218
|
continue;
|
|
178
219
|
}
|
|
220
|
+
if (arg === "--ca-cert") {
|
|
221
|
+
const val = argv[++i];
|
|
222
|
+
if (!val)
|
|
223
|
+
throw new Error("--ca-cert requires a path argument");
|
|
224
|
+
options.caCert = val;
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
if (arg.startsWith("--ca-cert=")) {
|
|
228
|
+
options.caCert = arg.slice("--ca-cert=".length);
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
179
231
|
if (arg === "--sarif") {
|
|
180
232
|
options.sarif = true;
|
|
181
233
|
continue;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { chalk } from "../utils/chalk.js";
|
|
2
|
+
import { readConfig, writeConfig, getConfigPath, validateCaCertFile, ConfigAction, ConfigKey } from "./config.js";
|
|
3
|
+
export function runConfigCommand(sub) {
|
|
4
|
+
if (sub.action === ConfigAction.Show) {
|
|
5
|
+
const config = readConfig();
|
|
6
|
+
const keys = Object.keys(config);
|
|
7
|
+
if (keys.length === 0) {
|
|
8
|
+
console.log("No configuration set.");
|
|
9
|
+
console.log(chalk.gray(`Config file: ${getConfigPath()}`));
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
console.log(chalk.gray(`Config file: ${getConfigPath()}`));
|
|
13
|
+
console.log("");
|
|
14
|
+
if (config.caCert) {
|
|
15
|
+
console.log(` ${chalk.bold(ConfigKey.CaCert)} ${chalk.cyan(config.caCert)}`);
|
|
16
|
+
}
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
if (sub.action === ConfigAction.Set && sub.key === ConfigKey.CaCert) {
|
|
20
|
+
validateCaCertFile(sub.value);
|
|
21
|
+
const config = readConfig();
|
|
22
|
+
config.caCert = sub.value;
|
|
23
|
+
writeConfig(config);
|
|
24
|
+
console.log(`${chalk.green("✔")} Saved: ${chalk.bold(ConfigKey.CaCert)} = ${chalk.cyan(sub.value)}`);
|
|
25
|
+
console.log(chalk.gray(`Config file: ${getConfigPath()}`));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (sub.action === ConfigAction.Unset && sub.key === ConfigKey.CaCert) {
|
|
29
|
+
const config = readConfig();
|
|
30
|
+
if (!config.caCert) {
|
|
31
|
+
console.log(`${chalk.bold(ConfigKey.CaCert)} is not set.`);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
delete config.caCert;
|
|
35
|
+
writeConfig(config);
|
|
36
|
+
console.log(`${chalk.green("✔")} Removed: ${chalk.bold(ConfigKey.CaCert)}`);
|
|
37
|
+
console.log(chalk.gray(`Config file: ${getConfigPath()}`));
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
export const ConfigAction = {
|
|
5
|
+
Set: "set",
|
|
6
|
+
Unset: "unset",
|
|
7
|
+
Show: "show",
|
|
8
|
+
};
|
|
9
|
+
export const ConfigKey = {
|
|
10
|
+
CaCert: "ca-cert",
|
|
11
|
+
};
|
|
12
|
+
export function getConfigDir() {
|
|
13
|
+
return path.join(os.homedir(), ".cve-lite-cli");
|
|
14
|
+
}
|
|
15
|
+
export function getConfigPath() {
|
|
16
|
+
return path.join(getConfigDir(), "config.json");
|
|
17
|
+
}
|
|
18
|
+
export function readConfig() {
|
|
19
|
+
const configPath = getConfigPath();
|
|
20
|
+
try {
|
|
21
|
+
const raw = fs.readFileSync(configPath, "utf8");
|
|
22
|
+
const parsed = JSON.parse(raw);
|
|
23
|
+
if (typeof parsed !== "object" || parsed === null)
|
|
24
|
+
return {};
|
|
25
|
+
const config = {};
|
|
26
|
+
if (typeof parsed.caCert === "string") {
|
|
27
|
+
config.caCert = parsed.caCert;
|
|
28
|
+
}
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return {};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export function validateCaCertFile(filePath) {
|
|
36
|
+
let stat;
|
|
37
|
+
try {
|
|
38
|
+
stat = fs.statSync(filePath);
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
throw new Error(`cannot read file: ${filePath}`);
|
|
42
|
+
}
|
|
43
|
+
if (!stat.isFile()) {
|
|
44
|
+
throw new Error(`not a file: ${filePath}`);
|
|
45
|
+
}
|
|
46
|
+
let content;
|
|
47
|
+
try {
|
|
48
|
+
content = fs.readFileSync(filePath, "utf8");
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
throw new Error(`cannot read file: ${filePath}`);
|
|
52
|
+
}
|
|
53
|
+
if (content.trim().length === 0) {
|
|
54
|
+
throw new Error(`file is empty: ${filePath}`);
|
|
55
|
+
}
|
|
56
|
+
if (!content.trimStart().startsWith("-----BEGIN")) {
|
|
57
|
+
throw new Error(`not a valid PEM certificate (expected file to start with -----BEGIN): ${filePath}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function writeConfig(config) {
|
|
61
|
+
const configDir = getConfigDir();
|
|
62
|
+
if (!fs.existsSync(configDir)) {
|
|
63
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
64
|
+
}
|
|
65
|
+
fs.writeFileSync(getConfigPath(), JSON.stringify(config, null, 2) + "\n", "utf8");
|
|
66
|
+
}
|
package/dist/cli/help.js
CHANGED
|
@@ -31,6 +31,7 @@ export function printHelp() {
|
|
|
31
31
|
" cve-lite [projectPath] [options]",
|
|
32
32
|
" cve-lite advisories sync [options]",
|
|
33
33
|
" cve-lite install-skill",
|
|
34
|
+
" cve-lite config <set|unset|show> [key] [value]",
|
|
34
35
|
"",
|
|
35
36
|
"Scan options:",
|
|
36
37
|
" --json Save scan results to a timestamped JSON file",
|
|
@@ -40,6 +41,8 @@ export function printHelp() {
|
|
|
40
41
|
" --no-open Don't auto-open the report in the browser",
|
|
41
42
|
" --fix Apply validated direct dependency fixes and rescan",
|
|
42
43
|
" --osv-url <url> Use a custom OSV-compatible advisory endpoint",
|
|
44
|
+
" --ca-cert <path> Path to a CA certificate file for corporate SSL proxies",
|
|
45
|
+
" --debug Write verbose runtime/network diagnostics to a timestamped log file",
|
|
43
46
|
" --verbose Show detailed output with fix plan, paths, and full table",
|
|
44
47
|
" --prod-only Exclude dev dependencies where available",
|
|
45
48
|
" --fail-on <severity> Exit non-zero at or above severity (default: critical)",
|
|
@@ -61,6 +64,10 @@ export function printHelp() {
|
|
|
61
64
|
" install-skill Install AI assistant skill files for Claude Code,",
|
|
62
65
|
" Codex CLI, Gemini CLI, Cursor, and GitHub Copilot",
|
|
63
66
|
"",
|
|
67
|
+
" config set ca-cert <path> Save a CA certificate path to ~/.cve-lite-cli/config.json",
|
|
68
|
+
" config unset ca-cert Remove the saved CA certificate path",
|
|
69
|
+
" config show Show current configuration",
|
|
70
|
+
"",
|
|
64
71
|
" -v, --version Show the CLI version",
|
|
65
72
|
" -h, --help Show this help message"
|
|
66
73
|
];
|
package/dist/cli/validate.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { validateCaCertFile } from "./config.js";
|
|
1
2
|
export function validateOptions(options) {
|
|
2
3
|
if ((options.offline || options.offlineDb) && options.osvUrl) {
|
|
3
4
|
throw new Error("--offline/--offline-db cannot be used with --osv-url");
|
|
@@ -19,4 +20,12 @@ export function validateOptions(options) {
|
|
|
19
20
|
if (options.report && options.json) {
|
|
20
21
|
throw new Error("--report cannot be used with --json");
|
|
21
22
|
}
|
|
23
|
+
if (options.caCert) {
|
|
24
|
+
try {
|
|
25
|
+
validateCaCertFile(options.caCert);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
throw new Error(`--ca-cert: ${err instanceof Error ? err.message : String(err)}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
22
31
|
}
|