vigievuln 1.2.0 → 1.3.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/CHANGELOG.md +23 -2
- package/README.md +13 -7
- package/lib/advisory-freshness.js +2 -0
- package/lib/airgap-project.js +35 -7
- package/lib/applicability-evidence.js +12 -0
- package/lib/artifacts/applications.js +54 -0
- package/lib/artifacts/cve-view.js +108 -0
- package/lib/artifacts/enrichment.js +86 -0
- package/lib/artifacts/go-main-identity.js +45 -0
- package/lib/artifacts/go-publisher-advisories.js +24 -0
- package/lib/artifacts/index.js +272 -0
- package/lib/artifacts/publisher-advisories.js +12 -0
- package/lib/artifacts/remediation-report.js +48 -0
- package/lib/artifacts/report-inventory.js +26 -0
- package/lib/artifacts/report.js +191 -0
- package/lib/artifacts/risk-report.js +120 -0
- package/lib/artifacts/sbom.js +68 -0
- package/lib/artifacts/scan.js +401 -0
- package/lib/cache-archive-sqlite.js +41 -25
- package/lib/certs/analyze.js +49 -13
- package/lib/charts.js +124 -32
- package/lib/cli-command-routing.js +20 -6
- package/lib/cli-groups.js +2 -1
- package/lib/cli-image.js +206 -0
- package/lib/codecs/binary/elf-metadata.js +42 -0
- package/lib/codecs/binary/go-buildinfo.js +37 -0
- package/lib/codecs/binary/metadata.js +7 -0
- package/lib/codecs/binary/pe-metadata.js +27 -1
- package/lib/codecs/binary/scan.js +44 -26
- package/lib/codecs/binary/sniff.js +16 -15
- package/lib/codecs/binary.codec.js +27 -4
- package/lib/codecs/go/parse.js +10 -4
- package/lib/codecs/go.codec.js +23 -6
- package/lib/codecs/gradle/parse.js +63 -2
- package/lib/codecs/gradle/versionless.js +175 -0
- package/lib/codecs/gradle.codec.js +20 -3
- package/lib/codecs/index.js +2 -2
- package/lib/codecs/maven.codec.js +9 -4
- package/lib/codecs/npm/collect.js +6 -11
- package/lib/codecs/nuget/parse.js +16 -5
- package/lib/codecs/nuget.codec.js +2 -1
- package/lib/codecs/pypi/parse.js +56 -15
- package/lib/codecs/pypi.codec.js +2 -0
- package/lib/csaf-export.js +46 -11
- package/lib/cve-download.js +33 -29
- package/lib/cve-match.js +10 -0
- package/lib/cve-packages-proxy.js +19 -0
- package/lib/cve-report.js +273 -165
- package/lib/deps-descriptor.js +25 -3
- package/lib/diagnostics.js +12 -0
- package/lib/diff.js +0 -0
- package/lib/epss.js +6 -6
- package/lib/euvd.js +34 -4
- package/lib/finding-enrichment.js +165 -0
- package/lib/finding-summary.js +4 -3
- package/lib/i18n.js +35 -9
- package/lib/image-network.js +54 -0
- package/lib/image-references.js +203 -0
- package/lib/image-registry.js +385 -0
- package/lib/image-update.js +39 -0
- package/lib/json-export.js +100 -10
- package/lib/kev.js +6 -6
- package/lib/maven-bom.js +2 -1
- package/lib/merge-sources.js +3 -0
- package/lib/native-advisories.js +9 -7
- package/lib/native-cna-identities.js +12 -0
- package/lib/native-package-match.js +159 -0
- package/lib/native-source-prepare.js +60 -0
- package/lib/nvd.js +34 -23
- package/lib/osv.js +33 -14
- package/lib/project-descriptor.js +3 -2
- package/lib/provenance.js +8 -2
- package/lib/providers/alpine.js +8 -0
- package/lib/providers/common.js +11 -3
- package/lib/providers/debian.js +11 -0
- package/lib/providers/euvd.js +2 -1
- package/lib/providers/freexian.js +13 -0
- package/lib/providers/github.js +1 -0
- package/lib/providers/go.js +2 -1
- package/lib/providers/index.js +18 -14
- package/lib/providers/nginx.js +5 -0
- package/lib/providers/nvd.js +1 -1
- package/lib/providers/osv.js +1 -1
- package/lib/providers/osvdb.js +2 -2
- package/lib/proxy-throttle.js +89 -29
- package/lib/purl.js +10 -2
- package/lib/record-freshness.js +22 -0
- package/lib/report-notices.js +47 -0
- package/lib/report-time.js +45 -0
- package/lib/request-failure.js +22 -0
- package/lib/resource-cache/engine.js +130 -26
- package/lib/resource-cache/snapshot-projection.js +33 -0
- package/lib/resource-cache/validate.js +22 -5
- package/lib/risk-evidence.js +18 -0
- package/lib/sarif-export.js +17 -9
- package/lib/sbom-export.js +38 -12
- package/lib/source-health.js +25 -8
- package/lib/source-image-scan.js +57 -0
- package/lib/source-profile.js +6 -3
- package/lib/sqlite-driver.js +15 -1
- package/lib/suppress.js +34 -13
- package/lib/system-inventory/advisories.js +169 -0
- package/lib/system-inventory/alpine-tracker.js +47 -0
- package/lib/system-inventory/collect.js +118 -0
- package/lib/system-inventory/current-debian.js +99 -0
- package/lib/system-inventory/distribution-sources.js +132 -0
- package/lib/system-inventory/freexian-ela.js +32 -0
- package/lib/system-inventory/freexian-release-evidence.js +35 -0
- package/lib/system-inventory/freexian-tracker.js +72 -0
- package/lib/system-inventory/historical-debian.js +196 -0
- package/lib/system-inventory/index.js +2 -0
- package/lib/system-inventory/nginx-advisories.js +39 -0
- package/lib/system-inventory/rpm-storage.js +86 -0
- package/lib/system-inventory/targeted.js +70 -0
- package/lib/system-inventory/versions.js +59 -0
- package/lib/transitive.js +11 -2
- package/lib/ui.js +8 -5
- package/lib/unmanaged.js +1 -1
- package/lib/xlsx-export.js +8 -2
- package/package.json +12 -3
- package/vigievuln.js +279 -127
package/vigievuln.js
CHANGED
|
@@ -45,7 +45,27 @@ try {
|
|
|
45
45
|
process.argv = [...process.argv.slice(0, 2), ...routed.args];
|
|
46
46
|
} catch (error) { console.error(`❌ ${error.message}`); process.exit(2); }
|
|
47
47
|
|
|
48
|
-
if (process.argv[2] === "
|
|
48
|
+
if (process.argv[2] === "image") {
|
|
49
|
+
if (!process.env.__FAD_PROXY_REEXEC__) {
|
|
50
|
+
const { parseProxyFlag, runtimeSupportsEnvProxy, reexecWithProxy } = require('./lib/proxy-cache');
|
|
51
|
+
const corpProxy = parseProxyFlag();
|
|
52
|
+
if (corpProxy) {
|
|
53
|
+
if (!/^https?:\/\//i.test(corpProxy)) { console.error('❌ --proxy expects an http(s) URL'); process.exit(2); }
|
|
54
|
+
if (!runtimeSupportsEnvProxy()) console.warn('⚠️ This Node version may not support environment proxy settings.');
|
|
55
|
+
const i=process.argv.indexOf('--proxy-cache');
|
|
56
|
+
let proxyCache=i>=0?process.argv[i+1]:null;
|
|
57
|
+
if(!proxyCache) {
|
|
58
|
+
const command=require('./lib/cli-image').makeCommand();command.exitOverride().configureOutput({writeErr(){},writeOut(){}});
|
|
59
|
+
try{command.parse(process.argv.slice(3),{from:'user'});const layers=require('./lib/options-env').loadLayers({configPath:command.opts().config,program:command});proxyCache=require('./lib/options-env').applyLayers(command,layers,require('./lib/config').load()).proxyCache;}catch{}
|
|
60
|
+
}
|
|
61
|
+
let noProxyHost=null;try{noProxyHost=new URL(proxyCache).hostname}catch{}
|
|
62
|
+
reexecWithProxy({proxyUrl:corpProxy,noProxy:noProxyHost});return;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
require("./lib/cli-image").run(process.argv.slice(3)).catch(err => {
|
|
66
|
+
console.error(`❌ ${err.message}`); process.exitCode = 2;
|
|
67
|
+
}).finally(() => { require('./lib/cache-db').closeCacheDbs(); });
|
|
68
|
+
} else if (process.argv[2] === "setup") {
|
|
49
69
|
require("./lib/cli-setup").run(process.argv.slice(3)).catch(err => {
|
|
50
70
|
console.error(`❌ ${err.message}`); process.exitCode = 2;
|
|
51
71
|
}).finally(() => process.exit(process.exitCode || 0));
|
|
@@ -238,7 +258,7 @@ if (process.argv.includes("--export-cache") || process.argv.includes("--import-c
|
|
|
238
258
|
// Resolve the same profile layers as a scan before the early archive command.
|
|
239
259
|
const { Command } = require("commander");
|
|
240
260
|
const archiveProgram = new Command().allowUnknownOption(true).allowExcessArguments(true)
|
|
241
|
-
.option("--config <file>").option("--source-profile <profile>")
|
|
261
|
+
.option("--config <file>").option("--source-profile <profile>").option("--cache-dir <directory>")
|
|
242
262
|
.option("--proxy-cache <url>").option("--vigievuln-proxy [domain]");
|
|
243
263
|
archiveProgram.parse(process.argv);
|
|
244
264
|
const layersApi = require("./lib/options-env");
|
|
@@ -246,8 +266,10 @@ if (process.argv.includes("--export-cache") || process.argv.includes("--import-c
|
|
|
246
266
|
let archiveOptions = layersApi.applyLayers(archiveProgram, layers, require("./lib/config").load());
|
|
247
267
|
archiveOptions = { ...archiveOptions, ...require("./lib/hosted-proxy").resolveHostedProxy({ ...archiveOptions, offline: true }) };
|
|
248
268
|
archiveOptions = require("./lib/source-profile").applySourceProfile(archiveOptions).options;
|
|
249
|
-
const proxyOrigin = archiveOptions.sourceProfile === "proxy" ? require("./lib/proxy-scope").proxyOrigin(archiveOptions.proxyCache) : null;
|
|
250
|
-
|
|
269
|
+
const proxyOrigin = archiveOptions.sourceProfile === "proxy" || (archiveOptions.cacheDir && archiveOptions.proxyCache) ? require("./lib/proxy-scope").proxyOrigin(archiveOptions.proxyCache) : null;
|
|
270
|
+
const customRoot = archiveOptions.cacheDir ? path.resolve(archiveOptions.cacheDir) : null;
|
|
271
|
+
if (proxyOrigin && customRoot) fs.mkdirSync(customRoot, {recursive:true,mode:0o700});
|
|
272
|
+
const cacheDir = proxyOrigin ? require("./lib/proxy-scope").proxyScope(proxyOrigin, customRoot ? {homeDir:customRoot} : {}) : customRoot || require("./lib/cache-directory").getCacheDir();
|
|
251
273
|
const { exportCache, importCache } = require("./lib/cache-archive-sqlite");
|
|
252
274
|
const verbose = process.argv.includes("--verbose");
|
|
253
275
|
const exportIdx = process.argv.indexOf("--export-cache");
|
|
@@ -298,7 +320,7 @@ if (process.argv.includes("--export-cache") || process.argv.includes("--import-c
|
|
|
298
320
|
// Standalone differential audit between two findings JSON exports. Mirrors the other
|
|
299
321
|
// pre-parse intercepts so it never collides with the main option set (which requires -s).
|
|
300
322
|
if (process.argv[2] === "diff") {
|
|
301
|
-
const { diffFindings, summarizeDiff, newProductionCveCount } = require("./lib/diff");
|
|
323
|
+
const { diffFindings, summarizeDiff, newProductionCveCount, isProductionCve, validateFindingsDocument, baselineProjectWarning } = require("./lib/diff");
|
|
302
324
|
const rest = process.argv.slice(3);
|
|
303
325
|
const positionals = rest.filter(a => !a.startsWith("-"));
|
|
304
326
|
const [basePath, curPath] = positionals;
|
|
@@ -310,26 +332,34 @@ if (process.argv[2] === "diff") {
|
|
|
310
332
|
process.exit(2);
|
|
311
333
|
}
|
|
312
334
|
let baseDoc, curDoc;
|
|
313
|
-
try { baseDoc = JSON.parse(fs.readFileSync(basePath, "utf8")); }
|
|
335
|
+
try { baseDoc = validateFindingsDocument(JSON.parse(fs.readFileSync(basePath, "utf8"))); }
|
|
314
336
|
catch (e) { console.error(chalk.red(`❌ cannot read baseline ${basePath}: ${e.message}`)); process.exit(2); }
|
|
315
|
-
try { curDoc = JSON.parse(fs.readFileSync(curPath, "utf8")); }
|
|
337
|
+
try { curDoc = validateFindingsDocument(JSON.parse(fs.readFileSync(curPath, "utf8"))); }
|
|
316
338
|
catch (e) { console.error(chalk.red(`❌ cannot read current ${curPath}: ${e.message}`)); process.exit(2); }
|
|
339
|
+
const baselineWarning = baselineProjectWarning(baseDoc, curDoc);
|
|
340
|
+
if (baselineWarning) console.error(chalk.yellow(`⚠ ${baselineWarning.message}`));
|
|
317
341
|
const d = diffFindings(baseDoc, curDoc);
|
|
318
342
|
const s = summarizeDiff(d);
|
|
319
343
|
const newProd = newProductionCveCount(d);
|
|
320
344
|
console.log(chalk.bold(`\nDifferential audit ${chalk.dim(basePath)} → ${chalk.dim(curPath)}\n`));
|
|
321
|
-
const line = (label, c) => console.log(` ${label.padEnd(10)} ${chalk.red(`+${c.added} new`)} ${chalk.green(`-${c.removed} fixed`)} ${chalk.dim(`${c.unchanged} unchanged`)}`);
|
|
345
|
+
const line = (label, c) => console.log(` ${label.padEnd(10)} ${chalk.red(`+${c.added} new`)} ${chalk.green(`-${c.removed} fixed`)} ${chalk.dim(`${c.unchanged} unchanged`)}${c.unassessed ? ` ${c.unassessed} previous unassessed` : ''}${c.unassessedAdded ? ` ${c.unassessedAdded} current unassessed` : ''}`);
|
|
322
346
|
line("CVE", s.cve); line("EOL", s.eol); line("Obsolete", s.obsolete); line("Outdated", s.outdated); line("Licenses", s.licenses);
|
|
323
347
|
console.log();
|
|
324
348
|
const sev = Object.entries(s.cve.addedBySeverity).filter(([, n]) => n).map(([k, n]) => `${n} ${k.toLowerCase()}`).join(", ") || "none";
|
|
325
349
|
console.log(` ${chalk.bold("New production CVE findings:")} ${newProd ? chalk.red.bold(newProd) : chalk.green("0")} ${chalk.dim(`(${sev})`)}`);
|
|
326
|
-
const newCves = (d.cve.added || []).filter(
|
|
350
|
+
const newCves = (d.cve.added || []).filter(isProductionCve);
|
|
327
351
|
for (const f of newCves.slice(0, 25)) console.log(` ${chalk.red("•")} ${f.id} ${chalk.dim((f.severity || "") + " · " + ((f.dep && f.dep.coord) || "") + "@" + ((f.dep && f.dep.version) || ""))}`);
|
|
328
352
|
if (newCves.length > 25) console.log(chalk.dim(` …and ${newCves.length - 25} more`));
|
|
329
353
|
if (jsonOut) {
|
|
330
|
-
const out = { tool: "vigievuln", kind: "fad-diff/1", baseline: basePath, current: curPath, summary: s, diff: d
|
|
331
|
-
|
|
332
|
-
|
|
354
|
+
const out = { tool: "vigievuln", kind: "fad-diff/1", baseline: basePath, current: curPath, summary: s, diff: d,
|
|
355
|
+
warnings: baselineWarning ? [baselineWarning] : [] };
|
|
356
|
+
try {
|
|
357
|
+
fs.mkdirSync(path.dirname(path.resolve(jsonOut)), { recursive: true });
|
|
358
|
+
fs.writeFileSync(jsonOut, JSON.stringify(out, null, 2) + "\n");
|
|
359
|
+
} catch (err) {
|
|
360
|
+
console.error(chalk.red(`❌ cannot write diff report to ${jsonOut}: ${err.message}`));
|
|
361
|
+
process.exit(2);
|
|
362
|
+
}
|
|
333
363
|
console.log(chalk.green(`\n✅ diff written → ${jsonOut}`));
|
|
334
364
|
}
|
|
335
365
|
console.log();
|
|
@@ -450,6 +480,9 @@ program
|
|
|
450
480
|
.option("--no-default-excludes", "walk everything, including node_modules/vendor/target/…")
|
|
451
481
|
.option("--verbose", "verbose") // -v is the version flag; verbose is long-form only
|
|
452
482
|
.option("--force-update", "revalidate all consulted online sources, retaining cached data on failure")
|
|
483
|
+
.option("--reuse-stable-advisories", "reuse cached individual advisories unchanged for at least the configured age", true)
|
|
484
|
+
.option("--no-reuse-stable-advisories", "refresh older individual advisories using normal cache lifetimes")
|
|
485
|
+
.option("--stable-advisory-age-days <days>", "minimum unchanged advisory age for reuse (default: 365)", Number)
|
|
453
486
|
// Defaults: report + transitive + allLibs all ON. Use --no-* to disable.
|
|
454
487
|
.option("--no-report", "write NO output files at all — the scan, terminal summary and --fail-on gate still run (gate-only / CI mode)")
|
|
455
488
|
.option("--no-transitive", "skip transitive dependency resolution")
|
|
@@ -488,6 +521,7 @@ program
|
|
|
488
521
|
.option("--no-nvd-mirror", "NVD only: don't fall back to the fkie-cad/nvd-json-data-feeds mirror when NVD does not answer")
|
|
489
522
|
.option("--retries <n>", "retries (waiting 5+n s each) before a data source is marked unavailable; 0 = none", "5")
|
|
490
523
|
.option("--proxy-cache <url|vigievuln|default>", "shared data-source cache or official VigieVuln proxy")
|
|
524
|
+
.option("--proxy-rate-limit-wait-ms <milliseconds>", "maximum proxy retry wait per request (default: 45000)", Number)
|
|
491
525
|
.option("--allow-insecure-http", "allow unencrypted HTTP to the selected proxy for this invocation")
|
|
492
526
|
.option("--set-proxy-cache <url|vigievuln|default>", "save the proxy cache for future scans")
|
|
493
527
|
.option("--unset-proxy-cache", "remove the saved proxy cache")
|
|
@@ -553,6 +587,9 @@ program
|
|
|
553
587
|
.option("--no-go", "skip the Go codec")
|
|
554
588
|
.option("--no-ruby", "skip the Ruby (Bundler) codec")
|
|
555
589
|
.option("--no-binaries", "skip scanning committed native binaries (.dll/.exe/.so/.dylib)")
|
|
590
|
+
.option("--images", "enable image analysis in source-tree scans (off by default)", false)
|
|
591
|
+
.option("--no-images", "skip image declaration discovery and image analysis in source-tree scans")
|
|
592
|
+
.option("--image-platform <os/arch[/variant]>", "image platform when no platform is declared", "linux/amd64")
|
|
556
593
|
.option("--no-jars", "skip scanning embedded .jar/.war/.ear binaries for Maven coordinates")
|
|
557
594
|
.option("--no-certs", "skip scanning committed certificates, private/public keys (PEM/SSH/PuTTY/PGP) and keystores")
|
|
558
595
|
.option("--cert-expiry-days <n>", "warn on certificates expiring within N days", "90")
|
|
@@ -572,8 +609,8 @@ program
|
|
|
572
609
|
program.addHelpText("after", `
|
|
573
610
|
-d eol nvd nvd-mirror osv packagist-audit epss kev euvd gcve certfr retire transitive all-libs checksums
|
|
574
611
|
osv-db report vendored-js-inventory default-excludes
|
|
575
|
-
maven gradle npm yarn nuget composer pypi go ruby js jars binaries certs
|
|
576
|
-
-a licenses eol-support typosquat snyk osv-db nvd-cpe-match cve-refresh
|
|
612
|
+
maven gradle npm yarn nuget composer pypi go ruby js jars binaries certs images
|
|
613
|
+
-a images licenses eol-support typosquat snyk osv-db nvd-cpe-match cve-refresh
|
|
577
614
|
cve-offline gcve-offline osv-db-refresh retire-refresh
|
|
578
615
|
e.g. vigievuln scan . -d nvd,epss,certs -a licenses,typosquat -o ./audit
|
|
579
616
|
--help-all lists the individual flags these replace. Full guide: docs/USAGE.md`);
|
|
@@ -584,6 +621,7 @@ if (!process.argv.includes("--help-all")) {
|
|
|
584
621
|
const { foldedFlags } = require("./lib/cli-groups");
|
|
585
622
|
const { ADMIN_FLAGS, REPORTS } = require("./lib/cli-groups");
|
|
586
623
|
const folded = new Set([...foldedFlags(), ...ADMIN_FLAGS, ...REPORTS.map(r => `--report-${r}`),
|
|
624
|
+
"--images", "--image-platform", "--reuse-stable-advisories", "--no-reuse-stable-advisories", "--stable-advisory-age-days", "--proxy-rate-limit-wait-ms",
|
|
587
625
|
"--source", "--list-app-plugins", "--scan-context", "--private-component", "--public-component", "--wordfence-live", "--wordfence-feed", "--drupal-advisories", "--wordfence-feed-url", "--drupal-advisories-live", "--prestashop-advisories", "--prestashop-advisories-live", "--typo3-advisories", "--typo3-advisories-live", "--spip-advisories", "--spip-advisories-live", "--wp-checksums", "--wp-checksums-live", "--wp-checksums-locale", "--max-advisory-age", "--fail-on-incomplete", "--proxy-cache-token", "--advisory-query-ttl", "--prepare-offline", "--output"]);
|
|
588
626
|
for (const opt of program.options) if (folded.has(opt.long)) opt.hidden = true;
|
|
589
627
|
} else {
|
|
@@ -727,17 +765,27 @@ if (options.advisoryQueryTtl !== undefined && (!/^(?:0|[1-9]\d*)$/.test(String(o
|
|
|
727
765
|
console.error(chalk.red('❌ --advisory-query-ttl must be an integer from 0 to 8760 hours.'));
|
|
728
766
|
process.exit(2);
|
|
729
767
|
}
|
|
768
|
+
if (options.imagePlatform && (typeof options.imagePlatform !== 'string' || !/^[a-z0-9][a-z0-9._-]*\/[a-z0-9][a-z0-9._-]*(?:\/[a-z0-9][a-z0-9._-]*)?$/.test(options.imagePlatform))) {
|
|
769
|
+
console.error(chalk.red('❌ --image-platform must be os/architecture[/variant].'));
|
|
770
|
+
process.exit(2);
|
|
771
|
+
}
|
|
730
772
|
options.advisoryQueryTtlMs = options.advisoryQueryTtl === undefined ? 4 * 3600 * 1000 : Number(options.advisoryQueryTtl) * 3600 * 1000;
|
|
773
|
+
try { options.maxAdvisoryAgeMs = options.maxAdvisoryAge ? require('./lib/advisory-freshness').parseMaxAge(options.maxAdvisoryAge) : 0; }
|
|
774
|
+
catch (err) { console.error(chalk.red(`❌ ${err.message}`)); process.exit(2); }
|
|
731
775
|
if (options.forceUpdate && (options.offline || options.exportAnonymized || options.prepareProject)) {
|
|
732
776
|
console.error(chalk.red('❌ --force-update requires an online scan or cache preparation.'));
|
|
733
777
|
process.exit(2);
|
|
734
778
|
}
|
|
735
779
|
require('./lib/cache-policy').setForceUpdate(!!options.forceUpdate);
|
|
736
|
-
|
|
780
|
+
if (options.stableAdvisoryAgeDays !== undefined && (!Number.isSafeInteger(options.stableAdvisoryAgeDays) || options.stableAdvisoryAgeDays < 1 || options.stableAdvisoryAgeDays > 36500)) {
|
|
781
|
+
console.error(chalk.red('❌ --stable-advisory-age-days must be an integer from 1 to 36500.'));
|
|
782
|
+
process.exit(2);
|
|
783
|
+
}
|
|
784
|
+
let profileWarnings = [], profileNotices = [];
|
|
737
785
|
try {
|
|
738
786
|
const explicit = name => program.getOptionValueSource(name) === 'cli' || (name === 'osvDb' && String(options.activate || '').split(',').includes('osv-db'));
|
|
739
787
|
const result = require('./lib/source-profile').applySourceProfile(options, {explicit});
|
|
740
|
-
Object.assign(options, result.options); profileWarnings = result.warnings;
|
|
788
|
+
Object.assign(options, result.options); profileWarnings = result.warnings; profileNotices = result.notices || [];
|
|
741
789
|
for (const warning of profileWarnings) ui.warn(warning);
|
|
742
790
|
} catch (err) { console.error(chalk.red(`❌ ${err.message}`)); process.exit(2); }
|
|
743
791
|
if (options.sourceProfile === 'proxy') {
|
|
@@ -755,6 +803,9 @@ const verbose = !!options.verbose;
|
|
|
755
803
|
// globalThis.fetch, so wrapping it once covers all of them — and a lookup served from the
|
|
756
804
|
// warm cache issues no request at all, which IS the "100% from cache, stay silent" rule.
|
|
757
805
|
const sourceHealth = createSourceHealth();
|
|
806
|
+
// Image registries supply dependency artifacts, while advisory requests retain
|
|
807
|
+
// their configured proxy route. Never send a VigieVuln proxy token to a registry.
|
|
808
|
+
const registryFetch = globalThis.fetch;
|
|
758
809
|
const officialAccountFetch = options.sourceProfile === 'proxy' && options.vigievulnProxy && !options.offline
|
|
759
810
|
? require('./lib/source-profile').officialAccountFetch(globalThis.fetch) : null;
|
|
760
811
|
try { setRetryAttempts(options.retries == null ? 5 : options.retries); }
|
|
@@ -772,7 +823,7 @@ if (!options.offline) {
|
|
|
772
823
|
const { configureResourceRoute } = require("./lib/providers");
|
|
773
824
|
const { createCacheStore } = require("./lib/proxy-cache");
|
|
774
825
|
try {
|
|
775
|
-
configureResourceRoute({ proxyUrl: options.proxyCache, hosted: !!options.vigievulnProxy,
|
|
826
|
+
configureResourceRoute({ proxyUrl: options.proxyCache, hosted: !!options.vigievulnProxy, resetRateLimit:true, proxyRateLimitMaxWaitMs:options.proxyRateLimitWaitMs,
|
|
776
827
|
token: options.proxyCacheToken || (process.env.VIGIEVULN_PROXY_CACHE_TOKEN ?? process.env.FAD_PROXY_CACHE_TOKEN) || null,
|
|
777
828
|
health: sourceHealth, fetcher: baseFetch,
|
|
778
829
|
store: options.vigievulnProxy ? null : createCacheStore(require("node:path").join(require("./lib/cache-directory").getCacheDir(), "resource-cache")),
|
|
@@ -812,6 +863,19 @@ if (options.failOn) {
|
|
|
812
863
|
}
|
|
813
864
|
options.failOn = lvl;
|
|
814
865
|
}
|
|
866
|
+
let baselineDoc = null;
|
|
867
|
+
if (options.failOnNew && !options.baseline) {
|
|
868
|
+
console.error(chalk.red("❌ --fail-on-new requires --baseline <findings.json>"));
|
|
869
|
+
process.exit(2);
|
|
870
|
+
}
|
|
871
|
+
if (options.baseline) {
|
|
872
|
+
try {
|
|
873
|
+
baselineDoc = require("./lib/diff").validateFindingsDocument(JSON.parse(fs.readFileSync(options.baseline, "utf8")));
|
|
874
|
+
} catch (err) {
|
|
875
|
+
console.error(chalk.red(`❌ cannot read baseline ${options.baseline}: ${err.message}`));
|
|
876
|
+
process.exit(2);
|
|
877
|
+
}
|
|
878
|
+
}
|
|
815
879
|
// Read-only when no target is given. No need for an explicit --test flag.
|
|
816
880
|
const readOnly = !options.target;
|
|
817
881
|
// -t is an EXTRACTION step (walk + link the reactor + cleaned tree + POM analysis),
|
|
@@ -1065,9 +1129,9 @@ async function timedPhase(label, fn) {
|
|
|
1065
1129
|
try { descriptor = JSON.parse(fs.readFileSync(options.importAnonymized, "utf8")); }
|
|
1066
1130
|
catch (e) { console.error(chalk.red(`❌ could not read --import-anonymized file: ${e.message}`)); process.exit(1); }
|
|
1067
1131
|
let imported;
|
|
1068
|
-
try { imported = deserializeDeps(descriptor); }
|
|
1132
|
+
try { imported = deserializeDeps(descriptor, { images: options.images }); }
|
|
1069
1133
|
catch (e) { console.error(chalk.red(`❌ invalid descriptor: ${e.message}`)); process.exit(1); }
|
|
1070
|
-
const { resolved, activeIds, runMaven, runNpm, externalParents = [], importBoms = [], propertyOverrides = {}, applications = [], reactor } = imported;
|
|
1134
|
+
const { resolved, activeIds, runMaven, runNpm, externalParents = [], importBoms = [], propertyOverrides = {}, applications = [], imageReferences = [], reactor } = imported;
|
|
1071
1135
|
// Resolve the project and query its package versions below. A global OSV
|
|
1072
1136
|
// seed is optional and must not be downloaded for a project archive.
|
|
1073
1137
|
ui.section("Anonymized descriptor");
|
|
@@ -1075,7 +1139,7 @@ async function timedPhase(label, fn) {
|
|
|
1075
1139
|
+ (applications.length ? ` · ${chalk.bold(applications.length)} application(s) (${[...new Set(applications.map(a => a.type))].join(", ")})` : ""));
|
|
1076
1140
|
if (options.offline) ui.warn("--offline: caches won't warm; only useful to re-render from an already-warm cache");
|
|
1077
1141
|
if (runMaven && !reactor) ui.warn("This descriptor lacks Maven module resolution information; the offline cache may be incomplete. Re-export the descriptor from the extracted manifests with this version.");
|
|
1078
|
-
if (!resolved.size && !applications.length) { ui.warn("descriptor has no dependencies or applications — nothing to scan"); process.exit(0); }
|
|
1142
|
+
if (!resolved.size && !applications.length && !imageReferences.length) { ui.warn("descriptor has no dependencies or applications — nothing to scan"); process.exit(0); }
|
|
1079
1143
|
// Replay the external-parent / import-BOM backfill from the descriptor's carried hints.
|
|
1080
1144
|
// Workflow B has no source tree here, so the mainline store-based backfill can't run —
|
|
1081
1145
|
// without this, versionless deps (spring-boot-starter-*) stay unresolved and their CVE
|
|
@@ -1138,14 +1202,14 @@ async function timedPhase(label, fn) {
|
|
|
1138
1202
|
? await classifyMavenLibs([...resolved.values()].filter(d => d.ecosystem === "maven")
|
|
1139
1203
|
.map(d => `${d.namespace || d.groupId}:${d.name || d.artifactId}`), mavenRepos)
|
|
1140
1204
|
: [];
|
|
1141
|
-
const warmedReport = await runReportFlow(resolved, { activeIds, runMaven, runNpm, privateLibIds, mavenRepos, regMap, collectWarnings: [], walkOpts, mavenStore: reactor?.store, mavenPropsByPom: reactor?.propsByPom });
|
|
1205
|
+
const warmedReport = await runReportFlow(resolved, { activeIds, runMaven, runNpm, privateLibIds, mavenRepos, regMap, collectWarnings: [], walkOpts, mavenStore: reactor?.store, mavenPropsByPom: reactor?.propsByPom, imageReferences });
|
|
1142
1206
|
if (options.prepareOffline && !process.exitCode) {
|
|
1143
|
-
const scope=require('./lib/airgap-project').buildProjectScope(resolved,{applications,cves:warmedReport?.cveIds || []});
|
|
1207
|
+
const scope=require('./lib/airgap-project').buildProjectScope(resolved,{applications,cves:warmedReport?.cveIds || [],imageReferences:warmedReport?.imageReferences || [],images:options.images});
|
|
1144
1208
|
const cacheDir=require('./lib/cache-directory').getCacheDir();
|
|
1145
1209
|
const proxyOrigin=options.sourceProfile==='proxy' ? require('./lib/proxy-scope').proxyOrigin(options.proxyCache) : null;
|
|
1146
|
-
if(!scope.packages.length) ui.warn('no package scope available; exporting the complete local cache');
|
|
1210
|
+
if(!scope.packages.length && !scope.imageReferences?.length) ui.warn('no package scope available; exporting the complete local cache');
|
|
1147
1211
|
try {
|
|
1148
|
-
const result=await require('./lib/cache-archive-sqlite').exportCache(options.output,{sourceDir:cacheDir,proxyOrigin,project:scope.packages.length?scope:null});
|
|
1212
|
+
const result=await require('./lib/cache-archive-sqlite').exportCache(options.output,{sourceDir:cacheDir,proxyOrigin,project:(scope.packages.length || scope.imageReferences?.length)?scope:null});
|
|
1149
1213
|
ui.ok(`offline archive prepared: ${result.path} (${(result.size/1048576).toFixed(2)} MiB; ${scope.packages.length} packages)`);
|
|
1150
1214
|
} catch(error) {console.error(chalk.red(`❌ could not prepare offline archive: ${error.message}`));process.exitCode=2;}
|
|
1151
1215
|
}
|
|
@@ -1185,6 +1249,12 @@ async function timedPhase(label, fn) {
|
|
|
1185
1249
|
// inventory — including files parsed that contributed no scannable dep (ranges-only /
|
|
1186
1250
|
// no lockfile), which would otherwise be invisible.
|
|
1187
1251
|
const parsedManifests = [];
|
|
1252
|
+
const imageDiscovery = options.images === false ? { references: [], warnings: [] }
|
|
1253
|
+
: require('./lib/image-references').discoverImageReferences(options.src, walkOpts);
|
|
1254
|
+
for (const ref of imageDiscovery.references) ref.platform ||= options.imagePlatform;
|
|
1255
|
+
// Declarations and unresolved CI variables belong to image coverage details.
|
|
1256
|
+
// Only actual discovery failures enter the scan diagnostics.
|
|
1257
|
+
collectWarnings.push(...imageDiscovery.warnings);
|
|
1188
1258
|
for (const id of activeIds) {
|
|
1189
1259
|
if (id === "yarn") continue; // the npm codec already collects yarn.lock
|
|
1190
1260
|
const codec = getCodec(id);
|
|
@@ -1237,7 +1307,7 @@ async function timedPhase(label, fn) {
|
|
|
1237
1307
|
}
|
|
1238
1308
|
if (embeddedCount) ui.ok(`${chalk.bold("Embedded".padEnd(8))} ${embeddedCount} coord(s) in .jar/.war/.ear`);
|
|
1239
1309
|
if (binaryCount) ui.ok(`${chalk.bold("Binary".padEnd(8))} ${binaryCount} native lib(s) (.dll/.exe/.so/.dylib)`);
|
|
1240
|
-
if (!ecoCount.maven && !ecoCount.npm && !Object.keys(ecoCount).length) ui.warn("no dependencies found in the source tree");
|
|
1310
|
+
if (!ecoCount.maven && !ecoCount.npm && !Object.keys(ecoCount).length && !imageDiscovery.references.length) ui.warn("no dependencies found in the source tree");
|
|
1241
1311
|
if (collectWarnings.length) {
|
|
1242
1312
|
ui.warn(`${collectWarnings.length} manifest warning(s) — best-effort / no lockfile:`);
|
|
1243
1313
|
for (const w of collectWarnings.slice(0, 5)) ui.info(chalk.dim(w.message));
|
|
@@ -1246,7 +1316,7 @@ async function timedPhase(label, fn) {
|
|
|
1246
1316
|
|
|
1247
1317
|
// --- Anonymized phase 1: export a descriptor and exit (no network, no report) ---
|
|
1248
1318
|
if (options.prepareProject) {
|
|
1249
|
-
const descriptor = require("./lib/project-descriptor").buildProjectDescriptor(resolved, {generator:`vigievuln ${pkg.version}
|
|
1319
|
+
const descriptor = require("./lib/project-descriptor").buildProjectDescriptor(resolved, {generator:`vigievuln ${pkg.version}`,imageReferences:imageDiscovery.references,images:options.images});
|
|
1250
1320
|
try { fs.writeFileSync(options.prepareProject, JSON.stringify(descriptor, null, 2) + "\n", {mode:0o600}); fs.chmodSync(options.prepareProject,0o600); }
|
|
1251
1321
|
catch (e) { console.error(chalk.red(`❌ could not write project descriptor: ${e.message}`)); process.exitCode=1; return; }
|
|
1252
1322
|
const counts = Object.fromEntries(["direct","transitive","unknown"].map(k=>[k,descriptor.deps.filter(d=>d.relation===k).length]));
|
|
@@ -1294,6 +1364,7 @@ async function timedPhase(label, fn) {
|
|
|
1294
1364
|
let omittedProperties = 0;
|
|
1295
1365
|
const reactor = mavenCtx?.store && mavenCtx?.propsByPom ? require('./lib/maven-airgap').buildReactorHints(mavenCtx, { exclude: deps2Exclude, versionPropertyNames: collectVersionPropertyNames(mavenCtx.store) }) : null;
|
|
1296
1366
|
const descriptor = serializeDeps(resolved, { generator: `vigievuln ${pkgVersion}`, externalParents, importBoms, reactor,
|
|
1367
|
+
imageReferences: imageDiscovery.references, images: options.images,
|
|
1297
1368
|
propertyOverrides, versionPropertyNames: collectVersionPropertyNames(mavenCtx?.store), applications,
|
|
1298
1369
|
onOmittedProperties: n => { omittedProperties = n; } });
|
|
1299
1370
|
try { fs.writeFileSync(options.exportAnonymized, JSON.stringify(descriptor, null, 2) + "\n"); }
|
|
@@ -1303,7 +1374,7 @@ async function timedPhase(label, fn) {
|
|
|
1303
1374
|
ui.ok(`${chalk.bold(descriptor.summary.total)} dep(s) (${ecoSummary || "none"}) → ${chalk.white(options.exportAnonymized)}`);
|
|
1304
1375
|
ui.info(chalk.dim("dependency coordinates and filtered version hints — exclude private coordinates and review before transfer."));
|
|
1305
1376
|
if (omittedProperties) ui.warn(`${omittedProperties} Maven property value(s) omitted for privacy. Unusual version-property overrides used only by uncached external parents may require review.`);
|
|
1306
|
-
if (!descriptor.summary.total) ui.warn("no dependencies collected — descriptor is empty");
|
|
1377
|
+
if (!descriptor.summary.total && !descriptor.imageReferences?.length) ui.warn("no dependencies collected — descriptor is empty");
|
|
1307
1378
|
// Guide the operator through the remaining two phases (the descriptor file +
|
|
1308
1379
|
// this run's --src are filled in so the commands are copy-paste ready).
|
|
1309
1380
|
const descFile = options.exportAnonymized;
|
|
@@ -1444,15 +1515,23 @@ async function timedPhase(label, fn) {
|
|
|
1444
1515
|
// The scan always runs — it feeds the terminal summary, the file outputs and the
|
|
1445
1516
|
// CI gate. Which files get written is decided by the --report-* family inside
|
|
1446
1517
|
// (HTML + findings JSON by default; --no-report writes nothing).
|
|
1447
|
-
await runReportFlow(resolved, { activeIds, runMaven, runGradle, runNpm, privateLibIds, mavenRepos, regMap, collectWarnings, mavenPropsByPom: mavenCtx?.propsByPom, mavenStore: mavenCtx?.store, gradlePlatformBoms: gradleCtx?.platformBoms || [], parsedManifests, composerPlatforms: composerCtx?.platforms || [], walkOpts });
|
|
1518
|
+
await runReportFlow(resolved, { activeIds, runMaven, runGradle, runNpm, privateLibIds, mavenRepos, regMap, collectWarnings, mavenPropsByPom: mavenCtx?.propsByPom, mavenStore: mavenCtx?.store, gradlePlatformBoms: gradleCtx?.platformBoms || [], parsedManifests, composerPlatforms: composerCtx?.platforms || [], walkOpts, imageReferences: imageDiscovery.references });
|
|
1448
1519
|
if (!readOnly) {
|
|
1449
1520
|
ui.section("Next step");
|
|
1450
1521
|
ui.info(`run Snyk on the cleaned tree:`);
|
|
1451
1522
|
console.log(" " + chalk.white(`cd ${options.target} && snyk test --json --all-projects | snyk-to-html -o ../snyk-deps-check.html`));
|
|
1452
1523
|
}
|
|
1453
|
-
})()
|
|
1524
|
+
})().catch(err => {
|
|
1525
|
+
console.error(chalk.red(`❌ scan failed: ${err.message || String(err)}`));
|
|
1526
|
+
if (verbose && err.stack) console.error(err.stack);
|
|
1527
|
+
process.exitCode = 2;
|
|
1528
|
+
});
|
|
1454
1529
|
|
|
1455
1530
|
async function runReportFlow(resolved, ecoFlags = {}) {
|
|
1531
|
+
if (!options.proxyCache && !options.importAnonymized) {
|
|
1532
|
+
const t = require("./lib/i18n").makeT(options.lang);
|
|
1533
|
+
console.error("\n " + chalk.yellow("⚠") + " " + chalk.yellow(t("For faster scans with the VigieVuln DB or a seed → vigievuln setup")));
|
|
1534
|
+
}
|
|
1456
1535
|
const { activeIds = [], runMaven = true, runGradle = false, runNpm = false, privateLibIds = [], mavenRepos = [], regMap = {}, collectWarnings = [], mavenPropsByPom = null, mavenStore = null, gradlePlatformBoms = [], parsedManifests = [], composerPlatforms = [], walkOpts = {} } = ecoFlags;
|
|
1457
1536
|
const { excludePath = [], defaultExcludes = true } = walkOpts;
|
|
1458
1537
|
const registriesFor = eco => regMap[eco] || [];
|
|
@@ -1467,6 +1546,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1467
1546
|
// Collection counts already shown in the "Collection" section by main();
|
|
1468
1547
|
// for --import-anonymized they were shown in the "Anonymized descriptor" section.
|
|
1469
1548
|
const npmWarnings = collectWarnings || [];
|
|
1549
|
+
const scanNotices = [...profileNotices];
|
|
1470
1550
|
let scanWarnings = profileWarnings.map(message => ({type:'source-unavailable', message}));
|
|
1471
1551
|
const sourceLimitations = [];
|
|
1472
1552
|
const noteSourceLimitation = (source, message) => {
|
|
@@ -1490,15 +1570,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1490
1570
|
ui.warn("Wordfence live scan requires an API key: use --wordfence-api-key or WORDFENCE_API_KEY. No report was written.");
|
|
1491
1571
|
process.exit(2);
|
|
1492
1572
|
}
|
|
1493
|
-
|
|
1494
|
-
if (options.maxAdvisoryAge) {
|
|
1495
|
-
const { parseMaxAge } = require("./lib/advisory-freshness");
|
|
1496
|
-
try { maxAdvisoryAgeMs = parseMaxAge(options.maxAdvisoryAge); }
|
|
1497
|
-
catch (error) {
|
|
1498
|
-
console.error(chalk.red(`❌ ${error.message}`));
|
|
1499
|
-
process.exit(2);
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1573
|
+
const maxAdvisoryAgeMs = options.maxAdvisoryAgeMs;
|
|
1502
1574
|
const drupalLiveUrl = options.drupalAdvisoriesLive
|
|
1503
1575
|
? (options.drupalAdvisoriesLive === true ? DRUPAL_ADVISORIES_URL : options.drupalAdvisoriesLive) : null;
|
|
1504
1576
|
const prestashopLiveUrl = options.prestashopAdvisoriesLive
|
|
@@ -1602,8 +1674,11 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1602
1674
|
// them through the same managed-version backfill (e.g. spring-boot-dependencies → all the
|
|
1603
1675
|
// versionless spring-boot-starter-* declared in build.gradle get their version).
|
|
1604
1676
|
const gradleBoms = (gradlePlatformBoms || [])
|
|
1677
|
+
.filter(b => !b.inferred)
|
|
1605
1678
|
.map(b => ({ groupId: b.group, artifactId: b.name, version: b.version }))
|
|
1606
1679
|
.filter(b => b.groupId && b.artifactId && b.version);
|
|
1680
|
+
const inferredGradleBoms = (gradlePlatformBoms || []).filter(b => b.inferred && b.manifestPath)
|
|
1681
|
+
.map(b => ({ groupId: b.group, artifactId: b.name, version: b.version, manifestPath: b.manifestPath }));
|
|
1607
1682
|
const allBoms = importBoms.concat(gradleBoms);
|
|
1608
1683
|
// External <parent> POMs (e.g. spring-boot-starter-parent) manage versionless declared
|
|
1609
1684
|
// deps via their own inherited depMgmt (spring-boot-dependencies). core.js only follows
|
|
@@ -1612,7 +1687,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1612
1687
|
// captures the parent POMs for offline reuse.
|
|
1613
1688
|
const externalParents = (runMaven && mavenStore)
|
|
1614
1689
|
? require("./lib/maven-bom").collectExternalParents(mavenStore) : [];
|
|
1615
|
-
const willBom = allBoms.length > 0 || externalParents.length > 0;
|
|
1690
|
+
const willBom = allBoms.length > 0 || inferredGradleBoms.length > 0 || externalParents.length > 0;
|
|
1616
1691
|
const willOsv = !!options.osv || options.osvDb === true;
|
|
1617
1692
|
// Packagist security-advisories lane (Composer): the advisory DB `composer audit`
|
|
1618
1693
|
// queries. OSV misses CVEs that exist there only as CVEProject entries without
|
|
@@ -1658,6 +1733,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1658
1733
|
// The external import-BOM + <parent> managed table, kept for the transitive pass: Maven
|
|
1659
1734
|
// pins transitive versions with it too, not only versionless declarations.
|
|
1660
1735
|
let bomDepMgmt = new Map();
|
|
1736
|
+
let gradleBomDepMgmt = new Map();
|
|
1661
1737
|
if (willBom) {
|
|
1662
1738
|
const st = progress.start("BOM / parent version resolution (Maven Central)");
|
|
1663
1739
|
try {
|
|
@@ -1677,7 +1753,9 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1677
1753
|
for (const [k, v] of parentMgmt) if (!mgmt.has(k)) mgmt.set(k, v);
|
|
1678
1754
|
bomDepMgmt = mgmt;
|
|
1679
1755
|
const filled = backfillVersions(resolved, mgmt);
|
|
1680
|
-
|
|
1756
|
+
gradleBomDepMgmt = await resolveBomManagedVersions(inferredGradleBoms, base);
|
|
1757
|
+
const gradleFilled = backfillVersions(resolved, gradleBomDepMgmt);
|
|
1758
|
+
st.done(`${filled + gradleFilled} dep version(s) from ${allBoms.length + inferredGradleBoms.length} BOM(s) + ${externalParents.length} parent(s)`);
|
|
1681
1759
|
} catch (err) { st.fail(err.message); scanWarnings.push({type:'dependency-coverage',message:'Maven BOM or parent resolution failed; dependency coverage is incomplete.'}); }
|
|
1682
1760
|
}
|
|
1683
1761
|
|
|
@@ -1709,6 +1787,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1709
1787
|
includeTestDeps: !options.ignoreTest,
|
|
1710
1788
|
repos: mavenRepos,
|
|
1711
1789
|
bomDepMgmt,
|
|
1790
|
+
gradleBomDepMgmt,
|
|
1712
1791
|
...mavenCoverage,
|
|
1713
1792
|
// With the reactor in charge of the Maven records, only Gradle ones are seeded here.
|
|
1714
1793
|
...(willReactor ? { only: d => d.ecosystemType === "gradle" } : {}),
|
|
@@ -1742,6 +1821,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1742
1821
|
|
|
1743
1822
|
// 1. CVE — native scanner contributed by the maven codec (local cvelistV5 index).
|
|
1744
1823
|
let cveMatches = [];
|
|
1824
|
+
const sourceConsultations = [];
|
|
1745
1825
|
let cveDataDate = null;
|
|
1746
1826
|
if (willCve) {
|
|
1747
1827
|
const st = progress.start("CVE index (CVEProject)");
|
|
@@ -1750,15 +1830,11 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1750
1830
|
cveMatches = r.matches || [];
|
|
1751
1831
|
cveDataDate = r.meta?.cveDataDate || null;
|
|
1752
1832
|
if (r.meta?.incomplete) {
|
|
1753
|
-
if (!
|
|
1833
|
+
if (!r.meta.refreshError) noteSourceLimitation('CVEProject','The Maven lookup uses a partial native or legacy projection; some source records may not be represented.');
|
|
1754
1834
|
else scanWarnings.push({type:"source-unavailable",message:`CVEProject: ${r.meta.refreshError ? `refresh failed (${r.meta.refreshError}); ` : ""}native or legacy source coverage is partial; Maven advisory coverage is incomplete.`});
|
|
1755
1835
|
}
|
|
1756
1836
|
if (r.meta?.identityUncertain) {
|
|
1757
|
-
|
|
1758
|
-
const needsReview=require('./lib/coverage-diagnostics').needsMavenReview;
|
|
1759
|
-
if (r.meta.oldProjection || candidates.some(candidate=>needsReview(candidate,cveStore,{ttlMs:options.advisoryQueryTtlMs})))
|
|
1760
|
-
scanWarnings.push({type:"source-unavailable",message:"CVEProject: some advisory product identities or version ranges could not be verified; those candidates were not reported and coverage is incomplete."});
|
|
1761
|
-
else noteSourceLimitation('CVEProject','Some product-only candidates lack a reliable Maven package identity; independent OSV evidence is used when available.');
|
|
1837
|
+
noteSourceLimitation('CVEProject','Some advisory candidates have insufficient product identity or version evidence to establish applicability; they were not reported as findings.');
|
|
1762
1838
|
}
|
|
1763
1839
|
if (r.meta?.stale || r.meta?.timestampUnknown) scanWarnings.push({type:"source-stale",message:`CVEProject: proxy response ${r.meta.timestampUnknown ? "has no trustworthy collection timestamp" : "is stale"}; advisory coverage may be outdated.`});
|
|
1764
1840
|
if (r.meta?.conflict) scanWarnings.push({type:"source-unavailable",message:"CVEProject: a native record conflicts with the proxy corpus; the native revision or rejection was used."});
|
|
@@ -1784,7 +1860,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1784
1860
|
cveMatches = require('./lib/merge-sources').mergeBySource(cveMatches, npmCves.matches);
|
|
1785
1861
|
if (npmCves.unknown.length) scanWarnings.push({type:'source-unavailable',message:`CVEProject: ${npmCves.unknown.length} npm package/version comparison(s) are undecidable; advisory coverage is incomplete.`});
|
|
1786
1862
|
const npmNames=require('./lib/cve-npm-proxy').packageNames(resolved);
|
|
1787
|
-
if (!cveStore.getSourceCoverage('cveproject','*')?.complete && npmNames.some(name
|
|
1863
|
+
if (!cveStore.getSourceCoverage('cveproject','*')?.complete && npmNames.some(name=>{const q=cveStore.getQuery({source:'cveproject',ecosystem:'npm',name,version:'*'},{ttlMs:options.advisoryQueryTtlMs});return !q || q.provenance?.stale || (!(offline || options.cveOffline) && !q.fresh);})) scanWarnings.push({type:'source-unavailable',message:'CVEProject: native npm advisory coverage is incomplete; records absent from OSV may be missing.'});
|
|
1788
1864
|
} catch (err) { scanWarnings.push({type:'source-unavailable',message:`CVEProject npm: ${err.message}; advisory coverage is incomplete.`}); }
|
|
1789
1865
|
}
|
|
1790
1866
|
|
|
@@ -1907,7 +1983,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1907
1983
|
const st = progress.start("OSV.dev");
|
|
1908
1984
|
try {
|
|
1909
1985
|
const { queryOsvForDeps } = require("./lib/osv");
|
|
1910
|
-
const osvMatches = await queryOsvForDeps(resolved, { verbose, offline, allowStaleFallback:true, queryTtlMs:options.osvDbRefresh ? 0 : options.advisoryQueryTtlMs, useStoredRanges:options.osvDb !== false,
|
|
1986
|
+
const osvMatches = await queryOsvForDeps(resolved, { ...options, verbose, offline, allowStaleFallback:true, queryTtlMs:options.osvDbRefresh ? 0 : options.advisoryQueryTtlMs, useStoredRanges:options.osvDb !== false,
|
|
1911
1987
|
onProgress: (p, t) => st.tick(p, t), onWarning: w => scanWarnings.push(w) });
|
|
1912
1988
|
const before = cveMatches.length;
|
|
1913
1989
|
cveMatches = mergeBySource(cveMatches, osvMatches);
|
|
@@ -1918,7 +1994,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1918
1994
|
}
|
|
1919
1995
|
}
|
|
1920
1996
|
else {
|
|
1921
|
-
try { cveMatches=mergeBySource(cveMatches,require('./lib/osv').queryReviewedForDeps(resolved,{store:cveStore,queryTtlMs:options.advisoryQueryTtlMs,onWarning:w=>scanWarnings.push(w)})); }
|
|
1997
|
+
try { cveMatches=mergeBySource(cveMatches,require('./lib/osv').queryReviewedForDeps(resolved,{store:cveStore,offline,maxAdvisoryAgeMs:options.maxAdvisoryAgeMs,queryTtlMs:options.advisoryQueryTtlMs,onWarning:w=>scanWarnings.push(w)})); }
|
|
1922
1998
|
catch(err) { scanWarnings.push({type:'source-unavailable',message:`VigieVuln: reviewed advisory matching failed (${err.message}); coverage is incomplete.`}); }
|
|
1923
1999
|
}
|
|
1924
2000
|
|
|
@@ -1983,7 +2059,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1983
2059
|
const result = require('./lib/native-advisories').matchGcveStore(resolved,store,index);
|
|
1984
2060
|
const before = cveMatches.length;
|
|
1985
2061
|
cveMatches = mergeBySource(cveMatches,result.matches);
|
|
1986
|
-
if (stale) scanWarnings.push({type:'source-stale',message:'GCVE index is older than the advisory query TTL or lacks a source timestamp; advisory coverage may be outdated.'});
|
|
2062
|
+
if (stale) scanWarnings.push({type:'source-stale',...(offline || options.gcveOffline ? {severity:'info'} : {}),message:'GCVE index is older than the advisory query TTL or lacks a source timestamp; advisory coverage may be outdated.'});
|
|
1987
2063
|
const skipped = index?.directory?.notCollected;
|
|
1988
2064
|
const unindexed = result.coverage.reduce((n,c)=>n+(c.unindexed || 0),0);
|
|
1989
2065
|
if (!result.sourceCoverage?.complete || (index && (!index.directory?.verified || !result.coverage.length || result.coverage.some(c=>!c.complete) || skipped || unindexed)))
|
|
@@ -1996,6 +2072,30 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
1996
2072
|
}
|
|
1997
2073
|
}
|
|
1998
2074
|
|
|
2075
|
+
// Typed native package records share one SQL matching path for every
|
|
2076
|
+
// ecosystem. This pass is independent of OSV/NVD results and complements
|
|
2077
|
+
// the older Maven/npm projections without guessing product identities.
|
|
2078
|
+
{
|
|
2079
|
+
const sources = [!options.disableCveProject && 'cveproject', willGcve && 'gcve'].filter(Boolean);
|
|
2080
|
+
try {
|
|
2081
|
+
// The Maven scanner already prepares CVEProject. Other ecosystems
|
|
2082
|
+
// need the same preparation even when OSV has returned no findings.
|
|
2083
|
+
if (!willCve && !options.disableCveProject && [...resolved.values()].some(d => d.provenance !== 'binary' && require('./lib/native-package-match').depIdentity(d))) {
|
|
2084
|
+
const prepared = await require('./lib/native-source-prepare').prepareNativeSources(resolved,{
|
|
2085
|
+
...options, offline, store:cveStore, nativeSources:['cveproject'],
|
|
2086
|
+
});
|
|
2087
|
+
for (const c of prepared.coverage) {
|
|
2088
|
+
sourceConsultations.push({capability:'sources',collector:c.source,execution:c.execution,result:c.status,reason:c.reason,fetchedAt:c.fetchedAt});
|
|
2089
|
+
if (c.issue && c.issue!=='refresh-failed') scanWarnings.push({type:'source-unavailable',...(c.issue==='missing-source'?{severity:'info'}:{}),source:c.source,message:`CVEProject: ${c.reason}.`});
|
|
2090
|
+
}
|
|
2091
|
+
for (const warning of prepared.warnings) scanWarnings.push(typeof warning==='string'?{type:'source-unavailable',message:warning}:warning);
|
|
2092
|
+
}
|
|
2093
|
+
const native = require('./lib/native-advisories').matchNativePackages(resolved,cveStore,{sources});
|
|
2094
|
+
cveMatches = mergeBySource(cveMatches,native.matches);
|
|
2095
|
+
if (native.unknown.length) scanWarnings.push({type:'source-unavailable',severity:'info',message:`Native advisories: ${native.unknown.length} package/version comparison(s) are undecidable; coverage is incomplete.`});
|
|
2096
|
+
} catch (err) { scanWarnings.push({type:'source-unavailable',message:`Native advisories: ${err.message}; coverage is incomplete.`}); }
|
|
2097
|
+
}
|
|
2098
|
+
|
|
1999
2099
|
// Application-provider findings enter the shared enrichment, priority and gate
|
|
2000
2100
|
// pipeline through the same alias-aware seam as every other CVE source: a publisher
|
|
2001
2101
|
// constat that the standard Composer lane already found (same coord+version+CVE —
|
|
@@ -2020,9 +2120,11 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2020
2120
|
try {
|
|
2021
2121
|
const { enrichMatches, hasCachedAbsence } = require("./lib/nvd");
|
|
2022
2122
|
const nvdCandidates = [...cveMatches, ...nvdBindings];
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
const
|
|
2123
|
+
const answeredAbsent = new Set();
|
|
2124
|
+
await enrichMatches(nvdCandidates, { ...options, verbose, offline, mirror: options.nvdMirror !== false, onProgress: (p, t) => st.tick(p, t), onAbsent:id=>answeredAbsent.add(id) });
|
|
2125
|
+
const isAbsent = id => answeredAbsent.has(id) || hasCachedAbsence(id,{offline});
|
|
2126
|
+
const unavailableBindings = new Set(nvdBindings.filter(m => !m.source.split('+').includes('nvd') && !isAbsent(m.cve.id)).map(m => m.cve.id));
|
|
2127
|
+
const absentBindings = new Set(nvdBindings.filter(m => !m.source.split('+').includes('nvd') && isAbsent(m.cve.id)).map(m => m.cve.id));
|
|
2026
2128
|
if (unavailableBindings.size) scanWarnings.push({type:'source-unavailable',message:`NVD: ${unavailableBindings.size} package-bound CVE record(s) unavailable; additional version-range coverage is incomplete.`});
|
|
2027
2129
|
if (absentBindings.size) noteSourceLimitation('NVD',`NVD returned no record for ${absentBindings.size} package-linked CVE(s) at the last consultation.`);
|
|
2028
2130
|
|
|
@@ -2036,7 +2138,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2036
2138
|
let nativeNvdUncertain = false, nativeNvdCandidates = false;
|
|
2037
2139
|
const needsReview=require('./lib/coverage-diagnostics').needsMavenReview;
|
|
2038
2140
|
const boundNvd = [...matchNvdAffected(resolved, nvdCandidates, {onUncertain:candidate=>{nativeNvdCandidates=true;if(needsReview(candidate,cveStore,{ttlMs:options.advisoryQueryTtlMs}))nativeNvdUncertain=true;}}), ...matchBoundNvdRanges(resolved, nvdCandidates)];
|
|
2039
|
-
if (nativeNvdUncertain) scanWarnings.push({type:'source-unavailable',message:'NVD: some native affected entries have unverified package identities or version applicability; those candidates were not reported and coverage is incomplete.'});
|
|
2141
|
+
if (nativeNvdUncertain) scanWarnings.push({type:'source-unavailable',severity:'info',message:'NVD: some native affected entries have unverified package identities or version applicability; those candidates were not reported and coverage is incomplete.'});
|
|
2040
2142
|
else if (nativeNvdCandidates) noteSourceLimitation('NVD','Some product-only candidates lack a reliable Maven package identity; independent OSV evidence is used when available.');
|
|
2041
2143
|
if (boundNvd.length) {
|
|
2042
2144
|
const before = cveMatches.length;
|
|
@@ -2102,39 +2204,6 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2102
2204
|
}
|
|
2103
2205
|
}
|
|
2104
2206
|
|
|
2105
|
-
// 4f-bis. European references — GCVE id (defined by the GCVE rules, no request), the
|
|
2106
|
-
// ENISA EUVD id + exploited flag, and the CERT-FR advisories citing the CVE. All three
|
|
2107
|
-
// are bulk/incremental reads directly, or targeted CVE lookups in hosted proxy mode.
|
|
2108
|
-
if (cveMatches.length) {
|
|
2109
|
-
try { require("./lib/gcve").enrichGcve(cveMatches); }
|
|
2110
|
-
catch (err) { ui.warn(`GCVE ids skipped: ${err.message}`); }
|
|
2111
|
-
}
|
|
2112
|
-
if (willEuvd) {
|
|
2113
|
-
const st = progress.start("ENISA EUVD");
|
|
2114
|
-
if (!cveMatches.length) { st.skip("no CVE"); }
|
|
2115
|
-
else {
|
|
2116
|
-
try {
|
|
2117
|
-
const { enrichEuvd } = require("./lib/euvd");
|
|
2118
|
-
await enrichEuvd(cveMatches, { verbose, offline, hostedProxy: !!options.vigievulnProxy, onStale: date => sourceHealth.markStale('euvd', date) });
|
|
2119
|
-
const ids = new Set(cveMatches.filter(m => m.cve?.euvd?.id).map(m => m.cve.id)).size;
|
|
2120
|
-
const exploited = new Set(cveMatches.filter(m => m.cve?.euvd?.exploitedSince != null).map(m => m.cve.id)).size;
|
|
2121
|
-
st.done(`${ids} EUVD id(s) · ${exploited} exploited per ENISA`);
|
|
2122
|
-
} catch (err) { st.fail(err.message); scanWarnings.push({type:"source-unavailable",message:`EUVD: ${err.message}; enrichment is incomplete.`}); }
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2125
|
-
if (willCertFr) {
|
|
2126
|
-
const st = progress.start("CERT-FR advisories");
|
|
2127
|
-
if (!cveMatches.length) { st.skip("no CVE"); }
|
|
2128
|
-
else {
|
|
2129
|
-
try {
|
|
2130
|
-
const { enrichCertFr } = require("./lib/certfr");
|
|
2131
|
-
await enrichCertFr(cveMatches, { verbose, offline, hostedProxy: !!options.vigievulnProxy, onProgress: (p, t) => st.tick(p, t) });
|
|
2132
|
-
const cited = new Set(cveMatches.filter(m => m.cve?.certfr?.length).map(m => m.cve.id)).size;
|
|
2133
|
-
st.done(`${cited} CVE(s) cited by CERT-FR`);
|
|
2134
|
-
} catch (err) { st.fail(err.message); scanWarnings.push({type:"source-unavailable",message:`CERT-FR: ${err.message}; enrichment is incomplete.`}); }
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
2207
|
// 4g. Composite priority (KEV > EPSS-weighted CVSS). Always — cheap, pure.
|
|
2139
2208
|
try {
|
|
2140
2209
|
const { attachPriority } = require("./lib/priority");
|
|
@@ -2175,7 +2244,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2175
2244
|
if (retireMatches.length && willNvd) {
|
|
2176
2245
|
try {
|
|
2177
2246
|
const { enrichMatches } = require("./lib/nvd");
|
|
2178
|
-
await enrichMatches(retireMatches, { verbose, offline, mirror: options.nvdMirror !== false, onProgress: (p, t) => st.tick(p, t) });
|
|
2247
|
+
await enrichMatches(retireMatches, { ...options, verbose, offline, mirror: options.nvdMirror !== false, onProgress: (p, t) => st.tick(p, t) });
|
|
2179
2248
|
} catch (err) { if (verbose) ui.warn(`vendored-JS NVD enrichment skipped: ${err.message}`); }
|
|
2180
2249
|
}
|
|
2181
2250
|
st.done(`${retireMatches.length} finding(s)${invN ? ` · ${invN} lib(s) inventoried` : ""}`);
|
|
@@ -2224,6 +2293,63 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2224
2293
|
}
|
|
2225
2294
|
}
|
|
2226
2295
|
|
|
2296
|
+
// Context applies to every finding origin, including vendored JS and optional
|
|
2297
|
+
// late providers. Each source runs independently and keeps per-CVE evidence.
|
|
2298
|
+
{
|
|
2299
|
+
const { enrichEuropeanFindings, europeanAdapters } = require('./lib/finding-enrichment');
|
|
2300
|
+
const contextMatches = [...cveMatches, ...retireMatches];
|
|
2301
|
+
const enabled = {gcve:willGcve,euvd:willEuvd,certfr:willCertFr};
|
|
2302
|
+
for (const adapter of europeanAdapters.filter(a => enabled[a.id])) {
|
|
2303
|
+
const st = adapter.id === 'gcve' ? null : progress.start(adapter.id === 'euvd' ? 'ENISA EUVD' : 'CERT-FR advisories');
|
|
2304
|
+
const result = await enrichEuropeanFindings(contextMatches, {
|
|
2305
|
+
...options, verbose, offline, hostedProxy:!!options.vigievulnProxy,
|
|
2306
|
+
europeanAdapters:[adapter,...europeanAdapters.filter(a=>a.parent===adapter.id)],
|
|
2307
|
+
onEnrichmentProgress:event=>st?.tick(`${event.source} ${event.completed}/${event.total}`),
|
|
2308
|
+
});
|
|
2309
|
+
sourceConsultations.push(...result.coverage);
|
|
2310
|
+
scanWarnings.push(...result.warnings);
|
|
2311
|
+
const status = result.coverage[0];
|
|
2312
|
+
if (status?.execution === 'not-applicable') st?.skip('no CVE');
|
|
2313
|
+
else if (status?.execution === 'failed') st?.fail(status.reason);
|
|
2314
|
+
else st?.done(`${status?.count || 0} CVE(s) enriched${status?.execution === 'partial' ? ' · incomplete coverage' : ''}`);
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
|
|
2318
|
+
// Source declarations and anonymous descriptors share the same acquisition and
|
|
2319
|
+
// assessment pipeline. Only the isolated report binds local source locations.
|
|
2320
|
+
const imageProgress = new ui.Progress(2);
|
|
2321
|
+
let imageProgressStep = null, imageProgressPhase = null;
|
|
2322
|
+
const imageState = await require('./lib/source-image-scan').scanSourceImages(ecoFlags.imageReferences, {
|
|
2323
|
+
...options, offline, cacheDir:require('./lib/cache-directory').getCacheDir(),
|
|
2324
|
+
platform:options.imagePlatform, fetcher:globalThis.fetch,
|
|
2325
|
+
registryFetcher:offline ? async () => { throw Error('Registry access is disabled offline'); } : registryFetch,
|
|
2326
|
+
queryTtlMs:options.advisoryQueryTtlMs,
|
|
2327
|
+
onImageProgress:event => {
|
|
2328
|
+
const phase=event.phase==='acquiring'||event.phase==='acquired'?'inventory':'advisories';
|
|
2329
|
+
if(phase!==imageProgressPhase){
|
|
2330
|
+
if(!imageProgressPhase)ui.section('Images');
|
|
2331
|
+
const label=phase==='inventory'?'Image inventories':'Image vulnerability analysis';
|
|
2332
|
+
if(!ui.isTTY)ui.info(`${label}: ${event.total} image(s)`);
|
|
2333
|
+
imageProgressStep=imageProgress.start(label);imageProgressPhase=phase;
|
|
2334
|
+
}
|
|
2335
|
+
const finished=event.phase==='acquired'||event.phase==='assessed';
|
|
2336
|
+
const detail=event.stage?`${event.stage}${event.items?` ${event.processed}/${event.items}`:''} · `:'';
|
|
2337
|
+
imageProgressStep.tick(`${finished?event.completed:event.completed+1}/${event.total} · ${detail}${event.reference}`);
|
|
2338
|
+
if(finished && event.completed===event.total)imageProgressStep.done(`${event.total} image(s) processed`);
|
|
2339
|
+
},
|
|
2340
|
+
});
|
|
2341
|
+
cveMatches = mergeBySource(cveMatches, imageState.matches);
|
|
2342
|
+
for(const [key, dep] of imageState.resolvedDeps) resolved.set(key, dep);
|
|
2343
|
+
scanWarnings.push(...imageState.warnings);
|
|
2344
|
+
scanNotices.push(...imageState.notices);
|
|
2345
|
+
const imageAcquisitionFailed = imageState.references.some(ref => ['failed','assessment-failed'].includes(ref.imageScan?.status));
|
|
2346
|
+
// A preparation must not advertise a usable archive when a requested image
|
|
2347
|
+
// could not be acquired or its assessment failed. Preserve the diagnostics.
|
|
2348
|
+
if(options.prepareOffline && imageAcquisitionFailed) {
|
|
2349
|
+
ui.warn('Offline archive preparation blocked: required image acquisition or assessment failed. See the image diagnostics.');
|
|
2350
|
+
process.exitCode = 2;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2227
2353
|
// 6a-bis. Attribute every match to the manifest/module that actually resolves the
|
|
2228
2354
|
// version it matched on. A depRecord is coord-wide (versions[] and manifestPaths[]
|
|
2229
2355
|
// with no link between them); a match carries ONE version. Must run after ALL match
|
|
@@ -2285,12 +2411,18 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2285
2411
|
// Marked in place; kept in the machine exports (flagged) but dropped from the
|
|
2286
2412
|
// human report's active chapters and from CI gating.
|
|
2287
2413
|
let suppressedCount = 0;
|
|
2414
|
+
const triageWarnings = [];
|
|
2288
2415
|
if (options.ignore || options.vex) {
|
|
2289
2416
|
try {
|
|
2290
|
-
const { parseIgnoreFile, parseVex, applySuppressions } = require("./lib/suppress");
|
|
2417
|
+
const { parseIgnoreFile, parseVex, applySuppressions, hasGlobalIgnoreRule } = require("./lib/suppress");
|
|
2291
2418
|
const rules = [];
|
|
2292
2419
|
if (options.ignore) rules.push(...parseIgnoreFile(fs.readFileSync(options.ignore, "utf8")));
|
|
2293
2420
|
if (options.vex) rules.push(...parseVex(JSON.parse(fs.readFileSync(options.vex, "utf8"))));
|
|
2421
|
+
if (hasGlobalIgnoreRule(rules)) {
|
|
2422
|
+
const warning = { type: "global-ignore", message: "The --ignore file contains a global wildcard: all CVE findings are suppressed, including CI gates. Use an advisory ID or package scope to narrow it." };
|
|
2423
|
+
triageWarnings.push(warning);
|
|
2424
|
+
ui.warn(warning.message);
|
|
2425
|
+
}
|
|
2294
2426
|
suppressedCount = applySuppressions(cveMatches, rules);
|
|
2295
2427
|
const via = [options.ignore && "--ignore", options.vex && "--vex"].filter(Boolean).join(" + ");
|
|
2296
2428
|
if (suppressedCount) ui.info(chalk.dim(`triage: ${suppressedCount} finding(s) suppressed by ${via}`));
|
|
@@ -2298,7 +2430,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2298
2430
|
}
|
|
2299
2431
|
|
|
2300
2432
|
const { sortByPriority } = require("./lib/priority");
|
|
2301
|
-
const isEmbedded = m => m.dep?.provenance === "embedded";
|
|
2433
|
+
const isEmbedded = m => !m.dep?.artifactTargetId && m.dep?.provenance === "embedded";
|
|
2302
2434
|
// Embedded-binary findings get their own chapter, so keep them out of the
|
|
2303
2435
|
// declared prod/dev sets (a coord that's both declared AND embedded yields two
|
|
2304
2436
|
// distinct records — one in each — which is the intended, audit-useful split).
|
|
@@ -2359,7 +2491,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2359
2491
|
|
|
2360
2492
|
{
|
|
2361
2493
|
const { buildInventory } = require("./lib/unmanaged");
|
|
2362
|
-
const inv = buildInventory(resolved);
|
|
2494
|
+
const inv = buildInventory(new Map([...resolved].filter(([, dep]) => !dep.artifactTargetId)));
|
|
2363
2495
|
if (inv.length) {
|
|
2364
2496
|
heading("Unmanaged binaries", inv.length);
|
|
2365
2497
|
for (const e of inv.slice(0, 10)) {
|
|
@@ -2403,10 +2535,12 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2403
2535
|
|
|
2404
2536
|
const durableIssues = require('./lib/package-versions').drainIssues();
|
|
2405
2537
|
if (durableIssues.length) scanWarnings.push({type:'source-unavailable', message:`${durableIssues.length} package version observation(s) are conflicting or invalid; dependency coverage may be incomplete.`,items:durableIssues});
|
|
2538
|
+
{ const split=require('./lib/diagnostics').partitionDiagnostics(scanWarnings); scanWarnings=split.warnings; scanNotices.push(...split.notices); }
|
|
2406
2539
|
if (scanWarnings.length) {
|
|
2407
2540
|
console.log();
|
|
2408
|
-
|
|
2409
|
-
|
|
2541
|
+
const groupedWarnings = require('./lib/report-notices').groupReportWarnings(scanWarnings);
|
|
2542
|
+
ui.warn(`${groupedWarnings.length} scan issue(s):`);
|
|
2543
|
+
for (const w of groupedWarnings) {
|
|
2410
2544
|
ui.info(chalk.dim(`[${w.type}] ${w.message}`));
|
|
2411
2545
|
// Items may be plain strings or { id, manifestPaths } objects (the
|
|
2412
2546
|
// unresolved-versions warning carries the defining manifest paths).
|
|
@@ -2448,6 +2582,8 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2448
2582
|
generatedAt: new Date().toISOString(),
|
|
2449
2583
|
toolVersion: pkg.version,
|
|
2450
2584
|
cveDataDate,
|
|
2585
|
+
...(imageState.references.length ? { imageReferences: imageState.references } : {}),
|
|
2586
|
+
...(imageState.artifacts.length ? { artifacts:imageState.artifacts } : {}),
|
|
2451
2587
|
};
|
|
2452
2588
|
// Scan-provenance manifest: data-source freshness + run configuration, for a
|
|
2453
2589
|
// reproducible/defensible audit. Surfaced in the report's Methodology chapter and
|
|
@@ -2457,6 +2593,8 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2457
2593
|
projectInfo.provenance = buildScanProvenance({ toolVersion: pkg.version, generatedAt: projectInfo.generatedAt, options,
|
|
2458
2594
|
ecosystems:new Set([...resolved.values()].filter(d=>d.provenance!=='binary').map(d=>d.ecosystem)) });
|
|
2459
2595
|
if (sourceLimitations.length) projectInfo.provenance.sourceLimitations=sourceLimitations;
|
|
2596
|
+
projectInfo.provenance.sourceConsultations = sourceConsultations;
|
|
2597
|
+
projectInfo.provenance.notices = scanNotices;
|
|
2460
2598
|
if (mavenDepthLimited) projectInfo.provenance.mavenDepthLimitReached=true;
|
|
2461
2599
|
} catch (err) { if (verbose) ui.warn(`provenance manifest skipped: ${err.message}`); }
|
|
2462
2600
|
|
|
@@ -2494,13 +2632,14 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2494
2632
|
}
|
|
2495
2633
|
|
|
2496
2634
|
const reportWarnings = [
|
|
2497
|
-
...
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2635
|
+
...triageWarnings,
|
|
2636
|
+
...sourceHealth.unreportedOutages(scanWarnings.flatMap(w=>w.requestKeys||[])).map(s => ({type:"source-unavailable",count:1,
|
|
2637
|
+
message:`${s.id}: requested source data could not be retrieved (${s.codes.join(", ") || "no response"}).`})),
|
|
2638
|
+
...sourceHealth.unreportedStale(scanWarnings.flatMap(w=>w.requestKeys||[])).map(s => ({ type:"source-stale", count:1,...(!s.blocking?{severity:'info'}:{}),...(s.refreshFailure?{refreshFailure:s.refreshFailure}:{}),
|
|
2639
|
+
message:s.blocking ? `${s.id}: source refresh failed${s.refreshFailure ? ` (${s.refreshFailure.cause}, HTTP ${s.refreshFailure.status}${s.refreshFailure.retryAfterSeconds!=null?`, retry after ${s.refreshFailure.retryAfterSeconds}s`:''})` : ''}; cached data${s.at ? ` from ${new Date(s.at).toISOString()}` : " of unknown age"} was used. Coverage may be incomplete.` : `${s.id}: cached data${s.at ? ` from ${new Date(s.at).toISOString()}` : " of unknown age"} was used; freshness was not confirmed.` })),
|
|
2501
2640
|
// A project already on a vendor build of an open-source-EOL cycle: covered by the paid
|
|
2502
2641
|
// support that build comes from, so it is a note, not an EOL finding.
|
|
2503
|
-
...commercialBuildNotes.map(e => ({ type: "commercial-build",
|
|
2642
|
+
...commercialBuildNotes.map(e => ({ type: "commercial-build", severity:"info",
|
|
2504
2643
|
product: e.product, cycle: e.cycle, coord: `${e.dep.groupId}:${e.dep.artifactId}`,
|
|
2505
2644
|
version: e.commercialBuild.version, lastPublic: e.commercialBuild.lastPublic, until: e.extendedSupport,
|
|
2506
2645
|
...(e.dep.manifestPaths?.[0] ? { manifestPath: e.dep.manifestPaths[0] } : {}),
|
|
@@ -2539,7 +2678,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2539
2678
|
});
|
|
2540
2679
|
})(),
|
|
2541
2680
|
...(suppressedCount ? [{
|
|
2542
|
-
type: "suppressed",
|
|
2681
|
+
type: "suppressed", severity:"info",
|
|
2543
2682
|
count: suppressedCount,
|
|
2544
2683
|
message: `${suppressedCount} finding(s) suppressed via triage (--ignore/--vex) — excluded from the chapters above and from CI gating, but retained (flagged) in the JSON/SBOM/CSAF exports.`,
|
|
2545
2684
|
}] : []),
|
|
@@ -2569,7 +2708,13 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2569
2708
|
})(),
|
|
2570
2709
|
];
|
|
2571
2710
|
// Freshness is provenance, not a source outage. Keep the evidence in JSON
|
|
2572
|
-
// and
|
|
2711
|
+
// and scan context, without classifying normal provenance as failed work.
|
|
2712
|
+
const informational=require('./lib/diagnostics').partitionDiagnostics(reportWarnings);
|
|
2713
|
+
if(informational.notices.length){
|
|
2714
|
+
projectInfo.provenance ||= {mode:offline?'offline':'online'};
|
|
2715
|
+
projectInfo.provenance.notices=[...(projectInfo.provenance.notices||[]),...informational.notices];
|
|
2716
|
+
reportWarnings.splice(0,reportWarnings.length,...informational.warnings);
|
|
2717
|
+
}
|
|
2573
2718
|
const freshnessNotices = [];
|
|
2574
2719
|
const { freshnessNotice } = require('./lib/cve-report');
|
|
2575
2720
|
for (let i = reportWarnings.length - 1; i >= 0; i--) {
|
|
@@ -2583,39 +2728,46 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2583
2728
|
|
|
2584
2729
|
// Differential audit vs --baseline: build the current findings doc once, diff it
|
|
2585
2730
|
// against the prior export → a `diff` block for the report + JSON export, and a
|
|
2586
|
-
// `--fail-on-new` gate signal.
|
|
2731
|
+
// `--fail-on-new` gate signal. The baseline is validated before scanning.
|
|
2587
2732
|
let diff = null, jsonDiff = null;
|
|
2588
2733
|
if (options.baseline) {
|
|
2589
2734
|
try {
|
|
2590
|
-
const baseDoc =
|
|
2735
|
+
const baseDoc = baselineDoc;
|
|
2591
2736
|
const { buildFindings } = require("./lib/json-export");
|
|
2592
2737
|
const curDoc = buildFindings({ cveMatches, retireMatches, vendoredJsInventory, eolResults, obsoleteResults, outdatedResults, licenseResults,
|
|
2593
2738
|
excludedDirs, resolvedDeps: resolved, projectInfo, toolVersion: pkg.version, typosquats,
|
|
2594
2739
|
applications: appState.applications, applicationInventory: appState.inventory,
|
|
2595
2740
|
applicationRelations, coverage: appState.coverage, warnings: reportWarnings });
|
|
2596
|
-
const { diffFindings, summarizeDiff } = require("./lib/diff");
|
|
2741
|
+
const { diffFindings, summarizeDiff, baselineProjectWarning } = require("./lib/diff");
|
|
2742
|
+
const warning = baselineProjectWarning(baseDoc, curDoc);
|
|
2743
|
+
if (warning) { reportWarnings.push(warning); ui.warn(warning.message); }
|
|
2597
2744
|
const dd = diffFindings(baseDoc, curDoc);
|
|
2598
2745
|
diff = { ...dd, summary: summarizeDiff(dd) };
|
|
2599
2746
|
jsonDiff = { summary: diff.summary, cve: { added: dd.cve.added, removed: dd.cve.removed, unassessed: dd.cve.unassessed } };
|
|
2600
|
-
} catch (err) {
|
|
2747
|
+
} catch (err) { throw new Error(`baseline diff failed (${options.baseline}): ${err.message}`); }
|
|
2601
2748
|
}
|
|
2602
2749
|
|
|
2603
2750
|
const wrote = [];
|
|
2604
|
-
let
|
|
2751
|
+
let exportFailed = false;
|
|
2605
2752
|
// Announce coverage gaps for every output combination, including JSON-only.
|
|
2606
2753
|
warnIfDegraded();
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2754
|
+
for (const [format, label] of [["html", "HTML report"], ["doc", "Word .doc"]]) {
|
|
2755
|
+
if (!out[format]) continue;
|
|
2756
|
+
try {
|
|
2757
|
+
// Write formats independently: a failed destination must not prevent
|
|
2758
|
+
// the remaining requested artifacts or the gate summary from running.
|
|
2759
|
+
await writeReports({
|
|
2760
|
+
cveMatches: prodMatches, devCveMatches: devMatches, embeddedMatches, retireMatches, vendoredJsInventory, certFindings,
|
|
2761
|
+
eolResults, obsoleteResults, outdatedResults, licenseResults, excludedDirs,
|
|
2762
|
+
resolvedDeps: resolved, projectInfo, warnings: reportWarnings, parsedManifests, diff, locale: options.lang,
|
|
2763
|
+
applications: appState.applications, applicationInventory: appState.inventory, applicationRelations, coverage: appState.coverage,
|
|
2764
|
+
htmlPath: format === "html" ? out.html : null, docPath: format === "doc" ? out.doc : null,
|
|
2765
|
+
});
|
|
2766
|
+
wrote.push([label, out[format]]);
|
|
2767
|
+
} catch (err) {
|
|
2768
|
+
exportFailed = true;
|
|
2769
|
+
ui.warn(`${label} export failed (${out[format]}): ${err.message}`);
|
|
2770
|
+
}
|
|
2619
2771
|
}
|
|
2620
2772
|
|
|
2621
2773
|
// Machine-readable exports. Use the full match set (prod + dev + cpe-filtered) so
|
|
@@ -2626,7 +2778,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2626
2778
|
await ensureDir(out.sbom);
|
|
2627
2779
|
writeCycloneDx(resolved, cveMatches, out.sbom, { projectInfo, toolVersion: pkg.version, timestamp: projectInfo.generatedAt, licenseResults });
|
|
2628
2780
|
wrote.push(["CycloneDX SBOM", out.sbom]);
|
|
2629
|
-
} catch (err) { ui.warn(`SBOM export failed: ${err.message}`); }
|
|
2781
|
+
} catch (err) { exportFailed = true; ui.warn(`SBOM export failed: ${err.message}`); }
|
|
2630
2782
|
}
|
|
2631
2783
|
if (out.csaf) {
|
|
2632
2784
|
try {
|
|
@@ -2634,7 +2786,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2634
2786
|
await ensureDir(out.csaf);
|
|
2635
2787
|
writeCsaf(resolved, cveMatches, out.csaf, { projectInfo, toolVersion: pkg.version, timestamp: projectInfo.generatedAt });
|
|
2636
2788
|
wrote.push(["CSAF 2.0 VEX", out.csaf]);
|
|
2637
|
-
} catch (err) { ui.warn(`CSAF export failed: ${err.message}`); }
|
|
2789
|
+
} catch (err) { exportFailed = true; ui.warn(`CSAF export failed: ${err.message}`); }
|
|
2638
2790
|
}
|
|
2639
2791
|
if (out.json) {
|
|
2640
2792
|
try {
|
|
@@ -2645,7 +2797,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2645
2797
|
typosquats, diff: jsonDiff, applications: appState.applications, applicationInventory: appState.inventory,
|
|
2646
2798
|
applicationRelations, coverage: appState.coverage, warnings: reportWarnings }, out.json);
|
|
2647
2799
|
wrote.push(["Findings JSON", out.json]);
|
|
2648
|
-
} catch (err) { ui.warn(`JSON export failed: ${err.message}`); }
|
|
2800
|
+
} catch (err) { exportFailed = true; ui.warn(`JSON export failed: ${err.message}`); }
|
|
2649
2801
|
}
|
|
2650
2802
|
if (out.xlsx) {
|
|
2651
2803
|
try {
|
|
@@ -2656,7 +2808,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2656
2808
|
typosquats, diff: jsonDiff, applications: appState.applications, applicationInventory: appState.inventory,
|
|
2657
2809
|
applicationRelations, coverage: appState.coverage, warnings: reportWarnings }, out.xlsx);
|
|
2658
2810
|
wrote.push(["Excel workbook", out.xlsx]);
|
|
2659
|
-
} catch (err) {
|
|
2811
|
+
} catch (err) { exportFailed = true; ui.warn(`XLSX export failed: ${err.message}`); }
|
|
2660
2812
|
}
|
|
2661
2813
|
if (out.sarif) {
|
|
2662
2814
|
try {
|
|
@@ -2664,7 +2816,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2664
2816
|
await ensureDir(out.sarif);
|
|
2665
2817
|
writeSarif(cveMatches.filter(m => !m.suppressed), out.sarif, { projectInfo, toolVersion: pkg.version, certFindings });
|
|
2666
2818
|
wrote.push(["SARIF", out.sarif]);
|
|
2667
|
-
} catch (err) { ui.warn(`SARIF export failed: ${err.message}`); }
|
|
2819
|
+
} catch (err) { exportFailed = true; ui.warn(`SARIF export failed: ${err.message}`); }
|
|
2668
2820
|
}
|
|
2669
2821
|
|
|
2670
2822
|
// Integrity manifest: a standard SHA256SUMS over every artifact written this run,
|
|
@@ -2696,7 +2848,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2696
2848
|
const s = diff.summary;
|
|
2697
2849
|
ui.section("Baseline diff");
|
|
2698
2850
|
const sev = Object.entries(s.cve.addedBySeverity).filter(([, n]) => n).map(([k, n]) => `${n} ${k.toLowerCase()}`).join(", ") || "none";
|
|
2699
|
-
console.log(` CVE ${chalk.red(`+${s.cve.added} new`)} ${chalk.green(`-${s.cve.removed} fixed`)} ${chalk.dim(`${s.cve.unchanged} unchanged`)}`);
|
|
2851
|
+
console.log(` CVE ${chalk.red(`+${s.cve.added} new`)} ${chalk.green(`-${s.cve.removed} fixed`)} ${chalk.dim(`${s.cve.unchanged} unchanged`)}${s.cve.unassessed ? ` ${s.cve.unassessed} previous unassessed` : ''}${s.cve.unassessedAdded ? ` ${s.cve.unassessedAdded} current unassessed` : ''}`);
|
|
2700
2852
|
console.log(` ${chalk.bold("New production CVE:")} ${s.cve.addedProduction ? chalk.red.bold(s.cve.addedProduction) : chalk.green("0")} ${chalk.dim(`(${sev})`)}`);
|
|
2701
2853
|
console.log();
|
|
2702
2854
|
}
|
|
@@ -2731,14 +2883,14 @@ async function runReportFlow(resolved, ecoFlags = {}) {
|
|
|
2731
2883
|
if (!required.length || required.some(x => !known.has(x))) {
|
|
2732
2884
|
console.error(chalk.red(`❌ invalid --fail-on-incomplete capabilities: ${raw}`));
|
|
2733
2885
|
process.exitCode = 2;
|
|
2734
|
-
} else if (((required.includes("inventory") || required.includes("sources")) && (mavenDepthLimited || reportWarnings.some(w => w.type === "dependency-coverage" || w.type === "go-coverage"))) || (required.includes("sources") && (
|
|
2886
|
+
} else if (imageAcquisitionFailed || require("./lib/artifacts/scan").incompleteCapabilities(imageState,required).length || ((required.includes("inventory") || required.includes("sources")) && (mavenDepthLimited || reportWarnings.some(w => w.type === "dependency-coverage" || w.type === "go-coverage"))) || (required.includes("sources") && (sourceHealth.degraded().length || sourceHealth.stale().some(s=>s.blocking) || reportWarnings.some(w => w.type === "source-unavailable" || w.type === "source-stale" || w.type === "osv-coverage"))) || !requiredCoverageComplete(appState.coverage, required.filter(x => x !== "sources"))) {
|
|
2735
2887
|
ui.section("Coverage gate");
|
|
2736
|
-
console.log(chalk.red(`✗ required
|
|
2888
|
+
console.log(chalk.red(`✗ required scan checks incomplete: ${required.join(", ")}`));
|
|
2737
2889
|
process.exitCode = 2;
|
|
2738
2890
|
}
|
|
2739
2891
|
}
|
|
2740
|
-
if (
|
|
2741
|
-
return {cveIds:[...new Set(cveMatches.map(m=>m.cve?.id).filter(id=>/^CVE-\d{4}-\d{4,7}$/.test(id||'')))]};
|
|
2892
|
+
if (exportFailed) process.exitCode = 2;
|
|
2893
|
+
return {imageReferences:imageState.references,cveIds:[...new Set(cveMatches.map(m=>m.cve?.id).filter(id=>/^CVE-\d{4}-\d{4,7}$/.test(id||'')))]};
|
|
2742
2894
|
}
|
|
2743
2895
|
|
|
2744
2896
|
// mergeBySource now lives in lib/merge-sources.js (extracted to be unit-testable,
|