cve-lite-cli 1.37.0 → 1.38.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 (45) hide show
  1. package/README.md +20 -1
  2. package/dist/cli/args.js +120 -103
  3. package/dist/cli/flags.js +39 -0
  4. package/dist/cli/help.js +6 -3
  5. package/dist/cli/overrides.js +25 -19
  6. package/dist/cli/validate.js +31 -9
  7. package/dist/index.js +6 -1
  8. package/dist/output/compact-truncation.js +35 -0
  9. package/dist/output/formatters.js +10 -2
  10. package/dist/output/html-reporter.js +24 -12
  11. package/dist/output/multi-folder-html-reporter.js +26 -7
  12. package/dist/output/override-findings-html.js +24 -3
  13. package/dist/output/override-findings-json.js +5 -2
  14. package/dist/output/override-findings-sarif.js +1 -0
  15. package/dist/output/override-findings-terminal.js +21 -1
  16. package/dist/output/printers.js +34 -21
  17. package/dist/output/sarif.js +54 -3
  18. package/dist/output/scan-json.js +74 -0
  19. package/dist/output/skipped-override-rules.js +41 -0
  20. package/dist/output/write-outputs.js +16 -28
  21. package/dist/overrides/admitted-scan.js +12 -1
  22. package/dist/overrides/api.js +75 -21
  23. package/dist/overrides/context-builder.js +17 -2
  24. package/dist/overrides/detectors/index.js +2 -0
  25. package/dist/overrides/detectors/oa008-materialized.js +72 -13
  26. package/dist/overrides/detectors/oa009-stale-floor.js +12 -15
  27. package/dist/overrides/detectors/oa010-vulnerable-floor.js +5 -1
  28. package/dist/overrides/detectors/oa011-exceeds-range.js +128 -0
  29. package/dist/overrides/detectors/pd001-override-only-phantom.js +5 -4
  30. package/dist/overrides/detectors/pd002-transitive-only-phantom.js +5 -4
  31. package/dist/overrides/detectors/phantom-utils.js +29 -0
  32. package/dist/overrides/parsing/registry.js +79 -10
  33. package/dist/scan/multi-folder-scan.js +65 -51
  34. package/dist/scan/override-audit.js +49 -0
  35. package/dist/scan/single-scan.js +108 -33
  36. package/dist/scanner.js +8 -4
  37. package/dist/skills/content.js +4 -2
  38. package/dist/usage/scanner.js +219 -28
  39. package/dist/utils/contextual-signals.js +193 -0
  40. package/dist/utils/finding.js +5 -0
  41. package/dist/utils/package-json.js +66 -14
  42. package/dist/utils/severity.js +22 -0
  43. package/dist/utils/update-check.js +2 -1
  44. package/dist/utils/version.js +33 -19
  45. package/package.json +1 -1
@@ -4,6 +4,7 @@ import os from "node:os";
4
4
  import { chalk, stripAnsi } from "./chalk.js";
5
5
  import { getCliVersion } from "./version-info.js";
6
6
  const NPM_REGISTRY_URL = "https://registry.npmjs.org/cve-lite-cli/latest";
7
+ const NPM_INSTALL_COMMAND = "npm install -g cve-lite-cli";
7
8
  const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
8
9
  const BOX_INNER_WIDTH = 50;
9
10
  export function isNewer(latest, current) {
@@ -75,7 +76,7 @@ function renderBox(current, latest) {
75
76
  const empty = chalk.yellow("│") + " ".repeat(BOX_INNER_WIDTH) + chalk.yellow("│");
76
77
  const bottom = chalk.yellow("╰" + "─".repeat(BOX_INNER_WIDTH) + "╯");
77
78
  const line1 = ` ${chalk.bold.yellow("Update available!")} ${chalk.gray(current)} ${chalk.yellow("→")} ${chalk.green(latest)}`;
78
- const line2 = ` ${chalk.white("Run: npm install -g cve-lite-cli")}`;
79
+ const line2 = ` ${chalk.white("Run: " + NPM_INSTALL_COMMAND)}`;
79
80
  const padLine = (content) => {
80
81
  const visual = stripAnsi(content).length;
81
82
  return chalk.yellow("│") + content + " ".repeat(Math.max(0, BOX_INNER_WIDTH - visual)) + chalk.yellow("│");
@@ -225,29 +225,43 @@ export function isValidRange(input) {
225
225
  /**
226
226
  * Does `version` satisfy `range`?
227
227
  *
228
- * `includePrerelease` is deliberate. A pre-release install must still match an
229
- * advisory range that covers it, otherwise a vulnerable `1.2.3-beta.1` is
230
- * cleared by a `<1.2.3` advisory. That is the defect v1.34.0 fixed on the OSV
231
- * path, and it survived here because the old implementation ran the version
232
- * through `coerceVersion` first, which strips the pre-release tag and made the
233
- * beta compare equal to the release.
234
- *
235
- * Messy inputs (`v1.2.3`, `2.0`) fall back to `coerceVersion`, which is kept
236
- * for exactly that: lockfiles and manifests carry version strings semver will
237
- * not parse.
228
+ * Delegates normalization and comparison to `positionAgainstRange` so
229
+ * prerelease handling and coercion stay on one path. Uninterpretable input
230
+ * returns false because `positionAgainstRange` returns null.
238
231
  */
239
232
  export function satisfiesRange(version, range) {
233
+ return positionAgainstRange(version, range) === "satisfies";
234
+ }
235
+ /**
236
+ * Classify a concrete version relative to the complete set represented by a
237
+ * semver range. "outside" covers gaps in compound/union ranges: for example,
238
+ * 2.0.0 is neither globally below nor globally above `1.x || 3.x`.
239
+ *
240
+ * Returns null when either input cannot be interpreted as semver. Callers that
241
+ * already validate their inputs can treat null conservatively as "outside".
242
+ */
243
+ export function positionAgainstRange(version, range) {
240
244
  if (!version || !range)
241
- return false;
245
+ return null;
242
246
  const parsed = semver.parse(version.trim(), { loose: true });
243
247
  const normalizedVersion = parsed ? parsed.version : coerceVersion(version);
244
- if (!normalizedVersion)
245
- return false;
246
248
  const trimmedRange = range.trim();
247
- if (!semver.validRange(trimmedRange, { loose: true }))
248
- return false;
249
- return semver.satisfies(normalizedVersion, trimmedRange, {
250
- loose: true,
251
- includePrerelease: true,
252
- });
249
+ // validRange only GUARDS here. Its normalized output is computed without
250
+ // includePrerelease, which rewrites prerelease bounds and would silently
251
+ // change the classification below, so the comparisons take the raw range.
252
+ if (!normalizedVersion || !semver.validRange(trimmedRange, { loose: true }))
253
+ return null;
254
+ const options = { loose: true, includePrerelease: true };
255
+ try {
256
+ if (semver.satisfies(normalizedVersion, trimmedRange, options))
257
+ return "satisfies";
258
+ if (semver.ltr(normalizedVersion, trimmedRange, options))
259
+ return "below";
260
+ if (semver.gtr(normalizedVersion, trimmedRange, options))
261
+ return "above";
262
+ return "outside";
263
+ }
264
+ catch {
265
+ return null;
266
+ }
253
267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.37.0",
3
+ "version": "1.38.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": {