cve-lite-cli 1.27.0 → 1.29.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.
- package/README.md +45 -3
- package/dist/advisory/osv-advisory-source.js +5 -3
- package/dist/cli/advisories-init.js +24 -0
- package/dist/cli/args.js +30 -0
- package/dist/cli/help.js +6 -2
- package/dist/cli/validate.js +6 -0
- package/dist/constants.js +1 -0
- package/dist/index.js +67 -7
- package/dist/maintenance/dm001-maintenance-risk.js +122 -0
- package/dist/maintenance/score.js +51 -0
- package/dist/maintenance/types.js +1 -0
- package/dist/osv/cache.js +49 -50
- package/dist/output/formatters.js +10 -4
- package/dist/output/html-reporter.js +163 -14
- package/dist/output/maintenance-findings-html.js +60 -0
- package/dist/output/maintenance-findings-json.js +3 -0
- package/dist/output/maintenance-findings-sarif.js +58 -0
- package/dist/output/maintenance-terminal.js +138 -0
- package/dist/output/multi-folder-html-reporter.js +61 -5
- package/dist/output/multi-folder-printer.js +11 -2
- package/dist/output/override-findings-html.js +22 -32
- package/dist/output/printers.js +95 -22
- package/dist/output/sarif.js +23 -7
- package/dist/output/spinner.js +5 -0
- package/dist/output/write-outputs.js +7 -2
- package/dist/parsers/bun-lock.js +47 -7
- package/dist/parsers/npm-lock-graph.js +90 -12
- package/dist/parsers/pnpm-lock.js +42 -6
- package/dist/parsers/utils.js +0 -15
- package/dist/parsers/yarn-lock.js +140 -58
- package/dist/remediation/cooldown.js +74 -0
- package/dist/remediation/fix-commands.js +42 -2
- package/dist/remediation/npm-registry.js +70 -42
- package/dist/remediation/parent-upgrade.js +114 -18
- package/dist/scan/completeness.js +49 -0
- package/dist/scan/multi-folder-scan.js +193 -13
- package/dist/scanner.js +284 -165
- package/dist/usage/scanner.js +12 -2
- package/dist/utils/network.js +66 -0
- package/dist/utils/vuln.js +16 -0
- package/package.json +2 -2
package/dist/utils/network.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import https from "node:https";
|
|
2
|
+
import fs from "node:fs";
|
|
3
|
+
import { rootCertificates } from "node:tls";
|
|
1
4
|
export function extractErrorMessage(error) {
|
|
2
5
|
if (!(error instanceof Error))
|
|
3
6
|
return String(error);
|
|
@@ -151,3 +154,66 @@ export function getNetworkErrorHint(error, errorMessage) {
|
|
|
151
154
|
return blockedAdvisoryRequestHint();
|
|
152
155
|
return fetchErrorCaCertHint();
|
|
153
156
|
}
|
|
157
|
+
export function createCertAwareFetch(caCertPath) {
|
|
158
|
+
// Lazily create the agent on first use so that callers can be wired up before
|
|
159
|
+
// the cert path is validated. validateOptions() in index.ts catches invalid
|
|
160
|
+
// paths before any actual request is made.
|
|
161
|
+
let agent;
|
|
162
|
+
function getAgent() {
|
|
163
|
+
if (!agent) {
|
|
164
|
+
const ca = fs.readFileSync(caCertPath);
|
|
165
|
+
agent = new https.Agent({ ca: [...rootCertificates, ca] });
|
|
166
|
+
}
|
|
167
|
+
return agent;
|
|
168
|
+
}
|
|
169
|
+
return async (input, init) => {
|
|
170
|
+
const url = typeof input === "string"
|
|
171
|
+
? input
|
|
172
|
+
: input instanceof URL
|
|
173
|
+
? input.href
|
|
174
|
+
: input.url;
|
|
175
|
+
if (!url.startsWith("https://")) {
|
|
176
|
+
return fetch(input, init);
|
|
177
|
+
}
|
|
178
|
+
return new Promise((resolve, reject) => {
|
|
179
|
+
const parsed = new URL(url);
|
|
180
|
+
const method = (init?.method ?? "GET").toUpperCase();
|
|
181
|
+
const rawHeaders = init?.headers;
|
|
182
|
+
const headers = rawHeaders
|
|
183
|
+
? Object.fromEntries(new Headers(rawHeaders).entries())
|
|
184
|
+
: {};
|
|
185
|
+
const reqOptions = {
|
|
186
|
+
hostname: parsed.hostname,
|
|
187
|
+
port: parsed.port ? parseInt(parsed.port, 10) : 443,
|
|
188
|
+
path: parsed.pathname + parsed.search,
|
|
189
|
+
method,
|
|
190
|
+
headers,
|
|
191
|
+
agent: getAgent(),
|
|
192
|
+
};
|
|
193
|
+
const req = https.request(reqOptions, res => {
|
|
194
|
+
const chunks = [];
|
|
195
|
+
res.on("data", (chunk) => chunks.push(chunk));
|
|
196
|
+
res.on("end", () => {
|
|
197
|
+
const body = Buffer.concat(chunks);
|
|
198
|
+
const responseHeaders = {};
|
|
199
|
+
for (const [key, val] of Object.entries(res.headers)) {
|
|
200
|
+
if (val !== undefined) {
|
|
201
|
+
responseHeaders[key] = Array.isArray(val) ? val.join(", ") : val;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
resolve(new Response(body, {
|
|
205
|
+
status: res.statusCode ?? 200,
|
|
206
|
+
statusText: res.statusMessage ?? "",
|
|
207
|
+
headers: responseHeaders,
|
|
208
|
+
}));
|
|
209
|
+
});
|
|
210
|
+
res.on("error", reject);
|
|
211
|
+
});
|
|
212
|
+
req.on("error", reject);
|
|
213
|
+
if (init?.body != null) {
|
|
214
|
+
req.write(init.body);
|
|
215
|
+
}
|
|
216
|
+
req.end();
|
|
217
|
+
});
|
|
218
|
+
};
|
|
219
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { unique } from "./array.js";
|
|
2
|
+
// MAL-* is the OSV prefix for malicious code advisories. Guarded because OSV
|
|
3
|
+
// records are external data - the declared `string` type on OsvVuln.id does
|
|
4
|
+
// not guarantee a malformed advisory record cannot have a missing/non-string id.
|
|
5
|
+
export function isMaliciousVulnId(id) {
|
|
6
|
+
return typeof id === "string" && id.startsWith("MAL-");
|
|
7
|
+
}
|
|
8
|
+
export function hasMaliciousAdvisory(vulns) {
|
|
9
|
+
return vulns.some(v => isMaliciousVulnId(v.id));
|
|
10
|
+
}
|
|
11
|
+
// Guards against non-string alias elements from malformed OSV records - a
|
|
12
|
+
// malformed record with a null/undefined/non-string entry in `aliases` must
|
|
13
|
+
// not abort the whole scan.
|
|
14
|
+
export function extractCveAliases(vulns) {
|
|
15
|
+
return unique(vulns.flatMap(v => (v.aliases ?? []).filter((a) => typeof a === "string" && a.startsWith("CVE-"))));
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cve-lite-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.29.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": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@types/better-sqlite3": "^7.6.13",
|
|
29
29
|
"@types/jest": "^30.0.0",
|
|
30
30
|
"@types/node": "^24.0.0",
|
|
31
|
-
"jest": "^30.4.
|
|
31
|
+
"jest": "^30.4.2",
|
|
32
32
|
"ts-jest": "^29.4.9",
|
|
33
33
|
"tsx": "^4.22.0",
|
|
34
34
|
"typescript": "^5.8.2"
|