cve-lite-cli 1.17.2 → 1.17.3

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.
@@ -1,3 +1,4 @@
1
+ import { extractErrorMessage } from "../utils/network.js";
1
2
  export class OsvAdvisorySource {
2
3
  baseUrl;
3
4
  constructor(baseUrl = "https://api.osv.dev") {
@@ -31,7 +32,7 @@ export class OsvAdvisorySource {
31
32
  }));
32
33
  }
33
34
  catch (error) {
34
- const message = error instanceof Error ? error.message : String(error);
35
+ const message = extractErrorMessage(error);
35
36
  throw new Error(`OSV batch query failed for ${this.baseUrl}: ${message}`);
36
37
  }
37
38
  }
@@ -44,7 +45,7 @@ export class OsvAdvisorySource {
44
45
  return response.json();
45
46
  }
46
47
  catch (error) {
47
- const message = error instanceof Error ? error.message : String(error);
48
+ const message = extractErrorMessage(error);
48
49
  throw new Error(`OSV vuln fetch failed for ${id} via ${this.baseUrl}: ${message}`);
49
50
  }
50
51
  }
package/dist/index.js CHANGED
@@ -255,7 +255,7 @@ 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 (isSslCertificateError(errorMessage)) {
258
+ if (isSslCertificateError(error)) {
259
259
  const [hint, ...rest] = sslCertificateErrorHint();
260
260
  console.error(chalk.yellow(hint));
261
261
  rest.forEach(line => console.error(chalk.gray(line)));
@@ -1,3 +1,11 @@
1
+ export function extractErrorMessage(error) {
2
+ if (!(error instanceof Error))
3
+ return String(error);
4
+ const cause = error.cause;
5
+ if (cause instanceof Error)
6
+ return `${error.message}: ${extractErrorMessage(cause)}`;
7
+ return error.message;
8
+ }
1
9
  export function sslCertificateErrorHint() {
2
10
  return [
3
11
  "Hint: SSL certificate error — your network may be using a corporate proxy that intercepts HTTPS traffic.",
@@ -14,19 +22,33 @@ export function blockedAdvisoryRequestHint() {
14
22
  "Command to build the DB on a network-allowed machine: `cve-lite advisories sync --output /path/to/advisories.db`",
15
23
  ];
16
24
  }
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));
25
+ const SSL_ERROR_CODES = new Set([
26
+ "SELF_SIGNED_CERT_IN_CHAIN",
27
+ "CERT_UNTRUSTED",
28
+ "UNABLE_TO_VERIFY_LEAF_SIGNATURE",
29
+ "DEPTH_ZERO_SELF_SIGNED_CERT",
30
+ "CERT_HAS_EXPIRED",
31
+ "UNABLE_TO_GET_ISSUER_CERT_LOCALLY",
32
+ "ERR_TLS_CERT_ALTNAME_INVALID",
33
+ ]);
34
+ const SSL_ERROR_MESSAGE_FRAGMENTS = [
35
+ "self signed certificate",
36
+ "self-signed certificate",
37
+ "certificate chain",
38
+ "certificate has expired",
39
+ "unable to verify the first certificate",
40
+ ];
41
+ export function isSslCertificateError(error) {
42
+ if (!(error instanceof Error))
43
+ return false;
44
+ const code = error.code;
45
+ if (code && SSL_ERROR_CODES.has(code))
46
+ return true;
47
+ const cause = error.cause;
48
+ if (cause)
49
+ return isSslCertificateError(cause);
50
+ const normalized = error.message.toLowerCase();
51
+ return SSL_ERROR_MESSAGE_FRAGMENTS.some(f => normalized.includes(f));
30
52
  }
31
53
  export function isLikelyBlockedAdvisoryRequestError(message) {
32
54
  if (!message.includes("OSV")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cve-lite-cli",
3
- "version": "1.17.2",
3
+ "version": "1.17.3",
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": {