cve-lite-cli 1.39.0 → 1.41.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 +28 -22
- package/dist/advisory/local-advisory-source.js +9 -5
- package/dist/advisory/local-db.js +91 -13
- package/dist/advisory/osv-sync.js +187 -56
- package/dist/advisory/staging-directory.js +112 -0
- package/dist/cli/advisories-sync.js +16 -2
- package/dist/cli/args.js +46 -35
- package/dist/cli/config.js +4 -1
- package/dist/cli/help.js +5 -3
- package/dist/cli/validate.js +23 -1
- package/dist/constants.js +15 -28
- package/dist/index.js +8 -3
- package/dist/osv/severity.js +1 -1
- package/dist/output/cyclonedx.js +24 -15
- package/dist/output/debug.js +68 -18
- package/dist/output/formatters.js +35 -7
- package/dist/output/html-reporter.js +68 -12
- package/dist/output/multi-folder-html-reporter.js +71 -11
- package/dist/output/output-dir.js +193 -7
- package/dist/output/override-findings-html.js +3 -6
- package/dist/output/override-findings-terminal.js +7 -12
- package/dist/output/override-fix-command.js +13 -0
- package/dist/output/printers.js +27 -12
- package/dist/output/sarif.js +168 -57
- package/dist/output/sbom-dependency-edges.js +16 -10
- package/dist/output/sbom-file.js +14 -6
- package/dist/output/scan-json.js +46 -3
- package/dist/output/spdx.js +61 -23
- package/dist/output/spinner.js +2 -1
- package/dist/output/write-outputs.js +143 -41
- package/dist/overrides/context-builder.js +23 -70
- package/dist/overrides/parsing/registry.js +1 -1
- package/dist/parsers/bun-lock.js +1 -2
- package/dist/parsers/index.js +22 -1
- package/dist/parsers/npm-lock-graph.js +39 -1
- package/dist/parsers/package-lock.js +25 -5
- package/dist/parsers/pnpm-lock.js +26 -12
- package/dist/parsers/utils.js +5 -3
- package/dist/parsers/yarn-lock-graph.js +5 -2
- package/dist/parsers/yarn-lock.js +1 -2
- package/dist/remediation/fix-commands.js +140 -50
- package/dist/remediation/npm-registry.js +56 -7
- package/dist/remediation/npm-transitive-graph.js +30 -72
- package/dist/remediation/npm-transitive-resolution.js +35 -107
- package/dist/remediation/parent-candidate-resolver.js +65 -0
- package/dist/remediation/parent-upgrade-blockers.js +51 -0
- package/dist/remediation/parent-upgrade.js +11 -116
- package/dist/remediation/registry-parent-ranges.js +21 -0
- package/dist/remediation/transitive-chain-resolver.js +3 -3
- package/dist/scan/completeness.js +17 -11
- package/dist/scan/multi-folder-scan.js +154 -59
- package/dist/scan/override-audit.js +11 -1
- package/dist/scan/single-scan.js +123 -67
- package/dist/scanner.js +288 -66
- package/dist/skills/content.js +12 -12
- package/dist/usage/scanner.js +19 -8
- package/dist/utils/array.js +11 -3
- package/dist/utils/contextual-signals.js +1 -1
- package/dist/utils/debug-bundle.js +118 -0
- package/dist/utils/debug-project.js +102 -0
- package/dist/utils/debug-redaction.js +117 -0
- package/dist/utils/effective-options.js +55 -0
- package/dist/utils/file.js +2 -1
- package/dist/utils/finding.js +1 -1
- package/dist/utils/fix-runner.js +98 -15
- package/dist/utils/import-type-queries.js +322 -0
- package/dist/utils/network.js +14 -10
- package/dist/utils/npm-lockfile.js +12 -0
- package/dist/utils/osv-fetch.js +70 -0
- package/dist/utils/package-identity.js +43 -0
- package/dist/utils/package-manager-source.js +24 -0
- package/dist/utils/purl.js +37 -0
- package/dist/utils/registry-config.js +129 -0
- package/dist/utils/severity.js +8 -0
- package/dist/utils/string.js +8 -0
- package/dist/utils/validate-url.js +4 -4
- package/dist/utils/version.js +47 -8
- package/dist/utils/versions/osv-range.js +191 -0
- package/dist/utils/versions/pep440.js +246 -0
- package/dist/utils/versions/scheme.js +10 -0
- package/dist/utils/vuln.js +75 -0
- package/package.json +3 -2
package/dist/scan/single-scan.js
CHANGED
|
@@ -2,7 +2,7 @@ import path from "node:path";
|
|
|
2
2
|
import { loadPackages, buildNoPackagesMessage } from "../parsers/index.js";
|
|
3
3
|
import { scanPackages, buildCoverageNotes, createAdvisorySource } from "../scanner.js";
|
|
4
4
|
import { normalizeSeverity } from "../osv/severity.js";
|
|
5
|
-
import { OVERRIDES_COMMAND } from "../constants.js";
|
|
5
|
+
import { OVERRIDES_COMMAND, RATCHET_BASELINE_COMMIT_HINT } from "../constants.js";
|
|
6
6
|
import { chalk } from "../utils/chalk.js";
|
|
7
7
|
import { buildSuggestedFixCommandPlan } from "../remediation/fix-commands.js";
|
|
8
8
|
import { scanProjectForPackageUsage, usageScanTruncationWarning } from "../usage/scanner.js";
|
|
@@ -11,10 +11,11 @@ import { formatAdvisoryDbFreshness } from "../utils/time.js";
|
|
|
11
11
|
import { pluralize } from "../utils/string.js";
|
|
12
12
|
import { EXIT_ERROR } from "../types.js";
|
|
13
13
|
import { formatAdvisorySourceLine, logInfo, logWarn, printCacheSummary, sortFindingsForOutput, } from "../output/formatters.js";
|
|
14
|
-
import { countBySeverity, failingGateSummary } from "../utils/severity.js";
|
|
14
|
+
import { GATE_CLASS_LABELS, countBySeverity, failingGateSummary } from "../utils/severity.js";
|
|
15
15
|
import { buildReportData, writeHtmlReport } from "../output/html-reporter.js";
|
|
16
16
|
import { buildScanJson } from "../output/scan-json.js";
|
|
17
17
|
import { writeOutputs } from "../output/write-outputs.js";
|
|
18
|
+
import { isOutputStdout } from "../output/output-dir.js";
|
|
18
19
|
import { selectFindingsForTable } from "../output/finding-display.js";
|
|
19
20
|
import { printActionSummary, printCompactOutput, printCoverage, printFinalStatus, printOverrideHint, printSkippedDependencies, printSuggestedFixCommands, printSuggestedFixCommandSkips, printSummary, printTable, } from "../output/printers.js";
|
|
20
21
|
import { renderOverrideFindings, renderSkippedOverrideRules } from "../output/override-findings-terminal.js";
|
|
@@ -29,8 +30,10 @@ import { buildFixResultAppliedEntries, createPullRequestForFixes, } from "../uti
|
|
|
29
30
|
import { buildCveFixAppliedEvent } from "../audit-log/events.js";
|
|
30
31
|
import { readBaseline, writeBaseline, filterNewFindings, ratchetOutcome } from "../utils/baseline.js";
|
|
31
32
|
import { formatDiagnosticMessage, getCompletenessImpact, shouldFailForIncompleteScan } from "./completeness.js";
|
|
33
|
+
import { packageManagerForSource, resolveRegistryConfig } from "../utils/registry-config.js";
|
|
34
|
+
import { isNpmLockSource } from "../utils/package-manager-source.js";
|
|
32
35
|
export async function handleSingleFolderScan(params) {
|
|
33
|
-
const { projectPath, projectArg, batchSize, searchDepth, options, debugLog, fetchImpl, auditLog, scanStartedAt, cliVersion, } = params;
|
|
36
|
+
const { projectPath, projectArg, batchSize, searchDepth, options, debugLog, fetchImpl, auditLog, scanStartedAt, cliVersion, onScanJsonPath, } = params;
|
|
34
37
|
let advisorySourceLine = "";
|
|
35
38
|
let advisoryDbFreshnessLine = null;
|
|
36
39
|
let advisoryDbWarning = null;
|
|
@@ -66,7 +69,7 @@ export async function handleSingleFolderScan(params) {
|
|
|
66
69
|
}
|
|
67
70
|
throw error;
|
|
68
71
|
}
|
|
69
|
-
if (!options.json && !options.ratchet) {
|
|
72
|
+
if (!options.json && !options.ratchet && !isOutputStdout(options.output)) {
|
|
70
73
|
if (options.offline || options.offlineDb) {
|
|
71
74
|
console.log(chalk.gray("Offline mode:") + " " + chalk.yellow("enabled") + " " + chalk.gray("(no external advisory calls will be made)"));
|
|
72
75
|
}
|
|
@@ -82,6 +85,15 @@ export async function handleSingleFolderScan(params) {
|
|
|
82
85
|
}
|
|
83
86
|
let scanInput = loadPackages(projectPath, !!options.prodOnly, searchDepth);
|
|
84
87
|
let packages = scanInput.packages;
|
|
88
|
+
// Reported only when the project configured one, so an unconfigured scan says nothing
|
|
89
|
+
// new. An adopter whose results differ from public npm can then see why without asking.
|
|
90
|
+
const reportedRegistry = resolveRegistryConfig({
|
|
91
|
+
projectPath,
|
|
92
|
+
packageManager: packageManagerForSource(scanInput.source),
|
|
93
|
+
});
|
|
94
|
+
if (reportedRegistry.sourceFile && !options.json && !options.ratchet && !isOutputStdout(options.output)) {
|
|
95
|
+
console.log(`${chalk.gray("Package registry:")} ${reportedRegistry.registry} ${chalk.gray(`(from ${reportedRegistry.sourceFile})`)}`);
|
|
96
|
+
}
|
|
85
97
|
if (scanInput.filePath) {
|
|
86
98
|
debugLog("Lockfile selected", {
|
|
87
99
|
source: scanInput.source,
|
|
@@ -131,7 +143,7 @@ export async function handleSingleFolderScan(params) {
|
|
|
131
143
|
});
|
|
132
144
|
return 0;
|
|
133
145
|
}
|
|
134
|
-
if (!options.json && !options.ratchet)
|
|
146
|
+
if (!options.json && !options.ratchet && !isOutputStdout(options.output))
|
|
135
147
|
console.log();
|
|
136
148
|
let scanState = await scanProject({
|
|
137
149
|
scanInput,
|
|
@@ -156,6 +168,7 @@ export async function handleSingleFolderScan(params) {
|
|
|
156
168
|
if (options.checkOverrides && !options.ratchet) {
|
|
157
169
|
const outcome = await runOverrideAudit({
|
|
158
170
|
projectPath,
|
|
171
|
+
scanSource: scanInput.source,
|
|
159
172
|
checkNetwork: !!options.checkNetwork,
|
|
160
173
|
osvUrl: options.osvUrl,
|
|
161
174
|
auditLog,
|
|
@@ -170,6 +183,9 @@ export async function handleSingleFolderScan(params) {
|
|
|
170
183
|
});
|
|
171
184
|
overrideFindings = outcome.findings;
|
|
172
185
|
overrideSkipped = outcome.skipped;
|
|
186
|
+
if (overrideSkipped.length > 0) {
|
|
187
|
+
debugLog("Rules skipped", { rules: overrideSkipped });
|
|
188
|
+
}
|
|
173
189
|
}
|
|
174
190
|
let maintenanceFindings = [];
|
|
175
191
|
let licenseFindings = [];
|
|
@@ -337,72 +353,106 @@ export async function handleSingleFolderScan(params) {
|
|
|
337
353
|
// existing baseline, GATE instead of re-saving - fail on findings not in the
|
|
338
354
|
// baseline. Re-saving here would silently absorb a new vulnerability into a
|
|
339
355
|
// fresh baseline, so a ratcheted CI job could never fail on a regression.
|
|
356
|
+
// Every --ratchet exit used to return before the single writeOutputs call below, so a
|
|
357
|
+
// ratchet run wrote no --json and no --sarif file on ANY path: first run, fully suppressed,
|
|
358
|
+
// new-findings-above-baseline, and the incomplete-detection refusal alike. Nobody combining --ratchet with either flag has
|
|
359
|
+
// ever received an artefact. #1314 did not cause that; it made the first-run path exit 1,
|
|
360
|
+
// which turned a silent gap into a red build with nothing to attach (#1332, #1315).
|
|
361
|
+
//
|
|
362
|
+
// This writes from inside the ratchet block rather than falling through, deliberately:
|
|
363
|
+
// the code between here and that call re-applies the baseline filter for non-ratchet runs,
|
|
364
|
+
// so falling through would filter an already-filtered set.
|
|
365
|
+
const finishRatchetRun = async (reported, accepted, exitCode) => {
|
|
366
|
+
await writeOutputs(options, {
|
|
367
|
+
registry: reportedRegistry,
|
|
368
|
+
sorted: reported,
|
|
369
|
+
acceptedFindings: accepted,
|
|
370
|
+
allPackages: scanState.allPackages,
|
|
371
|
+
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
372
|
+
coverage: scanState.coverage,
|
|
373
|
+
minSeverity: scanState.minSeverity,
|
|
374
|
+
tableFindings: scanState.tableFindings,
|
|
375
|
+
completeness: scanState.completeness,
|
|
376
|
+
// A ratchet run does not audit overrides, so these stay absent rather than empty:
|
|
377
|
+
// absent means "never audited", which is the distinction #1222 established.
|
|
378
|
+
overrideFindings: [],
|
|
379
|
+
overrideSkipped: undefined,
|
|
380
|
+
maintenanceFindings: [],
|
|
381
|
+
licenseFindings: [],
|
|
382
|
+
licenseLimitedToDirectOnly: false,
|
|
383
|
+
}, scanInput, projectPath);
|
|
384
|
+
auditLog.emit({
|
|
385
|
+
ts: new Date().toISOString(),
|
|
386
|
+
type: "scan.finished",
|
|
387
|
+
schemaVersion: 1,
|
|
388
|
+
durationMs: Date.now() - scanStartTime,
|
|
389
|
+
findingsCount: reported.length,
|
|
390
|
+
exitCode,
|
|
391
|
+
});
|
|
392
|
+
return exitCode;
|
|
393
|
+
};
|
|
340
394
|
if (options.ratchet) {
|
|
395
|
+
const isStdout = isOutputStdout(options.output);
|
|
341
396
|
const { hasDetectionGap } = getCompletenessImpact(scanState.completeness);
|
|
342
397
|
if (hasDetectionGap) {
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
398
|
+
if (!isStdout) {
|
|
399
|
+
console.log(chalk.red("Scan data is incomplete. Refusing to create or evaluate a baseline from partial detection data."));
|
|
400
|
+
for (const diagnostic of scanState.completeness.diagnostics) {
|
|
401
|
+
if (diagnostic.impact !== "detection")
|
|
402
|
+
continue;
|
|
403
|
+
console.log(chalk.red(` ${formatDiagnosticMessage(diagnostic.code, diagnostic.count, diagnostic.affectedPackageCount)}`));
|
|
404
|
+
}
|
|
348
405
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
findingsCount: scanState.sorted.length,
|
|
355
|
-
exitCode: EXIT_ERROR,
|
|
356
|
-
});
|
|
357
|
-
return EXIT_ERROR;
|
|
406
|
+
// Writes the requested artefact too, and accepts nothing: the baseline was never
|
|
407
|
+
// evaluated, so claiming anything is accepted would be a lie. This is the path where
|
|
408
|
+
// an artefact matters most, since the build goes red and the diagnostics are the only
|
|
409
|
+
// thing that explains why. A non-ratchet scan with the same gap already writes one.
|
|
410
|
+
return finishRatchetRun(scanState.sorted, [], EXIT_ERROR);
|
|
358
411
|
}
|
|
359
412
|
const outcome = ratchetOutcome(baseline, scanState.sorted);
|
|
360
413
|
if (outcome.action === "save") {
|
|
361
414
|
writeBaseline(projectArg ?? ".", scanState.sorted);
|
|
362
415
|
const count = scanState.sorted.length;
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
416
|
+
if (!isStdout) {
|
|
417
|
+
console.log(chalk.green(`✓ Baseline saved to .cve-lite/baseline.json with ${count} ${count === 1 ? "finding" : "findings"}. Future scans will only report findings above this baseline.`));
|
|
418
|
+
if (options.checkOverrides) {
|
|
419
|
+
console.log(chalk.gray(`Note: override hygiene (--check-overrides) is not part of the ratchet baseline; run \`${OVERRIDES_COMMAND}\` to audit overrides.`));
|
|
420
|
+
}
|
|
366
421
|
}
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
}
|
|
375
|
-
|
|
422
|
+
// A missing baseline accepts no debt, including on fresh CI checkouts.
|
|
423
|
+
const gateLine = failingGateSummary([{ label: GATE_CLASS_LABELS.vulnerability, findings: scanState.sorted }], options.failOn);
|
|
424
|
+
if (gateLine && !options.json && !isStdout && !options.fix) {
|
|
425
|
+
console.log(chalk.red(gateLine));
|
|
426
|
+
}
|
|
427
|
+
if (count > 0 && !options.json && !isStdout) {
|
|
428
|
+
console.log(chalk.gray(`Commit .cve-lite/baseline.json ${RATCHET_BASELINE_COMMIT_HINT}`));
|
|
429
|
+
}
|
|
430
|
+
const exitCode = gateLine && !options.fix ? 1 : 0;
|
|
431
|
+
// A first run accepts nothing, so every finding is reported and none is accepted.
|
|
432
|
+
return finishRatchetRun(scanState.sorted, [], exitCode);
|
|
376
433
|
}
|
|
377
434
|
const { newFindings, suppressedCount: sc } = outcome;
|
|
378
435
|
const suppressedLabel = `${sc} existing ${sc === 1 ? "finding" : "findings"} suppressed`;
|
|
379
436
|
if (newFindings.length === 0) {
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
findingsCount: scanState.sorted.length,
|
|
387
|
-
exitCode: 0,
|
|
388
|
-
});
|
|
389
|
-
return 0;
|
|
437
|
+
if (!isStdout) {
|
|
438
|
+
console.log(chalk.green(`No new findings above baseline - ${suppressedLabel}`));
|
|
439
|
+
}
|
|
440
|
+
// Nothing actionable, so the artefact carries an empty finding set and records what the
|
|
441
|
+
// baseline is holding. Writing no file at all is what made accepted debt look resolved.
|
|
442
|
+
return finishRatchetRun([], scanState.sorted, 0);
|
|
390
443
|
}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
const
|
|
394
|
-
|
|
444
|
+
if (!isStdout) {
|
|
445
|
+
console.log(chalk.red(`${newFindings.length} new ${newFindings.length === 1 ? "finding" : "findings"} above baseline - ${suppressedLabel}`));
|
|
446
|
+
for (const f of newFindings) {
|
|
447
|
+
const ids = f.vulnerabilities.map(v => v.id).join(", ");
|
|
448
|
+
console.log(` ${chalk.yellow(f.severity)} ${f.pkg.name}@${f.pkg.version}${ids ? ` (${ids})` : ""}`);
|
|
449
|
+
}
|
|
450
|
+
console.log(chalk.gray("To accept these, re-baseline intentionally by deleting .cve-lite/baseline.json and re-running --ratchet."));
|
|
395
451
|
}
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
schemaVersion: 1,
|
|
401
|
-
durationMs: Date.now() - scanStartTime,
|
|
402
|
-
findingsCount: newFindings.length,
|
|
403
|
-
exitCode: 1,
|
|
404
|
-
});
|
|
405
|
-
return 1;
|
|
452
|
+
// The build fails here because something new appeared, which is exactly the run where a
|
|
453
|
+
// machine-readable artefact matters most, and it produced none.
|
|
454
|
+
const acceptedHere = scanState.sorted.filter(f => !newFindings.includes(f));
|
|
455
|
+
return finishRatchetRun(newFindings, acceptedHere, 1);
|
|
406
456
|
}
|
|
407
457
|
// auto-apply baseline if it exists - filter before output
|
|
408
458
|
if (baseline) {
|
|
@@ -430,13 +480,14 @@ export async function handleSingleFolderScan(params) {
|
|
|
430
480
|
const licenseResult = await detectLicenseIssues({
|
|
431
481
|
lockfilePath: scanInput.filePath,
|
|
432
482
|
directDeps,
|
|
433
|
-
isNpm: scanInput.source
|
|
483
|
+
isNpm: isNpmLockSource(scanInput.source),
|
|
434
484
|
isOffline: !!options.offline || !!options.offlineDb,
|
|
435
485
|
});
|
|
436
486
|
licenseFindings = licenseResult.findings;
|
|
437
487
|
licenseLimitedToDirectOnly = licenseResult.limitedToDirectOnly;
|
|
438
488
|
}
|
|
439
|
-
await writeOutputs(options, {
|
|
489
|
+
const scanJsonPath = await writeOutputs(options, {
|
|
490
|
+
registry: reportedRegistry,
|
|
440
491
|
sorted: scanState.sorted,
|
|
441
492
|
allPackages: scanState.allPackages,
|
|
442
493
|
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
@@ -452,7 +503,9 @@ export async function handleSingleFolderScan(params) {
|
|
|
452
503
|
licenseFindings,
|
|
453
504
|
licenseLimitedToDirectOnly,
|
|
454
505
|
}, scanInput, projectPath);
|
|
455
|
-
if (
|
|
506
|
+
if (scanJsonPath)
|
|
507
|
+
onScanJsonPath?.(scanJsonPath);
|
|
508
|
+
if (!isOutputStdout(options.output) && (!(options.json || options.sarif || options.sbom) || options.verbose)) {
|
|
456
509
|
const offline = !!options.offline || !!options.offlineDb;
|
|
457
510
|
const showOverrideHint = !options.checkOverrides && !options.ratchet && hasOverrideEntries(projectPath);
|
|
458
511
|
if (options.verbose) {
|
|
@@ -522,6 +575,7 @@ export async function handleSingleFolderScan(params) {
|
|
|
522
575
|
if (options.report) {
|
|
523
576
|
const outputDir = path.resolve(typeof options.report === "string" ? options.report : "./cve-report");
|
|
524
577
|
const reportData = buildReportData({
|
|
578
|
+
registry: { registry: reportedRegistry.registry, sourceFile: reportedRegistry.sourceFile },
|
|
525
579
|
projectPath,
|
|
526
580
|
cliVersion,
|
|
527
581
|
packageManager: scanInput.source,
|
|
@@ -542,13 +596,15 @@ export async function handleSingleFolderScan(params) {
|
|
|
542
596
|
licenseLimitedToDirectOnly: options.checkLicenses ? licenseLimitedToDirectOnly : undefined,
|
|
543
597
|
completeness: scanState.completeness,
|
|
544
598
|
});
|
|
545
|
-
// report.json follows the --json schema, plus
|
|
546
|
-
//
|
|
599
|
+
// report.json follows the --json schema, plus saved-artifact provenance
|
|
600
|
+
// (cliVersion/scannedAt/effectiveOptions via the builders, #1296),
|
|
601
|
+
// lockfileSource, and per-finding riskSummary/nextAction (stdout --json
|
|
547
602
|
// stays unchanged via buildScanJson alone).
|
|
548
603
|
const jsonPayload = {
|
|
549
604
|
...buildScanJson({
|
|
550
605
|
projectPath,
|
|
551
606
|
scanInput,
|
|
607
|
+
registry: reportedRegistry,
|
|
552
608
|
findings: scanState.sorted,
|
|
553
609
|
suggestedFixCommands: scanState.suggestedFixCommands,
|
|
554
610
|
coverage: scanState.coverage,
|
|
@@ -561,9 +617,9 @@ export async function handleSingleFolderScan(params) {
|
|
|
561
617
|
maintenanceFindings,
|
|
562
618
|
licenseFindings,
|
|
563
619
|
licenseLimitedToDirectOnly,
|
|
620
|
+
// Saved-artifact provenance for report.json (#1296).
|
|
621
|
+
provenance: { cliVersion, options },
|
|
564
622
|
}),
|
|
565
|
-
scannedAt: reportData.scannedAt,
|
|
566
|
-
cliVersion: reportData.cliVersion,
|
|
567
623
|
lockfileSource: reportData.lockfileSource,
|
|
568
624
|
findings: reportData.findings,
|
|
569
625
|
};
|
|
@@ -580,7 +636,7 @@ export async function handleSingleFolderScan(params) {
|
|
|
580
636
|
findings: scanState.sorted.length,
|
|
581
637
|
packages: packages.length,
|
|
582
638
|
});
|
|
583
|
-
if (baseline) {
|
|
639
|
+
if (baseline && !isOutputStdout(options.output)) {
|
|
584
640
|
if (scanState.sorted.length === 0) {
|
|
585
641
|
console.log(chalk.green(`No new findings above baseline - ${suppressedCount} existing ${suppressedCount === 1 ? "finding" : "findings"} suppressed`));
|
|
586
642
|
}
|
|
@@ -595,12 +651,12 @@ export async function handleSingleFolderScan(params) {
|
|
|
595
651
|
// The gate and the line that explains it come from one call, so the exit code
|
|
596
652
|
// and the printed reason cannot drift apart.
|
|
597
653
|
const gateLine = failingGateSummary([
|
|
598
|
-
{ label:
|
|
599
|
-
{ label:
|
|
600
|
-
{ label:
|
|
654
|
+
{ label: GATE_CLASS_LABELS.vulnerability, findings: scanState.sorted },
|
|
655
|
+
{ label: GATE_CLASS_LABELS.overrideHygiene, findings: overrideFindings },
|
|
656
|
+
{ label: GATE_CLASS_LABELS.maintenanceRisk, findings: maintenanceFindings },
|
|
601
657
|
], options.failOn);
|
|
602
658
|
const shouldFail = gateLine !== null;
|
|
603
|
-
if (gateLine && !options.json && !options.fix)
|
|
659
|
+
if (gateLine && !options.json && !isOutputStdout(options.output) && !options.fix)
|
|
604
660
|
console.log(chalk.red(gateLine));
|
|
605
661
|
// In fix mode, remaining transitive findings cannot be auto-fixed.
|
|
606
662
|
// Exiting non-zero would prevent the Action PR step from running.
|