cve-lite-cli 1.22.0 → 1.23.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.
@@ -110,13 +110,8 @@ export async function syncOsvAdvisories(options = {}) {
110
110
  return { advisoryCount, dbPath, sourceUrl };
111
111
  }
112
112
  catch (error) {
113
- try {
114
- db.close();
115
- }
116
- finally {
117
- if (fs.existsSync(dbPath)) {
118
- fs.rmSync(dbPath, { force: true });
119
- }
113
+ if (fs.existsSync(dbPath)) {
114
+ fs.rmSync(dbPath, { force: true });
120
115
  }
121
116
  throw error;
122
117
  }
package/dist/constants.js CHANGED
@@ -12,6 +12,12 @@ export const NPM_PUBLIC_REGISTRY = "https://registry.npmjs.org/";
12
12
  export const MAL_PRIVATE_REGISTRY_MESSAGE = "This package has a MAL- advisory but resolved from a private registry - unverifiable whether this advisory applies to your artifact. Inspect the source manually.";
13
13
  export const MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE = "MAL- advisory could not be confirmed for this artifact.";
14
14
  export const MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE = "verify artifact source manually";
15
+ export const MAL_GIT_SOURCE_PINNED_MESSAGE = "Advisory targets registry packages. This package resolves from a git source pinned to a commit SHA — verify the repository and org are trusted.";
16
+ export const MAL_GIT_SOURCE_FLOATING_MESSAGE = "Advisory targets registry packages. This package resolves from a git source with a floating reference — verify the repository, org, and ref are safe.";
17
+ export const MAL_GIT_SOURCE_COMPACT_MESSAGE = "Git source — verify repository and org are trusted.";
18
+ export const MAL_GIT_SOURCE_LEGEND_MESSAGE = "verify repository and org are trusted";
19
+ export const MAL_GIT_SOURCE_PINNED_DISPLAY = "⚠ Git source (SHA-pinned)";
20
+ export const MAL_GIT_SOURCE_FLOATING_DISPLAY = "⚠ Git source (floating ref)";
15
21
  export const EXCLUDED_DIRS = new Set([
16
22
  ".git",
17
23
  "node_modules",
@@ -83,6 +83,15 @@ export function writeCycloneDxReport(allPackages, findings, plan, projectMeta) {
83
83
  const filename = `cve-lite-scan-${ts}.cdx.json`;
84
84
  const outputPath = path.join(process.cwd(), filename);
85
85
  const bom = buildCycloneDxBom(allPackages, findings, projectMeta, getCliVersion(), plan);
86
- fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
86
+ try {
87
+ fs.writeFileSync(outputPath, JSON.stringify(bom, null, 2));
88
+ }
89
+ catch (err) {
90
+ try {
91
+ fs.rmSync(outputPath, { force: true });
92
+ }
93
+ catch { }
94
+ throw new Error(`Failed to write CycloneDX report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
95
+ }
87
96
  return filename;
88
97
  }
@@ -1,6 +1,6 @@
1
1
  import { findSuggestedCommandForFinding } from "../remediation/fix-commands.js";
2
2
  import { chalk } from "../utils/chalk.js";
3
- import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE } from "../constants.js";
3
+ import { severityOrder, MAL_PRIVATE_REGISTRY_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, } from "../constants.js";
4
4
  import { loadCache } from "../osv/cache.js";
5
5
  import { inferSeverity } from "../osv/severity.js";
6
6
  import { getPrimaryParent } from "../utils/finding.js";
@@ -91,6 +91,14 @@ export function getRecommendedAction(finding) {
91
91
  return `No parent dependency was identified for ${finding.pkg.name} in the lockfile. Run \`npm ls ${finding.pkg.name}\` (or your package manager equivalent) to find which package pulls it in.`;
92
92
  }
93
93
  export function summarizeRisk(finding) {
94
+ if (finding.maliciousUnverifiable) {
95
+ return MAL_PRIVATE_REGISTRY_MESSAGE;
96
+ }
97
+ if (finding.maliciousGitSource) {
98
+ return finding.maliciousGitSourcePinned
99
+ ? MAL_GIT_SOURCE_PINNED_MESSAGE
100
+ : MAL_GIT_SOURCE_FLOATING_MESSAGE;
101
+ }
94
102
  let risk = "";
95
103
  if (finding.severity === "critical" && finding.relationship === "direct") {
96
104
  risk = "Critical direct dependency. Prioritize this first because the project controls it directly.";
@@ -206,6 +214,8 @@ export function serializeFinding(finding, plan) {
206
214
  dependencyPaths: finding.dependencyPaths,
207
215
  usage: finding.usage ?? null,
208
216
  maliciousUnverifiable: finding.maliciousUnverifiable ?? false,
217
+ maliciousGitSource: finding.maliciousGitSource ?? false,
218
+ maliciousGitSourcePinned: finding.maliciousGitSourcePinned ?? false,
209
219
  vulnerabilities: finding.vulnerabilities.map(v => ({
210
220
  id: v.id,
211
221
  aliases: v.aliases ?? [],
@@ -1,11 +1,19 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { spawn } from "node:child_process";
4
- import { serializeFinding } from "./formatters.js";
4
+ import { serializeFinding, summarizeNextAction, summarizeRisk } from "./formatters.js";
5
5
  import { LOGO_BASE64 } from "./logo-base64.js";
6
6
  import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
7
7
  import { isMajorVersionBump } from "../utils/version.js";
8
8
  import { pluralize } from "../utils/string.js";
9
+ import { MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY } from "../constants.js";
10
+ export function serializeHtmlFinding(finding, plan) {
11
+ return {
12
+ ...serializeFinding(finding, plan),
13
+ riskSummary: summarizeRisk(finding),
14
+ nextAction: summarizeNextAction(finding),
15
+ };
16
+ }
9
17
  export function buildReportData(params) {
10
18
  return {
11
19
  projectPath: params.projectPath,
@@ -14,7 +22,7 @@ export function buildReportData(params) {
14
22
  packageManager: params.packageManager,
15
23
  lockfileSource: params.lockfileSource,
16
24
  packageCount: params.packageCount,
17
- findings: params.findings.map(finding => serializeFinding(finding, params.suggestedFixCommands)),
25
+ findings: params.findings.map(finding => serializeHtmlFinding(finding, params.suggestedFixCommands)),
18
26
  suggestedFixCommands: params.suggestedFixCommands,
19
27
  notes: params.notes,
20
28
  warnings: params.warnings,
@@ -98,6 +106,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
98
106
  .sev-badge.low{background:#388bfd22;color:#388bfd;border:1px solid #388bfd66}
99
107
  .sev-badge.unknown{background:#8b949e22;color:#8b949e;border:1px solid #8b949e66}
100
108
  .badge-warning{display:inline-block;font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;padding:2px 8px;border-radius:4px;background:#e3b34122;color:#e3b341;border:1px solid #e3b34166}
109
+ .badge-git-source{background:#fb8c0022;color:#fb8c00;border:1px solid #fb8c0055;border-radius:4px;font-size:11px;padding:2px 6px}
101
110
  .rel-badge{font-size:11px;padding:2px 7px;border-radius:4px}
102
111
  .rel-badge.direct{color:#3fb950;background:#3fb95022}
103
112
  .rel-badge.transitive{color:#e3b341;background:#e3b34122}
@@ -115,6 +124,7 @@ button.header-link:hover{color:#58a6ff;border-color:#58a6ff}
115
124
  .expanded-inner{padding:16px 20px 20px 48px;display:flex;gap:32px}
116
125
  .detail-col{flex:1}
117
126
  .detail-col h4{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.4px;color:#8b949e;margin-bottom:8px}
127
+ .detail-col h4.detail-subheading{margin-top:14px}
118
128
  .detail-col p{font-size:12px;color:#8b949e;line-height:1.6}
119
129
  .dep-path{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
120
130
  .dep-node{font-size:11px;font-family:monospace;background:#161b22;border:1px solid #30363d;border-radius:4px;padding:2px 8px;color:#e6edf3}
@@ -414,9 +424,13 @@ export function renderFindingRow(finding, idx, skippedKeys) {
414
424
  ? `<span class="fix-hint">${escapeHtml(fixVersion)}</span>`
415
425
  : isMalicious && finding.maliciousUnverifiable
416
426
  ? `<span class="badge badge-warning" title="MAL- advisory found but package resolved from a private registry - may not apply to your artifact">Unverifiable (private source)</span>`
417
- : isMalicious
418
- ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
419
- : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
427
+ : isMalicious && finding.maliciousGitSource && finding.maliciousGitSourcePinned
428
+ ? `<span class="badge badge-git-source" title="MAL- advisory found but package resolves from a git source pinned to a commit SHA — verify the repository and org are trusted">${escapeHtml(MAL_GIT_SOURCE_PINNED_DISPLAY)}</span>`
429
+ : isMalicious && finding.maliciousGitSource
430
+ ? `<span class="badge badge-git-source" title="MAL- advisory found but package resolves from a git source with a floating reference — verify the repository, org, and ref are safe">${escapeHtml(MAL_GIT_SOURCE_FLOATING_DISPLAY)}</span>`
431
+ : isMalicious
432
+ ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
433
+ : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
420
434
  const depPathHtml = finding.dependencyPaths.length > 0
421
435
  ? finding.dependencyPaths[0].map((node, i, arr) => {
422
436
  const isLast = i === arr.length - 1;
@@ -457,6 +471,10 @@ export function renderFindingRow(finding, idx, skippedKeys) {
457
471
  <div class="detail-col">
458
472
  <h4>Recommended action</h4>
459
473
  ${recommendedActionHtml}
474
+ <h4 class="detail-subheading">Risk summary</h4>
475
+ <p>${escapeHtml(finding.riskSummary)}</p>
476
+ <h4 class="detail-subheading">Next action</h4>
477
+ <p>${escapeHtml(finding.nextAction)}</p>
460
478
  </div>
461
479
  </div>
462
480
  </td>
@@ -573,11 +591,28 @@ export function renderFixPlan(plan) {
573
591
  </div>`;
574
592
  }
575
593
  export async function writeHtmlReport(params) {
576
- fs.mkdirSync(params.outputDir, { recursive: true });
594
+ const dirExisted = fs.existsSync(params.outputDir);
595
+ try {
596
+ fs.mkdirSync(params.outputDir, { recursive: true });
597
+ }
598
+ catch (err) {
599
+ throw new Error(`Failed to create report directory ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
600
+ }
577
601
  const indexPath = path.join(params.outputDir, "index.html");
578
602
  const jsonPath = path.join(params.outputDir, "report.json");
579
- fs.writeFileSync(jsonPath, JSON.stringify(params.data, null, 2), "utf8");
580
- fs.writeFileSync(indexPath, renderHtmlReport(params.data), "utf8");
603
+ try {
604
+ fs.writeFileSync(jsonPath, JSON.stringify(params.data, null, 2), "utf8");
605
+ fs.writeFileSync(indexPath, renderHtmlReport(params.data), "utf8");
606
+ }
607
+ catch (err) {
608
+ if (!dirExisted) {
609
+ try {
610
+ fs.rmSync(params.outputDir, { recursive: true, force: true });
611
+ }
612
+ catch { }
613
+ }
614
+ throw new Error(`Failed to write HTML report to ${params.outputDir}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
615
+ }
581
616
  if (params.autoOpen) {
582
617
  openInBrowser(indexPath);
583
618
  }
@@ -1,9 +1,8 @@
1
1
  import fs from "node:fs";
2
2
  import path from "node:path";
3
- import { REPORT_STYLES, escapeHtml, renderFindingRow, renderFixPlan, openInBrowser } from "./html-reporter.js";
3
+ import { REPORT_STYLES, escapeHtml, openInBrowser, renderFindingRow, renderFixPlan, serializeHtmlFinding, } from "./html-reporter.js";
4
4
  import { LOGO_BASE64 } from "./logo-base64.js";
5
5
  import { OWASP_LOGO_BASE64 } from "./owasp-logo-base64.js";
6
- import { serializeFinding } from "./formatters.js";
7
6
  import { pluralize } from "../utils/string.js";
8
7
  function summaryCounts(results) {
9
8
  const counts = { critical: 0, high: 0, medium: 0, low: 0, unknown: 0, none: 0 };
@@ -97,7 +96,7 @@ export async function writeMultiFolderHtmlReport(params) {
97
96
  const totalCVEs = params.results.reduce((sum, r) => sum + r.sorted.reduce((s, f) => s + f.cveAliases.length, 0), 0);
98
97
  const folderCount = params.results.length;
99
98
  // Pre-serialize findings once per folder for both HTML rendering and JS filter/sort
100
- const allSerialized = params.results.map(r => r.sorted.map(f => serializeFinding(f, r.suggestedFixCommands)));
99
+ const allSerialized = params.results.map(r => r.sorted.map(f => serializeHtmlFinding(f, r.suggestedFixCommands)));
101
100
  // Compact per-folder findings for JavaScript (only fields needed for filter/sort/search)
102
101
  const folderFindingsJson = JSON.stringify(allSerialized.map(findings => findings.map(f => ({
103
102
  package: f.package,
@@ -5,7 +5,7 @@ import { getPrimaryParent } from "../utils/finding.js";
5
5
  import { countUniqueAdvisories, formatSeverityLabel, formatRelationshipLabel, formatRelLabel } from "./formatters.js";
6
6
  import { pluralize } from "../utils/string.js";
7
7
  import { selectFindingsForCompact } from "./finding-display.js";
8
- import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE } from "../constants.js";
8
+ 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";
9
9
  export function printSummary(findings, packageCount, scanInput) {
10
10
  if (findings.length === 0) {
11
11
  if (scanInput.mode === "manifest-fallback") {
@@ -168,6 +168,9 @@ export function printTable(findings, threshold, skippedKeys) {
168
168
  else if (f.maliciousUnverifiable) {
169
169
  fixedDisplay = chalk.yellow("⚠ Unverifiable (private source)");
170
170
  }
171
+ else if (f.maliciousGitSource) {
172
+ fixedDisplay = chalk.yellow(f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_DISPLAY : MAL_GIT_SOURCE_FLOATING_DISPLAY);
173
+ }
171
174
  else if (f.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
172
175
  fixedDisplay = chalk.yellow("⚠ Malicious");
173
176
  }
@@ -224,6 +227,11 @@ export function printTable(findings, threshold, skippedKeys) {
224
227
  if (f.maliciousUnverifiable) {
225
228
  console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${action}`));
226
229
  }
230
+ else if (f.maliciousGitSource) {
231
+ const msg = f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_MESSAGE : MAL_GIT_SOURCE_FLOATING_MESSAGE;
232
+ const url = f.pkg.resolvedUrl ? ` (${f.pkg.resolvedUrl})` : "";
233
+ console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version}${url} - ${msg}`));
234
+ }
227
235
  else {
228
236
  console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} - ${action}`));
229
237
  }
@@ -336,6 +344,10 @@ export function printCompactOutput(findings, scanInput, options) {
336
344
  if (finding.maliciousUnverifiable) {
337
345
  console.log(` ${chalk.yellow(`⚠ Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE}`)}`);
338
346
  }
347
+ else if (finding.maliciousGitSource) {
348
+ const url = finding.pkg.resolvedUrl ? ` Source: ${finding.pkg.resolvedUrl}` : "";
349
+ console.log(` ${chalk.yellow(`⚠ ${MAL_GIT_SOURCE_COMPACT_MESSAGE}${url}`)}`);
350
+ }
339
351
  else {
340
352
  const action = finding.relationship === "direct"
341
353
  ? "Remove this package from your dependencies immediately."
@@ -447,6 +459,9 @@ export function printCompactOutput(findings, scanInput, options) {
447
459
  if (f.maliciousUnverifiable) {
448
460
  console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE}`));
449
461
  }
462
+ else if (f.maliciousGitSource) {
463
+ console.log(chalk.yellow(` · ${f.pkg.name}@${f.pkg.version} - Git source - ${MAL_GIT_SOURCE_LEGEND_MESSAGE}`));
464
+ }
450
465
  else {
451
466
  const action = f.relationship === "direct"
452
467
  ? "Remove it from your dependencies immediately."
@@ -81,6 +81,15 @@ export function writeSarifReport(findings, lockfileUri, plan) {
81
81
  const filename = `cve-lite-scan-${ts}.sarif`;
82
82
  const outputPath = path.join(process.cwd(), filename);
83
83
  const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan);
84
- fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
84
+ try {
85
+ fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
86
+ }
87
+ catch (err) {
88
+ try {
89
+ fs.rmSync(outputPath, { force: true });
90
+ }
91
+ catch { }
92
+ throw new Error(`Failed to write SARIF report to ${outputPath}: ${err instanceof Error ? err.message : String(err)}`, { cause: err });
93
+ }
85
94
  return filename;
86
95
  }
@@ -32,8 +32,9 @@ function extractChildDependencyNames(depMeta) {
32
32
  function collectBunPaths(rootDepNames, childDepsByPackageName, map, packageNameToVersion) {
33
33
  const queue = rootDepNames.map(name => ({ name, path: ["project"] }));
34
34
  const visitedStates = new Set();
35
- while (queue.length > 0) {
36
- const current = queue.shift();
35
+ let head = 0;
36
+ while (head < queue.length) {
37
+ const current = queue[head++];
37
38
  const nextPath = [...current.path, current.name];
38
39
  const version = packageNameToVersion.get(current.name);
39
40
  const stateKey = `${current.name}@${version ?? ""}>${nextPath.join(">")}`;
@@ -160,8 +160,9 @@ function loadV9(parsed, prodOnly) {
160
160
  function collectPnpmPaths(rootDeps, graph, map, parsePackageKey) {
161
161
  const queue = rootDeps.map(dep => ({ key: dep, path: ["project"] }));
162
162
  const visitedStates = new Set();
163
- while (queue.length > 0) {
164
- const current = queue.shift();
163
+ let head = 0;
164
+ while (head < queue.length) {
165
+ const current = queue[head++];
165
166
  const ref = parsePackageKey(current.key);
166
167
  if (!ref)
167
168
  continue;
@@ -86,8 +86,9 @@ function parseYarnPackageKey(key) {
86
86
  function collectYarnPaths(rootDepKeys, graph, map) {
87
87
  const queue = rootDepKeys.map(key => ({ key, path: ["project"] }));
88
88
  const visitedStates = new Set();
89
- while (queue.length > 0) {
90
- const current = queue.shift();
89
+ let head = 0;
90
+ while (head < queue.length) {
91
+ const current = queue[head++];
91
92
  const ref = parseYarnPackageKey(current.key);
92
93
  if (!ref)
93
94
  continue;
package/dist/scanner.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { chunk, unique, runWithConcurrency } from "./utils/array.js";
2
- import { isPrivateRegistrySource } from "./utils/advisory.js";
2
+ import { isPrivateRegistrySource, isGitSource, hasCommitShaPinning } from "./utils/advisory.js";
3
3
  import { compareVersions, isPreReleaseVersion, looksLikeVersion } from "./utils/version.js";
4
4
  import { loadCache, saveCache, isEntryStale } from "./osv/cache.js";
5
5
  import { maxSeverity } from "./osv/severity.js";
@@ -9,7 +9,7 @@ import { LocalAdvisorySource } from "./advisory/local-advisory-source.js";
9
9
  import { LocalAdvisoryDatabase } from "./advisory/local-db.js";
10
10
  import { ADVISORY_DB_STALE_AFTER_MS, getDefaultAdvisoryDbPath } from "./advisory/osv-sync.js";
11
11
  import { resolveRecommendedParentUpgrade } from "./remediation/parent-upgrade.js";
12
- import { configureNpmRegistryDebug, resolveLowestKnownNonVulnerableVersion, resolvePublishedFixVersion, } from "./remediation/npm-registry.js";
12
+ import { configureNpmRegistryDebug, fetchPackument, resolveLowestKnownNonVulnerableVersion, resolvePublishedFixVersion, } from "./remediation/npm-registry.js";
13
13
  import { countBySeverity } from "./utils/severity.js";
14
14
  import { resolveNpmTransitiveRemediation, resolveTransitiveRemediationViaRegistry } from "./remediation/npm-transitive-resolution.js";
15
15
  import { loadNpmLockGraph } from "./parsers/npm-lock-graph.js";
@@ -142,25 +142,37 @@ export async function scanPackages(packages, batchSize, options, context, debugL
142
142
  const ids = [...idSet];
143
143
  const detailSpinner = createSpinner("Fetching vulnerability details...", options);
144
144
  try {
145
- for (let i = 0; i < ids.length; i++) {
146
- const id = ids[i];
147
- detailSpinner.update(`Fetching vulnerability details ${i + 1}/${ids.length}...`);
145
+ // cache.entries holds OsvVuln detail records. Unlike cache.queryEntries (which has a
146
+ // 30-minute staleness check applied earlier in this function), detail records have no
147
+ // expiry — they are considered valid for the lifetime of the cache file. The check below
148
+ // is therefore a simple presence check, not a staleness check. This is intentional and
149
+ // matches the original behaviour. Fetches run concurrently because there is no ordering
150
+ // dependency between CVE ID detail requests.
151
+ const uncachedIds = [];
152
+ for (const id of ids) {
148
153
  if (id in cache.entries) {
149
154
  const cached = cache.entries[id];
150
- if (cached) {
155
+ if (cached)
151
156
  vulnMap.set(id, cached);
152
- }
153
- continue;
154
- }
155
- try {
156
- const detail = await advisorySource.getVuln(id);
157
- vulnMap.set(id, detail);
158
- cache.entries[id] = detail;
159
157
  }
160
- catch (_error) {
161
- cache.entries[id] = null;
158
+ else {
159
+ uncachedIds.push(id);
162
160
  }
163
161
  }
162
+ // Fetch all uncached IDs concurrently
163
+ if (uncachedIds.length > 0) {
164
+ detailSpinner.update(`Fetching ${uncachedIds.length} vulnerability details...`);
165
+ await runWithConcurrency(uncachedIds, 10, async (id) => {
166
+ try {
167
+ const detail = await advisorySource.getVuln(id);
168
+ vulnMap.set(id, detail);
169
+ cache.entries[id] = detail;
170
+ }
171
+ catch {
172
+ cache.entries[id] = null;
173
+ }
174
+ });
175
+ }
164
176
  detailSpinner.succeed(`Loaded ${ids.length} vulnerability detail ${pluralize(ids.length, "record")}`);
165
177
  }
166
178
  catch (error) {
@@ -172,9 +184,7 @@ export async function scanPackages(packages, batchSize, options, context, debugL
172
184
  const ids = [...idSet];
173
185
  const detailSpinner = createSpinner("Loading local advisory details...", options);
174
186
  try {
175
- for (let i = 0; i < ids.length; i++) {
176
- const id = ids[i];
177
- detailSpinner.update(`Loading local advisory details ${i + 1}/${ids.length}...`);
187
+ await runWithConcurrency(ids, 10, async (id) => {
178
188
  try {
179
189
  const detail = await advisorySource.getVuln(id);
180
190
  vulnMap.set(id, detail);
@@ -182,7 +192,7 @@ export async function scanPackages(packages, batchSize, options, context, debugL
182
192
  catch {
183
193
  // ignore missing local records so scans remain resilient to partial DB state
184
194
  }
185
- }
195
+ });
186
196
  detailSpinner.succeed(`Loaded ${ids.length} local advisory detail ${pluralize(ids.length, "record")}`);
187
197
  }
188
198
  catch (error) {
@@ -219,9 +229,14 @@ export async function scanPackages(packages, batchSize, options, context, debugL
219
229
  };
220
230
  });
221
231
  for (const finding of findings) {
222
- if (finding.vulnerabilities.some(v => v.id.startsWith("MAL-")) &&
223
- isPrivateRegistrySource(finding.pkg)) {
224
- finding.maliciousUnverifiable = true;
232
+ if (finding.vulnerabilities.some(v => v.id.startsWith("MAL-"))) {
233
+ if (isGitSource(finding.pkg)) {
234
+ finding.maliciousGitSource = true;
235
+ finding.maliciousGitSourcePinned = hasCommitShaPinning(finding.pkg);
236
+ }
237
+ else if (isPrivateRegistrySource(finding.pkg)) {
238
+ finding.maliciousUnverifiable = true;
239
+ }
225
240
  }
226
241
  }
227
242
  const npmTransitiveGraph = context?.scanSource === "package-lock" && context.scanFilePath
@@ -297,6 +312,29 @@ export async function scanPackages(packages, batchSize, options, context, debugL
297
312
  updateAnalysisProgress("validating fix target for", `${finding.pkg.name}@${finding.pkg.version}`);
298
313
  }, log);
299
314
  }
315
+ // Pre-warm packument cache for all packages needed in the remediation loop.
316
+ // This converts N sequential registry round-trips into one concurrent burst,
317
+ // after which the loop runs entirely from the in-memory packument cache.
318
+ if (!offline) {
319
+ const packumentsToPrewarm = new Set();
320
+ for (const finding of findings) {
321
+ if (finding.relationship !== "transitive")
322
+ continue;
323
+ packumentsToPrewarm.add(finding.pkg.name);
324
+ const paths = finding.dependencyPaths;
325
+ if (paths.length > 0 && paths[0].length >= 2) {
326
+ packumentsToPrewarm.add(paths[0][paths[0].length - 2]);
327
+ }
328
+ }
329
+ if (packumentsToPrewarm.size > 0) {
330
+ await runWithConcurrency([...packumentsToPrewarm], 8, async (name) => {
331
+ try {
332
+ await fetchPackument(name);
333
+ }
334
+ catch { /* loop will handle missing packuments */ }
335
+ });
336
+ }
337
+ }
300
338
  for (const finding of findings) {
301
339
  if (finding.relationship !== "transitive")
302
340
  continue;
@@ -4,3 +4,20 @@ export function isPrivateRegistrySource(pkg) {
4
4
  pkg.resolvedUrl !== "" &&
5
5
  !pkg.resolvedUrl.startsWith(NPM_PUBLIC_REGISTRY));
6
6
  }
7
+ const GIT_SOURCE_PREFIXES = [
8
+ "https://codeload.github.com/",
9
+ "https://github.com/",
10
+ "https://gitlab.com/",
11
+ "https://bitbucket.org/",
12
+ "git+https://",
13
+ "git+ssh://",
14
+ "git://",
15
+ ];
16
+ export function isGitSource(pkg) {
17
+ return (pkg.resolvedUrl !== undefined &&
18
+ pkg.resolvedUrl !== "" &&
19
+ GIT_SOURCE_PREFIXES.some(prefix => pkg.resolvedUrl.startsWith(prefix)));
20
+ }
21
+ export function hasCommitShaPinning(pkg) {
22
+ return pkg.resolvedUrl !== undefined && /[0-9a-f]{40}/i.test(pkg.resolvedUrl);
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.22.0",
3
+ "version": "1.23.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": {
@@ -25,7 +25,7 @@
25
25
  "@types/node": "^24.0.0",
26
26
  "jest": "^30.3.0",
27
27
  "ts-jest": "^29.4.9",
28
- "tsx": "^4.19.2",
28
+ "tsx": "^4.22.0",
29
29
  "typescript": "^5.8.2"
30
30
  },
31
31
  "keywords": [
@@ -44,6 +44,14 @@
44
44
  "engines": {
45
45
  "node": ">=18"
46
46
  },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/OWASP/cve-lite-cli.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/OWASP/cve-lite-cli/issues"
53
+ },
54
+ "homepage": "https://github.com/OWASP/cve-lite-cli#readme",
47
55
  "files": [
48
56
  "dist",
49
57
  "README.md",