cve-lite-cli 1.5.1 → 1.5.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 +41 -7
- package/dist/cli/args.js +4 -0
- package/dist/cli/help.js +1 -0
- package/dist/index.js +216 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
<a href="#why-offline-mode-matters">Why offline mode matters</a><br/>
|
|
38
38
|
<a href="docs/case-studies/owasp-juice-shop.md">OWASP Juice Shop case study</a><br/>
|
|
39
39
|
<a href="docs/case-studies/nestjs.md">NestJS case study</a><br/>
|
|
40
|
+
<a href="docs/fix-mode.md">Fix mode guide (--fix)</a><br/>
|
|
41
|
+
<a href="docs/how-to-read-verbose-output.md">How to read verbose output</a><br/>
|
|
40
42
|
<a href="#what-it-looks-like">What it looks like</a><br/>
|
|
41
43
|
<a href="#why-this-tool-exists">Why this tool exists</a><br/>
|
|
42
44
|
<a href="#project-scope-and-differentiation">Project scope and differentiation</a>
|
|
@@ -81,15 +83,20 @@ It is designed to be:
|
|
|
81
83
|
- capable of zero-runtime-network scans through a local advisory database
|
|
82
84
|
|
|
83
85
|
For real-world remediation examples, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md) and the [NestJS case study](docs/case-studies/nestjs.md).
|
|
86
|
+
If you are new to verbose mode, use the [How to read verbose output guide](docs/how-to-read-verbose-output.md).
|
|
87
|
+
If you want automatic direct remediation, use the [Fix mode guide](docs/fix-mode.md).
|
|
84
88
|
|
|
85
89
|
## New here? Start here
|
|
86
90
|
|
|
91
|
+
If the verbose output feels dense at first, start with the [How to read verbose output guide](docs/how-to-read-verbose-output.md).
|
|
92
|
+
|
|
87
93
|
1. run one scan on a real project with `npx cve-lite-cli /path/to/project --verbose`
|
|
88
94
|
2. review direct vs transitive findings and the `Copy And Run These Fix Commands` section (direct command groups apply to manifest-declared dependencies)
|
|
89
95
|
3. compare the output with your current scanner workflow
|
|
90
96
|
4. check a real walkthrough:
|
|
91
97
|
- [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md)
|
|
92
98
|
- [NestJS case study](docs/case-studies/nestjs.md)
|
|
99
|
+
5. use the [How to read verbose output guide](docs/how-to-read-verbose-output.md) to convert scan sections into next steps
|
|
93
100
|
|
|
94
101
|
If CVE Lite CLI helps your release workflow, a GitHub star helps more developers discover it: [Star CVE Lite CLI](https://github.com/sonukapoor/cve-lite-cli).
|
|
95
102
|
|
|
@@ -174,6 +181,9 @@ cve-lite /path/to/project --min-severity high
|
|
|
174
181
|
# Recommended for CI logs when you want full context
|
|
175
182
|
cve-lite /path/to/project --verbose
|
|
176
183
|
|
|
184
|
+
# Apply validated direct dependency fixes and rescan
|
|
185
|
+
cve-lite /path/to/project --fix
|
|
186
|
+
|
|
177
187
|
# Limit the scan to production dependencies where supported by the lockfile
|
|
178
188
|
cve-lite /path/to/project --prod-only
|
|
179
189
|
|
|
@@ -199,6 +209,29 @@ cve-lite /path/to/project --offline
|
|
|
199
209
|
cve-lite /path/to/project --offline-db /path/to/advisories.db
|
|
200
210
|
```
|
|
201
211
|
|
|
212
|
+
## Auto-fix mode (`--fix`)
|
|
213
|
+
|
|
214
|
+
`--fix` is designed to speed up remediation without overpromising safety.
|
|
215
|
+
|
|
216
|
+
In v1, `--fix`:
|
|
217
|
+
- applies only direct dependency fixes with a validated lowest known non-vulnerable target
|
|
218
|
+
- uses your project’s package manager (`npm install`, `pnpm add`, or `yarn add`)
|
|
219
|
+
- rescans automatically after applying fixes
|
|
220
|
+
- prints a concise summary of applied fixes, skipped findings, and remaining findings
|
|
221
|
+
|
|
222
|
+
In v1, `--fix` does not:
|
|
223
|
+
- auto-apply transitive overrides/resolutions
|
|
224
|
+
- guarantee compatibility with your application code
|
|
225
|
+
- perform exploitability or runtime reachability analysis
|
|
226
|
+
|
|
227
|
+
Example:
|
|
228
|
+
|
|
229
|
+
```bash
|
|
230
|
+
npx cve-lite-cli /path/to/project --fix
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
For output details and interpretation, see [Fix mode guide](docs/fix-mode.md).
|
|
234
|
+
|
|
202
235
|
## Workflow modes
|
|
203
236
|
|
|
204
237
|
CVE Lite CLI now supports three clear advisory workflows:
|
|
@@ -268,6 +301,7 @@ The final status line also gives the scan a clear ending, which makes terminal u
|
|
|
268
301
|
See the example below using OWASP Juice Shop for real output samples.
|
|
269
302
|
|
|
270
303
|
For real-world case studies, see the [OWASP Juice Shop case study](docs/case-studies/owasp-juice-shop.md) and the [NestJS case study](docs/case-studies/nestjs.md).
|
|
304
|
+
For a section-by-section walkthrough of the terminal output, see [How to read verbose output](docs/how-to-read-verbose-output.md).
|
|
271
305
|
|
|
272
306
|
If you maintain an open-source JavaScript or TypeScript project and want CVE Lite CLI evaluated on it, open an issue and share the repository. Strong candidates may be turned into future public case studies.
|
|
273
307
|
|
|
@@ -800,13 +834,13 @@ Compared with other tools in this space, CVE Lite CLI focuses on:
|
|
|
800
834
|
|
|
801
835
|
### At a glance
|
|
802
836
|
|
|
803
|
-
| Tool | Best at | Ecosystem scope | Lockfile support | Dependency remediation guidance | JSON/SARIF | Best fit |
|
|
804
|
-
|
|
805
|
-
| **CVE Lite CLI** | Fast, developer-friendly pre-release CVE scanning | Focused on JS/TS | npm, pnpm, Yarn | **Dependency fix guidance** | **Yes** | Developers and small teams who want a free, practical release-time check |
|
|
806
|
-
| `npm audit` | Built-in npm auditing | npm-centric | npm | Basic remediation info | Limited compared to dedicated scanner workflows | Teams already living fully inside npm |
|
|
807
|
-
| OSV-Scanner | Broad multi-ecosystem scanning | Broad | Many ecosystems and lockfiles | More general-purpose | Strong machine-readable workflows | Teams needing wider ecosystem coverage |
|
|
808
|
-
| Snyk CLI | Broader enterprise security workflows | Broad | Strong ecosystem coverage | Strong commercial guidance | Strong | Teams adopting a larger security platform |
|
|
809
|
-
| Socket CLI | Broader package and supply-chain risk visibility | Broad | Multi-ecosystem/package-risk focus | Strong for package risk workflows | Strong | Teams that want more than CVE scanning alone |
|
|
837
|
+
| Tool | Best at | Ecosystem scope | Lockfile support | Dependency remediation guidance | Auto-fix support | JSON/SARIF | Best fit |
|
|
838
|
+
|---|---|---|---|---|---|---|---|
|
|
839
|
+
| **CVE Lite CLI** | Fast, developer-friendly pre-release CVE scanning | Focused on JS/TS | npm, pnpm, Yarn | **Dependency fix guidance** | **Yes (scoped `--fix` for validated direct dependencies in v1)** | **Yes** | Developers and small teams who want a free, practical release-time check |
|
|
840
|
+
| `npm audit` | Built-in npm auditing | npm-centric | npm | Basic remediation info | Yes (`npm audit fix`) | Limited compared to dedicated scanner workflows | Teams already living fully inside npm |
|
|
841
|
+
| OSV-Scanner | Broad multi-ecosystem scanning | Broad | Many ecosystems and lockfiles | More general-purpose | Yes (guided remediation, experimental) | Strong machine-readable workflows | Teams needing wider ecosystem coverage |
|
|
842
|
+
| Snyk CLI | Broader enterprise security workflows | Broad | Strong ecosystem coverage | Strong commercial guidance | Yes (CLI + platform-driven fix/PR workflows) | Strong | Teams adopting a larger security platform |
|
|
843
|
+
| Socket CLI | Broader package and supply-chain risk visibility | Broad | Multi-ecosystem/package-risk focus | Strong for package risk workflows | Varies by product/workflow | Strong | Teams that want more than CVE scanning alone |
|
|
810
844
|
|
|
811
845
|
### Offline support at a glance
|
|
812
846
|
|
package/dist/cli/args.js
CHANGED
package/dist/cli/help.js
CHANGED
|
@@ -31,6 +31,7 @@ export function printHelp() {
|
|
|
31
31
|
"",
|
|
32
32
|
"Scan options:",
|
|
33
33
|
" --json Print JSON output",
|
|
34
|
+
" --fix Apply validated direct dependency fixes and rescan",
|
|
34
35
|
" --osv-url <url> Use a custom OSV-compatible advisory endpoint",
|
|
35
36
|
" --verbose Show detailed output with fix plan, paths, and full table",
|
|
36
37
|
" --prod-only Exclude dev dependencies where available",
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { spawn } from "node:child_process";
|
|
2
3
|
import fs from "node:fs";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import process from "node:process";
|
|
@@ -81,6 +82,9 @@ if (parsedArgs) {
|
|
|
81
82
|
throw new Error(`Invalid value for --osv-url: ${options.osvUrl}`);
|
|
82
83
|
}
|
|
83
84
|
}
|
|
85
|
+
if (options.fix && options.json) {
|
|
86
|
+
throw new Error("--fix cannot be used with --json");
|
|
87
|
+
}
|
|
84
88
|
let advisorySourceLine;
|
|
85
89
|
let advisoryDbFreshnessLine = null;
|
|
86
90
|
let advisoryDbWarning = null;
|
|
@@ -118,8 +122,8 @@ if (parsedArgs) {
|
|
|
118
122
|
if (advisoryDbWarning) {
|
|
119
123
|
logWarn(advisoryDbWarning, options);
|
|
120
124
|
}
|
|
121
|
-
|
|
122
|
-
|
|
125
|
+
let scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
126
|
+
let packages = scanInput.packages;
|
|
123
127
|
logInfo(`Parsed ${packages.length} package${packages.length === 1 ? "" : "s"} from ${scanInput.source}${scanInput.filePath ? ` (${path.relative(projectPath, scanInput.filePath) || path.basename(scanInput.filePath)})` : ""}`, options);
|
|
124
128
|
printCacheSummary(options.cacheDir, options);
|
|
125
129
|
if (scanInput.warnings.length > 0) {
|
|
@@ -132,57 +136,90 @@ if (parsedArgs) {
|
|
|
132
136
|
process.exit(0);
|
|
133
137
|
return;
|
|
134
138
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
139
|
+
let scanState = await scanProject({
|
|
140
|
+
scanInput,
|
|
141
|
+
batchSize,
|
|
142
|
+
options,
|
|
143
|
+
projectPath,
|
|
144
|
+
});
|
|
145
|
+
const findingsBeforeFix = scanState.sorted.length;
|
|
146
|
+
let fixResult = null;
|
|
147
|
+
if (options.fix) {
|
|
148
|
+
fixResult = await applyFixesIfRequested({
|
|
149
|
+
plan: scanState.suggestedFixCommands,
|
|
150
|
+
projectPath,
|
|
151
|
+
totalFindings: scanState.sorted.length,
|
|
152
|
+
options,
|
|
153
|
+
});
|
|
154
|
+
if (fixResult.appliedFixCount > 0) {
|
|
155
|
+
console.log(`${chalk.cyan("⠋")} ${chalk.gray("Rescanning project...")}`);
|
|
156
|
+
scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
157
|
+
packages = scanInput.packages;
|
|
158
|
+
if (packages.length === 0) {
|
|
159
|
+
logWarn(buildNoPackagesMessage(projectPath), options);
|
|
160
|
+
process.exit(0);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
scanState = await scanProject({
|
|
164
|
+
scanInput,
|
|
165
|
+
batchSize,
|
|
166
|
+
options,
|
|
167
|
+
projectPath,
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (options.fix) {
|
|
172
|
+
printFixModeSummary({
|
|
173
|
+
fixResult,
|
|
174
|
+
findingsBeforeFix,
|
|
175
|
+
findingsAfterFix: scanState.sorted.length,
|
|
176
|
+
remainingBySeverity: countBySeverity(scanState.sorted),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else if (options.json) {
|
|
143
180
|
console.log(JSON.stringify({
|
|
144
181
|
projectPath,
|
|
145
182
|
mode: scanInput.mode,
|
|
146
183
|
source: scanInput.source,
|
|
147
184
|
packageCount: packages.length,
|
|
148
|
-
findingCount: sorted.length,
|
|
149
|
-
suggestedFixCommands,
|
|
150
|
-
notes: [...scanInput.notes, ...coverage],
|
|
185
|
+
findingCount: scanState.sorted.length,
|
|
186
|
+
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
187
|
+
notes: [...scanInput.notes, ...scanState.coverage],
|
|
151
188
|
warnings: scanInput.warnings,
|
|
152
189
|
skippedDependencies: scanInput.skippedDependencies,
|
|
153
|
-
findings: sorted.map(serializeFinding)
|
|
190
|
+
findings: scanState.sorted.map(serializeFinding)
|
|
154
191
|
}, null, 2));
|
|
155
192
|
}
|
|
156
193
|
else if (options.verbose) {
|
|
157
194
|
// Verbose output - show all details
|
|
158
|
-
printSummary(sorted, packages.length, scanInput);
|
|
159
|
-
printActionSummary(sorted);
|
|
160
|
-
printSuggestedFixCommands(sorted, scanInput);
|
|
161
|
-
printPriorityFixes(sorted);
|
|
162
|
-
printFixPlan(sorted);
|
|
163
|
-
printSuggestedFixCommandSkips(sorted, scanInput);
|
|
164
|
-
printCoverage([...scanInput.notes, ...coverage]);
|
|
195
|
+
printSummary(scanState.sorted, packages.length, scanInput);
|
|
196
|
+
printActionSummary(scanState.sorted);
|
|
197
|
+
printSuggestedFixCommands(scanState.sorted, scanInput);
|
|
198
|
+
printPriorityFixes(scanState.sorted);
|
|
199
|
+
printFixPlan(scanState.sorted);
|
|
200
|
+
printSuggestedFixCommandSkips(scanState.sorted, scanInput);
|
|
201
|
+
printCoverage([...scanInput.notes, ...scanState.coverage]);
|
|
165
202
|
if (scanInput.skippedDependencies.length > 0) {
|
|
166
203
|
printSkippedDependencies(scanInput.skippedDependencies);
|
|
167
204
|
}
|
|
168
|
-
if (sorted.length > 0) {
|
|
169
|
-
printGroupSummary(sorted);
|
|
170
|
-
if (tableFindings.length > 0) {
|
|
171
|
-
printTable(tableFindings, options.all ? null : minSeverity);
|
|
172
|
-
printPathHints(tableFindings);
|
|
205
|
+
if (scanState.sorted.length > 0) {
|
|
206
|
+
printGroupSummary(scanState.sorted);
|
|
207
|
+
if (scanState.tableFindings.length > 0) {
|
|
208
|
+
printTable(scanState.tableFindings, options.all ? null : scanState.minSeverity);
|
|
209
|
+
printPathHints(scanState.tableFindings);
|
|
173
210
|
}
|
|
174
211
|
else {
|
|
175
|
-
logInfo(`No findings met the table threshold of ${minSeverity}. Re-run with --all to show everything.`, options);
|
|
212
|
+
logInfo(`No findings met the table threshold of ${scanState.minSeverity}. Re-run with --all to show everything.`, options);
|
|
176
213
|
}
|
|
177
214
|
}
|
|
178
|
-
printFinalStatus(sorted);
|
|
215
|
+
printFinalStatus(scanState.sorted);
|
|
179
216
|
}
|
|
180
217
|
else {
|
|
181
218
|
// Simplified output - cleaner, focused view
|
|
182
|
-
printCompactOutput(sorted, scanInput);
|
|
219
|
+
printCompactOutput(scanState.sorted, scanInput);
|
|
183
220
|
}
|
|
184
221
|
const failLevel = normalizeSeverity(options.failOn);
|
|
185
|
-
const shouldFail = sorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]);
|
|
222
|
+
const shouldFail = scanState.sorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]);
|
|
186
223
|
process.exit(shouldFail ? 1 : 0);
|
|
187
224
|
return;
|
|
188
225
|
}
|
|
@@ -199,6 +236,155 @@ function formatAdvisorySourceLine(sourceLabel) {
|
|
|
199
236
|
}
|
|
200
237
|
return `${match[1]} (${chalk.cyan(match[2])})`;
|
|
201
238
|
}
|
|
239
|
+
async function scanProject(params) {
|
|
240
|
+
const directDependencyNames = readDirectDependencyNames(params.projectPath, !!params.options.prodOnly);
|
|
241
|
+
const findings = await scanPackages(params.scanInput.packages, params.batchSize, params.options, { directDependencyNames });
|
|
242
|
+
const sorted = findings.sort((a, b) => severityOrder[b.severity] - severityOrder[a.severity]);
|
|
243
|
+
const coverage = buildCoverageNotes(params.scanInput, !!params.options.offline || !!params.options.offlineDb);
|
|
244
|
+
const minSeverity = normalizeSeverity(params.options.minSeverity || "medium");
|
|
245
|
+
const tableFindings = params.options.all
|
|
246
|
+
? sorted
|
|
247
|
+
: sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity]);
|
|
248
|
+
const suggestedFixCommands = buildSuggestedFixCommandPlan(sorted, params.scanInput);
|
|
249
|
+
return {
|
|
250
|
+
sorted,
|
|
251
|
+
coverage,
|
|
252
|
+
minSeverity,
|
|
253
|
+
tableFindings,
|
|
254
|
+
suggestedFixCommands,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
async function applyFixesIfRequested(params) {
|
|
258
|
+
console.log("");
|
|
259
|
+
console.log(chalk.bold.cyan("Applying fixes (--fix)"));
|
|
260
|
+
if (!params.plan) {
|
|
261
|
+
return {
|
|
262
|
+
appliedFixCount: 0,
|
|
263
|
+
skippedCount: params.totalFindings,
|
|
264
|
+
skippedTransitiveCount: 0,
|
|
265
|
+
skippedNoValidatedTargetCount: params.totalFindings,
|
|
266
|
+
applied: [],
|
|
267
|
+
note: "No package-manager-native fix command is available for this project.",
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
const directTargets = params.plan.targets.filter(target => target.kind === "direct");
|
|
271
|
+
const transitiveTargets = params.plan.targets.filter(target => target.kind !== "direct");
|
|
272
|
+
const skippedDirect = params.plan.skipped.filter(skip => skip.relationship === "direct" || skip.relationship === "unknown");
|
|
273
|
+
if (directTargets.length === 0) {
|
|
274
|
+
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
275
|
+
return {
|
|
276
|
+
appliedFixCount: 0,
|
|
277
|
+
skippedCount,
|
|
278
|
+
skippedTransitiveCount: transitiveTargets.length,
|
|
279
|
+
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
280
|
+
applied: [],
|
|
281
|
+
note: "No validated direct dependency fixes were eligible for auto-apply.",
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
const commandLabel = commandLabelForPackageManager(params.plan.packageManager);
|
|
285
|
+
const total = directTargets.length;
|
|
286
|
+
const spinner = createSpinner(`Applying direct package fixes with ${commandLabel}... 0/${total}`, params.options);
|
|
287
|
+
for (let i = 0; i < directTargets.length; i++) {
|
|
288
|
+
const target = directTargets[i];
|
|
289
|
+
const commandParts = buildFixCommandParts(params.plan.packageManager, [target]);
|
|
290
|
+
spinner.update(`Applying direct fix ${i + 1}/${total}: ${commandParts.join(" ")}`);
|
|
291
|
+
const run = await runInstallCommand(commandParts[0], commandParts.slice(1), params.projectPath);
|
|
292
|
+
if (run.error) {
|
|
293
|
+
spinner.fail("Failed to apply fixes");
|
|
294
|
+
throw new Error(`Failed to apply fixes: ${run.error.message}`);
|
|
295
|
+
}
|
|
296
|
+
if ((run.status ?? 1) !== 0) {
|
|
297
|
+
spinner.fail(`Fix command failed (${commandLabel})`);
|
|
298
|
+
throw new Error(`Fix command exited with status ${run.status ?? 1}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
spinner.succeed(`Applied ${directTargets.length} direct package fix${directTargets.length === 1 ? "" : "es"} with ${commandLabel}`);
|
|
302
|
+
const skippedCount = transitiveTargets.length + skippedDirect.length;
|
|
303
|
+
return {
|
|
304
|
+
appliedFixCount: directTargets.length,
|
|
305
|
+
skippedCount,
|
|
306
|
+
skippedTransitiveCount: transitiveTargets.length,
|
|
307
|
+
skippedNoValidatedTargetCount: skippedDirect.length,
|
|
308
|
+
applied: directTargets.map(target => ({
|
|
309
|
+
package: target.package,
|
|
310
|
+
from: target.currentVersion ?? "unknown",
|
|
311
|
+
to: target.targetVersion,
|
|
312
|
+
})),
|
|
313
|
+
note: null,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
function buildFixCommandParts(packageManager, targets) {
|
|
317
|
+
if (packageManager === "npm") {
|
|
318
|
+
return ["npm", "install", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
319
|
+
}
|
|
320
|
+
if (packageManager === "pnpm") {
|
|
321
|
+
return ["pnpm", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
322
|
+
}
|
|
323
|
+
return ["yarn", "add", ...targets.map(target => `${target.package}@${target.targetVersion}`)];
|
|
324
|
+
}
|
|
325
|
+
async function runInstallCommand(command, args, cwd) {
|
|
326
|
+
return await new Promise(resolve => {
|
|
327
|
+
const child = spawn(command, args, {
|
|
328
|
+
cwd,
|
|
329
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
330
|
+
});
|
|
331
|
+
child.stdout.on("data", () => { });
|
|
332
|
+
child.stderr.on("data", () => { });
|
|
333
|
+
child.on("error", error => {
|
|
334
|
+
resolve({ status: null, error });
|
|
335
|
+
});
|
|
336
|
+
child.on("close", code => {
|
|
337
|
+
resolve({ status: code, error: null });
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
function commandLabelForPackageManager(packageManager) {
|
|
342
|
+
if (packageManager === "npm")
|
|
343
|
+
return "npm install";
|
|
344
|
+
if (packageManager === "pnpm")
|
|
345
|
+
return "pnpm add";
|
|
346
|
+
return "yarn add";
|
|
347
|
+
}
|
|
348
|
+
function countBySeverity(findings) {
|
|
349
|
+
const counts = {
|
|
350
|
+
none: 0,
|
|
351
|
+
low: 0,
|
|
352
|
+
medium: 0,
|
|
353
|
+
high: 0,
|
|
354
|
+
critical: 0,
|
|
355
|
+
unknown: 0,
|
|
356
|
+
};
|
|
357
|
+
for (const finding of findings) {
|
|
358
|
+
counts[finding.severity] += 1;
|
|
359
|
+
}
|
|
360
|
+
return counts;
|
|
361
|
+
}
|
|
362
|
+
function printFixModeSummary(params) {
|
|
363
|
+
const result = params.fixResult;
|
|
364
|
+
if (!result)
|
|
365
|
+
return;
|
|
366
|
+
if (result.note) {
|
|
367
|
+
console.log(chalk.gray(result.note));
|
|
368
|
+
}
|
|
369
|
+
if (result.applied.length > 0) {
|
|
370
|
+
console.log("");
|
|
371
|
+
console.log(chalk.bold.cyan("Applied fixes"));
|
|
372
|
+
for (const item of result.applied) {
|
|
373
|
+
console.log(`- ${chalk.white(item.package)}: ${chalk.gray(item.from)} ${chalk.cyan("->")} ${chalk.green(item.to)}`);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
console.log("");
|
|
377
|
+
console.log(chalk.bold.cyan("Fix summary"));
|
|
378
|
+
console.log(`- Applied fixes: ${chalk.green(String(result.appliedFixCount))}`);
|
|
379
|
+
console.log(`- Skipped findings: ${chalk.yellow(String(result.skippedCount))}`);
|
|
380
|
+
if (result.skippedCount > 0) {
|
|
381
|
+
console.log(` - Transitive (v1 skip): ${chalk.yellow(String(result.skippedTransitiveCount))}`);
|
|
382
|
+
console.log(` - No validated direct target: ${chalk.yellow(String(result.skippedNoValidatedTargetCount))}`);
|
|
383
|
+
}
|
|
384
|
+
console.log(`- Findings before fix: ${chalk.white(String(params.findingsBeforeFix))}`);
|
|
385
|
+
console.log(`- Remaining findings after fix: ${chalk.white(String(params.findingsAfterFix))}`);
|
|
386
|
+
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))}`);
|
|
387
|
+
}
|
|
202
388
|
function readDirectDependencyNames(projectPath, prodOnly) {
|
|
203
389
|
const packageJsonPath = path.join(projectPath, "package.json");
|
|
204
390
|
if (!fs.existsSync(packageJsonPath)) {
|