cve-lite-cli 1.25.0 → 1.26.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 (39) hide show
  1. package/README.md +38 -13
  2. package/assets/OWASP_Logo_Black_TM.png +0 -0
  3. package/assets/logo-with-title-removebg-preview.png +0 -0
  4. package/dist/advisory/local-db.js +7 -1
  5. package/dist/advisory/osv-advisory-source.js +2 -1
  6. package/dist/cli/args.js +4 -0
  7. package/dist/cli/help.js +2 -1
  8. package/dist/cli/overrides.js +1 -1
  9. package/dist/cli/validate.js +9 -1
  10. package/dist/index.js +47 -16
  11. package/dist/osv/cache.js +5 -1
  12. package/dist/output/formatters.js +0 -15
  13. package/dist/output/html-reporter.js +11 -12
  14. package/dist/output/logos.js +18 -0
  15. package/dist/output/multi-folder-html-reporter.js +3 -4
  16. package/dist/output/override-findings-html.js +10 -4
  17. package/dist/output/override-findings-terminal.js +90 -21
  18. package/dist/output/printers.js +42 -16
  19. package/dist/parsers/pnpm-lock.js +46 -3
  20. package/dist/remediation/npm-registry.js +55 -73
  21. package/dist/scan/multi-folder-scan.js +13 -3
  22. package/dist/scanner.js +79 -59
  23. package/dist/utils/create-pr.js +1 -0
  24. package/dist/utils/fix-runner.js +6 -0
  25. package/dist/utils/package-json.js +21 -0
  26. package/dist/utils/severity.js +16 -0
  27. package/dist/utils/validate-url.js +223 -0
  28. package/dist/utils/version.js +20 -2
  29. package/package.json +6 -2
  30. package/dist/learn/keypress.js +0 -50
  31. package/dist/learn/runner.js +0 -96
  32. package/dist/learn/scenario.js +0 -47
  33. package/dist/learn/session.js +0 -36
  34. package/dist/learn/types.js +0 -1
  35. package/dist/llm/client.js +0 -40
  36. package/dist/llm/config.js +0 -48
  37. package/dist/llm/explainer.js +0 -31
  38. package/dist/output/logo-base64.js +0 -1
  39. package/dist/output/owasp-logo-base64.js +0 -1
