cve-lite-cli 1.41.4 → 1.42.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 +22 -19
- package/dist/advisory/detail-resolution.js +62 -0
- package/dist/advisory/local-db.js +90 -15
- package/dist/advisory/osv-advisory-source.js +113 -62
- package/dist/advisory/osv-sync.js +18 -16
- package/dist/advisory/sqlite.js +50 -0
- package/dist/audit-log/ndjson-writer.js +6 -3
- package/dist/audit-log/open-error.js +22 -0
- package/dist/cli/args.js +145 -87
- package/dist/cli/flags.js +2 -0
- package/dist/cli/help.js +6 -2
- package/dist/cli/overrides.js +5 -2
- package/dist/cli/validate.js +45 -5
- package/dist/constants.js +10 -0
- package/dist/index.js +15 -6
- package/dist/licenses/license-check.js +17 -4
- package/dist/osv/cache.js +7 -13
- package/dist/output/cyclonedx.js +57 -18
- package/dist/output/finding-display.js +8 -1
- package/dist/output/formatters.js +52 -11
- package/dist/output/html-reporter.js +40 -8
- package/dist/output/override-findings-terminal.js +21 -13
- package/dist/output/printers.js +185 -76
- package/dist/output/sarif.js +182 -16
- package/dist/output/spdx.js +15 -1
- package/dist/output/write-outputs.js +29 -20
- package/dist/overrides/context-builder.js +1 -7
- package/dist/overrides/detectors/oa005-nested-ineffective.js +6 -1
- package/dist/overrides/detectors/oa008-materialized.js +33 -10
- package/dist/overrides/detectors/oa009-stale-floor.js +2 -2
- package/dist/overrides/detectors/oa010-vulnerable-floor.js +19 -13
- package/dist/overrides/detectors/phantom-utils.js +2 -10
- package/dist/overrides/fixer.js +13 -2
- package/dist/overrides/index.js +1 -0
- package/dist/overrides/types.js +15 -1
- package/dist/parsers/bun-lock.js +6 -0
- package/dist/parsers/index.js +177 -40
- package/dist/parsers/multi-package.js +4 -0
- package/dist/parsers/package-lock.js +6 -2
- package/dist/parsers/pnpm-lock.js +4 -7
- package/dist/parsers/requirements-txt.js +185 -0
- package/dist/parsers/utils.js +11 -6
- package/dist/parsers/yarn-lock.js +1 -5
- package/dist/remediation/fix-commands.js +60 -36
- package/dist/remediation/parent-update-child-note.js +3 -2
- package/dist/scan/completeness.js +57 -4
- package/dist/scan/multi-folder-scan.js +27 -13
- package/dist/scan/single-scan.js +118 -37
- package/dist/scanner.js +59 -36
- package/dist/types.js +1 -1
- package/dist/usage/scanner.js +345 -45
- package/dist/utils/array.js +5 -0
- package/dist/utils/baseline.js +8 -2
- package/dist/utils/chalk.js +1 -3
- package/dist/utils/create-pr.js +2 -2
- package/dist/utils/debug-bundle.js +37 -22
- package/dist/utils/debug-project.js +6 -5
- package/dist/utils/debug-redaction.js +1 -1
- package/dist/utils/effective-options.js +5 -1
- package/dist/utils/finding.js +4 -0
- package/dist/utils/fix-runner.js +110 -36
- package/dist/utils/import-type-queries.js +5 -1
- package/dist/utils/install-command.js +6 -0
- package/dist/utils/malicious.js +11 -0
- package/dist/utils/package-identity.js +12 -2
- package/dist/utils/path-coverage.js +1 -5
- package/dist/utils/sanitize.js +59 -0
- package/dist/utils/sbom-format.js +17 -8
- package/dist/utils/severity.js +61 -7
- package/dist/utils/url.js +175 -0
- package/dist/utils/version.js +44 -0
- package/dist/utils/vuln.js +11 -14
- package/package.json +2 -4
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { relative } from "node:path";
|
|
2
2
|
import { groupSkippedByReason, skippedHeadline, skippedRuleCount } from "./skipped-override-rules.js";
|
|
3
3
|
import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
4
|
+
import { sanitizeTableCell, sanitizeOutputString } from "../utils/sanitize.js";
|
|
4
5
|
import { formatSeverityLabel, SEVERITY_ORDER } from "../utils/severity.js";
|
|
5
6
|
import { pluralize } from "../utils/string.js";
|
|
6
7
|
import { buildOverrideFixCommand, isPasteableOverrideTarget, overrideCommandTargetSuffix } from "./override-fix-command.js";
|
|
@@ -42,18 +43,22 @@ export function renderOverrideFindings(findings, options) {
|
|
|
42
43
|
continue;
|
|
43
44
|
lines.push(`${formatSeverityLabel(sev.toUpperCase())} (${bucket.length})`);
|
|
44
45
|
const sorted = [...bucket].sort((a, b) => a.ruleId.localeCompare(b.ruleId));
|
|
45
|
-
const ruleWidth = Math.min(COL_RULE_MAX, Math.max(4, ...sorted.map(f => f.ruleId.length)));
|
|
46
|
-
const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => f.package.name.length)));
|
|
47
|
-
const msgWidth = Math.min(COL_MSG_MAX, Math.max(7, ...sorted.map(f => Math.min(COL_MSG_MAX, Math.max(f.message.length, locationString(f).length)))));
|
|
46
|
+
const ruleWidth = Math.min(COL_RULE_MAX, Math.max(4, ...sorted.map(f => stripAnsi(sanitizeTableCell(sanitizeOutputString(f.ruleId))).length)));
|
|
47
|
+
const pkgWidth = Math.min(COL_PKG_MAX, Math.max(7, ...sorted.map(f => stripAnsi(sanitizeTableCell(sanitizeOutputString(f.package.name))).length)));
|
|
48
|
+
const msgWidth = Math.min(COL_MSG_MAX, Math.max(7, ...sorted.map(f => Math.min(COL_MSG_MAX, Math.max(stripAnsi(sanitizeTableCell(sanitizeOutputString(f.message))).length, stripAnsi(sanitizeTableCell(sanitizeOutputString(locationString(f)))).length)))));
|
|
48
49
|
const hr = (l, m, r) => l + "─".repeat(ruleWidth + 2) + m + "─".repeat(pkgWidth + 2) + m + "─".repeat(msgWidth + 2) + r;
|
|
49
50
|
lines.push(hr("┌", "┬", "┐"));
|
|
50
51
|
lines.push(tableRow(["Rule", "Package", "Message"], [ruleWidth, pkgWidth, msgWidth]));
|
|
51
52
|
lines.push(hr("├", "┼", "┤"));
|
|
52
53
|
for (let i = 0; i < sorted.length; i++) {
|
|
53
54
|
const f = sorted[i];
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
55
|
+
const cleanRule = sanitizeOutputString(f.ruleId);
|
|
56
|
+
const cleanPkg = sanitizeOutputString(f.package.name);
|
|
57
|
+
const cleanMsg = sanitizeOutputString(f.message);
|
|
58
|
+
const cleanLoc = sanitizeOutputString(locationString(f));
|
|
59
|
+
const msgLines = wrapText(cleanMsg, msgWidth);
|
|
60
|
+
const locLines = wrapText(cleanLoc, msgWidth);
|
|
61
|
+
lines.push(tableRow([chalk.gray(cleanRule), chalk.whiteBright(cleanPkg), msgLines[0] ?? ""], [ruleWidth, pkgWidth, msgWidth]));
|
|
57
62
|
for (let m = 1; m < msgLines.length; m++) {
|
|
58
63
|
lines.push(tableRow(["", "", msgLines[m]], [ruleWidth, pkgWidth, msgWidth]));
|
|
59
64
|
}
|
|
@@ -98,21 +103,24 @@ function tableRow(cells, widths) {
|
|
|
98
103
|
return "│" + cells.map((c, i) => padCell(c, widths[i])).join("│") + "│";
|
|
99
104
|
}
|
|
100
105
|
function padCell(value, width) {
|
|
101
|
-
const
|
|
106
|
+
const sanitized = sanitizeTableCell(value);
|
|
107
|
+
const truncated = truncate(sanitized, width);
|
|
102
108
|
const visible = stripAnsi(truncated).length;
|
|
103
109
|
return ` ${truncated}${" ".repeat(Math.max(0, width - visible))} `;
|
|
104
110
|
}
|
|
105
111
|
function truncate(value, width) {
|
|
106
|
-
const
|
|
112
|
+
const clean = sanitizeTableCell(value);
|
|
113
|
+
const plain = stripAnsi(clean);
|
|
107
114
|
if (plain.length <= width)
|
|
108
|
-
return
|
|
115
|
+
return clean;
|
|
109
116
|
return plain.slice(0, Math.max(0, width - 1)) + "…";
|
|
110
117
|
}
|
|
111
118
|
function wrapText(text, width) {
|
|
112
|
-
|
|
113
|
-
|
|
119
|
+
const sanitized = sanitizeTableCell(text);
|
|
120
|
+
if (sanitized.length <= width)
|
|
121
|
+
return [sanitized];
|
|
114
122
|
const lines = [];
|
|
115
|
-
let remaining =
|
|
123
|
+
let remaining = sanitized.trim();
|
|
116
124
|
while (remaining.length > width) {
|
|
117
125
|
let breakAt = remaining.lastIndexOf(" ", width);
|
|
118
126
|
if (breakAt <= 0)
|
|
@@ -122,7 +130,7 @@ function wrapText(text, width) {
|
|
|
122
130
|
}
|
|
123
131
|
if (remaining.length > 0)
|
|
124
132
|
lines.push(remaining);
|
|
125
|
-
return lines.length > 0 ? lines : [
|
|
133
|
+
return lines.length > 0 ? lines : [sanitized];
|
|
126
134
|
}
|
|
127
135
|
/**
|
|
128
136
|
* Renders the rules that could not run. Printed whether or not there are findings,
|
package/dist/output/printers.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { chalk, stripAnsi } from "../utils/chalk.js";
|
|
2
2
|
import { buildSuggestedFixCommandPlan, formatParentUpgradeBlockedReason, planVersionForFinding, UNVERIFIED_PARENT_UPGRADE_NOTE } from "../remediation/fix-commands.js";
|
|
3
3
|
import { formatParentUpdateChildNote } from "../remediation/parent-update-child-note.js";
|
|
4
|
-
import { isBreakingUpgrade } from "../utils/version.js";
|
|
4
|
+
import { isBreakingUpgrade, isPep440Ecosystem } from "../utils/version.js";
|
|
5
5
|
import { getPrimaryParent } from "../utils/finding.js";
|
|
6
|
-
import { countUniqueAdvisories, countProdFindings, formatPackageName, formatRelationshipLabel, formatRelLabel, formatRootDependencySummary, formatFixCommandWithPublishDates, formatCooldownWarning, } from "./formatters.js";
|
|
6
|
+
import { countUniqueAdvisories, countProdFindings, formatPackageName, formatRelationshipLabel, formatRelLabel, formatRootDependencySummary, formatFixCommandWithPublishDates, formatCooldownWarning, getRecommendedAction, } from "./formatters.js";
|
|
7
7
|
import { formatSeverityLabel } from "../utils/severity.js";
|
|
8
8
|
import { severityOrder } from "../constants.js";
|
|
9
9
|
import { pluralize } from "../utils/string.js";
|
|
@@ -15,6 +15,8 @@ import { computeContextualSignals, formatContextualSignalValues, formatContextua
|
|
|
15
15
|
import { renderLicenseFindings } from "./license-terminal.js";
|
|
16
16
|
import { getCompletenessImpact } from "../scan/completeness.js";
|
|
17
17
|
import { MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE, MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_MESSAGE, MAL_GIT_SOURCE_FLOATING_MESSAGE, MAL_GIT_SOURCE_COMPACT_MESSAGE, MAL_GIT_SOURCE_LEGEND_MESSAGE, MAL_GIT_SOURCE_PINNED_DISPLAY, MAL_GIT_SOURCE_FLOATING_DISPLAY, OVERRIDES_COMMAND, } from "../constants.js";
|
|
18
|
+
export const PYTHON_GATE_EXCLUSION_NOTE = "Python findings are experimental and do not affect the exit code.";
|
|
19
|
+
import { FIX_COMMAND_SUPPRESSED_MESSAGE, isCommandSuppressed, isMalformedOrUnsafeIdentity, sanitizeOutputString, sanitizeTableCell, } from "../utils/sanitize.js";
|
|
18
20
|
export function printSummary(findings, packageCount, scanInput) {
|
|
19
21
|
if (findings.length === 0) {
|
|
20
22
|
if (scanInput.mode === "manifest-fallback") {
|
|
@@ -93,6 +95,7 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
|
|
|
93
95
|
console.log("");
|
|
94
96
|
console.log(chalk.bold.yellow("🛠 Suggested Fix Commands"));
|
|
95
97
|
console.log(chalk.white(formatFixCommandSummary(plan)));
|
|
98
|
+
let hasSuppressedCommand = false;
|
|
96
99
|
for (const section of plan.sections) {
|
|
97
100
|
console.log("");
|
|
98
101
|
console.log(colorFixSectionTitle(section.severity, section.title));
|
|
@@ -104,15 +107,18 @@ export function printSuggestedFixCommands(findings, scanInput, options) {
|
|
|
104
107
|
const remainingNotes = [];
|
|
105
108
|
printActionTargetsTable(section.targets, remainingNotes, sharedActionTableWidths, fixRowContexts, showUsage);
|
|
106
109
|
for (const note of remainingNotes) {
|
|
107
|
-
console.log(chalk.gray(` Note: ${note}`));
|
|
110
|
+
console.log(chalk.gray(` Note: ${sanitizeOutputString(note)}`));
|
|
108
111
|
}
|
|
109
112
|
for (const target of section.targets) {
|
|
110
113
|
printCooldownWarning(target);
|
|
111
114
|
printUnverifiedParentUpgradeWarning(target);
|
|
112
115
|
}
|
|
116
|
+
if (isCommandSuppressed(section.command)) {
|
|
117
|
+
hasSuppressedCommand = true;
|
|
118
|
+
}
|
|
113
119
|
console.log(renderCommandCallout(section.command, section.targets));
|
|
114
120
|
}
|
|
115
|
-
if (plan.coveredFindingCount > 0) {
|
|
121
|
+
if (plan.coveredFindingCount > 0 && !hasSuppressedCommand) {
|
|
116
122
|
console.log("");
|
|
117
123
|
const coverage = plan.coveredFindingCount === plan.totalFindingCount
|
|
118
124
|
? chalk.gray(`Running all commands above should fix all ${plan.totalFindingCount} vulnerability ${pluralize(plan.totalFindingCount, "finding")}.`)
|
|
@@ -141,7 +147,7 @@ export function printSuggestedFixCommandSkips(findings, scanInput, options) {
|
|
|
141
147
|
console.log("");
|
|
142
148
|
console.log(chalk.gray("Unpublishable fixed-version hints:"));
|
|
143
149
|
for (const skipped of unpublishable.slice(0, 5)) {
|
|
144
|
-
console.log(`- ${skipped.package}@${skipped.version}: ${skipped.reason}`);
|
|
150
|
+
console.log(`- ${sanitizeOutputString(skipped.package)}@${sanitizeOutputString(skipped.version)}: ${sanitizeOutputString(skipped.reason)}`);
|
|
145
151
|
}
|
|
146
152
|
if (unpublishable.length > 5) {
|
|
147
153
|
console.log(`- ...and ${unpublishable.length - 5} more`);
|
|
@@ -151,7 +157,7 @@ export function printSuggestedFixCommandSkips(findings, scanInput, options) {
|
|
|
151
157
|
console.log("");
|
|
152
158
|
console.log(chalk.gray("No auto-fix command available for these direct dependencies:"));
|
|
153
159
|
for (const skipped of remaining.slice(0, 5)) {
|
|
154
|
-
console.log(`- ${skipped.package}@${skipped.version}: ${skipped.reason}`);
|
|
160
|
+
console.log(`- ${sanitizeOutputString(skipped.package)}@${sanitizeOutputString(skipped.version)}: ${sanitizeOutputString(skipped.reason)}`);
|
|
155
161
|
}
|
|
156
162
|
if (remaining.length > 5) {
|
|
157
163
|
console.log(`- ...and ${remaining.length - 5} more`);
|
|
@@ -164,14 +170,14 @@ export function printCoverage(notes) {
|
|
|
164
170
|
console.log("");
|
|
165
171
|
console.log(chalk.bold.blue("Coverage notes"));
|
|
166
172
|
for (const note of notes) {
|
|
167
|
-
console.log(`${chalk.blue("•")} ${note}`);
|
|
173
|
+
console.log(`${chalk.blue("•")} ${sanitizeOutputString(note)}`);
|
|
168
174
|
}
|
|
169
175
|
}
|
|
170
176
|
export function printSkippedDependencies(skipped) {
|
|
171
177
|
console.log("");
|
|
172
178
|
console.log(chalk.bold.yellow("Skipped manifest dependencies"));
|
|
173
179
|
for (const item of skipped.slice(0, 10)) {
|
|
174
|
-
console.log(`${chalk.yellow("•")} ${item}`);
|
|
180
|
+
console.log(`${chalk.yellow("•")} ${sanitizeOutputString(item)}`);
|
|
175
181
|
}
|
|
176
182
|
if (skipped.length > 10) {
|
|
177
183
|
console.log(`${chalk.yellow("•")} ...and ${skipped.length - 10} more`);
|
|
@@ -199,14 +205,14 @@ const DEFAULT_COLUMN_CAP = 40;
|
|
|
199
205
|
const ROOT_COLUMN_CAP = 24;
|
|
200
206
|
// Context is prose, so it gets room and is word-wrapped rather than truncated.
|
|
201
207
|
const CONTEXT_COLUMN_CAP = 60;
|
|
202
|
-
const dash = (value) =>
|
|
208
|
+
const dash = (value) => value == null || value === "" ? "-" : sanitizeOutputString(value);
|
|
203
209
|
const TABLE_COLUMNS = [
|
|
204
210
|
{
|
|
205
211
|
name: "package",
|
|
206
212
|
header: "Package",
|
|
207
213
|
cap: PACKAGE_NAME_COLUMN_CAP,
|
|
208
214
|
wrap: true,
|
|
209
|
-
cell: row => ({ value: row.package, decorated: row.packageDecorated }),
|
|
215
|
+
cell: row => ({ value: sanitizeOutputString(row.package), decorated: row.packageDecorated }),
|
|
210
216
|
},
|
|
211
217
|
{ name: "version", header: "Version", cell: row => ({ value: dash(row.version) }) },
|
|
212
218
|
{
|
|
@@ -249,7 +255,14 @@ const TABLE_COLUMNS = [
|
|
|
249
255
|
return { value, decorated: chalk.gray(value) };
|
|
250
256
|
},
|
|
251
257
|
},
|
|
252
|
-
{
|
|
258
|
+
{
|
|
259
|
+
name: "target",
|
|
260
|
+
header: "Target",
|
|
261
|
+
cell: row => {
|
|
262
|
+
const value = dash(row.target);
|
|
263
|
+
return { value, decorated: row.targetDecorated ?? value };
|
|
264
|
+
},
|
|
265
|
+
},
|
|
253
266
|
{
|
|
254
267
|
name: "scanned",
|
|
255
268
|
header: "Scanned",
|
|
@@ -328,12 +341,12 @@ function selectColumns(names, showUsage) {
|
|
|
328
341
|
});
|
|
329
342
|
}
|
|
330
343
|
function columnWidths(columns, rows) {
|
|
331
|
-
return columns.map(column => Math.min(column.cap ?? DEFAULT_COLUMN_CAP, Math.max(cellWidth(column.header), ...rows.map(row => cellWidth(column.cell(row).value)))));
|
|
344
|
+
return columns.map(column => Math.min(column.cap ?? DEFAULT_COLUMN_CAP, Math.max(cellWidth(column.header), ...rows.map(row => cellWidth(sanitizeTableCell(column.cell(row).value))))));
|
|
332
345
|
}
|
|
333
346
|
function renderCells(columns, row) {
|
|
334
347
|
return columns.map(column => {
|
|
335
348
|
const { value, decorated } = column.cell(row);
|
|
336
|
-
return decorated ?? value;
|
|
349
|
+
return sanitizeTableCell(decorated ?? value);
|
|
337
350
|
});
|
|
338
351
|
}
|
|
339
352
|
/** Draws a table from a column selection. `wrap` word-wraps instead of truncating. */
|
|
@@ -391,17 +404,19 @@ function findingToTableRow(finding, plan, skippedKeys) {
|
|
|
391
404
|
// command sitting a few lines above. For parent-update this is the child's
|
|
392
405
|
// destination, not the parent's unchanged version stored on targetVersion.
|
|
393
406
|
const planTarget = plan ? planVersionForFinding(plan, finding) : undefined;
|
|
394
|
-
const ownFixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
407
|
+
const ownFixVersion = isPep440Ecosystem(finding.pkg.ecosystem) ? null : (finding.validatedFirstFixedVersion ?? finding.firstFixedVersion);
|
|
395
408
|
const fixVersion = planTarget ?? ownFixVersion ?? null;
|
|
409
|
+
const targetDisplay = formatTargetDisplay(finding, fixVersion, isSkipped);
|
|
396
410
|
return {
|
|
397
411
|
package: formatPackageName(finding.pkg),
|
|
398
|
-
version: finding.pkg.version,
|
|
412
|
+
version: sanitizeOutputString(finding.pkg.version),
|
|
399
413
|
severity: finding.severity,
|
|
400
414
|
relationship: formatRelLabel(finding),
|
|
401
415
|
root: shortenRootSummary(formatRootDependencySummary(finding)),
|
|
402
416
|
usage: finding.usage ?? null,
|
|
403
|
-
advisoryVersion: finding.firstFixedVersion
|
|
404
|
-
target:
|
|
417
|
+
advisoryVersion: finding.firstFixedVersion ? sanitizeOutputString(finding.firstFixedVersion) : null,
|
|
418
|
+
target: targetDisplay.value,
|
|
419
|
+
targetDecorated: targetDisplay.decorated,
|
|
405
420
|
// These count the versions walked above the installed one while checking the
|
|
406
421
|
// advisory's hint, so they stand on their own even when the fix plan then
|
|
407
422
|
// raises Target higher to cover a package's children. Blanking them whenever
|
|
@@ -416,20 +431,33 @@ function findingToTableRow(finding, plan, skippedKeys) {
|
|
|
416
431
|
};
|
|
417
432
|
}
|
|
418
433
|
function formatTargetDisplay(finding, fixVersion, isSkipped) {
|
|
419
|
-
if (isSkipped && fixVersion)
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
if (
|
|
424
|
-
|
|
434
|
+
if (isSkipped && fixVersion) {
|
|
435
|
+
const clean = sanitizeOutputString(fixVersion);
|
|
436
|
+
return { value: `${clean} ⊘`, decorated: chalk.gray(`${clean} ⊘`) };
|
|
437
|
+
}
|
|
438
|
+
if (fixVersion) {
|
|
439
|
+
const clean = sanitizeOutputString(fixVersion);
|
|
440
|
+
return { value: clean };
|
|
441
|
+
}
|
|
442
|
+
if (finding.maliciousUnverifiable) {
|
|
443
|
+
return { value: "⚠ Unverifiable (private source)", decorated: chalk.yellow("⚠ Unverifiable (private source)") };
|
|
444
|
+
}
|
|
425
445
|
if (finding.maliciousGitSource) {
|
|
426
|
-
|
|
446
|
+
const label = finding.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_DISPLAY : MAL_GIT_SOURCE_FLOATING_DISPLAY;
|
|
447
|
+
return { value: label, decorated: chalk.yellow(label) };
|
|
448
|
+
}
|
|
449
|
+
if (hasMaliciousAdvisory(finding.vulnerabilities)) {
|
|
450
|
+
return { value: "⚠ Malicious", decorated: chalk.yellow("⚠ Malicious") };
|
|
451
|
+
}
|
|
452
|
+
if (finding.advisoryBoundaryUnreadable) {
|
|
453
|
+
return { value: "⚠ unreadable advisory data", decorated: chalk.yellow("⚠ unreadable advisory data") };
|
|
454
|
+
}
|
|
455
|
+
// Python findings show no remediation target, but only when there is a fix to
|
|
456
|
+
// withhold: malicious, unreadable, and no-fix states must render as they do for npm.
|
|
457
|
+
if (isPep440Ecosystem(finding.pkg.ecosystem) && (finding.validatedFirstFixedVersion ?? finding.firstFixedVersion)) {
|
|
458
|
+
return { value: "-", decorated: chalk.gray("-") };
|
|
427
459
|
}
|
|
428
|
-
|
|
429
|
-
return chalk.yellow("⚠ Malicious");
|
|
430
|
-
if (finding.advisoryBoundaryUnreadable)
|
|
431
|
-
return chalk.yellow("⚠ unreadable advisory data");
|
|
432
|
-
return chalk.yellow("⚠ no fix");
|
|
460
|
+
return { value: "⚠ no fix", decorated: chalk.yellow("⚠ no fix") };
|
|
433
461
|
}
|
|
434
462
|
function fixTargetContext(target) {
|
|
435
463
|
const childNote = formatParentUpdateChildNote(target);
|
|
@@ -444,15 +472,19 @@ function fixTargetContext(target) {
|
|
|
444
472
|
return childNote ?? reason;
|
|
445
473
|
}
|
|
446
474
|
function fixTargetToTableRow(target, context) {
|
|
475
|
+
const cleanTargetVersion = sanitizeOutputString(target.targetVersion);
|
|
447
476
|
return {
|
|
448
|
-
package: target.package,
|
|
449
|
-
version: target.currentVersion
|
|
477
|
+
package: sanitizeOutputString(target.package),
|
|
478
|
+
version: target.currentVersion ? sanitizeOutputString(target.currentVersion) : "-",
|
|
450
479
|
severity: context?.severity ?? null,
|
|
451
480
|
relationship: context?.relationship ?? null,
|
|
452
|
-
root: context?.root
|
|
481
|
+
root: context?.root ? sanitizeOutputString(context.root) : null,
|
|
453
482
|
usage: target.usage ?? null,
|
|
454
|
-
advisoryVersion: target.advisoryVersion ?? context?.advisoryVersion
|
|
455
|
-
|
|
483
|
+
advisoryVersion: (target.advisoryVersion ?? context?.advisoryVersion)
|
|
484
|
+
? sanitizeOutputString(target.advisoryVersion ?? context?.advisoryVersion ?? "")
|
|
485
|
+
: null,
|
|
486
|
+
target: cleanTargetVersion,
|
|
487
|
+
targetDecorated: chalk.cyan(cleanTargetVersion),
|
|
456
488
|
// A parent-upgrade target carries no validation counts of its own, but the
|
|
457
489
|
// finding it resolves does, and the action table is a filtered view of the
|
|
458
490
|
// findings table: the same package must read the same on both.
|
|
@@ -495,7 +527,7 @@ export function printTable(findings, threshold, skippedKeys, plan) {
|
|
|
495
527
|
console.log(chalk.gray("Triage hints only: not exploitability or runtime reachability proofs."));
|
|
496
528
|
for (const finding of findings) {
|
|
497
529
|
const values = formatContextualSignalValues(computeContextualSignals(finding));
|
|
498
|
-
console.log(chalk.gray(` ${finding.pkg
|
|
530
|
+
console.log(chalk.gray(` · ${formatPackageName(finding.pkg)}@${sanitizeOutputString(finding.pkg.version)} ${values}`));
|
|
499
531
|
}
|
|
500
532
|
}
|
|
501
533
|
const maliciousFindings = findings.filter(f => hasMaliciousAdvisory(f.vulnerabilities));
|
|
@@ -507,15 +539,15 @@ export function printTable(findings, threshold, skippedKeys, plan) {
|
|
|
507
539
|
? "Remove it from your dependencies immediately."
|
|
508
540
|
: "Upgrade or remove the parent package that pulls it in.";
|
|
509
541
|
if (f.maliciousUnverifiable) {
|
|
510
|
-
console.log(chalk.yellow(` · ${f.pkg
|
|
542
|
+
console.log(chalk.yellow(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)} - Unverifiable (private source) - ${action}`));
|
|
511
543
|
}
|
|
512
544
|
else if (f.maliciousGitSource) {
|
|
513
545
|
const msg = f.maliciousGitSourcePinned ? MAL_GIT_SOURCE_PINNED_MESSAGE : MAL_GIT_SOURCE_FLOATING_MESSAGE;
|
|
514
|
-
const url = f.pkg.resolvedUrl ? ` (${f.pkg.resolvedUrl})` : "";
|
|
515
|
-
console.log(chalk.yellow(` · ${f.pkg
|
|
546
|
+
const url = f.pkg.resolvedUrl ? ` (${sanitizeOutputString(f.pkg.resolvedUrl)})` : "";
|
|
547
|
+
console.log(chalk.yellow(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)}${url} - ${msg}`));
|
|
516
548
|
}
|
|
517
549
|
else {
|
|
518
|
-
console.log(chalk.red(` · ${f.pkg
|
|
550
|
+
console.log(chalk.red(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)} - ${action}`));
|
|
519
551
|
}
|
|
520
552
|
}
|
|
521
553
|
}
|
|
@@ -587,6 +619,9 @@ export function printFinalStatus(findings, overrideCount = 0, completeness) {
|
|
|
587
619
|
console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
|
|
588
620
|
}
|
|
589
621
|
printIncompleteDiagnostics(completeness);
|
|
622
|
+
if (findings.some(f => isPep440Ecosystem(f.pkg.ecosystem))) {
|
|
623
|
+
console.log(chalk.gray(PYTHON_GATE_EXCLUSION_NOTE));
|
|
624
|
+
}
|
|
590
625
|
}
|
|
591
626
|
export function printOverrideHint() {
|
|
592
627
|
console.log("💡 " + chalk.gray("Tip:") + " override entries detected - run with --check-overrides to audit them for stale or broken overrides.");
|
|
@@ -673,7 +708,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
673
708
|
if (hasRemediationGap) {
|
|
674
709
|
console.log(chalk.yellow("⚠ Remediation guidance is incomplete."));
|
|
675
710
|
}
|
|
676
|
-
if (options?.completeness?.
|
|
711
|
+
if (options?.completeness?.diagnostics.length) {
|
|
677
712
|
printIncompleteDiagnostics(options.completeness);
|
|
678
713
|
}
|
|
679
714
|
else {
|
|
@@ -707,7 +742,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
707
742
|
usageContext = chalk.green(` (no direct import found)`);
|
|
708
743
|
}
|
|
709
744
|
}
|
|
710
|
-
console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(formatPackageName(finding.pkg))}@${finding.pkg.version}`);
|
|
745
|
+
console.log(`${formatSeverityLabel(sevLabel)} ${chalk.whiteBright(formatPackageName(finding.pkg))}@${sanitizeOutputString(finding.pkg.version)}`);
|
|
711
746
|
console.log(` ${typeLabel}${usageContext}`);
|
|
712
747
|
console.log(` ${chalk.gray(formatContextualSignalsLine(computeContextualSignals(finding)))}`);
|
|
713
748
|
if (finding.epssScores && finding.epssScores.length > 0) {
|
|
@@ -727,7 +762,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
727
762
|
console.log(` ${chalk.yellow(`⚠ Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_COMPACT_MESSAGE}`)}`);
|
|
728
763
|
}
|
|
729
764
|
else if (finding.maliciousGitSource) {
|
|
730
|
-
const url = finding.pkg.resolvedUrl ? ` Source: ${finding.pkg.resolvedUrl}` : "";
|
|
765
|
+
const url = finding.pkg.resolvedUrl ? ` Source: ${sanitizeOutputString(finding.pkg.resolvedUrl)}` : "";
|
|
731
766
|
console.log(` ${chalk.yellow(`⚠ ${MAL_GIT_SOURCE_COMPACT_MESSAGE}${url}`)}`);
|
|
732
767
|
}
|
|
733
768
|
else {
|
|
@@ -741,40 +776,96 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
741
776
|
console.log(` ${chalk.gray("Fix: unreadable advisory data; the fix is inconclusive")}`);
|
|
742
777
|
}
|
|
743
778
|
else if (finding.recommendedNpmTransitiveRemediation?.kind === "update-parent-within-range") {
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
779
|
+
if (isMalformedOrUnsafeIdentity(finding.recommendedNpmTransitiveRemediation.package)) {
|
|
780
|
+
console.log(` ${chalk.gray("Fix: suggested fix unavailable: package name contains control characters or a workflow command marker")}`);
|
|
781
|
+
}
|
|
782
|
+
else {
|
|
783
|
+
console.log(` ${chalk.gray(`Fix: run \`npm install\` - ${sanitizeOutputString(finding.recommendedNpmTransitiveRemediation.package)} already permits a safe version`)}`);
|
|
784
|
+
}
|
|
748
785
|
}
|
|
749
786
|
else if (finding.recommendedParentUpgrade) {
|
|
750
|
-
|
|
787
|
+
if (isMalformedOrUnsafeIdentity(finding.recommendedParentUpgrade.targetVersion)) {
|
|
788
|
+
console.log(` ${chalk.gray("Fix: suggested fix unavailable: version contains control characters or a workflow command marker")}`);
|
|
789
|
+
}
|
|
790
|
+
else if (isMalformedOrUnsafeIdentity(finding.recommendedParentUpgrade.package)) {
|
|
791
|
+
console.log(` ${chalk.gray("Fix: suggested fix unavailable: package name contains control characters or a workflow command marker")}`);
|
|
792
|
+
}
|
|
793
|
+
else if (finding.parentUpgradeBlockers?.length) {
|
|
794
|
+
const hasMalformedBlocker = finding.parentUpgradeBlockers.some(b => (b.package && isMalformedOrUnsafeIdentity(b.package)) ||
|
|
795
|
+
(b.version && isMalformedOrUnsafeIdentity(b.version)) ||
|
|
796
|
+
(b.range && isMalformedOrUnsafeIdentity(b.range)));
|
|
797
|
+
const hasMalformedIdentity = (finding.pkg.name && isMalformedOrUnsafeIdentity(finding.pkg.name)) ||
|
|
798
|
+
(finding.pkg.version && isMalformedOrUnsafeIdentity(finding.pkg.version));
|
|
799
|
+
if (hasMalformedBlocker || hasMalformedIdentity) {
|
|
800
|
+
console.log(` ${chalk.gray("Fix: parent upgrade is blocked: inspect lockfile dependency data to identify conflicting packages")}`);
|
|
801
|
+
}
|
|
802
|
+
else {
|
|
803
|
+
console.log(` ${chalk.gray(`Fix: ${sanitizeOutputString(formatParentUpgradeBlockedReason(finding))}`)}`);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
else {
|
|
807
|
+
console.log(` ${chalk.gray(`Fix: upgrade ${sanitizeOutputString(finding.recommendedParentUpgrade.package)} to ${sanitizeOutputString(finding.recommendedParentUpgrade.targetVersion)}`)}`);
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
else if (isPep440Ecosystem(finding.pkg.ecosystem)) {
|
|
811
|
+
const hasFixTarget = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
812
|
+
const pythonNoFixAction = hasFixTarget ? null : getRecommendedAction(finding);
|
|
813
|
+
console.log(` ${chalk.gray(`Fix: ${pythonNoFixAction ?? "-"}`)}`);
|
|
751
814
|
}
|
|
752
815
|
else if (finding.firstFixedVersion) {
|
|
753
|
-
const
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
816
|
+
const rawFixVersion = finding.validatedFirstFixedVersion ?? finding.firstFixedVersion;
|
|
817
|
+
if (rawFixVersion && isMalformedOrUnsafeIdentity(rawFixVersion)) {
|
|
818
|
+
console.log(` ${chalk.gray("Fix: suggested fix unavailable: version contains control characters or a workflow command marker")}`);
|
|
819
|
+
}
|
|
820
|
+
else if (finding.pkg.name && isMalformedOrUnsafeIdentity(finding.pkg.name)) {
|
|
821
|
+
console.log(` ${chalk.gray("Fix: suggested fix unavailable: package name contains control characters or a workflow command marker")}`);
|
|
757
822
|
}
|
|
758
823
|
else {
|
|
759
|
-
const
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
824
|
+
const displayFixVersion = sanitizeOutputString(rawFixVersion);
|
|
825
|
+
const pkgName = sanitizeOutputString(finding.pkg.name);
|
|
826
|
+
let action;
|
|
827
|
+
if (finding.relationship === "direct") {
|
|
828
|
+
action = `upgrade to ${displayFixVersion}`;
|
|
829
|
+
}
|
|
830
|
+
else {
|
|
831
|
+
const rawParent = getPrimaryParent(finding);
|
|
832
|
+
if (rawParent && isMalformedOrUnsafeIdentity(rawParent)) {
|
|
833
|
+
action = `Parent package name is malformed (contains control characters or a workflow command marker): inspect lockfile dependency path for ${pkgName}`;
|
|
834
|
+
}
|
|
835
|
+
else if (rawParent) {
|
|
836
|
+
action = `Upgrade ${sanitizeOutputString(rawParent)}: check for release resolving ${pkgName} to ${displayFixVersion}+`;
|
|
837
|
+
}
|
|
838
|
+
else {
|
|
839
|
+
action = `No dependency path found: inspect lockfile to identify which package pulls in ${pkgName}`;
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
763
843
|
}
|
|
764
|
-
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
765
844
|
}
|
|
766
845
|
else {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
action = "review and upgrade directly";
|
|
846
|
+
if (finding.pkg.name && isMalformedOrUnsafeIdentity(finding.pkg.name)) {
|
|
847
|
+
console.log(` ${chalk.gray("Fix: package name is malformed: inspect lockfile dependency data")}`);
|
|
770
848
|
}
|
|
771
849
|
else {
|
|
772
|
-
const
|
|
773
|
-
action
|
|
774
|
-
|
|
775
|
-
|
|
850
|
+
const pkgName = sanitizeOutputString(finding.pkg.name);
|
|
851
|
+
let action;
|
|
852
|
+
if (finding.relationship === "direct") {
|
|
853
|
+
action = "review and upgrade directly";
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
const rawParent = getPrimaryParent(finding);
|
|
857
|
+
if (rawParent && isMalformedOrUnsafeIdentity(rawParent)) {
|
|
858
|
+
action = `Parent package name is malformed (contains control characters or a workflow command marker): inspect lockfile dependency path for ${pkgName}`;
|
|
859
|
+
}
|
|
860
|
+
else if (rawParent) {
|
|
861
|
+
action = `Upgrade ${sanitizeOutputString(rawParent)} to resolve ${pkgName}`;
|
|
862
|
+
}
|
|
863
|
+
else {
|
|
864
|
+
action = `No dependency path found: inspect lockfile to identify which package pulls in ${pkgName}`;
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
776
868
|
}
|
|
777
|
-
console.log(` ${chalk.gray(`Fix: ${action}`)}`);
|
|
778
869
|
}
|
|
779
870
|
console.log("");
|
|
780
871
|
}
|
|
@@ -801,7 +892,7 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
801
892
|
console.log(`${section.title}`);
|
|
802
893
|
for (const target of section.targets) {
|
|
803
894
|
if (section.kind === "direct-adjusted" && target.adjustmentNote) {
|
|
804
|
-
console.log(chalk.gray(` Note: ${target.adjustmentNote}`));
|
|
895
|
+
console.log(chalk.gray(` Note: ${sanitizeOutputString(target.adjustmentNote)}`));
|
|
805
896
|
}
|
|
806
897
|
printCooldownWarning(target);
|
|
807
898
|
}
|
|
@@ -874,16 +965,16 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
874
965
|
console.log(chalk.bold.red("⚠ Malicious package advisory:"));
|
|
875
966
|
for (const f of maliciousCompact) {
|
|
876
967
|
if (f.maliciousUnverifiable) {
|
|
877
|
-
console.log(chalk.yellow(` · ${f.pkg
|
|
968
|
+
console.log(chalk.yellow(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)} - Unverifiable (private source) - ${MAL_PRIVATE_REGISTRY_LEGEND_MESSAGE}`));
|
|
878
969
|
}
|
|
879
970
|
else if (f.maliciousGitSource) {
|
|
880
|
-
console.log(chalk.yellow(` · ${f.pkg
|
|
971
|
+
console.log(chalk.yellow(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)} - Git source - ${MAL_GIT_SOURCE_LEGEND_MESSAGE}`));
|
|
881
972
|
}
|
|
882
973
|
else {
|
|
883
974
|
const action = f.relationship === "direct"
|
|
884
975
|
? "Remove it from your dependencies immediately."
|
|
885
976
|
: "Upgrade or remove the parent package that pulls it in.";
|
|
886
|
-
console.log(chalk.red(` · ${f.pkg
|
|
977
|
+
console.log(chalk.red(` · ${formatPackageName(f.pkg)}@${sanitizeOutputString(f.pkg.version)} - ${action}`));
|
|
887
978
|
}
|
|
888
979
|
}
|
|
889
980
|
}
|
|
@@ -912,19 +1003,27 @@ export function printCompactOutput(findings, scanInput, options) {
|
|
|
912
1003
|
if (!options?.all) {
|
|
913
1004
|
console.log(chalk.gray(`Run with ${chalk.whiteBright("--verbose")} for fix plan, paths, and full table.`));
|
|
914
1005
|
}
|
|
915
|
-
if (
|
|
1006
|
+
if (findings.some(f => isPep440Ecosystem(f.pkg.ecosystem))) {
|
|
1007
|
+
console.log(chalk.gray(PYTHON_GATE_EXCLUSION_NOTE));
|
|
1008
|
+
}
|
|
1009
|
+
if (!options?.completeness?.diagnostics.length) {
|
|
916
1010
|
console.log("");
|
|
917
1011
|
}
|
|
918
1012
|
}
|
|
1013
|
+
// Prints every diagnostic, including a freshness note on a complete scan (cached
|
|
1014
|
+
// details stood in for a failed lookup, #1443). Only a partial scan is asked to
|
|
1015
|
+
// resolve anything, since a freshness note leaves nothing missing.
|
|
919
1016
|
export function printIncompleteDiagnostics(completeness) {
|
|
920
|
-
if (!completeness || completeness.
|
|
1017
|
+
if (!completeness || completeness.diagnostics.length === 0)
|
|
921
1018
|
return;
|
|
922
1019
|
for (const diag of completeness.diagnostics) {
|
|
923
1020
|
const color = diag.impact === "detection" ? chalk.yellow : chalk.gray;
|
|
924
1021
|
console.log(color(`⚠ ${diag.message}`));
|
|
925
1022
|
}
|
|
926
1023
|
console.log("");
|
|
927
|
-
|
|
1024
|
+
if (!completeness.complete) {
|
|
1025
|
+
console.log(chalk.gray("Resolve the issues above and re-run the scan."));
|
|
1026
|
+
}
|
|
928
1027
|
}
|
|
929
1028
|
function renderSeverityTable(counts) {
|
|
930
1029
|
const labels = ["Critical", "High", "Medium", "Low", "Unknown"];
|
|
@@ -969,22 +1068,32 @@ export function formatFixCommandSummary(plan) {
|
|
|
969
1068
|
if (!plan)
|
|
970
1069
|
return "";
|
|
971
1070
|
const packageCount = plan.targets.length;
|
|
972
|
-
const
|
|
1071
|
+
const packageLabel = packageCount === 1 ? "package" : "packages";
|
|
1072
|
+
const readySections = plan.sections.filter(s => !isCommandSuppressed(s.command));
|
|
1073
|
+
const suppressedCount = plan.sections.length - readySections.length;
|
|
1074
|
+
const readyCount = readySections.length;
|
|
973
1075
|
const severityCounts = new Map();
|
|
974
|
-
for (const section of
|
|
1076
|
+
for (const section of readySections) {
|
|
975
1077
|
severityCounts.set(section.severity, (severityCounts.get(section.severity) ?? 0) + 1);
|
|
976
1078
|
}
|
|
977
1079
|
const severitySummary = ["critical", "high", "medium", "low", "unknown"]
|
|
978
1080
|
.filter(severity => (severityCounts.get(severity) ?? 0) > 0)
|
|
979
1081
|
.map(severity => `${severityCounts.get(severity)} ${severity}`)
|
|
980
1082
|
.join(", ");
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
1083
|
+
if (suppressedCount > 0) {
|
|
1084
|
+
const readyLabel = readyCount === 1 ? "group" : "groups";
|
|
1085
|
+
const severityPart = severitySummary ? ` (${severitySummary})` : "";
|
|
1086
|
+
return `${readyCount} command ${readyLabel} ready${severityPart}, ${suppressedCount} suppressed across ${packageCount} ${packageLabel}.`;
|
|
1087
|
+
}
|
|
1088
|
+
const sectionLabel = readyCount === 1 ? "group" : "groups";
|
|
1089
|
+
return `${readyCount} command ${sectionLabel} ready across ${packageCount} ${packageLabel}${severitySummary ? ` (${severitySummary})` : ""}.`;
|
|
984
1090
|
}
|
|
985
1091
|
// No table carries a Published column, so the publish date rides on the command
|
|
986
1092
|
// itself in both verbose and compact output, as it did before the column existed.
|
|
987
1093
|
function renderCommandCallout(command, targets) {
|
|
1094
|
+
if (isCommandSuppressed(command)) {
|
|
1095
|
+
return chalk.gray(`⊘ ${FIX_COMMAND_SUPPRESSED_MESSAGE}`);
|
|
1096
|
+
}
|
|
988
1097
|
const display = targets ? formatFixCommandWithPublishDates(command, targets) : command;
|
|
989
1098
|
return chalk.bold.cyan(`> ${display}`);
|
|
990
1099
|
}
|