cve-lite-cli 1.17.0 → 1.17.2

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/dist/cli/help.js CHANGED
@@ -31,7 +31,7 @@ export function printHelp() {
31
31
  " cve-lite install-skill",
32
32
  "",
33
33
  "Scan options:",
34
- " --json Print JSON output",
34
+ " --json Save scan results to a timestamped JSON file",
35
35
  " --report [dir] Generate an HTML report in [dir] (default: ./cve-report)",
36
36
  " --sarif Write SARIF 2.1.0 output to a timestamped .sarif file",
37
37
  " --cdx Write CycloneDX 1.4 SBOM to a timestamped .cdx.json file",
package/dist/index.js CHANGED
@@ -15,7 +15,7 @@ import { createSpinner } from "./output/spinner.js";
15
15
  import { buildSuggestedFixCommandPlan } from "./remediation/fix-commands.js";
16
16
  import { scanProjectForPackageUsage } from "./usage/scanner.js";
17
17
  import { getCliVersion } from "./utils/version-info.js";
18
- import { isLikelyBlockedAdvisoryRequestError } from "./utils/network.js";
18
+ import { isLikelyBlockedAdvisoryRequestError, isSslCertificateError, sslCertificateErrorHint, blockedAdvisoryRequestHint } from "./utils/network.js";
19
19
  import { logInfo, logWarn, printCacheSummary, sortFindingsForOutput } from "./output/formatters.js";
20
20
  import { buildReportData, writeHtmlReport } from "./output/html-reporter.js";
21
21
  import { writeOutputs } from "./output/write-outputs.js";
@@ -255,10 +255,15 @@ if (parsedArgs) {
255
255
  main().catch((error) => {
256
256
  const errorMessage = error instanceof Error ? error.message : String(error);
257
257
  console.error(chalk.red(`Error: ${errorMessage}`));
258
- if (isLikelyBlockedAdvisoryRequestError(errorMessage)) {
259
- console.error(chalk.yellow("Hint: Outbound access to the OSV API may be blocked or restricted in this environment."));
260
- console.error(chalk.gray("If that is expected, build the advisory DB on a machine with OSV access, then scan here with `--offline` or `--offline-db /path/to/advisories.db`."));
261
- console.error(chalk.gray("Command to build the DB on a network-allowed machine: `cve-lite advisories sync --output /path/to/advisories.db`"));
258
+ if (isSslCertificateError(errorMessage)) {
259
+ const [hint, ...rest] = sslCertificateErrorHint();
260
+ console.error(chalk.yellow(hint));
261
+ rest.forEach(line => console.error(chalk.gray(line)));
262
+ }
263
+ else if (isLikelyBlockedAdvisoryRequestError(errorMessage)) {
264
+ const [hint, ...rest] = blockedAdvisoryRequestHint();
265
+ console.error(chalk.yellow(hint));
266
+ rest.forEach(line => console.error(chalk.gray(line)));
262
267
  }
263
268
  process.exit(1);
264
269
  });
@@ -302,7 +307,7 @@ async function scanProject(params) {
302
307
  const minSeverity = normalizeSeverity(params.options.minSeverity || "medium");
303
308
  const tableFindings = params.options.all
304
309
  ? sorted
305
- : sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity]);
310
+ : sorted.filter(f => severityOrder[f.severity] >= severityOrder[minSeverity] || f.severity === "unknown");
306
311
  const suggestedFixCommands = buildSuggestedFixCommandPlan(sorted, params.scanInput, { offline });
307
312
  return {
308
313
  sorted,
@@ -26,7 +26,16 @@ export function formatRelationshipLabel(value) {
26
26
  return chalk.yellow(value);
27
27
  return chalk.gray(value);
28
28
  }
29
+ // MAL-* is the OSV prefix for malicious code advisories
30
+ function isMaliciousAdvisory(finding) {
31
+ return finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
32
+ }
29
33
  export function getRecommendedAction(finding) {
34
+ if (isMaliciousAdvisory(finding)) {
35
+ return finding.relationship === "direct"
36
+ ? "This package has a malicious code advisory. Remove it from your dependencies."
37
+ : "This package has a malicious code advisory. Upgrade or remove the parent package that pulls it in.";
38
+ }
30
39
  // Prefer the registry-validated target over the raw advisory hint when
31
40
  // available — they can disagree (the hint may not be published on npm or
32
41
  // may itself be vulnerable), and the validated target is what the fix
@@ -128,6 +137,11 @@ export function summarizeNextAction(finding) {
128
137
  // Prefer the registry-validated target over the raw advisory hint so this
129
138
  // line agrees with the fix-command table. See getRecommendedAction.
130
139
  const directTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
140
+ if (isMaliciousAdvisory(finding)) {
141
+ return finding.relationship === "direct"
142
+ ? "This package has a malicious code advisory. Remove it from your dependencies."
143
+ : "This package has a malicious code advisory. Upgrade or remove the parent package that pulls it in.";
144
+ }
131
145
  if (finding.relationship === "direct" && directTarget) {
132
146
  return `Upgrade ${finding.pkg.name} toward ${directTarget}.`;
133
147
  }
@@ -238,10 +238,10 @@ ${noticesHtml}
238
238
  <tr>
239
239
  <th style="width:32px"></th>
240
240
  <th onclick="sortBy('package')">Package <span class="sort-arrow">↕</span></th>
241
+ <th>Fix available</th>
241
242
  <th onclick="sortBy('severity')" class="sorted">Severity <span class="sort-arrow" style="color:#58a6ff">↓</span></th>
242
243
  <th onclick="sortBy('relationship')">Type <span class="sort-arrow">↕</span></th>
243
244
  <th>CVE / Advisory</th>
244
- <th>Fix available</th>
245
245
  </tr>
246
246
  </thead>
247
247
  <tbody id="findings-tbody">
@@ -324,7 +324,7 @@ function applyFilters() {
324
324
  function sortBy(col) {
325
325
  if (sortCol === col) { sortAsc = !sortAsc; } else { sortCol = col; sortAsc = col === 'package'; }
326
326
  document.querySelectorAll('.findings-table thead th').forEach(th => th.classList.remove('sorted'));
327
- const colIndex = ['', 'package', 'severity', 'relationship'].indexOf(col);
327
+ const colIndex = ['', 'package', '', 'severity', 'relationship'].indexOf(col);
328
328
  if (colIndex > 0) document.querySelectorAll('.findings-table thead th')[colIndex].classList.add('sorted');
329
329
 
330
330
  const tbody = document.getElementById('findings-tbody');
@@ -390,11 +390,14 @@ function renderFindingRow(finding, idx) {
390
390
  const cveLinks = finding.cves.length > 0
391
391
  ? finding.cves.map(advisoryLink).join(", ")
392
392
  : finding.vulnerabilities.map(v => advisoryLink(v.id)).join(", ");
393
+ const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
393
394
  const fixHtml = finding.validatedFirstFixedVersion
394
395
  ? `<span class="fix-hint">${escapeHtml(finding.validatedFirstFixedVersion)}</span>`
395
396
  : finding.firstFixedVersion
396
397
  ? `<span class="fix-hint">${escapeHtml(finding.firstFixedVersion)}</span>`
397
- : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
398
+ : isMalicious
399
+ ? `<span class="fix-hint none" title="Malicious code advisory — remove this package">⚠ Malicious</span>`
400
+ : `<span class="fix-hint none" title="No known fix — consider replacing this package">⚠ No fix</span>`;
398
401
  const depPathHtml = finding.dependencyPaths.length > 0
399
402
  ? finding.dependencyPaths[0].map((node, i, arr) => {
400
403
  const isLast = i === arr.length - 1;
@@ -415,10 +418,10 @@ function renderFindingRow(finding, idx) {
415
418
  return ` <tr id="row-${idx}" onclick="toggleRow(${idx})">
416
419
  <td><span class="expand-icon" id="icon-${idx}">▶</span></td>
417
420
  <td><div class="pkg-name">${escapeHtml(finding.package)}</div><div class="pkg-version">${escapeHtml(finding.version)}</div></td>
421
+ <td>${fixHtml}</td>
418
422
  <td><span class="sev-badge ${escapeHtml(finding.severity)}">${escapeHtml(finding.severity)}</span></td>
419
423
  <td><span class="rel-badge ${escapeHtml(finding.relationship)}">${escapeHtml(finding.relationship)}</span></td>
420
424
  <td>${cveLinks}</td>
421
- <td>${fixHtml}</td>
422
425
  </tr>
423
426
  <tr id="detail-${idx}" class="detail-row">
424
427
  <td colspan="6">
@@ -152,7 +152,8 @@ export function printTable(findings, threshold) {
152
152
  f.severity,
153
153
  f.relationship,
154
154
  usageText,
155
- f.firstFixedVersion ?? chalk.yellow("⚠ no fix"),
155
+ (f.validatedFirstFixedVersion ?? f.firstFixedVersion) ??
156
+ (f.vulnerabilities.some(v => v.id.startsWith("MAL-")) ? chalk.yellow("⚠ Malicious") : chalk.yellow("⚠ no fix")),
156
157
  f.vulnerabilities.map(v => v.id).join(", ")
157
158
  ];
158
159
  });
@@ -185,8 +186,19 @@ export function printTable(findings, threshold) {
185
186
  console.log(renderRow(decorated, widths));
186
187
  }
187
188
  console.log(line("└", "┴", "┘"));
189
+ const maliciousFindings = findings.filter(f => f.vulnerabilities.some(v => v.id.startsWith("MAL-")));
190
+ if (maliciousFindings.length > 0) {
191
+ console.log("");
192
+ console.log(chalk.bold.red("⚠ Malicious package advisory:"));
193
+ for (const f of maliciousFindings) {
194
+ const action = f.relationship === "direct"
195
+ ? "Remove it from your dependencies immediately."
196
+ : "Upgrade or remove the parent package that pulls it in.";
197
+ console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} — ${action}`));
198
+ }
199
+ }
188
200
  if (threshold) {
189
- console.log(chalk.gray("Tip: use --all to include low/unknown findings, or --min-severity high to focus only on urgent issues."));
201
+ console.log(chalk.gray("Tip: use --all to include low findings, or --min-severity high to focus only on urgent issues."));
190
202
  }
191
203
  }
192
204
  export function printFinalStatus(findings) {
@@ -263,9 +275,9 @@ export function printCompactOutput(findings, scanInput, options) {
263
275
  console.log("────────────────────────────────");
264
276
  console.log(chalk.bold("📦 Vulnerabilities found"));
265
277
  console.log("────────────────────────────────\n");
266
- // Get top 3 critical/high issues
278
+ // Get top 3 critical/high issues plus all unknown (malicious) findings
267
279
  const urgentFindings = findings
268
- .filter(f => f.severity === "critical" || f.severity === "high")
280
+ .filter(f => f.severity === "critical" || f.severity === "high" || f.severity === "unknown")
269
281
  .slice(0, 3);
270
282
  for (const finding of urgentFindings) {
271
283
  const sevLabel = finding.severity.toUpperCase().padEnd(8);
@@ -285,21 +297,29 @@ export function printCompactOutput(findings, scanInput, options) {
285
297
  }
286
298
  console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(finding.pkg.name)}@${finding.pkg.version}`);
287
299
  console.log(` ${typeLabel}${usageContext}`);
288
- if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
300
+ const isMalicious = finding.vulnerabilities.some(v => v.id.startsWith("MAL-"));
301
+ if (isMalicious) {
302
+ const action = finding.relationship === "direct"
303
+ ? "Remove this package from your dependencies immediately."
304
+ : "Upgrade or remove the parent package that pulls it in.";
305
+ console.log(` ${chalk.red(`⚠ Malicious: ${action}`)}`);
306
+ }
307
+ else if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
289
308
  console.log(` ${chalk.gray(`Fix: update ${finding.recommendedNpmTransitiveRemediation.package} within its current dependency range`)}`);
290
309
  }
291
310
  else if (finding.recommendedParentUpgrade) {
292
311
  console.log(` ${chalk.gray(`Fix: upgrade ${finding.recommendedParentUpgrade.package} to ${finding.recommendedParentUpgrade.targetVersion}`)}`);
293
312
  }
294
313
  else if (finding.firstFixedVersion) {
314
+ const displayFixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
295
315
  let action;
296
316
  if (finding.relationship === "direct") {
297
- action = `upgrade to ${finding.firstFixedVersion}`;
317
+ action = `upgrade to ${displayFixVersion}`;
298
318
  }
299
319
  else {
300
320
  const parent = getPrimaryParent(finding);
301
321
  action = parent
302
- ? `Upgrade ${parent} — check for release resolving ${finding.pkg.name} to ${finding.firstFixedVersion}+`
322
+ ? `Upgrade ${parent} — check for release resolving ${finding.pkg.name} to ${displayFixVersion}+`
303
323
  : `No dependency path found — inspect lockfile to identify which package pulls in ${finding.pkg.name}`;
304
324
  }
305
325
  console.log(` ${chalk.gray(`Fix: ${action}`)}`);
@@ -380,6 +400,17 @@ export function printCompactOutput(findings, scanInput, options) {
380
400
  console.log(`${chalk.cyan(String(direct))} ${chalk.white("direct")}` +
381
401
  `${chalk.gray(" · ")}` +
382
402
  `${chalk.cyan(String(transitive))} ${chalk.white("transitive")}`);
403
+ const maliciousCompact = findings.filter(f => f.vulnerabilities.some(v => v.id.startsWith("MAL-")));
404
+ if (maliciousCompact.length > 0 && !options?.all) {
405
+ console.log("");
406
+ console.log(chalk.bold.red("⚠ Malicious package advisory:"));
407
+ for (const f of maliciousCompact) {
408
+ const action = f.relationship === "direct"
409
+ ? "Remove it from your dependencies immediately."
410
+ : "Upgrade or remove the parent package that pulls it in.";
411
+ console.log(chalk.red(` · ${f.pkg.name}@${f.pkg.version} — ${action}`));
412
+ }
413
+ }
383
414
  if (options?.all) {
384
415
  printTable(findings, null);
385
416
  }
@@ -27,6 +27,7 @@ export const chalk = {
27
27
  green: (text) => paint(ansi.bold + ansi.green, text),
28
28
  magenta: (text) => paint(ansi.bold + ansi.magenta, text),
29
29
  blue: (text) => paint(ansi.bold + ansi.blue, text),
30
+ red: (text) => paint(ansi.bold + ansi.red, text),
30
31
  yellow: (text) => paint(ansi.bold + ansi.yellow, text),
31
32
  whiteBright: (text) => paint(ansi.bold + ansi.whiteBright, text)
32
33
  }),
@@ -1,3 +1,33 @@
1
+ export function sslCertificateErrorHint() {
2
+ return [
3
+ "Hint: SSL certificate error — your network may be using a corporate proxy that intercepts HTTPS traffic.",
4
+ "Fix 1 (recommended): trust your corporate CA certificate:",
5
+ " NODE_EXTRA_CA_CERTS=/path/to/corporate-ca.crt cve-lite .",
6
+ "Fix 2 (quick workaround, not recommended for production): disable TLS verification:",
7
+ " NODE_TLS_REJECT_UNAUTHORIZED=0 cve-lite .",
8
+ ];
9
+ }
10
+ export function blockedAdvisoryRequestHint() {
11
+ return [
12
+ "Hint: Outbound access to the OSV API may be blocked or restricted in this environment.",
13
+ "If that is expected, build the advisory DB on a machine with OSV access, then scan here with `--offline` or `--offline-db /path/to/advisories.db`.",
14
+ "Command to build the DB on a network-allowed machine: `cve-lite advisories sync --output /path/to/advisories.db`",
15
+ ];
16
+ }
17
+ export function isSslCertificateError(message) {
18
+ const normalized = message.toLowerCase();
19
+ return [
20
+ "self-signed certificate",
21
+ "self_signed_cert_in_chain",
22
+ "cert_untrusted",
23
+ "unable_to_verify_leaf_signature",
24
+ "depth_zero_self_signed_cert",
25
+ "certificate has expired",
26
+ "cert_has_expired",
27
+ "unable to verify the first certificate",
28
+ "certificate chain",
29
+ ].some(indicator => normalized.includes(indicator));
30
+ }
1
31
  export function isLikelyBlockedAdvisoryRequestError(message) {
2
32
  if (!message.includes("OSV")) {
3
33
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.17.0",
3
+ "version": "1.17.2",
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": {