@@ -1,37 +1,106 @@
1
- const SEVERITY_ORDER = ["critical", "high", "medium", "low", "info"];
2
- export function renderOverrideFindings(findings) {
3
- if (findings.length === 0) {
4
- return "No override hygiene findings.";
5
- }
1
+ import { chalk, stripAnsi } from "../utils/chalk.js";
2
+ import { formatSeverityLabel, SEVERITY_ORDER } from "../utils/severity.js";
3
+ import { pluralize } from "../utils/string.js";
4
+ const COL_RULE_MAX = 8;
5
+ const COL_PKG_MAX = 30;
6
+ const COL_MSG_MAX = 50;
7
+ export function renderOverrideFindings(findings, options) {
6
8
  const lines = [];
7
9
  lines.push("");
8
- lines.push("Override hygiene");
9
- lines.push("================");
10
+ if (options?.verbose) {
11
+ lines.push(chalk.bold.cyan("🔍 Override Hygiene"));
12
+ }
13
+ else {
14
+ lines.push("────────────────────────────────");
15
+ lines.push(chalk.bold("🔍 Override Hygiene"));
16
+ lines.push("────────────────────────────────");
17
+ }
10
18
  lines.push("");
19
+ if (findings.length === 0) {
20
+ lines.push(chalk.greenBright("✔ No override hygiene issues found."));
21
+ return lines.join("\n");
22
+ }
11
23
  const grouped = new Map();
12
24
  for (const sev of SEVERITY_ORDER)
13
25
  grouped.set(sev, []);
14
- for (const f of findings) {
26
+ for (const f of findings)
15
27
  grouped.get(f.severity)?.push(f);
16
- }
17
28
  for (const sev of SEVERITY_ORDER) {
18
29
  const bucket = grouped.get(sev) ?? [];
19
30
  if (bucket.length === 0)
20
31
  continue;
21
- lines.push(`${sev.toUpperCase()} (${bucket.length})`);
22
- lines.push("-".repeat(`${sev.toUpperCase()} (${bucket.length})`.length));
23
- for (const f of bucket) {
24
- lines.push(` ${f.ruleId} ${f.package.name}`);
25
- lines.push(` ${f.location.file}${f.location.jsonPath ? `${f.location.jsonPath}` : ""}`);
26
- lines.push(` ${f.message}`);
27
- if (f.fix) {
28
- lines.push(` fix: autofix available (${f.fix.patch.length} op${f.fix.patch.length === 1 ? "" : "s"})`);
29
- if (f.fix.runnableCommand) {
30
- lines.push(` run: ${f.fix.runnableCommand}`);
31
- }
32
+ lines.push(`${formatSeverityLabel(sev.toUpperCase())} (${bucket.length})`);
33
+ const sorted = [...bucket].sort((a, b) => a.ruleId.localeCompare(b.ruleId));
34
+ const ruleWidth = Math.min(COL_RULE_MAX, Math.max(4, ...sorted.map(f => f.ruleId.length)));
35
+ const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => f.package.name.length)));
36
+ const msgWidth = Math.min(COL_MSG_MAX, Math.max(7, ...sorted.map(f => Math.min(COL_MSG_MAX, Math.max(f.message.length, locationString(f).length)))));
37
+ const hr = (l, m, r) => l + "─".repeat(ruleWidth + 2) + m + "─".repeat(pkgWidth + 2) + m + "─".repeat(msgWidth + 2) + r;
38
+ lines.push(hr("┌", "┬", "┐"));
39
+ lines.push(tableRow(["Rule", "Package", "Message"], [ruleWidth, pkgWidth, msgWidth]));
40
+ lines.push(hr("├", "┼", "┤"));
41
+ for (let i = 0; i < sorted.length; i++) {
42
+ const f = sorted[i];
43
+ const msgLines = wrapText(f.message, msgWidth);
44
+ const locLines = wrapText(locationString(f), msgWidth);
45
+ lines.push(tableRow([chalk.gray(f.ruleId), chalk.whiteBright(f.package.name), msgLines[0] ?? ""], [ruleWidth, pkgWidth, msgWidth]));
46
+ for (let m = 1; m < msgLines.length; m++) {
47
+ lines.push(tableRow(["", "", msgLines[m]], [ruleWidth, pkgWidth, msgWidth]));
48
+ }
49
+ for (const locLine of locLines) {
50
+ lines.push(tableRow(["", "", chalk.gray(locLine)], [ruleWidth, pkgWidth, msgWidth]));
51
+ }
52
+ if (i < sorted.length - 1)
53
+ lines.push(hr("├", "┼", "┤"));
54
+ }
55
+ lines.push(hr("└", "┴", "┘"));
56
+ const seenRules = new Set();
57
+ for (const f of sorted) {
58
+ if (f.fix?.runnableCommand && !seenRules.has(f.ruleId)) {
59
+ seenRules.add(f.ruleId);
60
+ lines.push(chalk.bold.cyan(`> ${f.fix.runnableCommand}`));
32
61
  }
33
- lines.push("");
34
62
  }
63
+ lines.push("");
35
64
  }
65
+ const worstSev = SEVERITY_ORDER.find(s => (grouped.get(s) ?? []).length > 0);
66
+ const footerColor = worstSev === "critical" || worstSev === "high" ? chalk.redBright : chalk.yellow;
67
+ lines.push(footerColor(`${findings.length} override hygiene ${pluralize(findings.length, "issue")} found.`));
68
+ lines.push("");
69
+ lines.push(chalk.gray("────────────────────────────────"));
36
70
  return lines.join("\n");
37
71
  }
