cve-lite-cli 1.23.1 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/args.js +0 -3
- package/dist/remediation/fix-commands.js +51 -24
- package/package.json +2 -2
package/dist/cli/args.js
CHANGED
|
@@ -267,9 +267,6 @@ export function parseArgs(argv) {
|
|
|
267
267
|
}
|
|
268
268
|
throw new Error(`Unexpected argument: ${arg}`);
|
|
269
269
|
}
|
|
270
|
-
if (options.sarif && options.report) {
|
|
271
|
-
throw new Error("cannot combine --sarif and --report");
|
|
272
|
-
}
|
|
273
270
|
if (options.cdx && options.report) {
|
|
274
271
|
throw new Error("cannot combine --cdx and --report");
|
|
275
272
|
}
|
|
@@ -32,6 +32,10 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
32
32
|
// workspace map is best-effort
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
+
const devLookup = new Map();
|
|
36
|
+
for (const pkg of scanInput.packages) {
|
|
37
|
+
devLookup.set(`${pkg.name}@${pkg.version}`, pkg.dev ?? false);
|
|
38
|
+
}
|
|
35
39
|
const prioritizedFindings = [...findings]
|
|
36
40
|
.filter(f => f.severity === "critical" || f.severity === "high")
|
|
37
41
|
.sort((a, b) => {
|
|
@@ -115,6 +119,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
115
119
|
reason: `Direct upgrade target for ${finding.pkg.name}@${finding.pkg.version}`,
|
|
116
120
|
usage: finding.usage ?? null,
|
|
117
121
|
workspaces: pkgWorkspaces.length > 0 ? pkgWorkspaces : undefined,
|
|
122
|
+
isDev: finding.pkg.dev ?? false,
|
|
118
123
|
});
|
|
119
124
|
}
|
|
120
125
|
else if (finding.fixVersionValidationNote) {
|
|
@@ -172,6 +177,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
172
177
|
reason: finding.recommendedNpmTransitiveRemediation.reason,
|
|
173
178
|
command: buildNpmUpdateCommand(finding.recommendedNpmTransitiveRemediation.package, finding.recommendedNpmTransitiveRemediation.workspaces),
|
|
174
179
|
usage: finding.usage ?? null,
|
|
180
|
+
isDev: devLookup.get(`${finding.recommendedNpmTransitiveRemediation.package}@${finding.recommendedNpmTransitiveRemediation.currentVersion}`) ?? false,
|
|
175
181
|
});
|
|
176
182
|
continue;
|
|
177
183
|
}
|
|
@@ -197,6 +203,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
197
203
|
coveredPaths: coverage.coveredPaths,
|
|
198
204
|
remainingPaths: coverage.remainingPaths,
|
|
199
205
|
usage: finding.usage ?? null,
|
|
206
|
+
isDev: devLookup.get(`${finding.recommendedNpmTransitiveRemediation.package}@${finding.recommendedNpmTransitiveRemediation.currentVersion}`) ?? false,
|
|
200
207
|
});
|
|
201
208
|
continue;
|
|
202
209
|
}
|
|
@@ -220,6 +227,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
220
227
|
coveredPaths: coverage.coveredPaths,
|
|
221
228
|
remainingPaths: coverage.remainingPaths,
|
|
222
229
|
usage: finding.usage ?? null,
|
|
230
|
+
isDev: devLookup.get(`${finding.recommendedParentUpgrade.package}@${finding.recommendedParentUpgrade.currentVersion}`) ?? false,
|
|
223
231
|
});
|
|
224
232
|
continue;
|
|
225
233
|
}
|
|
@@ -360,6 +368,9 @@ function commandPrefix(packageManager) {
|
|
|
360
368
|
return "bun add";
|
|
361
369
|
return "yarn add";
|
|
362
370
|
}
|
|
371
|
+
function devFlag(packageManager) {
|
|
372
|
+
return packageManager === "bun" ? "--dev" : "-D";
|
|
373
|
+
}
|
|
363
374
|
export function findSuggestedCommandForFinding(plan, finding) {
|
|
364
375
|
const target = plan.targets.find(item => {
|
|
365
376
|
if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
@@ -389,7 +400,8 @@ export function findSuggestedCommandForFinding(plan, finding) {
|
|
|
389
400
|
if (commands.length > 0)
|
|
390
401
|
return commands.join(" && ");
|
|
391
402
|
}
|
|
392
|
-
|
|
403
|
+
const flag = target.isDev ? ` ${devFlag(plan.packageManager)}` : "";
|
|
404
|
+
return `${commandPrefix(plan.packageManager)}${flag} ${target.package}@${target.targetVersion}`;
|
|
393
405
|
}
|
|
394
406
|
function packageManagerSourceLabel(scanInput) {
|
|
395
407
|
if (scanInput.filePath) {
|
|
@@ -424,6 +436,7 @@ function upsertTarget(targetsByPackage, next) {
|
|
|
424
436
|
: "parent-upgrade",
|
|
425
437
|
displayTargetVersion: existing.displayTargetVersion ?? next.displayTargetVersion,
|
|
426
438
|
command: existing.command ?? next.command,
|
|
439
|
+
isDev: (existing.isDev ?? false) && (next.isDev ?? false),
|
|
427
440
|
workspaces: mergeStringArrays(existing.workspaces, next.workspaces),
|
|
428
441
|
coverage: existing.coverage === "partial" || next.coverage === "partial"
|
|
429
442
|
? "partial"
|
|
@@ -570,32 +583,39 @@ function buildWorkspaceInstallCommands(targets, packageManager) {
|
|
|
570
583
|
const groups = groupByWorkspaceKey(targets);
|
|
571
584
|
const commands = [];
|
|
572
585
|
for (const [wsKey, groupTargets] of groups) {
|
|
573
|
-
const pkgArgs = groupTargets.map(t => `${t.package}@${t.targetVersion}`).join(" ");
|
|
574
586
|
const workspaces = wsKey ? wsKey.split("\0") : [];
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
const
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
commands.push(`yarn add ${pkgArgs}`);
|
|
587
|
+
const devTargets = groupTargets.filter(t => t.isDev);
|
|
588
|
+
const prodTargets = groupTargets.filter(t => !t.isDev);
|
|
589
|
+
for (const [targets, isDev] of [[prodTargets, false], [devTargets, true]]) {
|
|
590
|
+
if (targets.length === 0)
|
|
591
|
+
continue;
|
|
592
|
+
const pkgArgs = targets.map(t => `${t.package}@${t.targetVersion}`).join(" ");
|
|
593
|
+
const flag = isDev ? ` ${devFlag(packageManager)}` : "";
|
|
594
|
+
if (packageManager === "npm") {
|
|
595
|
+
const wsFlags = workspaces.map(ws => `-w ${ws}`).join(" ");
|
|
596
|
+
commands.push(`npm install${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
586
597
|
}
|
|
587
|
-
else {
|
|
588
|
-
|
|
589
|
-
|
|
598
|
+
else if (packageManager === "pnpm") {
|
|
599
|
+
const wsFlags = workspaces.map(ws => `--filter ./${ws}`).join(" ");
|
|
600
|
+
commands.push(`pnpm add${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
601
|
+
}
|
|
602
|
+
else if (packageManager === "yarn") {
|
|
603
|
+
if (workspaces.length === 0) {
|
|
604
|
+
commands.push(`yarn add${flag} ${pkgArgs}`);
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
for (const ws of workspaces) {
|
|
608
|
+
commands.push(`yarn workspace ${ws} add${flag} ${pkgArgs}`);
|
|
609
|
+
}
|
|
590
610
|
}
|
|
591
611
|
}
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
612
|
+
else if (packageManager === "bun") {
|
|
613
|
+
const wsFlags = workspaces.map(ws => `--filter ${ws}`).join(" ");
|
|
614
|
+
commands.push(`bun add${flag}${wsFlags ? " " + wsFlags : ""} ${pkgArgs}`);
|
|
615
|
+
}
|
|
616
|
+
else {
|
|
617
|
+
commands.push(`${commandPrefix(packageManager)}${flag} ${pkgArgs}`);
|
|
618
|
+
}
|
|
599
619
|
}
|
|
600
620
|
}
|
|
601
621
|
return commands;
|
|
@@ -621,7 +641,14 @@ function buildCommandForTargets(targets, packageManager) {
|
|
|
621
641
|
commandParts.push(...buildWorkspaceInstallCommands(installTargets, packageManager));
|
|
622
642
|
}
|
|
623
643
|
else {
|
|
624
|
-
|
|
644
|
+
const prodInstall = installTargets.filter(t => !t.isDev);
|
|
645
|
+
const devInstall = installTargets.filter(t => t.isDev);
|
|
646
|
+
if (prodInstall.length > 0) {
|
|
647
|
+
commandParts.push(`${commandPrefix(packageManager)} ${prodInstall.map(t => `${t.package}@${t.targetVersion}`).join(" ")}`);
|
|
648
|
+
}
|
|
649
|
+
if (devInstall.length > 0) {
|
|
650
|
+
commandParts.push(`${commandPrefix(packageManager)} ${devFlag(packageManager)} ${devInstall.map(t => `${t.package}@${t.targetVersion}`).join(" ")}`);
|
|
651
|
+
}
|
|
625
652
|
}
|
|
626
653
|
}
|
|
627
654
|
return commandParts.join(" && ");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cve-lite-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.24.0",
|
|
4
4
|
"description": "Developer-friendly CLI for scanning JS/TS projects for dependency vulnerabilities using local lockfiles and OSV",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"@types/better-sqlite3": "^7.6.13",
|
|
24
24
|
"@types/jest": "^30.0.0",
|
|
25
25
|
"@types/node": "^24.0.0",
|
|
26
|
-
"jest": "^30.
|
|
26
|
+
"jest": "^30.4.1",
|
|
27
27
|
"ts-jest": "^29.4.9",
|
|
28
28
|
"tsx": "^4.22.0",
|
|
29
29
|
"typescript": "^5.8.2"
|