cve-lite-cli 1.34.0 → 1.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -0
- package/dist/cli/advisories-init.js +13 -0
- package/dist/cli/advisories-sync.js +30 -0
- package/dist/cli/config-command.js +15 -0
- package/dist/cli/config.js +29 -0
- package/dist/cli/help.js +4 -4
- package/dist/cli/overrides.js +10 -1
- package/dist/constants.js +52 -0
- package/dist/index.js +25 -719
- package/dist/osv/cache.js +19 -12
- package/dist/output/cyclonedx.js +12 -0
- package/dist/output/html-reporter.js +73 -38
- package/dist/output/multi-folder-html-reporter.js +16 -10
- package/dist/output/multi-folder-printer.js +1 -1
- package/dist/output/override-findings-sarif.js +1 -0
- package/dist/output/printers.js +460 -288
- package/dist/output/sarif.js +17 -1
- package/dist/output/sbom-dependency-edges.js +29 -19
- package/dist/overrides/admitted-scan.js +158 -0
- package/dist/overrides/api.js +16 -0
- package/dist/overrides/context-builder.js +4 -0
- package/dist/overrides/context.js +8 -1
- package/dist/overrides/detectors/index.js +2 -0
- package/dist/overrides/detectors/oa010-vulnerable-floor.js +123 -0
- package/dist/overrides/parsing/registry.js +53 -0
- package/dist/parsers/bun-lock-graph.js +182 -0
- package/dist/parsers/bun-lock.js +93 -132
- package/dist/parsers/index.js +132 -147
- package/dist/parsers/multi-package.js +5 -6
- package/dist/parsers/pnpm-lock-graph.js +94 -0
- package/dist/parsers/pnpm-lock.js +5 -5
- package/dist/parsers/yarn-lock-graph.js +148 -0
- package/dist/parsers/yarn-lock.js +3 -3
- package/dist/remediation/fix-commands.js +76 -20
- package/dist/scan/completeness.js +1 -1
- package/dist/scan/single-scan.js +643 -0
- package/dist/scanner.js +29 -8
- package/dist/utils/file.js +11 -14
- package/dist/utils/network.js +4 -0
- package/dist/utils/version.js +10 -0
- package/package.json +2 -1
- package/scripts/pr-scan-delta.mjs +315 -0
|
@@ -59,7 +59,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
59
59
|
return relDelta;
|
|
60
60
|
return a.pkg.name.localeCompare(b.pkg.name);
|
|
61
61
|
});
|
|
62
|
-
const
|
|
62
|
+
const targetsByKey = new Map();
|
|
63
63
|
const skippedByKey = new Map();
|
|
64
64
|
const orderedFindings = [
|
|
65
65
|
...prioritizedFindings,
|
|
@@ -106,12 +106,13 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
106
106
|
isUpgradeTarget(finding.pkg.version, directTarget) &&
|
|
107
107
|
validatedFieldOk) {
|
|
108
108
|
const pkgWorkspaces = workspaceMap.get(finding.pkg.name)?.filter(w => w !== ".") ?? [];
|
|
109
|
-
upsertTarget(
|
|
109
|
+
upsertTarget(targetsByKey, finding, {
|
|
110
110
|
package: finding.pkg.name,
|
|
111
111
|
currentVersion: finding.pkg.version,
|
|
112
112
|
targetVersion: directTarget,
|
|
113
113
|
scannedVersions: finding.validatedTargetScannedVersions ?? null,
|
|
114
114
|
knownVulnerableVersions: finding.validatedTargetKnownVulnerableVersions ?? null,
|
|
115
|
+
advisoryVersion: finding.firstFixedVersion ?? null,
|
|
115
116
|
kind: "direct",
|
|
116
117
|
urgent,
|
|
117
118
|
severity: finding.severity,
|
|
@@ -170,7 +171,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
170
171
|
if (packageManager === "npm" &&
|
|
171
172
|
finding.relationship === "transitive" &&
|
|
172
173
|
finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
173
|
-
upsertTarget(
|
|
174
|
+
upsertTarget(targetsByKey, finding, {
|
|
174
175
|
package: finding.recommendedNpmTransitiveRemediation.package,
|
|
175
176
|
currentVersion: finding.recommendedNpmTransitiveRemediation.currentVersion,
|
|
176
177
|
targetVersion: finding.recommendedNpmTransitiveRemediation.targetChildVersion,
|
|
@@ -198,7 +199,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
198
199
|
? finding.chainResolution
|
|
199
200
|
: null;
|
|
200
201
|
const npmParentUpgradeWorkspaces = workspaceMap.get(finding.recommendedNpmTransitiveRemediation.package)?.filter(w => w !== ".") ?? [];
|
|
201
|
-
upsertTarget(
|
|
202
|
+
upsertTarget(targetsByKey, finding, {
|
|
202
203
|
package: finding.recommendedNpmTransitiveRemediation.package,
|
|
203
204
|
currentVersion: finding.recommendedNpmTransitiveRemediation.currentVersion,
|
|
204
205
|
targetVersion: finding.recommendedNpmTransitiveRemediation.targetVersion,
|
|
@@ -230,7 +231,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
230
231
|
? finding.chainResolution
|
|
231
232
|
: null;
|
|
232
233
|
const parentUpgradeWorkspaces = workspaceMap.get(finding.recommendedParentUpgrade.package)?.filter(w => w !== ".") ?? [];
|
|
233
|
-
upsertTarget(
|
|
234
|
+
upsertTarget(targetsByKey, finding, {
|
|
234
235
|
package: finding.recommendedParentUpgrade.package,
|
|
235
236
|
currentVersion: finding.recommendedParentUpgrade.currentVersion,
|
|
236
237
|
targetVersion: finding.recommendedParentUpgrade.targetVersion,
|
|
@@ -272,7 +273,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
272
273
|
: packageManager === "yarn"
|
|
273
274
|
? `yarn upgrade ${finding.pkg.name}`
|
|
274
275
|
: `bun update ${finding.pkg.name}`;
|
|
275
|
-
upsertTarget(
|
|
276
|
+
upsertTarget(targetsByKey, finding, {
|
|
276
277
|
package: finding.pkg.name,
|
|
277
278
|
currentVersion: finding.pkg.version,
|
|
278
279
|
targetVersion: finding.recommendedNpmTransitiveRemediation.targetChildVersion,
|
|
@@ -295,7 +296,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
295
296
|
const isDev = devLookup.get(`${finding.chainResolution.directDep}@${finding.chainResolution.directDepCurrentVersion}`) ?? false;
|
|
296
297
|
const coverage = calculatePathCoverage(finding.dependencyPaths, [finding.chainResolution.directDep]);
|
|
297
298
|
const chainWorkspaces = workspaceMap.get(finding.chainResolution.directDep)?.filter(w => w !== ".") ?? [];
|
|
298
|
-
upsertTarget(
|
|
299
|
+
upsertTarget(targetsByKey, finding, {
|
|
299
300
|
package: finding.chainResolution.directDep,
|
|
300
301
|
currentVersion: finding.chainResolution.directDepCurrentVersion,
|
|
301
302
|
targetVersion: finding.chainResolution.targetVersion,
|
|
@@ -336,7 +337,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
|
|
|
336
337
|
: "No confident automatic fix command could be generated for this issue.",
|
|
337
338
|
});
|
|
338
339
|
}
|
|
339
|
-
const targets = [...
|
|
340
|
+
const targets = [...targetsByKey.values()].sort((a, b) => {
|
|
340
341
|
const sevDelta = severityOrder[b.severity] - severityOrder[a.severity];
|
|
341
342
|
if (sevDelta !== 0)
|
|
342
343
|
return sevDelta;
|
|
@@ -474,7 +475,19 @@ export function findFixTargetForFinding(plan, finding) {
|
|
|
474
475
|
item.targetVersion === finding.chainResolution.targetVersion);
|
|
475
476
|
}
|
|
476
477
|
const directTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
477
|
-
|
|
478
|
+
if (item.package !== finding.pkg.name)
|
|
479
|
+
return false;
|
|
480
|
+
if (item.targetVersion === directTarget)
|
|
481
|
+
return true;
|
|
482
|
+
// Mirrors the recommendedParentUpgrade branch above: a command targeting a
|
|
483
|
+
// higher version also satisfies a lower-version fix. This is the merged case,
|
|
484
|
+
// where a package is both a direct finding and the parent of other findings,
|
|
485
|
+
// so the plan installs a higher version than this finding alone requires.
|
|
486
|
+
// Targets are unique per package name, so this cannot select a different package.
|
|
487
|
+
return (!!directTarget &&
|
|
488
|
+
looksLikeVersion(item.targetVersion) &&
|
|
489
|
+
looksLikeVersion(directTarget) &&
|
|
490
|
+
compareVersions(item.targetVersion, directTarget) >= 0);
|
|
478
491
|
});
|
|
479
492
|
return target ?? null;
|
|
480
493
|
}
|
|
@@ -519,10 +532,25 @@ function packageManagerSourceLabel(scanInput) {
|
|
|
519
532
|
return "bun.lock";
|
|
520
533
|
return scanInput.source;
|
|
521
534
|
}
|
|
522
|
-
|
|
523
|
-
|
|
535
|
+
// Install targets (direct / parent-upgrade) all mean "install <package>@<targetVersion>",
|
|
536
|
+
// so findings that land on the same package merge into one target and the higher
|
|
537
|
+
// version wins. A parent-update target means something else: "refresh <vulnerable
|
|
538
|
+
// child> within <package>'s declared range", and its targetVersion is the CHILD's
|
|
539
|
+
// version, not <package>'s. Merging it with an install target for the same package
|
|
540
|
+
// compares versions of two different packages, and the child's version can end up
|
|
541
|
+
// pinned onto the parent (`npm install axios@4.0.6`, where 4.0.6 is form-data's
|
|
542
|
+
// version - #1007). Keep parent-update targets in their own keyspace, per child, so
|
|
543
|
+
// they only ever merge with a refresh of the same child through the same package.
|
|
544
|
+
function targetKey(finding, target) {
|
|
545
|
+
return target.kind === "parent-update"
|
|
546
|
+
? `parent-update:${target.package}>${finding.pkg.name}`
|
|
547
|
+
: `install:${target.package}`;
|
|
548
|
+
}
|
|
549
|
+
function upsertTarget(targetsByKey, finding, next) {
|
|
550
|
+
const key = targetKey(finding, next);
|
|
551
|
+
const existing = targetsByKey.get(key);
|
|
524
552
|
if (!existing) {
|
|
525
|
-
|
|
553
|
+
targetsByKey.set(key, next);
|
|
526
554
|
return;
|
|
527
555
|
}
|
|
528
556
|
const merged = {
|
|
@@ -555,9 +583,22 @@ function upsertTarget(targetsByPackage, next) {
|
|
|
555
583
|
: existing.confidence ?? next.confidence,
|
|
556
584
|
};
|
|
557
585
|
if (looksLikeVersion(existing.targetVersion) && looksLikeVersion(next.targetVersion)) {
|
|
558
|
-
|
|
586
|
+
const comparison = compareVersions(next.targetVersion, existing.targetVersion);
|
|
587
|
+
if (comparison > 0) {
|
|
559
588
|
merged.targetVersion = next.targetVersion;
|
|
560
589
|
merged.currentVersion = next.currentVersion ?? merged.currentVersion;
|
|
590
|
+
// An explicit command is built for one specific version (a chain-resolution
|
|
591
|
+
// command, say). Once the merge raises the target, a command built for the
|
|
592
|
+
// lower version would hand the user a version the scan already found still
|
|
593
|
+
// vulnerable, so it must not survive. Clearing it falls through to buildTargetCommand
|
|
594
|
+
// deriving the command from targetVersion.
|
|
595
|
+
merged.command = next.command ?? undefined;
|
|
596
|
+
// The adjustment note narrates one specific version ("using lowest known
|
|
597
|
+
// non-vulnerable version 4.20.0"). It belongs to whichever target won the
|
|
598
|
+
// comparison, so inheriting the loser's leaves a note contradicting the
|
|
599
|
+
// Target column it is printed beside.
|
|
600
|
+
merged.adjustmentNote = next.adjustmentNote ?? null;
|
|
601
|
+
merged.advisoryVersion = next.advisoryVersion ?? existing.advisoryVersion ?? null;
|
|
561
602
|
// Keep the reason from the higher-severity finding so the most critical issue is visible
|
|
562
603
|
// in the context column. Only update the reason if next has strictly higher severity.
|
|
563
604
|
if (severityOrder[next.severity] > severityOrder[existing.severity]) {
|
|
@@ -567,7 +608,14 @@ function upsertTarget(targetsByPackage, next) {
|
|
|
567
608
|
merged.knownVulnerableVersions = next.knownVulnerableVersions ?? merged.knownVulnerableVersions ?? null;
|
|
568
609
|
merged.fixVersionPublishedAt = next.fixVersionPublishedAt ?? merged.fixVersionPublishedAt ?? null;
|
|
569
610
|
}
|
|
570
|
-
|
|
611
|
+
else if (comparison < 0) {
|
|
612
|
+
// Mirror case: the existing target wins, so a command or note built for the
|
|
613
|
+
// lower incoming version is equally stale and must not be inherited.
|
|
614
|
+
merged.command = existing.command ?? undefined;
|
|
615
|
+
merged.adjustmentNote = existing.adjustmentNote ?? null;
|
|
616
|
+
merged.advisoryVersion = existing.advisoryVersion ?? next.advisoryVersion ?? null;
|
|
617
|
+
}
|
|
618
|
+
targetsByKey.set(key, merged);
|
|
571
619
|
return;
|
|
572
620
|
}
|
|
573
621
|
if (next.kind === "direct" && existing.kind !== "direct") {
|
|
@@ -579,7 +627,7 @@ function upsertTarget(targetsByPackage, next) {
|
|
|
579
627
|
merged.knownVulnerableVersions = next.knownVulnerableVersions ?? merged.knownVulnerableVersions ?? null;
|
|
580
628
|
merged.fixVersionPublishedAt = next.fixVersionPublishedAt ?? merged.fixVersionPublishedAt ?? null;
|
|
581
629
|
}
|
|
582
|
-
|
|
630
|
+
targetsByKey.set(key, merged);
|
|
583
631
|
}
|
|
584
632
|
function buildParentUpgradeReason(finding, coverage) {
|
|
585
633
|
const coveredPath = coverage.coveredPaths[0];
|
|
@@ -661,21 +709,29 @@ function buildSections(targets, packageManager) {
|
|
|
661
709
|
key: `${entry.kind}:${entry.severity}`,
|
|
662
710
|
kind: entry.kind,
|
|
663
711
|
severity: entry.severity,
|
|
664
|
-
title: buildSectionTitle(entry.kind, entry.severity),
|
|
712
|
+
title: buildSectionTitle(entry.kind, entry.severity, sectionTargets),
|
|
665
713
|
command: buildCommandForTargets(sectionTargets, packageManager),
|
|
666
714
|
targets: sectionTargets,
|
|
667
715
|
});
|
|
668
716
|
}
|
|
669
717
|
return groups;
|
|
670
718
|
}
|
|
671
|
-
function buildSectionTitle(kind, severity) {
|
|
719
|
+
function buildSectionTitle(kind, severity, targets = []) {
|
|
672
720
|
const severityTitle = severity === "unknown"
|
|
673
721
|
? "Unknown severity"
|
|
674
722
|
: `${capitalize(severity)} severity`;
|
|
723
|
+
// Every other kind names the table it produces, and the renderer picks the table
|
|
724
|
+
// from the target kinds. An urgent section can hold either kind, so a fixed
|
|
725
|
+
// "fix commands" title described a direct-fix table in one project and a
|
|
726
|
+
// parent-upgrade table in another. Name what the reader will actually see.
|
|
675
727
|
if (kind === "urgent") {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
728
|
+
const hasDirect = targets.some(target => target.kind === "direct");
|
|
729
|
+
const hasParent = targets.some(target => target.kind === "parent-upgrade" || target.kind === "parent-update");
|
|
730
|
+
if (hasDirect && !hasParent)
|
|
731
|
+
return `${severityTitle} direct fixes`;
|
|
732
|
+
if (hasParent && !hasDirect)
|
|
733
|
+
return `${severityTitle} parent upgrades`;
|
|
734
|
+
return `${severityTitle} fix commands`;
|
|
679
735
|
}
|
|
680
736
|
if (kind === "direct") {
|
|
681
737
|
return `${severityTitle} direct fixes`;
|
|
@@ -48,7 +48,7 @@ export function aggregateMultiFolderCompleteness(results) {
|
|
|
48
48
|
return { complete: deduped.size === 0, diagnostics: [...deduped.values()] };
|
|
49
49
|
}
|
|
50
50
|
export function shouldFailForIncompleteScan(completeness, policy) {
|
|
51
|
-
//
|
|
51
|
+
// only "error" triggers a non-zero exit; "warn" (the default) still surfaces the diagnostic but lets the scan succeed
|
|
52
52
|
if (policy !== "error") {
|
|
53
53
|
return false;
|
|
54
54
|
}
|