72
+ function locationString(f) {
73
+ return f.location.jsonPath
74
+ ? `${f.location.file} › ${f.location.jsonPath}`
75
+ : f.location.file;
76
+ }
77
+ function tableRow(cells, widths) {
78
+ return "│" + cells.map((c, i) => padCell(c, widths[i])).join("│") + "│";
79
+ }
80
+ function padCell(value, width) {
81
+ const truncated = truncate(value, width);
82
+ const visible = stripAnsi(truncated).length;
83
+ return ` ${truncated}${" ".repeat(Math.max(0, width - visible))} `;
84
+ }
85
+ function truncate(value, width) {
86
+ const plain = stripAnsi(value);
87
+ if (plain.length <= width)
88
+ return value;
89
+ return plain.slice(0, Math.max(0, width - 1)) + "…";
90
+ }
91
+ function wrapText(text, width) {
92
+ if (text.length <= width)
93
+ return [text];
94
+ const lines = [];
95
+ let remaining = text.trim();
96
+ while (remaining.length > width) {
97
+ let breakAt = remaining.lastIndexOf(" ", width);
98
+ if (breakAt <= 0)
99
+ breakAt = width;
100
+ lines.push(remaining.slice(0, breakAt).trimEnd());
101
+ remaining = remaining.slice(breakAt).trimStart();
102
+ }
103
+ if (remaining.length > 0)
104
+ lines.push(remaining);
105
+ return lines.length > 0 ? lines : [text];
106
+ }
@@ -2,7 +2,8 @@ import { chalk, stripAnsi } from "../utils/chalk.js";
2
2
  import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
3
3
  import { isMajorVersionBump } from "../utils/version.js";
4
4
  import { getPrimaryParent } from "../utils/finding.js";
5
- import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, } from "./formatters.js";
5
+ import { countUniqueAdvisories, formatRelationshipLabel, formatRelLabel, formatFixCommandWithPublishDates, } from "./formatters.js";
6
+ import { formatSeverityLabel } from "../utils/severity.js";
6
7
  import { pluralize } from "../utils/string.js";
7
8
  import { selectFindingsForCompact } from "./finding-display.js";
8
9
  import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, MAL_GIT_SOURCE_COMPACT_MESSAGE, MAL_GIT_SOURCE_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, } from "../constants.js";
@@ -29,8 +30,8 @@ export function printSummary(findings, packageCount, scanInput) {
29
30
  console.log(chalk.redBright(`✗ Found ${findings.length} ${pkgLabel} (${totalCVEs} ${cveLabel}) with known OSV matches from ${scanInput.source}`));
30
31
  console.log(renderSeverityTable(counts));
31
32
  }
