cve-lite-cli 1.31.0 → 1.33.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 +18 -15
- package/dist/advisory/npm-advisory-source.js +77 -0
- package/dist/cli/args.js +21 -0
- package/dist/cli/help.js +4 -0
- package/dist/epss/client.js +26 -0
- package/dist/index.js +32 -2
- package/dist/licenses/license-check.js +137 -0
- package/dist/licenses/types.js +1 -0
- package/dist/osv/cache.js +19 -8
- package/dist/output/formatters.js +4 -0
- package/dist/output/html-reporter.js +86 -5
- package/dist/output/license-findings-html.js +63 -0
- package/dist/output/license-findings-json.js +10 -0
- package/dist/output/license-findings-sarif.js +64 -0
- package/dist/output/license-terminal.js +35 -0
- package/dist/output/multi-folder-html-reporter.js +16 -8
- package/dist/output/printers.js +69 -14
- package/dist/output/sarif.js +10 -3
- package/dist/output/write-outputs.js +9 -2
- package/dist/remediation/parent-upgrade.js +8 -1
- package/dist/scan/completeness.js +6 -0
- package/dist/scan/multi-folder-scan.js +41 -6
- package/dist/scanner.js +75 -4
- package/dist/utils/priority-signal.js +40 -0
- package/package.json +1 -1
package/dist/output/sarif.js
CHANGED
|
@@ -7,6 +7,7 @@ import { severityToSarifLevel } from "../utils/severity.js";
|
|
|
7
7
|
import { sarifFingerprintHash } from "../utils/sarif.js";
|
|
8
8
|
import { buildOverrideSarifComponent, buildOverrideSarifResults } from "./override-findings-sarif.js";
|
|
9
9
|
import { buildMaintenanceSarifComponent, buildMaintenanceSarifResults } from "./maintenance-findings-sarif.js";
|
|
10
|
+
import { buildLicenseSarifComponent, buildLicenseSarifResults } from "./license-findings-sarif.js";
|
|
10
11
|
const SARIF_SCHEMA = "https://docs.oasis-open.org/sarif/sarif/v2.1.0/errata01/os/schemas/sarif-schema-2.1.0.json";
|
|
11
12
|
const LOCKFILE_NAMES = {
|
|
12
13
|
"package-lock": "package-lock.json",
|
|
@@ -77,7 +78,7 @@ export function deriveLockfileUri(scanInput) {
|
|
|
77
78
|
return path.basename(scanInput.filePath);
|
|
78
79
|
return LOCKFILE_NAMES[scanInput.source] ?? "lockfile";
|
|
79
80
|
}
|
|
80
|
-
export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings) {
|
|
81
|
+
export function buildSarifOutput(findings, lockfileUri, version, plan, overrideFindings, maintenanceFindings, licenseFindings) {
|
|
81
82
|
const ruleMap = new Map();
|
|
82
83
|
const ruleIndexMap = new Map();
|
|
83
84
|
const results = [];
|
|
@@ -135,17 +136,23 @@ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideF
|
|
|
135
136
|
}
|
|
136
137
|
const hasOverrides = overrideFindings != null && overrideFindings.length > 0;
|
|
137
138
|
const hasMaintenance = maintenanceFindings != null && maintenanceFindings.length > 0;
|
|
139
|
+
const hasLicense = licenseFindings != null && licenseFindings.length > 0;
|
|
138
140
|
const extensions = [
|
|
139
141
|
...(hasOverrides ? [buildOverrideSarifComponent()] : []),
|
|
140
142
|
...(hasMaintenance ? [buildMaintenanceSarifComponent()] : []),
|
|
143
|
+
...(hasLicense ? [buildLicenseSarifComponent()] : []),
|
|
141
144
|
];
|
|
142
145
|
const maintenanceExtensionIndex = hasOverrides ? 1 : 0;
|
|
146
|
+
const licenseExtensionIndex = (hasOverrides ? 1 : 0) + (hasMaintenance ? 1 : 0);
|
|
143
147
|
const allResults = [
|
|
144
148
|
...results,
|
|
145
149
|
...(hasOverrides ? buildOverrideSarifResults(overrideFindings) : []),
|
|
146
150
|
...(hasMaintenance
|
|
147
151
|
? buildMaintenanceSarifResults(maintenanceFindings, lockfileUri, maintenanceExtensionIndex)
|
|
148
152
|
: []),
|
|
153
|
+
...(hasLicense
|
|
154
|
+
? buildLicenseSarifResults(licenseFindings, lockfileUri, licenseExtensionIndex)
|
|
155
|
+
: []),
|
|
149
156
|
];
|
|
150
157
|
return {
|
|
151
158
|
$schema: SARIF_SCHEMA,
|
|
@@ -169,11 +176,11 @@ export function buildSarifOutput(findings, lockfileUri, version, plan, overrideF
|
|
|
169
176
|
],
|
|
170
177
|
};
|
|
171
178
|
}
|
|
172
|
-
export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings) {
|
|
179
|
+
export function writeSarifReport(findings, lockfileUri, plan, overrideFindings, maintenanceFindings, licenseFindings) {
|
|
173
180
|
const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
174
181
|
const filename = `cve-lite-scan-${ts}.sarif`;
|
|
175
182
|
const outputPath = path.join(process.cwd(), filename);
|
|
176
|
-
const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings);
|
|
183
|
+
const sarif = buildSarifOutput(findings, lockfileUri, getCliVersion(), plan, overrideFindings, maintenanceFindings, licenseFindings);
|
|
177
184
|
try {
|
|
178
185
|
fs.writeFileSync(outputPath, JSON.stringify(sarif, null, 2));
|
|
179
186
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from "node:fs";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { chalk } from "../utils/chalk.js";
|
|
4
|
+
import { serializeLicenseFindings } from "./license-findings-json.js";
|
|
4
5
|
import { serializeFinding } from "./formatters.js";
|
|
5
6
|
import { writeSarifReport, deriveLockfileUri } from "./sarif.js";
|
|
6
7
|
import { writeCycloneDxReport } from "./cyclonedx.js";
|
|
@@ -46,13 +47,19 @@ export async function writeOutputs(options, scanState, scanInput, projectPath) {
|
|
|
46
47
|
};
|
|
47
48
|
const overridePayload = overrideFindingsToJson(scanState.overrideFindings ?? []);
|
|
48
49
|
const maintenancePayload = maintenanceFindingsToJson(scanState.maintenanceFindings ?? []);
|
|
49
|
-
const
|
|
50
|
+
const licensePayload = scanState.licenseFindings && scanState.licenseFindings.length > 0
|
|
51
|
+
? {
|
|
52
|
+
licenseFindings: serializeLicenseFindings(scanState.licenseFindings),
|
|
53
|
+
...(scanState.licenseLimitedToDirectOnly ? { licenseLimitedToDirectOnly: true } : {}),
|
|
54
|
+
}
|
|
55
|
+
: {};
|
|
56
|
+
const combined = { ...payload, ...overridePayload, ...maintenancePayload, ...licensePayload };
|
|
50
57
|
fs.writeFileSync(jsonOutputPath, JSON.stringify(combined, null, 2));
|
|
51
58
|
console.log(`${chalk.gray("JSON saved to")} ${chalk.cyan(jsonFilename)}`);
|
|
52
59
|
}
|
|
53
60
|
if (options.sarif) {
|
|
54
61
|
const lockfileUri = deriveLockfileUri(scanInput);
|
|
55
|
-
const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings, scanState.maintenanceFindings);
|
|
62
|
+
const sarifFilename = writeSarifReport(scanState.sorted, lockfileUri, scanState.suggestedFixCommands, scanState.overrideFindings, scanState.maintenanceFindings, scanState.licenseFindings);
|
|
56
63
|
console.log(`${chalk.gray("SARIF report written to")} ${chalk.cyan(sarifFilename)}`);
|
|
57
64
|
}
|
|
58
65
|
if (options.cdx) {
|
|
@@ -79,7 +79,14 @@ function resolveDirectParentContext(viaPath, packages, directDependencyNames, pa
|
|
|
79
79
|
const directParentName = directParentCandidates[0];
|
|
80
80
|
if (!directParentName)
|
|
81
81
|
return null;
|
|
82
|
-
|
|
82
|
+
// Path-based lookup disambiguates when the same package name is installed at
|
|
83
|
+
// multiple versions (e.g. eslint@9.36.0 at root AND eslint@6.14.0 nested).
|
|
84
|
+
// A name-keyed Map (last-write-wins) would return an arbitrary version, making
|
|
85
|
+
// directParentVersion wrong and potentially producing downgrade suggestions.
|
|
86
|
+
const directParentIdx = viaPath.indexOf(directParentName);
|
|
87
|
+
const directParentPathPrefix = viaPath.slice(0, directParentIdx + 1);
|
|
88
|
+
const directParent = findPackageAlongPath(packages, directParentName, directParentPathPrefix) ??
|
|
89
|
+
findDirectDependency(packages, directParentName, directDependencyNames, packagesByName);
|
|
83
90
|
if (!directParent)
|
|
84
91
|
return null;
|
|
85
92
|
return { directParentName, immediateParentName, directParent };
|
|
@@ -47,3 +47,9 @@ export function aggregateMultiFolderCompleteness(results) {
|
|
|
47
47
|
}
|
|
48
48
|
return { complete: deduped.size === 0, diagnostics: [...deduped.values()] };
|
|
49
49
|
}
|
|
50
|
+
export function shouldFailForIncompleteScan(completeness, policy) {
|
|
51
|
+
if (policy !== "error") {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
return getCompletenessImpact(completeness).hasDetectionGap;
|
|
55
|
+
}
|
|
@@ -18,10 +18,12 @@ import { getCliVersion } from "../utils/version-info.js";
|
|
|
18
18
|
import { buildOverrideContext, audit } from "../overrides/index.js";
|
|
19
19
|
import { NULL_AUDIT_LOG } from "../audit-log/index.js";
|
|
20
20
|
import { detectDM001 } from "../maintenance/dm001-maintenance-risk.js";
|
|
21
|
+
import { detectLicenseIssues } from "../licenses/license-check.js";
|
|
22
|
+
import { renderLicenseFindings } from "../output/license-terminal.js";
|
|
21
23
|
import { reachesFailOn } from "../utils/severity.js";
|
|
22
24
|
import { readBaseline, writeBaseline, filterNewFindings, ratchetOutcome } from "../utils/baseline.js";
|
|
23
25
|
import { pluralize } from "../utils/string.js";
|
|
24
|
-
import { aggregateMultiFolderCompleteness, formatDiagnosticMessage, getCompletenessImpact, } from "./completeness.js";
|
|
26
|
+
import { aggregateMultiFolderCompleteness, formatDiagnosticMessage, getCompletenessImpact, shouldFailForIncompleteScan, } from "./completeness.js";
|
|
25
27
|
import { scanProjectForPackageUsage } from "../usage/scanner.js";
|
|
26
28
|
export async function runMultiFolderScan(params) {
|
|
27
29
|
const searchDepth = Math.max(0, Number(params.options.searchDepth || DEFAULT_SEARCH_DEPTH));
|
|
@@ -96,6 +98,20 @@ export async function runMultiFolderScan(params) {
|
|
|
96
98
|
const directDependencies = scanInput.packages.filter(p => directDependencyNames?.has(p.name));
|
|
97
99
|
maintenanceFindings = await detectDM001(sorted, directDependencies, offline);
|
|
98
100
|
}
|
|
101
|
+
let licenseFindings = [];
|
|
102
|
+
let licenseLimitedToDirectOnly = false;
|
|
103
|
+
if (params.options.checkLicenses && !params.options.ratchet) {
|
|
104
|
+
const directDeps = scanInput.packages.filter(p => directDependencyNames?.has(p.name));
|
|
105
|
+
const isNpm = scanInput.source === "package-lock" || scanInput.source === "npm-shrinkwrap";
|
|
106
|
+
const licenseResult = await detectLicenseIssues({
|
|
107
|
+
lockfilePath: scanInput.filePath,
|
|
108
|
+
directDeps,
|
|
109
|
+
isNpm,
|
|
110
|
+
isOffline: offline,
|
|
111
|
+
});
|
|
112
|
+
licenseFindings = licenseResult.findings;
|
|
113
|
+
licenseLimitedToDirectOnly = licenseResult.limitedToDirectOnly;
|
|
114
|
+
}
|
|
99
115
|
results.push({
|
|
100
116
|
subfolder,
|
|
101
117
|
scanInput,
|
|
@@ -108,6 +124,8 @@ export async function runMultiFolderScan(params) {
|
|
|
108
124
|
completeness,
|
|
109
125
|
overrideFindings,
|
|
110
126
|
maintenanceFindings,
|
|
127
|
+
licenseFindings,
|
|
128
|
+
licenseLimitedToDirectOnly,
|
|
111
129
|
suppressedCount,
|
|
112
130
|
});
|
|
113
131
|
}
|
|
@@ -229,19 +247,19 @@ export async function handleMultiFolderScan(params) {
|
|
|
229
247
|
if (params.options.ratchet) {
|
|
230
248
|
return handleMultiFolderRatchet(results, params.projectRoot, params.options);
|
|
231
249
|
}
|
|
250
|
+
const aggregatedCompleteness = aggregateMultiFolderCompleteness(results);
|
|
232
251
|
if (params.options.json) {
|
|
233
252
|
// Match single-folder writeOutputs: timestamped file in cwd, not stdout dump.
|
|
234
253
|
// Help text and CI both treat --json as "save a JSON file".
|
|
235
254
|
const allFindings = results.flatMap(r => r.sorted.map(f => ({ ...serializeFinding(f, r.suggestedFixCommands), subfolder: r.subfolder })));
|
|
236
|
-
const completeness = aggregateMultiFolderCompleteness(results);
|
|
237
255
|
const payload = {
|
|
238
256
|
multiFolder: true,
|
|
239
257
|
projectPath: params.projectRoot,
|
|
240
258
|
folders: results.map(r => r.subfolder),
|
|
241
259
|
findingCount: allFindings.length,
|
|
242
|
-
status:
|
|
243
|
-
complete:
|
|
244
|
-
diagnostics:
|
|
260
|
+
status: aggregatedCompleteness.complete ? "ok" : "partial",
|
|
261
|
+
complete: aggregatedCompleteness.complete,
|
|
262
|
+
diagnostics: aggregatedCompleteness.diagnostics,
|
|
245
263
|
findings: allFindings,
|
|
246
264
|
...(params.options.checkOverrides
|
|
247
265
|
? {
|
|
@@ -253,6 +271,11 @@ export async function handleMultiFolderScan(params) {
|
|
|
253
271
|
maintenanceFindings: results.flatMap(r => r.maintenanceFindings.map(f => ({ ...f, subfolder: r.subfolder }))),
|
|
254
272
|
}
|
|
255
273
|
: {}),
|
|
274
|
+
...(params.options.checkLicenses
|
|
275
|
+
? {
|
|
276
|
+
licenseFindings: results.flatMap(r => r.licenseFindings.map(f => ({ ...f, subfolder: r.subfolder }))),
|
|
277
|
+
}
|
|
278
|
+
: {}),
|
|
256
279
|
scannedAt: new Date().toISOString(),
|
|
257
280
|
};
|
|
258
281
|
const ts = new Date().toISOString().replace(/[:.]/g, "-").slice(0, 19);
|
|
@@ -277,6 +300,12 @@ export async function handleMultiFolderScan(params) {
|
|
|
277
300
|
console.log(renderMaintenanceFindings(r.maintenanceFindings, { verbose: !!params.options.verbose }));
|
|
278
301
|
}
|
|
279
302
|
}
|
|
303
|
+
if (params.options.checkLicenses) {
|
|
304
|
+
for (const r of results) {
|
|
305
|
+
process.stdout.write(`\n${chalk.bold.cyan(`📁 ${r.subfolder}/`)} ${chalk.gray("license issues")}\n`);
|
|
306
|
+
console.log(renderLicenseFindings(r.licenseFindings, { limitedToDirectOnly: r.licenseLimitedToDirectOnly }));
|
|
307
|
+
}
|
|
308
|
+
}
|
|
280
309
|
if (!params.options.checkOverrides && !params.options.ratchet) {
|
|
281
310
|
for (const r of results) {
|
|
282
311
|
const subfolderPath = path.join(params.projectRoot, r.subfolder);
|
|
@@ -300,6 +329,7 @@ export async function handleMultiFolderScan(params) {
|
|
|
300
329
|
// flag so empty panels render when the check ran with no hits.
|
|
301
330
|
includeOverrides: !!params.options.checkOverrides,
|
|
302
331
|
includeMaintenance: !!params.options.checkMaintenance,
|
|
332
|
+
includeLicenses: !!params.options.checkLicenses,
|
|
303
333
|
});
|
|
304
334
|
console.log(`${chalk.gray("Report:")} ${chalk.cyan(reportPath)}`);
|
|
305
335
|
}
|
|
@@ -313,7 +343,12 @@ export async function handleMultiFolderScan(params) {
|
|
|
313
343
|
const shouldFail = allSorted.some(f => severityOrder[f.severity] >= severityOrder[failLevel]) ||
|
|
314
344
|
reachesFailOn(allOverrideFindings, params.options.failOn) ||
|
|
315
345
|
reachesFailOn(allMaintenanceFindings, params.options.failOn);
|
|
316
|
-
const
|
|
346
|
+
const incompleteFailure = shouldFailForIncompleteScan(aggregatedCompleteness, params.options.incompletePolicy);
|
|
347
|
+
const exitCode = incompleteFailure
|
|
348
|
+
? EXIT_ERROR
|
|
349
|
+
: shouldFail
|
|
350
|
+
? EXIT_FINDINGS
|
|
351
|
+
: EXIT_OK;
|
|
317
352
|
auditLog.emit({
|
|
318
353
|
ts: new Date(scanFinishedAt).toISOString(),
|
|
319
354
|
type: "scan.finished",
|
package/dist/scanner.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { fetchEpssScores } from "./epss/client.js";
|
|
1
2
|
import { chunk, runWithConcurrency } from "./utils/array.js";
|
|
2
3
|
import { isPrivateRegistrySource, isGitSource, hasCommitShaPinning } from "./utils/advisory.js";
|
|
3
4
|
import { extractCveAliases, hasMaliciousAdvisory } from "./utils/vuln.js";
|
|
@@ -7,6 +8,7 @@ import { maxSeverity } from "./osv/severity.js";
|
|
|
7
8
|
import { createSpinner } from "./output/spinner.js";
|
|
8
9
|
import { OsvAdvisorySource } from "./advisory/osv-advisory-source.js";
|
|
9
10
|
import { LocalAdvisorySource } from "./advisory/local-advisory-source.js";
|
|
11
|
+
import { queryNpmAdvisoryGaps } from "./advisory/npm-advisory-source.js";
|
|
10
12
|
import { LocalAdvisoryDatabase } from "./advisory/local-db.js";
|
|
11
13
|
import { ADVISORY_DB_STALE_AFTER_MS, getDefaultAdvisoryDbPath } from "./advisory/osv-sync.js";
|
|
12
14
|
import { resolveRecommendedParentUpgrade } from "./remediation/parent-upgrade.js";
|
|
@@ -41,7 +43,7 @@ export function createAdvisorySource(options) {
|
|
|
41
43
|
offline: false,
|
|
42
44
|
sourceLabel: options?.osvUrl
|
|
43
45
|
? `custom OSV endpoint (${options.osvUrl})`
|
|
44
|
-
: "OSV (https://api.osv.dev)",
|
|
46
|
+
: "OSV + npm registry advisory (https://api.osv.dev)",
|
|
45
47
|
advisoryDbMetadata: null,
|
|
46
48
|
advisoryDbIsStale: false,
|
|
47
49
|
cleanup: () => { },
|
|
@@ -162,8 +164,56 @@ export async function scanPackages(packages, batchSize, options, context, debugL
|
|
|
162
164
|
}
|
|
163
165
|
spinner.succeed("Loaded package matches from the local advisory database");
|
|
164
166
|
}
|
|
165
|
-
const idSet = new Set(results.flatMap(r => r.vulnIds));
|
|
166
167
|
const vulnMap = new Map();
|
|
168
|
+
// npm advisory supplemental pass: query all npm packages and surface vulns that OSV missed
|
|
169
|
+
const existingVulnIds = new Set(results.flatMap(r => r.vulnIds));
|
|
170
|
+
const allNpmPkgs = packages.filter(pkg => pkg.ecosystem === "npm");
|
|
171
|
+
let wroteNpmAdvisoryEntries = false;
|
|
172
|
+
if (allNpmPkgs.length > 0 && !offline) {
|
|
173
|
+
const nowMs = Date.now();
|
|
174
|
+
const cachedAt = new Date(nowMs).toISOString();
|
|
175
|
+
const uncachedForNpm = [];
|
|
176
|
+
for (const pkg of allNpmPkgs) {
|
|
177
|
+
const key = getPackageCacheKey(pkg);
|
|
178
|
+
const cached = cache.npmAdvisoryEntries[key];
|
|
179
|
+
if (cached && !isEntryStale(cached, nowMs)) {
|
|
180
|
+
const newCachedVulnIds = cached.vulnIds.filter(id => !existingVulnIds.has(id));
|
|
181
|
+
if (newCachedVulnIds.length > 0) {
|
|
182
|
+
results.push({ pkg, vulnIds: newCachedVulnIds });
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
uncachedForNpm.push(pkg);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (uncachedForNpm.length > 0) {
|
|
190
|
+
const npmResults = await queryNpmAdvisoryGaps(uncachedForNpm, {
|
|
191
|
+
fetchImpl,
|
|
192
|
+
offline,
|
|
193
|
+
debugLog: log,
|
|
194
|
+
});
|
|
195
|
+
for (const pkg of uncachedForNpm) {
|
|
196
|
+
const found = npmResults.find(r => r.pkg.name === pkg.name && r.pkg.version === pkg.version);
|
|
197
|
+
const vulns = found?.vulns ?? [];
|
|
198
|
+
const vulnIds = vulns.map(v => v.id);
|
|
199
|
+
// Store the full list in cache (for cache correctness on future scans),
|
|
200
|
+
// but only add genuinely new vulns to results - ones OSV did not already surface
|
|
201
|
+
cache.npmAdvisoryEntries[getPackageCacheKey(pkg)] = { vulnIds, cachedAt };
|
|
202
|
+
const newVulns = vulns.filter(v => !existingVulnIds.has(v.id));
|
|
203
|
+
const newVulnIds = newVulns.map(v => v.id);
|
|
204
|
+
if (newVulns.length > 0) {
|
|
205
|
+
results.push({ pkg, vulnIds: newVulnIds });
|
|
206
|
+
for (const vuln of newVulns) {
|
|
207
|
+
vulnMap.set(vuln.id, vuln);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Persist npm advisory cache entries for clean projects that won't trigger
|
|
212
|
+
// the idSet.size > 0 saveCache path below
|
|
213
|
+
wroteNpmAdvisoryEntries = true;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const idSet = new Set(results.flatMap(r => r.vulnIds));
|
|
167
217
|
const transientDetailIds = new Set();
|
|
168
218
|
const offlineMissingDetailIds = new Set();
|
|
169
219
|
const confirmedMissingDetailIds = new Set();
|
|
@@ -186,7 +236,9 @@ export async function scanPackages(packages, batchSize, options, context, debugL
|
|
|
186
236
|
}
|
|
187
237
|
}
|
|
188
238
|
else {
|
|
189
|
-
|
|
239
|
+
if (!vulnMap.has(id)) {
|
|
240
|
+
uncachedIds.push(id);
|
|
241
|
+
}
|
|
190
242
|
}
|
|
191
243
|
}
|
|
192
244
|
if (uncachedIds.length > 0) {
|
|
@@ -255,7 +307,7 @@ export async function scanPackages(packages, batchSize, options, context, debugL
|
|
|
255
307
|
throw error;
|
|
256
308
|
}
|
|
257
309
|
}
|
|
258
|
-
if (!offline && idSet.size > 0) {
|
|
310
|
+
if (!offline && (idSet.size > 0 || wroteNpmAdvisoryEntries)) {
|
|
259
311
|
saveCache(cache, cacheDirOverride, options.debug ? log : undefined);
|
|
260
312
|
}
|
|
261
313
|
const findings = results.map(result => {
|
|
@@ -576,6 +628,9 @@ export async function scanPackages(packages, batchSize, options, context, debugL
|
|
|
576
628
|
complete: diagnostics.length === 0,
|
|
577
629
|
diagnostics,
|
|
578
630
|
};
|
|
631
|
+
if (!offline) {
|
|
632
|
+
await enrichWithEpssScores(findings, fetchImpl);
|
|
633
|
+
}
|
|
579
634
|
return { findings, completeness };
|
|
580
635
|
}
|
|
581
636
|
catch (error) {
|
|
@@ -792,6 +847,22 @@ function buildCompletenessDiagnostics(params) {
|
|
|
792
847
|
addDiagnostic("CHAIN_RESOLUTION_FAILURE", params.chainResolutionFailureCount, "remediation");
|
|
793
848
|
return diagnostics;
|
|
794
849
|
}
|
|
850
|
+
async function enrichWithEpssScores(findings, fetchImpl) {
|
|
851
|
+
const allCves = [...new Set(findings.flatMap(f => f.cveAliases))];
|
|
852
|
+
if (allCves.length === 0)
|
|
853
|
+
return;
|
|
854
|
+
const epssMap = await fetchEpssScores(allCves, fetchImpl);
|
|
855
|
+
if (epssMap.size === 0)
|
|
856
|
+
return;
|
|
857
|
+
for (const finding of findings) {
|
|
858
|
+
const scores = finding.cveAliases.flatMap(cve => {
|
|
859
|
+
const score = epssMap.get(cve.toUpperCase());
|
|
860
|
+
return score ? [score] : [];
|
|
861
|
+
});
|
|
862
|
+
if (scores.length > 0)
|
|
863
|
+
finding.epssScores = scores;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
795
866
|
export function buildCoverageNotes(scanInput, offline) {
|
|
796
867
|
const notes = [
|
|
797
868
|
"CVE Lite CLI checks package versions against OSV advisories. It does not prove exploitability or runtime reachability.",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
const EPSS_HIGH_EXPLOITATION_THRESHOLD = 0.90;
|
|
2
|
+
export const PRIORITY_SIGNAL_LABELS = {
|
|
3
|
+
fix_now: "⚡ Fix Now",
|
|
4
|
+
fix_soon: "Fix Soon",
|
|
5
|
+
monitor: "Monitor",
|
|
6
|
+
low_priority: "Low Priority",
|
|
7
|
+
};
|
|
8
|
+
// Emoji-free labels for fixed-width table columns (⚡ is 2-wide in terminals but 1 in JS string.length, breaking padEnd alignment)
|
|
9
|
+
export const PRIORITY_SIGNAL_TABLE_LABELS = {
|
|
10
|
+
fix_now: "Fix Now",
|
|
11
|
+
fix_soon: "Fix Soon",
|
|
12
|
+
monitor: "Monitor",
|
|
13
|
+
low_priority: "Low Priority",
|
|
14
|
+
};
|
|
15
|
+
export const PRIORITY_SIGNAL_DESCRIPTIONS = {
|
|
16
|
+
fix_now: "Critical or high severity + top 10% EPSS exploitation likelihood",
|
|
17
|
+
fix_soon: "Critical or high severity, EPSS not top 10%",
|
|
18
|
+
monitor: "Medium or lower severity, EPSS top 10% - watch closely",
|
|
19
|
+
low_priority: "Medium or lower severity, EPSS not top 10%",
|
|
20
|
+
};
|
|
21
|
+
export const PRIORITY_SIGNAL_LEGEND_DESCRIPTIONS = {
|
|
22
|
+
fix_now: "Critical or high severity and EPSS top 10% - high impact, actively exploited class of CVE",
|
|
23
|
+
fix_soon: "Critical or high severity, EPSS not top 10% - high impact but exploitation is less common",
|
|
24
|
+
monitor: "Medium or lower, EPSS top 10% - lower impact but exploitation is active",
|
|
25
|
+
low_priority: "Medium or lower, EPSS not top 10% - address in normal maintenance cycle",
|
|
26
|
+
};
|
|
27
|
+
export function computePrioritySignal(severity, epssScores) {
|
|
28
|
+
if (!epssScores || epssScores.length === 0)
|
|
29
|
+
return null;
|
|
30
|
+
const highImpact = severity === "critical" || severity === "high";
|
|
31
|
+
const maxPercentile = Math.max(...epssScores.map(e => e.percentile));
|
|
32
|
+
const highExploitation = maxPercentile >= EPSS_HIGH_EXPLOITATION_THRESHOLD;
|
|
33
|
+
if (highImpact && highExploitation)
|
|
34
|
+
return "fix_now";
|
|
35
|
+
if (highImpact)
|
|
36
|
+
return "fix_soon";
|
|
37
|
+
if (highExploitation)
|
|
38
|
+
return "monitor";
|
|
39
|
+
return "low_priority";
|
|
40
|
+
}
|