cve-lite-cli 1.34.0 → 1.35.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.
Files changed (37) hide show
  1. package/dist/cli/advisories-init.js +13 -0
  2. package/dist/cli/advisories-sync.js +30 -0
  3. package/dist/cli/config-command.js +15 -0
  4. package/dist/cli/config.js +29 -0
  5. package/dist/cli/help.js +4 -4
  6. package/dist/cli/overrides.js +10 -1
  7. package/dist/constants.js +52 -0
  8. package/dist/index.js +25 -719
  9. package/dist/output/cyclonedx.js +12 -0
  10. package/dist/output/html-reporter.js +73 -38
  11. package/dist/output/multi-folder-html-reporter.js +16 -10
  12. package/dist/output/multi-folder-printer.js +1 -1
  13. package/dist/output/override-findings-sarif.js +1 -0
  14. package/dist/output/printers.js +427 -270
  15. package/dist/output/sarif.js +17 -1
  16. package/dist/output/sbom-dependency-edges.js +29 -19
  17. package/dist/overrides/admitted-scan.js +158 -0
  18. package/dist/overrides/api.js +16 -0
  19. package/dist/overrides/context-builder.js +4 -0
  20. package/dist/overrides/context.js +8 -1
  21. package/dist/overrides/detectors/index.js +2 -0
  22. package/dist/overrides/detectors/oa010-vulnerable-floor.js +123 -0
  23. package/dist/overrides/parsing/registry.js +53 -0
  24. package/dist/parsers/bun-lock-graph.js +182 -0
  25. package/dist/parsers/bun-lock.js +93 -132
  26. package/dist/parsers/index.js +75 -149
  27. package/dist/parsers/multi-package.js +5 -6
  28. package/dist/parsers/pnpm-lock-graph.js +94 -0
  29. package/dist/parsers/pnpm-lock.js +5 -5
  30. package/dist/parsers/yarn-lock-graph.js +148 -0
  31. package/dist/parsers/yarn-lock.js +3 -3
  32. package/dist/remediation/fix-commands.js +48 -7
  33. package/dist/scan/completeness.js +1 -1
  34. package/dist/scan/single-scan.js +643 -0
  35. package/dist/utils/file.js +11 -14
  36. package/dist/utils/version.js +10 -0
  37. package/package.json +1 -1
@@ -112,6 +112,7 @@ export function buildSuggestedFixCommandPlan(findings, scanInput, options) {
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,
@@ -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
- return item.package === finding.pkg.name && item.targetVersion === directTarget;
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
  }
@@ -555,9 +568,22 @@ function upsertTarget(targetsByPackage, next) {
555
568
  : existing.confidence ?? next.confidence,
556
569
  };
557
570
  if (looksLikeVersion(existing.targetVersion) && looksLikeVersion(next.targetVersion)) {
558
- if (compareVersions(next.targetVersion, existing.targetVersion) > 0) {
571
+ const comparison = compareVersions(next.targetVersion, existing.targetVersion);
572
+ if (comparison > 0) {
559
573
  merged.targetVersion = next.targetVersion;
560
574
  merged.currentVersion = next.currentVersion ?? merged.currentVersion;
575
+ // An explicit command is built for one specific version (a chain-resolution
576
+ // command, say). Once the merge raises the target, a command built for the
577
+ // lower version would hand the user a version the scan already found still
578
+ // vulnerable, so it must not survive. Clearing it falls through to buildTargetCommand
579
+ // deriving the command from targetVersion.
580
+ merged.command = next.command ?? undefined;
581
+ // The adjustment note narrates one specific version ("using lowest known
582
+ // non-vulnerable version 4.20.0"). It belongs to whichever target won the
583
+ // comparison, so inheriting the loser's leaves a note contradicting the
584
+ // Target column it is printed beside.
585
+ merged.adjustmentNote = next.adjustmentNote ?? null;
586
+ merged.advisoryVersion = next.advisoryVersion ?? existing.advisoryVersion ?? null;
561
587
  // Keep the reason from the higher-severity finding so the most critical issue is visible
562
588
  // in the context column. Only update the reason if next has strictly higher severity.
563
589
  if (severityOrder[next.severity] > severityOrder[existing.severity]) {
@@ -567,6 +593,13 @@ function upsertTarget(targetsByPackage, next) {
567
593
  merged.knownVulnerableVersions = next.knownVulnerableVersions ?? merged.knownVulnerableVersions ?? null;
568
594
  merged.fixVersionPublishedAt = next.fixVersionPublishedAt ?? merged.fixVersionPublishedAt ?? null;
569
595
  }
596
+ else if (comparison < 0) {
597
+ // Mirror case: the existing target wins, so a command or note built for the
598
+ // lower incoming version is equally stale and must not be inherited.
599
+ merged.command = existing.command ?? undefined;
600
+ merged.adjustmentNote = existing.adjustmentNote ?? null;
601
+ merged.advisoryVersion = existing.advisoryVersion ?? next.advisoryVersion ?? null;
602
+ }
570
603
  targetsByPackage.set(next.package, merged);
571
604
  return;
572
605
  }
@@ -661,21 +694,29 @@ function buildSections(targets, packageManager) {
661
694
  key: `${entry.kind}:${entry.severity}`,
662
695
  kind: entry.kind,
663
696
  severity: entry.severity,
664
- title: buildSectionTitle(entry.kind, entry.severity),
697
+ title: buildSectionTitle(entry.kind, entry.severity, sectionTargets),
665
698
  command: buildCommandForTargets(sectionTargets, packageManager),
666
699
  targets: sectionTargets,
667
700
  });
668
701
  }
669
702
  return groups;
670
703
  }
671
- function buildSectionTitle(kind, severity) {
704
+ function buildSectionTitle(kind, severity, targets = []) {
672
705
  const severityTitle = severity === "unknown"
673
706
  ? "Unknown severity"
674
707
  : `${capitalize(severity)} severity`;
708
+ // Every other kind names the table it produces, and the renderer picks the table
709
+ // from the target kinds. An urgent section can hold either kind, so a fixed
710
+ // "fix commands" title described a direct-fix table in one project and a
711
+ // parent-upgrade table in another. Name what the reader will actually see.
675
712
  if (kind === "urgent") {
676
- return severity === "critical"
677
- ? "Critical severity fix commands"
678
- : "High severity fix commands";
713
+ const hasDirect = targets.some(target => target.kind === "direct");
714
+ const hasParent = targets.some(target => target.kind === "parent-upgrade" || target.kind === "parent-update");
715
+ if (hasDirect && !hasParent)
716
+ return `${severityTitle} direct fixes`;
717
+ if (hasParent && !hasDirect)
718
+ return `${severityTitle} parent upgrades`;
719
+ return `${severityTitle} fix commands`;
679
720
  }
680
721
  if (kind === "direct") {
681
722
  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
- // --incomplete-policy=warn has the same effect as not passing the flag at all
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
  }