32
- export function printActionSummary(findings) {
33
- if (findings.length === 0)
33
+ export function printActionSummary(findings, overrideCount = 0, packageManager) {
34
+ if (findings.length === 0 && overrideCount === 0)
34
35
  return;
35
36
  const direct = findings.filter(f => f.relationship === "direct").length;
36
37
  const transitive = findings.filter(f => f.relationship === "transitive").length;
@@ -39,13 +40,21 @@ export function printActionSummary(findings) {
39
40
  const fixable = findings.filter(f => Boolean(f.firstFixedVersion)).length;
40
41
  console.log("");
41
42
  console.log(chalk.bold.cyan("Quick take"));
42
- console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
43
- console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
44
- if (unknown > 0) {
45
- console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
43
+ if (packageManager) {
44
+ console.log(`- ${chalk.gray("Package manager:")} ${packageManager}`);
45
+ }
46
+ if (findings.length > 0) {
47
+ console.log(`- ${chalk.green(String(direct))} vulnerable ${pluralize(direct, "package")} look directly fixable in this project.`);
48
+ console.log(`- ${chalk.yellow(String(transitive))} ${pluralize(transitive, "issue")} come through other dependencies.`);
49
+ if (unknown > 0) {
50
+ console.log(`- ${chalk.magenta(String(unknown))} ${pluralize(unknown, "package")} could not be clearly classified as direct or transitive.`);
51
+ }
52
+ console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} ${pluralize(uniqueAdvisories, "CVE")} matched overall.`);
53
+ console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
54
+ }
55
+ if (overrideCount > 0) {
56
+ console.log(`- ${chalk.yellow(String(overrideCount))} override hygiene ${pluralize(overrideCount, "issue")} found. Run ${chalk.white("cve-lite overrides --fix")} to address ${pluralize(overrideCount, "it", "them")}.`);
46
57
  }
47
- console.log(`- ${chalk.blueBright(String(uniqueAdvisories))} ${pluralize(uniqueAdvisories, "CVE")} matched overall.`);
48
- console.log(`- ${chalk.blue(String(fixable))} ${pluralize(fixable, "package")} include a fixed-version hint from OSV.`);
49
58
  }
50
59
  function printChainProofLines(targets) {
51
60
  for (const target of targets) {
@@ -71,7 +80,6 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
71
80
  const sharedParentUpgradeTableWidths = computeSharedParentUpgradeTableWidths(plan.sections);
72
81
  console.log("");
73
82
  console.log(chalk.bold.yellow("🛠 Suggested Fix Commands"));
74
- console.log(`${chalk.gray("Detected package manager:")} ${chalk.cyan(plan.packageManager)} ${chalk.gray(`(${plan.sourceLabel})`)}`);
75
83
  console.log(chalk.white(formatFixCommandSummary(plan)));
76
84
  for (const section of plan.sections) {
77
85
  console.log("");
@@ -110,9 +118,13 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
110
118
  if (plan.coveredFindingCount > 0) {
111
119
  console.log("");
112
120
  const coverage = plan.coveredFindingCount === plan.totalFindingCount
113
- ? chalk.gray(`Running all commands above should fix all ${plan.totalFindingCount} findings.`)
114
- : chalk.gray(`Running all commands above should fix ${chalk.white(String(plan.coveredFindingCount))} of ${chalk.white(String(plan.totalFindingCount))} findings.`);
121
+ ? chalk.gray(`Running all commands above should fix all ${plan.totalFindingCount} vulnerability ${pluralize(plan.totalFindingCount, "finding")}.`)
122
+ : chalk.gray(`Running all commands above should fix ${chalk.white(String(plan.coveredFindingCount))} of ${chalk.white(String(plan.totalFindingCount))} vulnerability findings.`);
115
123
  console.log(coverage);
124
+ const overrideCount = options?.overrideCount ?? 0;
125
+ if (overrideCount > 0) {
126
+ console.log(chalk.gray(`${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} also ${pluralize(overrideCount, "requires", "require")} attention - see the Override Hygiene section below.`));
127
+ }
116
128
  }
117
129
  }
118
130
  export function printSuggestedFixCommandSkips(findings, scanInput, options) {
@@ -259,20 +271,31 @@ export function printTable(findings, threshold, skippedKeys) {
259
271
  console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
260
272
  }
261
273
  }
262
- export function printFinalStatus(findings) {
274
+ export function printFinalStatus(findings, overrideCount = 0) {
263
275
  console.log("");
264
276
  console.log(chalk.gray("────────────────────────────────"));
277
+ const overrideSuffix = overrideCount > 0
278
+ ? `, ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")}`
279
+ : "";
265
280
  if (findings.length === 0) {
266
- console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
281
+ if (overrideCount > 0) {
282
+ console.log(chalk.yellow(`▲ Scan complete. No known vulnerabilities found, but ${overrideCount} override hygiene ${pluralize(overrideCount, "issue")} detected.`));
283
+ }
284
+ else {
285
+ console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
286
+ }
267
287
  return;
268
288
  }
269
289
  const criticalCount = findings.filter(f => f.severity === "critical").length;
270
290
  const highCount = findings.filter(f => f.severity === "high").length;
271
291
  if (criticalCount > 0 || highCount > 0) {
272
- console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
292
+ console.log(chalk.redBright(`✖ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found (${criticalCount} critical, ${highCount} high). Start with the priority fixes above.`));
273
293
  return;
274
294
  }
275
- console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "issue")} found. Review the suggested fix plan above.`));
295
+ console.log(chalk.yellow(`▲ Scan complete. ${findings.length} ${pluralize(findings.length, "vulnerability")}${overrideSuffix} found. Review the suggested fix plan above.`));
296
+ }
297
+ export function printOverrideHint() {
298
+ console.log("💡 " + chalk.gray("Tip:") + " override entries detected - run with --check-overrides to audit them for stale or broken overrides.");
276
299
  }
277
300
  function renderRow(cells, widths) {
278
301
  const formatted = cells.map((cell, i) => {
@@ -324,6 +347,9 @@ function wrapCell(value, width) {
324
347
  }
325
348
  export function printCompactOutput(findings, scanInput, options) {
326
349
  console.log("");
350
+ if (options?.packageManager) {
351
+ console.log(chalk.gray("Package manager: ") + options.packageManager);
352
+ }
327
353
  if (findings.length === 0) {
328
354
  console.log(chalk.greenBright("✔ Scan complete. No known vulnerabilities found."));
329
355
  console.log("");
@@ -1,13 +1,56 @@
1
1
  import fs from "node:fs";
2
- import YAML from "yaml";
2
+ import YAML, { YAMLParseError } from "yaml";
3
3
  import { looksLikeVersion, normalizeRawVersion } from "../utils/version.js";
4
4
  import { upsertPackage, markDevPackages } from "./utils.js";
5
5
  import { uniquePathArrays } from "../utils/array.js";
6
6
  const MAX_PATHS_PER_PACKAGE = 5;
7
7
  const MAX_PATH_DEPTH = 10;
8
+ function parsePnpmLockContent(content) {
9
+ try {
10
+ return YAML.parse(content);
11
+ }
12
+ catch (error) {
13
+ if (!(error instanceof YAMLParseError) || error.code !== "MULTIPLE_DOCS") {
14
+ throw error;
15
+ }
16
+ }
17
+ const documents = YAML.parseAllDocuments(content)
18
+ .map(doc => doc.toJSON())
19
+ .filter((doc) => !!doc && typeof doc === "object");
20
+ if (documents.length === 0) {
21
+ throw new Error("pnpm-lock.yaml is empty or unreadable");
22
+ }
23
+ if (documents.length === 1) {
24
+ return documents[0];
25
+ }
26
+ return selectBestPnpmLockDocument(documents);
27
+ }
28
+ function selectBestPnpmLockDocument(documents) {
29
+ const projectDoc = documents.find(doc => hasProjectImporterSections(doc));
30
+ if (projectDoc)
31
+ return projectDoc;
32
+ const withImporters = documents.find(doc => doc.importers && typeof doc.importers === "object");
33
+ if (withImporters)
34
+ return withImporters;
35
+ throw new Error("pnpm-lock.yaml contains multiple YAML documents but none could be identified as the project lockfile. Please open an issue at https://github.com/OWASP/cve-lite-cli/issues");
36
+ }
37
+ function hasProjectImporterSections(document) {
38
+ const importers = document.importers;
39
+ if (!importers || typeof importers !== "object")
40
+ return false;
41
+ for (const importer of Object.values(importers)) {
42
+ if (!importer || typeof importer !== "object")
43
+ continue;
44
+ const sections = importer;
45
+ if (sections.dependencies || sections.devDependencies || sections.optionalDependencies || sections.peerDependencies) {
46
+ return true;
47
+ }
48
+ }
49
+ return false;
50
+ }
8
51
  export function buildPnpmWorkspaceMap(filePath) {
9
52
  const content = fs.readFileSync(filePath, "utf8");
10
- const parsed = YAML.parse(content);
53
+ const parsed = parsePnpmLockContent(content);
11
54
  const importers = parsed?.importers ?? {};
12
55
  const map = new Map();
13
56
  for (const [importerPath, importer] of Object.entries(importers)) {
@@ -27,7 +70,7 @@ export function buildPnpmWorkspaceMap(filePath) {
27
70
  }
28
71
  export function loadFromPnpmLock(filePath, prodOnly) {
29
72
  const content = fs.readFileSync(filePath, "utf8");
30
- const parsed = YAML.parse(content);
73
+ const parsed = parsePnpmLockContent(content);
31
74
  const majorVersion = parseInt(String(parsed?.lockfileVersion ?? "0"), 10);
32
75
  return majorVersion >= 9 ? loadV9(parsed, prodOnly) : loadLegacy(parsed, prodOnly);
33
76
  }
@@ -1,7 +1,4 @@
1
1
  import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "../utils/version.js";
2
- function getNpmVersionCacheKey(packageName, version) {
3
- return `${packageName}@${version}`;
4
- }
5
2
  const packumentCache = new Map();
6
3
  const DEFAULT_NPM_REGISTRY_URL = "https://registry.npmjs.org";
7
4
  let registryDebugLog;
@@ -18,59 +15,60 @@ export function clearPackumentCache() {
18
15
  packumentCache.clear();
19
16
  }
20
17
  export async function fetchPackument(packageName) {
21
- if (packumentCache.has(packageName)) {
22
- return packumentCache.get(packageName) ?? null;
23
- }
24
- const url = `${DEFAULT_NPM_REGISTRY_URL}/${encodeURIComponent(packageName)
25
- .replace(/%40/g, "@")
26
- .replace(/%2F/g, "/")}`;
27
- const batchId = registryDebugLog ? nextRegistryBatchId() : "";
28
- const startedAt = registryDebugLog ? Date.now() : 0;
29
- if (registryDebugLog) {
30
- registryDebugLog("Registry fetch", { batchId, package: packageName, url });
31
- }
32
- try {
33
- const response = await fetch(url);
34
- if (!response.ok) {
18
+ const cached = packumentCache.get(packageName);
19
+ if (cached)
20
+ return cached;
21
+ const promise = (async () => {
22
+ const url = `${DEFAULT_NPM_REGISTRY_URL}/${encodeURIComponent(packageName)
23
+ .replace(/%40/g, "@")
24
+ .replace(/%2F/g, "/")}`;
25
+ const batchId = registryDebugLog ? nextRegistryBatchId() : "";
26
+ const startedAt = registryDebugLog ? Date.now() : 0;
27
+ if (registryDebugLog) {
28
+ registryDebugLog("Registry fetch", { batchId, package: packageName, url });
29
+ }
30
+ try {
31
+ const response = await fetch(url);
32
+ if (!response.ok) {
33
+ if (registryDebugLog) {
34
+ registryDebugLog("Registry response", {
35
+ batchId,
36
+ package: packageName,
37
+ status: response.status,
38
+ durationMs: Date.now() - startedAt,
39
+ versionsCount: 0,
40
+ });
41
+ }
42
+ return null;
43
+ }
44
+ const json = (await response.json());
35
45
  if (registryDebugLog) {
36
46
  registryDebugLog("Registry response", {
37
47
  batchId,
38
48
  package: packageName,
39
49
  status: response.status,
40
50
  durationMs: Date.now() - startedAt,
41
- versionsCount: 0,
51
+ versionsCount: Object.keys(json.versions ?? {}).length,
42
52
  });
43
53
  }
44
- packumentCache.set(packageName, null);
45
- return null;
54
+ return json;
46
55
  }
47
- const json = (await response.json());
48
- if (registryDebugLog) {
49
- registryDebugLog("Registry response", {
50
- batchId,
51
- package: packageName,
52
- status: response.status,
53
- durationMs: Date.now() - startedAt,
54
- versionsCount: Object.keys(json.versions ?? {}).length,
55
- });
56
- }
57
- packumentCache.set(packageName, json);
58
- return json;
59
- }
60
- catch (error) {
61
- if (registryDebugLog) {
62
- registryDebugLog("Registry fetch failed", {
63
- batchId,
64
- package: packageName,
65
- durationMs: Date.now() - startedAt,
66
- error: error instanceof Error
67
- ? { message: error.message, stack: error.stack }
68
- : String(error),
69
- });
56
+ catch (error) {
57
+ if (registryDebugLog) {
58
+ registryDebugLog("Registry fetch failed", {
59
+ batchId,
60
+ package: packageName,
61
+ durationMs: Date.now() - startedAt,
62
+ error: error instanceof Error
63
+ ? { message: error.message, stack: error.stack }
64
+ : String(error),
65
+ });
66
+ }
67
+ return null;
70
68
  }
71
- packumentCache.set(packageName, null);
72
- return null;
73
- }
69
+ })();
70
+ packumentCache.set(packageName, promise);
71
+ return promise;
74
72
  }
75
73
  export async function packageVersionExists(packageName, version) {
76
74
  const packument = await fetchPackument(packageName);
@@ -78,33 +76,6 @@ export async function packageVersionExists(packageName, version) {
78
76
  return null;
79
77
  return Boolean(packument.versions && version in packument.versions);
80
78
  }
81
- export async function resolveVersionPublishDate(packageName, version, options) {
82
- const cacheKey = getNpmVersionCacheKey(packageName, version);
83
- if (options?.cache && !options.noCache) {
84
- const cached = options.cache.npmVersionEntries?.[cacheKey];
85
- if (cached) {
86
- return { publishedAt: cached.publishedAt, cacheWritten: false };
87
- }
88
- }
89
- const packument = await fetchPackument(packageName);
90
- if (!packument)
91
- return { publishedAt: null, cacheWritten: false };
92
- const publishedAt = packument.time?.[version];
93
- if (!publishedAt)
94
- return { publishedAt: null, cacheWritten: false };
95
- let cacheWritten = false;
96
- if (options?.cache) {
97
- if (!options.cache.npmVersionEntries) {
98
- options.cache.npmVersionEntries = {};
99
- }
100
- options.cache.npmVersionEntries[cacheKey] = {
101
- publishedAt,
102
- cachedAt: new Date().toISOString(),
103
- };
104
- cacheWritten = true;
105
- }
106
- return { publishedAt, cacheWritten };
107
- }
108
79
  export async function resolvePublishedFixVersion(packageName, fixedVersionHint) {
109
80
  const packument = await fetchPackument(packageName);
110
81
  if (!packument) {
@@ -115,6 +86,7 @@ export async function resolvePublishedFixVersion(packageName, fixedVersionHint)
115
86
  candidatesChecked: 0,
116
87
  candidatesKnownVulnerable: 0,
117
88
  candidatesUnknownCoverage: 0,
89
+ publishedAt: null,
118
90
  };
119
91
  }
120
92
  const publishedVersions = Object.keys(packument.versions ?? {})
@@ -128,6 +100,7 @@ export async function resolvePublishedFixVersion(packageName, fixedVersionHint)
128
100
  candidatesChecked: 0,
129
101
  candidatesKnownVulnerable: 0,
130
102
  candidatesUnknownCoverage: 0,
103
+ publishedAt: packument.time?.[fixedVersionHint] ?? null,
131
104
  };
132
105
  }
133
106
  const nearestPublishedVersion = publishedVersions.find(version => compareVersions(version, fixedVersionHint) >= 0) ?? null;
@@ -139,6 +112,7 @@ export async function resolvePublishedFixVersion(packageName, fixedVersionHint)
139
112
  candidatesChecked: 0,
140
113
  candidatesKnownVulnerable: 0,
141
114
  candidatesUnknownCoverage: 0,
115
+ publishedAt: packument.time?.[nearestPublishedVersion] ?? null,
142
116
  };
143
117
  }
144
118
  return {
@@ -148,6 +122,7 @@ export async function resolvePublishedFixVersion(packageName, fixedVersionHint)
148
122
  candidatesChecked: 0,
149
123
  candidatesKnownVulnerable: 0,
150
124
  candidatesUnknownCoverage: 0,
125
+ publishedAt: null,
151
126
  };
152
127
  }
153
128
  export async function resolveLowestKnownNonVulnerableVersion(packageName, installedVersion, vulnerabilities) {
@@ -159,6 +134,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
159
134
  candidatesChecked: 0,
160
135
  candidatesKnownVulnerable: 0,
161
136
  candidatesUnknownCoverage: 0,
137
+ publishedAt: null,
162
138
  };
163
139
  }
164
140
  if (vulnerabilities.length === 0) {
@@ -169,6 +145,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
169
145
  candidatesChecked: 0,
170
146
  candidatesKnownVulnerable: 0,
171
147
  candidatesUnknownCoverage: 0,
148
+ publishedAt: null,
172
149
  };
173
150
  }
174
151
  const packument = await fetchPackument(packageName);
@@ -180,6 +157,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
180
157
  candidatesChecked: 0,
181
158
  candidatesKnownVulnerable: 0,
182
159
  candidatesUnknownCoverage: 0,
160
+ publishedAt: null,
183
161
  };
184
162
  }
185
163
  const candidates = Object.keys(packument.versions ?? {})
@@ -195,6 +173,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
195
173
  candidatesChecked: 0,
196
174
  candidatesKnownVulnerable: 0,
197
175
  candidatesUnknownCoverage: 0,
176
+ publishedAt: null,
198
177
  };
199
178
  }
200
179
  let candidatesChecked = 0;
@@ -231,6 +210,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
231
210
  candidatesChecked,
232
211
  candidatesKnownVulnerable,
233
212
  candidatesUnknownCoverage,
213
+ publishedAt: packument.time?.[candidate] ?? null,
234
214
  };
235
215
  }
236
216
  if (sawUnknownCoverage) {
@@ -241,6 +221,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
241
221
  candidatesChecked,
242
222
  candidatesKnownVulnerable,
243
223
  candidatesUnknownCoverage,
224
+ publishedAt: null,
244
225
  };
245
226
  }
246
227
  return {
@@ -250,6 +231,7 @@ export async function resolveLowestKnownNonVulnerableVersion(packageName, instal
250
231
  candidatesChecked,
251
232
  candidatesKnownVulnerable,
252
233
  candidatesUnknownCoverage,
234
+ publishedAt: null,
253
235
  };
254
236
  }
255
237
  function isVersionAffectedByVulnerability(packageName, version, vuln) {
@@ -6,9 +6,10 @@ import { sortFindingsForOutput } from "../output/formatters.js";
6
6
  import { normalizeSeverity } from "../osv/severity.js";
7
7
  import { selectFindingsForTable } from "../output/finding-display.js";
8
8
  import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
9
- import { readDirectDependencyNames } from "../utils/package-json.js";
9
+ import { readDirectDependencyNames, hasOverrideEntries } from "../utils/package-json.js";
10
10
  import { DEFAULT_SEARCH_DEPTH, severityOrder } from "../constants.js";
11
11
  import { printMultiFolderResults } from "../output/multi-folder-printer.js";
12
+ import { printOverrideHint } from "../output/printers.js";
12
13
  import { writeMultiFolderHtmlReport } from "../output/multi-folder-html-reporter.js";
13
14
  import { chalk } from "../utils/chalk.js";
14
15
  import { getCliVersion } from "../utils/version-info.js";
@@ -97,10 +98,19 @@ export async function handleMultiFolderScan(params) {
97
98
  else {
98
99
  printMultiFolderResults(results, params.options);
99
100
  if (params.options.checkOverrides) {
100
- const { renderOverrideFindings } = await import("../output/formatters.js");
101
+ const { renderOverrideFindings } = await import("../output/override-findings-terminal.js");
101
102
  for (const r of results) {
102
103
  process.stdout.write(`\n${chalk.bold.cyan(`📁 ${r.subfolder}/`)} ${chalk.gray("override hygiene")}\n`);
103
- console.log(renderOverrideFindings(r.overrideFindings));
104
+ console.log(renderOverrideFindings(r.overrideFindings, { verbose: !!params.options.verbose }));
105
+ }
106
+ }
107
+ if (!params.options.checkOverrides && !params.options.ratchet) {
108
+ for (const r of results) {
109
+ const subfolderPath = path.join(params.projectRoot, r.subfolder);
110
+ if (hasOverrideEntries(subfolderPath)) {
111
+ printOverrideHint();
112
+ break; // one hint is enough even if multiple subfolders have overrides
113
+ }
104
114
  }
105
115
  }
106
116
  }