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.
- package/dist/advisory/osv-advisory-source.js +3 -2
- package/dist/index.js +1 -1
- package/dist/utils/network.js +35 -13
- package/package.json +1 -1
|
@@ -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 =
|
|
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 =
|
|
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(
|
|
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)));
|
package/dist/utils/network.js
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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")) {
|