cve-lite-cli 1.18.0 → 1.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -0
- package/dist/advisory/osv-sync.js +3 -2
- package/dist/cli/args.js +48 -0
- package/dist/cli/config-command.js +40 -0
- package/dist/cli/config.js +66 -0
- package/dist/cli/help.js +6 -0
- package/dist/cli/validate.js +9 -0
- package/dist/index.js +45 -127
- package/dist/output/formatters.js +4 -3
- package/dist/output/html-reporter.js +3 -2
- package/dist/output/printers.js +12 -11
- package/dist/parsers/yarn-lock.js +60 -0
- package/dist/remediation/fix-commands.js +91 -2
- package/dist/scanner.js +6 -5
- package/dist/utils/fix-runner.js +127 -0
- package/dist/utils/network.js +11 -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,10 @@ 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
|
+
|
|
216
|
+
In-repo lockfile fixtures for Astro and Turborepo live under [`examples/`](examples/readme.md) — clone the repo and scan immediately without downloading full upstream checkouts.
|
|
213
217
|
|
|
214
218
|
These are not demos. They are documented scans against real codebases with real findings, recorded before and after applying fix commands.
|
|
215
219
|
|
|
@@ -217,7 +221,13 @@ If you maintain an open-source JavaScript or TypeScript project and want CVE Lit
|
|
|
217
221
|
|
|
218
222
|
## Press
|
|
219
223
|
|
|
224
|
+
- **[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
|
|
225
|
+
- **[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
|
|
226
|
+
- **[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)
|
|
227
|
+
- **[AIがコーディングを加速する中、CVE Lite CLIはセキュリティを意図的にAI無しに保つ](https://blackhatnews.tokyo/archives/104903)** — TokyoBlackHatNews (Japan), May 2026
|
|
228
|
+
- **[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
229
|
- **[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
|
|
230
|
+
- **[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
231
|
- **[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
|
|
222
232
|
- **[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
233
|
- **[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
|
|
@@ -409,6 +419,8 @@ It is a good fit for:
|
|
|
409
419
|
|
|
410
420
|
See the [CI and Workflow Integration guide](https://owasp.org/cve-lite-cli/docs/ci-integration) for concrete patterns across these scenarios.
|
|
411
421
|
|
|
422
|
+
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.
|
|
423
|
+
|
|
412
424
|
## Current limitations
|
|
413
425
|
|
|
414
426
|
- does not detect malicious packages before they appear in advisory data
|
|
@@ -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];
|
|
@@ -176,6 +213,17 @@ export function parseArgs(argv) {
|
|
|
176
213
|
options.noCache = true;
|
|
177
214
|
continue;
|
|
178
215
|
}
|
|
216
|
+
if (arg === "--ca-cert") {
|
|
217
|
+
const val = argv[++i];
|
|
218
|
+
if (!val)
|
|
219
|
+
throw new Error("--ca-cert requires a path argument");
|
|
220
|
+
options.caCert = val;
|
|
221
|
+
continue;
|
|
222
|
+
}
|
|
223
|
+
if (arg.startsWith("--ca-cert=")) {
|
|
224
|
+
options.caCert = arg.slice("--ca-cert=".length);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
179
227
|
if (arg === "--sarif") {
|
|
180
228
|
options.sarif = true;
|
|
181
229
|
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,7 @@ 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",
|
|
43
45
|
" --verbose Show detailed output with fix plan, paths, and full table",
|
|
44
46
|
" --prod-only Exclude dev dependencies where available",
|
|
45
47
|
" --fail-on <severity> Exit non-zero at or above severity (default: critical)",
|
|
@@ -61,6 +63,10 @@ export function printHelp() {
|
|
|
61
63
|
" install-skill Install AI assistant skill files for Claude Code,",
|
|
62
64
|
" Codex CLI, Gemini CLI, Cursor, and GitHub Copilot",
|
|
63
65
|
"",
|
|
66
|
+
" config set ca-cert <path> Save a CA certificate path to ~/.cve-lite-cli/config.json",
|
|
67
|
+
" config unset ca-cert Remove the saved CA certificate path",
|
|
68
|
+
" config show Show current configuration",
|
|
69
|
+
"",
|
|
64
70
|
" -v, --version Show the CLI version",
|
|
65
71
|
" -h, --help Show this help message"
|
|
66
72
|
];
|
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
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import process from "node:process";
|
|
5
4
|
import { parseArgs } from "./cli/args.js";
|
|
@@ -15,15 +14,19 @@ import { createSpinner } from "./output/spinner.js";
|
|
|
15
14
|
import { buildSuggestedFixCommandPlan } from "./remediation/fix-commands.js";
|
|
16
15
|
import { scanProjectForPackageUsage } from "./usage/scanner.js";
|
|
17
16
|
import { getCliVersion } from "./utils/version-info.js";
|
|
18
|
-
import { blockedAdvisoryRequestHint, isLikelyBlockedAdvisoryRequestError, isRateLimitError, isServerError, isSslCertificateError, rateLimitAdvisoryRequestHint, serverAdvisoryRequestHint, sslCertificateErrorHint, } from "./utils/network.js";
|
|
17
|
+
import { blockedAdvisoryRequestHint, fetchErrorCaCertHint, isLikelyBlockedAdvisoryRequestError, isRateLimitError, isServerError, isSslCertificateError, rateLimitAdvisoryRequestHint, serverAdvisoryRequestHint, sslCertificateErrorHint, } from "./utils/network.js";
|
|
19
18
|
import { formatAdvisoryDbFreshness } from "./utils/time.js";
|
|
19
|
+
import { pluralize } from "./utils/string.js";
|
|
20
20
|
import { formatAdvisorySourceLine, logInfo, logWarn, printCacheSummary, sortFindingsForOutput } from "./output/formatters.js";
|
|
21
21
|
import { countBySeverity } from "./utils/severity.js";
|
|
22
22
|
import { buildReportData, writeHtmlReport } from "./output/html-reporter.js";
|
|
23
23
|
import { writeOutputs } from "./output/write-outputs.js";
|
|
24
24
|
import { printSummary, printActionSummary, printSuggestedFixCommands, printSuggestedFixCommandSkips, printCoverage, printSkippedDependencies, printTable, printFinalStatus, printCompactOutput } from "./output/printers.js";
|
|
25
25
|
import { installSkill } from "./skills/install.js";
|
|
26
|
+
import { readConfig, validateCaCertFile } from "./cli/config.js";
|
|
27
|
+
import { runConfigCommand } from "./cli/config-command.js";
|
|
26
28
|
import { readDirectDependencyNames } from "./utils/package-json.js";
|
|
29
|
+
import { applyFixesIfRequested, printFixModeSummary, } from "./utils/fix-runner.js";
|
|
27
30
|
let parsedArgs = null;
|
|
28
31
|
try {
|
|
29
32
|
parsedArgs = parseArgs(process.argv.slice(2));
|
|
@@ -51,6 +54,39 @@ if (parsedArgs) {
|
|
|
51
54
|
const searchDepth = Math.max(0, Number(options.searchDepth || DEFAULT_SEARCH_DEPTH));
|
|
52
55
|
async function main() {
|
|
53
56
|
printBanner(options);
|
|
57
|
+
if (command === "config") {
|
|
58
|
+
const { configSubcommand } = parsedArgs;
|
|
59
|
+
if (!configSubcommand) {
|
|
60
|
+
console.error(chalk.red("Error: config requires a subcommand: set, unset, show"));
|
|
61
|
+
console.error(chalk.gray("Run `cve-lite --help` for usage."));
|
|
62
|
+
process.exit(1);
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
runConfigCommand(configSubcommand);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
69
|
+
console.error(chalk.red(`Error: ${message}`));
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
process.exit(0);
|
|
73
|
+
}
|
|
74
|
+
const savedConfig = readConfig();
|
|
75
|
+
const resolvedCaCert = options.caCert ?? savedConfig.caCert;
|
|
76
|
+
if (resolvedCaCert) {
|
|
77
|
+
if (!options.caCert && savedConfig.caCert) {
|
|
78
|
+
try {
|
|
79
|
+
validateCaCertFile(resolvedCaCert);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
83
|
+
console.error(chalk.red(`Error: Saved ca-cert is no longer valid: ${message}`));
|
|
84
|
+
console.error(chalk.gray(`Run \`cve-lite config unset ca-cert\` to remove it.`));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
process.env.NODE_EXTRA_CA_CERTS = resolvedCaCert;
|
|
89
|
+
}
|
|
54
90
|
if (command === "advisories-sync") {
|
|
55
91
|
const spinner = createSpinner("Preparing advisory sync...", options);
|
|
56
92
|
const usePlainProgressLogs = !process.stdout.isTTY || !!options.json;
|
|
@@ -73,7 +109,7 @@ if (parsedArgs) {
|
|
|
73
109
|
else {
|
|
74
110
|
spinner.succeed(`Advisory sync complete (${result.advisoryCount} records)`);
|
|
75
111
|
}
|
|
76
|
-
console.log(`${chalk.gray("Advisory database:")} synced ${result.advisoryCount}
|
|
112
|
+
console.log(`${chalk.gray("Advisory database:")} synced ${result.advisoryCount} ${pluralize(result.advisoryCount, "record")} to ${chalk.cyan(result.dbPath)}`);
|
|
77
113
|
process.exit(0);
|
|
78
114
|
return;
|
|
79
115
|
}
|
|
@@ -124,7 +160,7 @@ if (parsedArgs) {
|
|
|
124
160
|
}
|
|
125
161
|
let scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
126
162
|
let packages = scanInput.packages;
|
|
127
|
-
logInfo(`Parsed ${packages.length}
|
|
163
|
+
logInfo(`Parsed ${packages.length} ${pluralize(packages.length, "package")} from ${scanInput.source}${scanInput.filePath ? ` (${path.relative(projectPath, scanInput.filePath) || path.basename(scanInput.filePath)})` : ""}`, options);
|
|
128
164
|
printCacheSummary(options.cacheDir, options);
|
|
129
165
|
if (scanInput.warnings.length > 0) {
|
|
130
166
|
for (const warning of scanInput.warnings) {
|
|
@@ -259,6 +295,11 @@ if (parsedArgs) {
|
|
|
259
295
|
console.error(chalk.yellow(hint));
|
|
260
296
|
rest.forEach(line => console.error(chalk.gray(line)));
|
|
261
297
|
}
|
|
298
|
+
else {
|
|
299
|
+
const [hint, ...rest] = fetchErrorCaCertHint();
|
|
300
|
+
console.error(chalk.yellow(hint));
|
|
301
|
+
rest.forEach(line => console.error(chalk.gray(line)));
|
|
302
|
+
}
|
|
262
303
|
process.exit(1);
|
|
263
304
|
});
|
|
264
305
|
}
|
|
@@ -305,126 +346,3 @@ async function scanProject(params) {
|
|
|
305
346
|
allPackages: params.scanInput.packages,
|
|
306
347
|
};
|
|
307
348
|
}
|
|
308
|
-
async function applyFixesIfRequested(params) {
|
|
309
|
-
console.log("");
|
|
310
|
-
console.log(chalk.bold.cyan("Applying fixes (--fix)"));
|
|
311
|
-
if (!params.plan) {
|
|
312
|
-
return {
|
|
313
|
-
appliedFixCount: 0,
|
|
314
|
-
skippedCount: params.totalFindings,
|
|
315
|
-
skippedTransitiveCount: 0,
|
|
316
|
-
skippedNoValidatedTargetCount: params.totalFindings,
|
|
317
|
-
applied: [],
|
|
318
|
-
note: "No package-manager-native fix command is available for this project.",
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
const directTargets = params.plan.targets.filter(target => target.kind === "direct");
|
|
322
|
-
const transitiveTargets = params.plan.targets.filter(target => target.kind !== "direct");
|
|
323
|
-
const skippedDirect = params.plan.skipped.filter(skip => skip.relationship === "direct" || skip.relationship === "unknown");
|
|
324
|
-
if (directTargets.length === 0) {
|
|
325
|
-
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
326
|
-
return {
|
|
327
|
-
appliedFixCount: 0,
|
|
328
|
-
skippedCount,
|
|
329
|
-
skippedTransitiveCount: transitiveTargets.length,
|
|
330
|
-
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
331
|
-
applied: [],
|
|
332
|
-
note: "No validated direct dependency fixes were eligible for auto-apply.",
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
const commandLabel = commandLabelForPackageManager(params.plan.packageManager);
|
|
336
|
-
const total = directTargets.length;
|
|
337
|
-
const spinner = createSpinner(`Applying direct package fixes with ${commandLabel}... 0/${total}`, params.options);
|
|
338
|
-
const fixHint = `\nHint: Check that \`${params.plan.packageManager}\` is available and you have write access to node_modules.\nIf running in CI, ensure the install step has already run before cve-lite --fix.`;
|
|
339
|
-
for (let i = 0; i < directTargets.length; i++) {
|
|
340
|
-
const target = directTargets[i];
|
|
341
|
-
const commandParts = buildFixCommandParts(params.plan.packageManager, [target]);
|
|
342
|
-
spinner.update(`Applying direct fix ${i + 1}/${total}: ${commandParts.join(" ")}`);
|
|
343
|
-
const run = await runInstallCommand(commandParts[0], commandParts.slice(1), params.projectPath);
|
|
344
|
-
if (run.error) {
|
|
345
|
-
spinner.fail("Failed to apply fixes");
|
|
346
|
-
throw new Error(`Failed to apply fixes: ${run.error.message}${fixHint}`);
|
|
347
|
-
}
|
|
348
|
-
if ((run.status ?? 1) !== 0) {
|
|
349
|
-
spinner.fail(`Fix command failed (${commandLabel})`);
|
|
350
|
-
throw new Error(`Fix command exited with status ${run.status ?? 1}${fixHint}`);
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
spinner.succeed(`Applied ${directTargets.length} direct package fix${directTargets.length === 1 ? "" : "es"} with ${commandLabel}`);
|
|
354
|
-
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
355
|
-
return {
|
|
356
|
-
appliedFixCount: directTargets.length,
|
|
357
|
-
skippedCount,
|
|
358
|
-
skippedTransitiveCount: transitiveTargets.length,
|
|
359
|
-
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
360
|
-
applied: directTargets.map(target => ({
|
|
361
|
-
package: target.package,
|
|
362
|
-
from: target.currentVersion ?? "unknown",
|
|
363
|
-
to: target.targetVersion,
|
|
364
|
-
})),
|
|
365
|
-
note: null,
|
|
366
|
-
};
|
|
367
|
-
}
|
|
368
|
-
function buildFixCommandParts(packageManager, targets) {
|
|
369
|
-
if (packageManager === "npm") {
|
|
370
|
-
return ["npm", "install", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
371
|
-
}
|
|
372
|
-
if (packageManager === "pnpm") {
|
|
373
|
-
return ["pnpm", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
374
|
-
}
|
|
375
|
-
if (packageManager === "bun") {
|
|
376
|
-
return ["bun", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
377
|
-
}
|
|
378
|
-
return ["yarn", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
379
|
-
}
|
|
380
|
-
async function runInstallCommand(command, args, cwd) {
|
|
381
|
-
return await new Promise(resolve => {
|
|
382
|
-
const child = spawn(command, args, {
|
|
383
|
-
cwd,
|
|
384
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
385
|
-
});
|
|
386
|
-
child.stdout.on("data", () => { });
|
|
387
|
-
child.stderr.on("data", () => { });
|
|
388
|
-
child.on("error", error => {
|
|
389
|
-
resolve({ status: null, error });
|
|
390
|
-
});
|
|
391
|
-
child.on("close", code => {
|
|
392
|
-
resolve({ status: code, error: null });
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
|
-
function commandLabelForPackageManager(packageManager) {
|
|
397
|
-
if (packageManager === "npm")
|
|
398
|
-
return "npm install";
|
|
399
|
-
if (packageManager === "pnpm")
|
|
400
|
-
return "pnpm add";
|
|
401
|
-
if (packageManager === "bun")
|
|
402
|
-
return "bun add";
|
|
403
|
-
return "yarn add";
|
|
404
|
-
}
|
|
405
|
-
function printFixModeSummary(params) {
|
|
406
|
-
const result = params.fixResult;
|
|
407
|
-
if (!result)
|
|
408
|
-
return;
|
|
409
|
-
if (result.note) {
|
|
410
|
-
console.log(chalk.gray(result.note));
|
|
411
|
-
}
|
|
412
|
-
if (result.applied.length > 0) {
|
|
413
|
-
console.log("");
|
|
414
|
-
console.log(chalk.bold.cyan("Applied fixes"));
|
|
415
|
-
for (const item of result.applied) {
|
|
416
|
-
console.log(`- ${chalk.white(item.package)}: ${chalk.gray(item.from)} ${chalk.cyan("->")} ${chalk.green(item.to)}`);
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
console.log("");
|
|
420
|
-
console.log(chalk.bold.cyan("Fix summary"));
|
|
421
|
-
console.log(`- Applied fixes: ${chalk.green(String(result.appliedFixCount))}`);
|
|
422
|
-
console.log(`- Skipped findings: ${chalk.yellow(String(result.skippedCount))}`);
|
|
423
|
-
if (result.skippedCount > 0) {
|
|
424
|
-
console.log(` - Transitive (v1 skip): ${chalk.yellow(String(result.skippedTransitiveCount))}`);
|
|
425
|
-
console.log(` - No validated direct target: ${chalk.yellow(String(result.skippedNoValidatedTargetCount))}`);
|
|
426
|
-
}
|
|
427
|
-
console.log(`- Findings before fix: ${chalk.white(String(params.findingsBeforeFix))}`);
|
|
428
|
-
console.log(`- Remaining findings after fix: ${chalk.white(String(params.findingsAfterFix))}`);
|
|
429
|
-
console.log(`- Remaining severity mix: critical ${chalk.redBright(String(params.remainingBySeverity.critical))}, high ${chalk.red(String(params.remainingBySeverity.high))}, medium ${chalk.yellow(String(params.remainingBySeverity.medium))}, low ${chalk.blueBright(String(params.remainingBySeverity.low))}, unknown ${chalk.magenta(String(params.remainingBySeverity.unknown))}`);
|
|
430
|
-
}
|
|
@@ -5,6 +5,7 @@ import { loadCache } from "../osv/cache.js";
|
|
|
5
5
|
import { inferSeverity } from "../osv/severity.js";
|
|
6
6
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
7
7
|
import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js";
|
|
8
|
+
import { pluralize } from "../utils/string.js";
|
|
8
9
|
export function formatSeverityLabel(severity) {
|
|
9
10
|
const lower = severity.toLowerCase();
|
|
10
11
|
if (lower === "critical")
|
|
@@ -138,7 +139,7 @@ function formatParentUpgradeAction(vulnerableName, vulnerableVersion, parentName
|
|
|
138
139
|
return `${upgrade} to resolve vulnerable ${vulnerableName}@${vulnerableVersion}${pathText}.`;
|
|
139
140
|
}
|
|
140
141
|
const remainingCount = coverage.remainingPaths.length;
|
|
141
|
-
return `${upgrade} to resolve the ${vulnerableName}@${vulnerableVersion} path${pathText}; run it, then rescan. ${remainingCount} other known
|
|
142
|
+
return `${upgrade} to resolve the ${vulnerableName}@${vulnerableVersion} path${pathText}; run it, then rescan. ${remainingCount} other known ${pluralize(remainingCount, "path")} may still need separate parent upgrades.`;
|
|
142
143
|
}
|
|
143
144
|
export function summarizeNextAction(finding) {
|
|
144
145
|
// Prefer the registry-validated target over the raw advisory hint so this
|
|
@@ -211,9 +212,9 @@ export function printCacheSummary(cacheDirOverride, options) {
|
|
|
211
212
|
const totalCount = advisoryCount + emptyCount;
|
|
212
213
|
if (totalCount === 0 && packageQueryCount === 0)
|
|
213
214
|
return;
|
|
214
|
-
console.log(chalk.gray(`Cache: ${packageQueryCount} package match
|
|
215
|
+
console.log(chalk.gray(`Cache: ${packageQueryCount} package match ${pluralize(packageQueryCount, "record")}, ${advisoryCount} advisory detail ${pluralize(advisoryCount, "record")}`) +
|
|
215
216
|
(emptyCount > 0
|
|
216
|
-
? chalk.gray(`, ${emptyCount} empty
|
|
217
|
+
? chalk.gray(`, ${emptyCount} empty ${pluralize(emptyCount, "lookup")}`)
|
|
217
218
|
: ""));
|
|
218
219
|
}
|
|
219
220
|
export function logInfo(message, options) {
|
|
@@ -5,6 +5,7 @@ import { serializeFinding } from "./formatters.js";
|
|
|
5
5
|
import { LOGO_BASE64 } from "./logo-base64.js";
|
|
6
6
|
import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
|
|
7
7
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
8
|
+
import { pluralize } from "../utils/string.js";
|
|
8
9
|
export function buildReportData(params) {
|
|
9
10
|
return {
|
|
10
11
|
projectPath: params.projectPath,
|
|
@@ -503,7 +504,7 @@ function renderFixPlan(plan) {
|
|
|
503
504
|
? ` <span class="fix-target-note">${escapeHtml(t.adjustmentNote)}</span>`
|
|
504
505
|
: "";
|
|
505
506
|
const coverageHtml = t.coverage === "partial"
|
|
506
|
-
? ` <span class="fix-target-coverage">Path-specific remediation. Run this command, then rescan; ${t.remainingPaths?.length ?? 0} other known
|
|
507
|
+
? ` <span class="fix-target-coverage">Path-specific remediation. Run this command, then rescan; ${t.remainingPaths?.length ?? 0} other known ${pluralize(t.remainingPaths?.length ?? 0, "path")} may still need separate parent upgrades.</span>`
|
|
507
508
|
: "";
|
|
508
509
|
return `<div class="fix-target-row">${versionHtml}${breakBadge}${statsHtml}${noteHtml}${coverageHtml}</div>`;
|
|
509
510
|
}).join("\n");
|
|
@@ -537,7 +538,7 @@ function renderFixPlan(plan) {
|
|
|
537
538
|
return `<div class="fix-plan">
|
|
538
539
|
<div class="fix-plan-header">
|
|
539
540
|
<h2><span class="icon">✦</span> Suggested Fix Plan</h2>
|
|
540
|
-
<span class="badge">${directCount} direct
|
|
541
|
+
<span class="badge">${directCount} direct ${pluralize(directCount, "fix", "fixes")}${skippedBadgePart}</span>
|
|
541
542
|
</div>
|
|
542
543
|
<div class="fix-commands">${commandRows}
|
|
543
544
|
</div>${skippedSection}
|
package/dist/output/printers.js
CHANGED
|
@@ -3,6 +3,7 @@ import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
|
3
3
|
import { isMajorVersionBump } from "../utils/version.js";
|
|
4
4
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
5
5
|
import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel } from "./formatters.js";
|
|
6
|
+
import { pluralize } from "../utils/string.js";
|
|
6
7
|
export function printSummary(findings, packageCount, scanInput) {
|
|
7
8
|
if (findings.length === 0) {
|
|
8
9
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -36,13 +37,13 @@ export function printActionSummary(findings) {
|
|
|
36
37
|
const fixable = findings.filter(f => Boolean(f.firstFixedVersion)).length;
|
|
37
38
|
console.log("");
|
|
38
39
|
console.log(chalk.bold.cyan("Quick take"));
|
|
39
|
-
console.log(`- ${chalk.green(String(direct))} vulnerable
|
|
40
|
-
console.log(`- ${chalk.yellow(String(transitive))}
|
|
40
|
+
console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
|
|
41
|
+
console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
|
|
41
42
|
if (unknown > 0) {
|
|
42
|
-
console.log(`- ${chalk.magenta(String(unknown))}
|
|
43
|
+
console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
|
|
43
44
|
}
|
|
44
|
-
console.log(`- ${chalk.blueBright(String(uniqueAdvisories))}
|
|
45
|
-
console.log(`- ${chalk.blue(String(fixable))}
|
|
45
|
+
console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} ${pluralize(uniqueAdvisories, "CVE")} matched overall.`);
|
|
46
|
+
console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
|
|
46
47
|
}
|
|
47
48
|
export function printSuggestedFixCommands(findings, scanInput, options) {
|
|
48
49
|
const plan = buildSuggestedFixCommandPlan(findings, scanInput, options);
|
|
@@ -218,10 +219,10 @@ export function printFinalStatus(findings) {
|
|
|
218
219
|
const criticalCount = findings.filter(f => f.severity === "critical").length;
|
|
219
220
|
const highCount = findings.filter(f => f.severity === "high").length;
|
|
220
221
|
if (criticalCount > 0 || highCount > 0) {
|
|
221
|
-
console.log(chalk.redBright(`✖ Scan complete. ${findings.length}
|
|
222
|
+
console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
|
|
222
223
|
return;
|
|
223
224
|
}
|
|
224
|
-
console.log(chalk.yellow(`▲ Scan complete. ${findings.length}
|
|
225
|
+
console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found. Review the suggested fix plan above.`));
|
|
225
226
|
}
|
|
226
227
|
function renderRow(cells, widths) {
|
|
227
228
|
const formatted = cells.map((cell, i) => {
|
|
@@ -296,7 +297,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
296
297
|
let usageContext = "";
|
|
297
298
|
if (finding.usage) {
|
|
298
299
|
if (finding.usage.imported) {
|
|
299
|
-
usageContext = chalk.red(` (imported in ${finding.usage.files.length}
|
|
300
|
+
usageContext = chalk.red(` (imported in ${finding.usage.files.length} ${pluralize(finding.usage.files.length, "file")})`);
|
|
300
301
|
}
|
|
301
302
|
else {
|
|
302
303
|
usageContext = chalk.green(` (no direct import found)`);
|
|
@@ -356,7 +357,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
356
357
|
console.log(formatFixCommandSummary(plan));
|
|
357
358
|
const compactValidationSummary = summarizeAdjustedValidation(plan.targets);
|
|
358
359
|
if (compactValidationSummary.checked > 0) {
|
|
359
|
-
console.log(chalk.gray(`Validation: scanned ${compactValidationSummary.checked} package
|
|
360
|
+
console.log(chalk.gray(`Validation: scanned ${compactValidationSummary.checked} package ${pluralize(compactValidationSummary.checked, "version")}; ${compactValidationSummary.vulnerable} ${pluralize(compactValidationSummary.vulnerable, "is", "are")} still known vulnerable.`));
|
|
360
361
|
}
|
|
361
362
|
console.log("");
|
|
362
363
|
for (const section of plan.sections.slice(0, 3)) {
|
|
@@ -427,10 +428,10 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
427
428
|
// Footer
|
|
428
429
|
const urgentCount = counts.critical + counts.high;
|
|
429
430
|
if (urgentCount > 0) {
|
|
430
|
-
console.log(chalk.redBright(`✖ Scan complete. ${urgentCount} urgent
|
|
431
|
+
console.log(chalk.redBright(`✖ Scan complete. ${urgentCount} urgent ${pluralize(urgentCount, "issue")} found.`));
|
|
431
432
|
}
|
|
432
433
|
else {
|
|
433
|
-
console.log(chalk.yellow(`▲ Scan complete. ${findings.length}
|
|
434
|
+
console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found.`));
|
|
434
435
|
}
|
|
435
436
|
if (!options?.all) {
|
|
436
437
|
console.log(chalk.gray(`Run with ${chalk.whiteBright("--verbose")} for fix plan, paths, and full table.`));
|
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import { parse as parseYarnLock } from "yarn-lockfile";
|
|
3
4
|
import { upsertPackage } from "./utils.js";
|
|
5
|
+
export function buildYarnWorkspaceMap(filePath) {
|
|
6
|
+
const dir = path.dirname(filePath);
|
|
7
|
+
const map = new Map();
|
|
8
|
+
let rootPkg;
|
|
9
|
+
try {
|
|
10
|
+
rootPkg = JSON.parse(fs.readFileSync(path.join(dir, "package.json"), "utf8"));
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
return map;
|
|
14
|
+
}
|
|
15
|
+
const patterns = Array.isArray(rootPkg.workspaces)
|
|
16
|
+
? rootPkg.workspaces
|
|
17
|
+
: rootPkg.workspaces?.packages ?? [];
|
|
18
|
+
if (!patterns.length)
|
|
19
|
+
return map;
|
|
20
|
+
for (const pattern of patterns) {
|
|
21
|
+
const parts = pattern.split("/");
|
|
22
|
+
const lastPart = parts[parts.length - 1];
|
|
23
|
+
const baseParts = parts.slice(0, -1);
|
|
24
|
+
let wsDirs;
|
|
25
|
+
if (lastPart === "*") {
|
|
26
|
+
const baseDir = path.join(dir, ...baseParts);
|
|
27
|
+
try {
|
|
28
|
+
wsDirs = fs.readdirSync(baseDir, { withFileTypes: true })
|
|
29
|
+
.filter(d => d.isDirectory())
|
|
30
|
+
.map(d => [...baseParts, d.name].join("/"));
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
wsDirs = [pattern];
|
|
38
|
+
}
|
|
39
|
+
for (const wsDir of wsDirs) {
|
|
40
|
+
let wsPkg;
|
|
41
|
+
try {
|
|
42
|
+
wsPkg = JSON.parse(fs.readFileSync(path.join(dir, wsDir, "package.json"), "utf8"));
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
const wsName = wsPkg.name;
|
|
48
|
+
if (!wsName)
|
|
49
|
+
continue;
|
|
50
|
+
for (const depSection of ["dependencies", "optionalDependencies", "devDependencies"]) {
|
|
51
|
+
const deps = wsPkg[depSection];
|
|
52
|
+
if (!deps || typeof deps !== "object")
|
|
53
|
+
continue;
|
|
54
|
+
for (const depName of Object.keys(deps)) {
|
|
55
|
+
const existing = map.get(depName) ?? [];
|
|
56
|
+
if (!existing.includes(wsName))
|
|
57
|
+
map.set(depName, [...existing, wsName]);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return map;
|
|
63
|
+
}
|
|
4
64
|
function isYarnBerry(content) {
|
|
5
65
|
return content.startsWith('__metadata:') || content.includes('\n__metadata:');
|
|
6
66
|
}
|
|
@@ -2,11 +2,36 @@ import { severityOrder } from "../constants.js";
|
|
|
2
2
|
import { compareVersions, looksLikeVersion } from "../utils/version.js";
|
|
3
3
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
4
4
|
import { calculatePathCoverage, formatDependencyPath } from "../utils/path-coverage.js";
|
|
5
|
+
import { pluralize } from "../utils/string.js";
|
|
6
|
+
import { buildNpmWorkspaceMap } from "../parsers/package-lock.js";
|
|
7
|
+
import { buildPnpmWorkspaceMap } from "../parsers/pnpm-lock.js";
|
|
8
|
+
import { buildYarnWorkspaceMap } from "../parsers/yarn-lock.js";
|
|
9
|
+
import { buildBunWorkspaceMap } from "../parsers/bun-lock.js";
|
|
5
10
|
export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
6
11
|
const packageManager = inferPackageManager(scanInput);
|
|
7
12
|
if (!packageManager)
|
|
8
13
|
return null;
|
|
9
14
|
const offline = !!options?.offline;
|
|
15
|
+
let workspaceMap = new Map();
|
|
16
|
+
if (scanInput.filePath) {
|
|
17
|
+
try {
|
|
18
|
+
if (packageManager === "npm" && (scanInput.source === "package-lock" || scanInput.source === "npm-shrinkwrap")) {
|
|
19
|
+
workspaceMap = buildNpmWorkspaceMap(scanInput.filePath);
|
|
20
|
+
}
|
|
21
|
+
else if (packageManager === "pnpm" && scanInput.source === "pnpm-lock") {
|
|
22
|
+
workspaceMap = buildPnpmWorkspaceMap(scanInput.filePath);
|
|
23
|
+
}
|
|
24
|
+
else if (packageManager === "yarn" && scanInput.source === "yarn-lock") {
|
|
25
|
+
workspaceMap = buildYarnWorkspaceMap(scanInput.filePath);
|
|
26
|
+
}
|
|
27
|
+
else if (packageManager === "bun" && scanInput.source === "bun-lock") {
|
|
28
|
+
workspaceMap = buildBunWorkspaceMap(scanInput.filePath);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// workspace map is best-effort
|
|
33
|
+
}
|
|
34
|
+
}
|
|
10
35
|
const prioritizedFindings = [...findings]
|
|
11
36
|
.filter(f => f.severity === "critical" || f.severity === "high")
|
|
12
37
|
.sort((a, b) => {
|
|
@@ -56,6 +81,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
56
81
|
if (directTarget &&
|
|
57
82
|
isUpgradeTarget(finding.pkg.version, directTarget) &&
|
|
58
83
|
validatedFieldOk) {
|
|
84
|
+
const pkgWorkspaces = workspaceMap.get(finding.pkg.name)?.filter(w => w !== ".") ?? [];
|
|
59
85
|
upsertTarget(targetsByPackage, {
|
|
60
86
|
package: finding.pkg.name,
|
|
61
87
|
currentVersion: finding.pkg.version,
|
|
@@ -75,6 +101,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
75
101
|
: null,
|
|
76
102
|
reason: `Direct upgrade target for ${finding.pkg.name}@${finding.pkg.version}`,
|
|
77
103
|
usage: finding.usage ?? null,
|
|
104
|
+
workspaces: pkgWorkspaces.length > 0 ? pkgWorkspaces : undefined,
|
|
78
105
|
});
|
|
79
106
|
}
|
|
80
107
|
else if (finding.fixVersionValidationNote) {
|
|
@@ -320,6 +347,11 @@ export function findSuggestedCommandForFinding(plan, finding) {
|
|
|
320
347
|
return null;
|
|
321
348
|
if (target.command)
|
|
322
349
|
return target.command;
|
|
350
|
+
if (target.workspaces?.length) {
|
|
351
|
+
const commands = buildWorkspaceInstallCommands([target], plan.packageManager);
|
|
352
|
+
if (commands.length > 0)
|
|
353
|
+
return commands.join(" && ");
|
|
354
|
+
}
|
|
323
355
|
return `${commandPrefix(plan.packageManager)} ${target.package}@${target.targetVersion}`;
|
|
324
356
|
}
|
|
325
357
|
function packageManagerSourceLabel(scanInput) {
|
|
@@ -355,6 +387,7 @@ function upsertTarget(targetsByPackage, next) {
|
|
|
355
387
|
: "parent-upgrade",
|
|
356
388
|
displayTargetVersion: existing.displayTargetVersion ?? next.displayTargetVersion,
|
|
357
389
|
command: existing.command ?? next.command,
|
|
390
|
+
workspaces: mergeStringArrays(existing.workspaces, next.workspaces),
|
|
358
391
|
coverage: existing.coverage === "partial" || next.coverage === "partial"
|
|
359
392
|
? "partial"
|
|
360
393
|
: existing.coverage ?? next.coverage,
|
|
@@ -394,7 +427,13 @@ function buildParentUpgradeReason(finding, coverage) {
|
|
|
394
427
|
if (coverage.coverage === "complete")
|
|
395
428
|
return base;
|
|
396
429
|
const remainingCount = coverage.remainingPaths.length;
|
|
397
|
-
return `${base}; run this command, then rescan. ${remainingCount} other known
|
|
430
|
+
return `${base}; run this command, then rescan. ${remainingCount} other known ${pluralize(remainingCount, "path")} may still need separate parent upgrades.`;
|
|
431
|
+
}
|
|
432
|
+
function mergeStringArrays(a, b) {
|
|
433
|
+
if (!a?.length && !b?.length)
|
|
434
|
+
return undefined;
|
|
435
|
+
const result = [...new Set([...(a ?? []), ...(b ?? [])])];
|
|
436
|
+
return result.length > 0 ? result : undefined;
|
|
398
437
|
}
|
|
399
438
|
function mergePathArrays(left, right) {
|
|
400
439
|
const seen = new Set();
|
|
@@ -476,6 +515,50 @@ function buildSectionTitle(kind, severity) {
|
|
|
476
515
|
}
|
|
477
516
|
return `${severityTitle} parent upgrades`;
|
|
478
517
|
}
|
|
518
|
+
function groupByWorkspaceKey(targets) {
|
|
519
|
+
const groups = new Map();
|
|
520
|
+
for (const target of targets) {
|
|
521
|
+
const key = (target.workspaces ?? []).slice().sort().join("\0");
|
|
522
|
+
const group = groups.get(key) ?? [];
|
|
523
|
+
group.push(target);
|
|
524
|
+
groups.set(key, group);
|
|
525
|
+
}
|
|
526
|
+
return groups;
|
|
527
|
+
}
|
|
528
|
+
function buildWorkspaceInstallCommands(targets, packageManager) {
|
|
529
|
+
const groups = groupByWorkspaceKey(targets);
|
|
530
|
+
const commands = [];
|
|
531
|
+
for (const [wsKey, groupTargets] of groups) {
|
|
532
|
+
const pkgArgs = groupTargets.map(t => `${t.package}@${t.targetVersion}`).join(" ");
|
|
533
|
+
const workspaces = wsKey ? wsKey.split("\0") : [];
|
|
534
|
+
if (packageManager === "npm") {
|
|
535
|
+
const wsFlags = workspaces.map(ws => `-w ${ws}`).join(" ");
|
|
536
|
+
commands.push(`npm install${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
537
|
+
}
|
|
538
|
+
else if (packageManager === "pnpm") {
|
|
539
|
+
const wsFlags = workspaces.map(ws => `--filter ./${ws}`).join(" ");
|
|
540
|
+
commands.push(`pnpm add${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
541
|
+
}
|
|
542
|
+
else if (packageManager === "yarn") {
|
|
543
|
+
if (workspaces.length === 0) {
|
|
544
|
+
commands.push(`yarn add ${pkgArgs}`);
|
|
545
|
+
}
|
|
546
|
+
else {
|
|
547
|
+
for (const ws of workspaces) {
|
|
548
|
+
commands.push(`yarn workspace ${ws} add ${pkgArgs}`);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
else if (packageManager === "bun") {
|
|
553
|
+
const wsFlags = workspaces.map(ws => `--filter ${ws}`).join(" ");
|
|
554
|
+
commands.push(`bun add${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
555
|
+
}
|
|
556
|
+
else {
|
|
557
|
+
commands.push(`${commandPrefix(packageManager)} ${pkgArgs}`);
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
return commands;
|
|
561
|
+
}
|
|
479
562
|
function buildCommandForTargets(targets, packageManager) {
|
|
480
563
|
const explicitCommands = targets
|
|
481
564
|
.map(target => target.command)
|
|
@@ -492,7 +575,13 @@ function buildCommandForTargets(targets, packageManager) {
|
|
|
492
575
|
commandParts.push(...updateCommands);
|
|
493
576
|
}
|
|
494
577
|
if (installTargets.length > 0) {
|
|
495
|
-
|
|
578
|
+
const hasWorkspaces = installTargets.some(t => t.workspaces?.length);
|
|
579
|
+
if (hasWorkspaces) {
|
|
580
|
+
commandParts.push(...buildWorkspaceInstallCommands(installTargets, packageManager));
|
|
581
|
+
}
|
|
582
|
+
else {
|
|
583
|
+
commandParts.push(`${commandPrefix(packageManager)} ${installTargets.map(target => `${target.package}@${target.targetVersion}`).join(" ")}`);
|
|
584
|
+
}
|
|
496
585
|
}
|
|
497
586
|
return commandParts.join(" && ");
|
|
498
587
|
}
|
package/dist/scanner.js
CHANGED
|
@@ -14,6 +14,7 @@ import { loadNpmLockGraph } from "./parsers/npm-lock-graph.js";
|
|
|
14
14
|
import { buildPnpmWorkspaceMap } from "./parsers/pnpm-lock.js";
|
|
15
15
|
import { buildNpmWorkspaceMap } from "./parsers/package-lock.js";
|
|
16
16
|
import { buildBunWorkspaceMap } from "./parsers/bun-lock.js";
|
|
17
|
+
import { pluralize } from "./utils/string.js";
|
|
17
18
|
export function createAdvisorySource(options) {
|
|
18
19
|
const offline = !!options?.offline || !!options?.offlineDb;
|
|
19
20
|
if (offline) {
|
|
@@ -74,7 +75,7 @@ export async function scanPackages(packages, batchSize, options, context) {
|
|
|
74
75
|
uncachedPackages.push(pkg);
|
|
75
76
|
}
|
|
76
77
|
const chunks = chunk(uncachedPackages, batchSize);
|
|
77
|
-
spinner.update(`Scanning OSV in ${chunks.length} parallel
|
|
78
|
+
spinner.update(`Scanning OSV in ${chunks.length} parallel ${pluralize(chunks.length, "batch", "batches")}...`);
|
|
78
79
|
const allAdvisoryResults = await runWithConcurrency(chunks, 5, c => advisorySource.queryBatch(c));
|
|
79
80
|
for (let i = 0; i < chunks.length; i++) {
|
|
80
81
|
const chunkItems = chunks[i];
|
|
@@ -93,7 +94,7 @@ export async function scanPackages(packages, batchSize, options, context) {
|
|
|
93
94
|
spinner.succeed("Loaded package matches from cache");
|
|
94
95
|
}
|
|
95
96
|
else {
|
|
96
|
-
spinner.succeed(`Queried OSV in ${chunks.length}
|
|
97
|
+
spinner.succeed(`Queried OSV in ${chunks.length} ${pluralize(chunks.length, "batch", "batches")}`);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
else {
|
|
@@ -134,7 +135,7 @@ export async function scanPackages(packages, batchSize, options, context) {
|
|
|
134
135
|
cache.entries[id] = null;
|
|
135
136
|
}
|
|
136
137
|
}
|
|
137
|
-
detailSpinner.succeed(`Loaded ${ids.length} vulnerability detail
|
|
138
|
+
detailSpinner.succeed(`Loaded ${ids.length} vulnerability detail ${pluralize(ids.length, "record")}`);
|
|
138
139
|
}
|
|
139
140
|
catch (error) {
|
|
140
141
|
detailSpinner.fail("Failed while fetching vulnerability details");
|
|
@@ -156,7 +157,7 @@ export async function scanPackages(packages, batchSize, options, context) {
|
|
|
156
157
|
// ignore missing local records so scans remain resilient to partial DB state
|
|
157
158
|
}
|
|
158
159
|
}
|
|
159
|
-
detailSpinner.succeed(`Loaded ${ids.length} local advisory detail
|
|
160
|
+
detailSpinner.succeed(`Loaded ${ids.length} local advisory detail ${pluralize(ids.length, "record")}`);
|
|
160
161
|
}
|
|
161
162
|
catch (error) {
|
|
162
163
|
detailSpinner.fail("Failed while loading local advisory details");
|
|
@@ -383,7 +384,7 @@ async function validateDirectFixTargets(findings, onFinding) {
|
|
|
383
384
|
continue;
|
|
384
385
|
}
|
|
385
386
|
finding.fixVersionValidationNote =
|
|
386
|
-
`Advisory fixed-version hint ${fixedVersionHint} is still known vulnerable for ${finding.pkg.name}; scanned ${lowestKnownResolution.candidatesChecked} package
|
|
387
|
+
`Advisory fixed-version hint ${fixedVersionHint} is still known vulnerable for ${finding.pkg.name}; scanned ${lowestKnownResolution.candidatesChecked} package ${pluralize(lowestKnownResolution.candidatesChecked, "version")} above current version (${lowestKnownResolution.candidatesKnownVulnerable} still known vulnerable); using lowest known non-vulnerable version ${lowestKnownResolution.resolvedVersion}.`;
|
|
387
388
|
continue;
|
|
388
389
|
}
|
|
389
390
|
if (!fixedVersionHint) {
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { createSpinner } from "../output/spinner.js";
|
|
3
|
+
import { chalk } from "./chalk.js";
|
|
4
|
+
import { pluralize } from "./string.js";
|
|
5
|
+
export function buildFixCommandParts(packageManager, targets) {
|
|
6
|
+
if (packageManager === "npm") {
|
|
7
|
+
return ["npm", "install", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
8
|
+
}
|
|
9
|
+
if (packageManager === "pnpm") {
|
|
10
|
+
return ["pnpm", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
11
|
+
}
|
|
12
|
+
if (packageManager === "bun") {
|
|
13
|
+
return ["bun", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
14
|
+
}
|
|
15
|
+
return ["yarn", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
16
|
+
}
|
|
17
|
+
export async function runInstallCommand(command, args, cwd) {
|
|
18
|
+
return await new Promise(resolve => {
|
|
19
|
+
const child = spawn(command, args, {
|
|
20
|
+
cwd,
|
|
21
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
22
|
+
});
|
|
23
|
+
child.stdout.on("data", () => { });
|
|
24
|
+
child.stderr.on("data", () => { });
|
|
25
|
+
child.on("error", error => {
|
|
26
|
+
resolve({ status: null, error });
|
|
27
|
+
});
|
|
28
|
+
child.on("close", code => {
|
|
29
|
+
resolve({ status: code, error: null });
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function commandLabelForPackageManager(packageManager) {
|
|
34
|
+
if (packageManager === "npm")
|
|
35
|
+
return "npm install";
|
|
36
|
+
if (packageManager === "pnpm")
|
|
37
|
+
return "pnpm add";
|
|
38
|
+
if (packageManager === "bun")
|
|
39
|
+
return "bun add";
|
|
40
|
+
return "yarn add";
|
|
41
|
+
}
|
|
42
|
+
export async function applyFixesIfRequested(params) {
|
|
43
|
+
console.log("");
|
|
44
|
+
console.log(chalk.bold.cyan("Applying fixes (--fix)"));
|
|
45
|
+
if (!params.plan) {
|
|
46
|
+
return {
|
|
47
|
+
appliedFixCount: 0,
|
|
48
|
+
skippedCount: params.totalFindings,
|
|
49
|
+
skippedTransitiveCount: 0,
|
|
50
|
+
skippedNoValidatedTargetCount: params.totalFindings,
|
|
51
|
+
applied: [],
|
|
52
|
+
note: "No package-manager-native fix command is available for this project.",
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const directTargets = params.plan.targets.filter(target => target.kind === "direct");
|
|
56
|
+
const transitiveTargets = params.plan.targets.filter(target => target.kind !== "direct");
|
|
57
|
+
const skippedDirect = params.plan.skipped.filter(skip => skip.relationship === "direct" || skip.relationship === "unknown");
|
|
58
|
+
if (directTargets.length === 0) {
|
|
59
|
+
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
60
|
+
return {
|
|
61
|
+
appliedFixCount: 0,
|
|
62
|
+
skippedCount,
|
|
63
|
+
skippedTransitiveCount: transitiveTargets.length,
|
|
64
|
+
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
65
|
+
applied: [],
|
|
66
|
+
note: "No validated direct dependency fixes were eligible for auto-apply.",
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
const commandLabel = commandLabelForPackageManager(params.plan.packageManager);
|
|
70
|
+
const total = directTargets.length;
|
|
71
|
+
const spinner = createSpinner(`Applying direct package fixes with ${commandLabel}... 0/${total}`, params.options);
|
|
72
|
+
const fixHint = `\nHint: Check that \`${params.plan.packageManager}\` is available and you have write access to node_modules.\nIf running in CI, ensure the install step has already run before cve-lite --fix.`;
|
|
73
|
+
for (let i = 0; i < directTargets.length; i++) {
|
|
74
|
+
const target = directTargets[i];
|
|
75
|
+
const commandParts = buildFixCommandParts(params.plan.packageManager, [target]);
|
|
76
|
+
spinner.update(`Applying direct fix ${i + 1}/${total}: ${commandParts.join(" ")}`);
|
|
77
|
+
const run = await runInstallCommand(commandParts[0], commandParts.slice(1), params.projectPath);
|
|
78
|
+
if (run.error) {
|
|
79
|
+
spinner.fail("Failed to apply fixes");
|
|
80
|
+
throw new Error(`Failed to apply fixes: ${run.error.message}${fixHint}`);
|
|
81
|
+
}
|
|
82
|
+
if ((run.status ?? 1) !== 0) {
|
|
83
|
+
spinner.fail(`Fix command failed (${commandLabel})`);
|
|
84
|
+
throw new Error(`Fix command exited with status ${run.status ?? 1}${fixHint}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
spinner.succeed(`Applied ${directTargets.length} direct package ${pluralize(directTargets.length, "fix", "fixes")} with ${commandLabel}`);
|
|
88
|
+
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
89
|
+
return {
|
|
90
|
+
appliedFixCount: directTargets.length,
|
|
91
|
+
skippedCount,
|
|
92
|
+
skippedTransitiveCount: transitiveTargets.length,
|
|
93
|
+
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
94
|
+
applied: directTargets.map(target => ({
|
|
95
|
+
package: target.package,
|
|
96
|
+
from: target.currentVersion ?? "unknown",
|
|
97
|
+
to: target.targetVersion,
|
|
98
|
+
})),
|
|
99
|
+
note: null,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export function printFixModeSummary(params) {
|
|
103
|
+
const result = params.fixResult;
|
|
104
|
+
if (!result)
|
|
105
|
+
return;
|
|
106
|
+
if (result.note) {
|
|
107
|
+
console.log(chalk.gray(result.note));
|
|
108
|
+
}
|
|
109
|
+
if (result.applied.length > 0) {
|
|
110
|
+
console.log("");
|
|
111
|
+
console.log(chalk.bold.cyan("Applied fixes"));
|
|
112
|
+
for (const item of result.applied) {
|
|
113
|
+
console.log(`- ${chalk.white(item.package)}: ${chalk.gray(item.from)} ${chalk.cyan("->")} ${chalk.green(item.to)}`);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
console.log("");
|
|
117
|
+
console.log(chalk.bold.cyan("Fix summary"));
|
|
118
|
+
console.log(`- Applied fixes: ${chalk.green(String(result.appliedFixCount))}`);
|
|
119
|
+
console.log(`- Skipped findings: ${chalk.yellow(String(result.skippedCount))}`);
|
|
120
|
+
if (result.skippedCount > 0) {
|
|
121
|
+
console.log(` - Transitive (v1 skip): ${chalk.yellow(String(result.skippedTransitiveCount))}`);
|
|
122
|
+
console.log(` - No validated direct target: ${chalk.yellow(String(result.skippedNoValidatedTargetCount))}`);
|
|
123
|
+
}
|
|
124
|
+
console.log(`- Findings before fix: ${chalk.white(String(params.findingsBeforeFix))}`);
|
|
125
|
+
console.log(`- Remaining findings after fix: ${chalk.white(String(params.findingsAfterFix))}`);
|
|
126
|
+
console.log(`- Remaining severity mix: critical ${chalk.redBright(String(params.remainingBySeverity.critical))}, high ${chalk.red(String(params.remainingBySeverity.high))}, medium ${chalk.yellow(String(params.remainingBySeverity.medium))}, low ${chalk.blueBright(String(params.remainingBySeverity.low))}, unknown ${chalk.magenta(String(params.remainingBySeverity.unknown))}`);
|
|
127
|
+
}
|
package/dist/utils/network.js
CHANGED
|
@@ -9,10 +9,10 @@ export function extractErrorMessage(error) {
|
|
|
9
9
|
export function sslCertificateErrorHint() {
|
|
10
10
|
return [
|
|
11
11
|
"Hint: SSL certificate error — your network may be using a corporate proxy that intercepts HTTPS traffic.",
|
|
12
|
-
"Fix
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
12
|
+
"Fix (recommended): save your corporate CA certificate path once:",
|
|
13
|
+
" cve-lite config set ca-cert /path/to/corporate-ca.crt",
|
|
14
|
+
"Or pass it per-invocation:",
|
|
15
|
+
" cve-lite . --ca-cert /path/to/corporate-ca.crt",
|
|
16
16
|
];
|
|
17
17
|
}
|
|
18
18
|
export function blockedAdvisoryRequestHint() {
|
|
@@ -20,6 +20,13 @@ export function blockedAdvisoryRequestHint() {
|
|
|
20
20
|
"Hint: Outbound access to the OSV API may be blocked or restricted in this environment.",
|
|
21
21
|
"If that is expected, build the advisory DB on a machine with OSV access, then scan here with `--offline` or `--offline-db /path/to/advisories.db`.",
|
|
22
22
|
"Command to build the DB on a network-allowed machine: `cve-lite advisories sync --output /path/to/advisories.db`",
|
|
23
|
+
"If your network uses SSL inspection, try: cve-lite config set ca-cert /path/to/corporate-ca.crt",
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
export function fetchErrorCaCertHint() {
|
|
27
|
+
return [
|
|
28
|
+
"Hint: If your network uses a corporate SSL proxy, a CA certificate may be required.",
|
|
29
|
+
"Run: cve-lite config set ca-cert /path/to/corporate-ca.crt",
|
|
23
30
|
];
|
|
24
31
|
}
|
|
25
32
|
const OFFLINE_FALLBACK_LINES = [
|
package/dist/utils/time.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { chalk } from "./chalk.js";
|
|
2
|
+
import { pluralize } from "./string.js";
|
|
2
3
|
export function formatAdvisoryDbFreshness(lastSyncAt) {
|
|
3
4
|
if (!lastSyncAt) {
|
|
4
5
|
return chalk.yellow("unknown");
|
|
@@ -19,12 +20,12 @@ export function relativeAge(timestamp) {
|
|
|
19
20
|
}
|
|
20
21
|
if (deltaMs < hour) {
|
|
21
22
|
const minutes = Math.floor(deltaMs / minute);
|
|
22
|
-
return `synced ${minutes}
|
|
23
|
+
return `synced ${minutes} ${pluralize(minutes, "minute")} ago`;
|
|
23
24
|
}
|
|
24
25
|
if (deltaMs < day) {
|
|
25
26
|
const hours = Math.floor(deltaMs / hour);
|
|
26
|
-
return `synced ${hours}
|
|
27
|
+
return `synced ${hours} ${pluralize(hours, "hour")} ago`;
|
|
27
28
|
}
|
|
28
29
|
const days = Math.floor(deltaMs / day);
|
|
29
|
-
return `synced ${days}
|
|
30
|
+
return `synced ${days} ${pluralize(days, "day")} ago`;
|
|
30
31
|
}
|