vigievuln 1.3.0 → 1.3.1

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/vigievuln.js CHANGED
@@ -846,8 +846,8 @@ if (!options.offline) {
846
846
  * Provider outages are coverage warnings by default. Write the partial reports before
847
847
  * evaluating an explicitly requested --fail-on-incomplete gate.
848
848
  */
849
- function warnIfDegraded() {
850
- const bad = sourceHealth.degraded();
849
+ function warnIfDegraded(handledKeys = []) {
850
+ const bad = sourceHealth.unreportedOutages(handledKeys);
851
851
  if (!bad.length) return;
852
852
  ui.warn(`Sources unavailable: ${bad.map(s => s.id).join(", ")}; report coverage is incomplete.`);
853
853
  }
@@ -1822,6 +1822,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
1822
1822
  // 1. CVE — native scanner contributed by the maven codec (local cvelistV5 index).
1823
1823
  let cveMatches = [];
1824
1824
  const sourceConsultations = [];
1825
+ const undecidableAdvisories = [];
1825
1826
  let cveDataDate = null;
1826
1827
  if (willCve) {
1827
1828
  const st = progress.start("CVE index (CVEProject)");
@@ -1853,14 +1854,14 @@ async function runReportFlow(resolved, ecoFlags = {}) {
1853
1854
  if (!offline && !options.cveOffline && require('./lib/providers').hasHostedProxy()) {
1854
1855
  try {
1855
1856
  const status=await require('./lib/cve-npm-proxy').refreshNpmCves(resolved,cveStore,{ttlMs:options.advisoryQueryTtlMs});
1856
- if(status.incomplete)scanWarnings.push({type:'source-unavailable',message:'CVEProject: the npm proxy index is partial or stale; advisory coverage is incomplete.'});
1857
+ if(status.incomplete)noteSourceLimitation('CVEProject','Available npm proxy records were assessed; the response does not certify an exhaustive, current catalogue.');
1857
1858
  } catch (err) {scanWarnings.push({type:'source-unavailable',message:`CVEProject npm proxy: ${err.message}; cached records are still matched.`});}
1858
1859
  }
1859
1860
  const npmCves = require('./lib/native-advisories').matchNativeNpmCves(resolved, cveStore);
1860
1861
  cveMatches = require('./lib/merge-sources').mergeBySource(cveMatches, npmCves.matches);
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.`});
1862
+ undecidableAdvisories.push(...npmCves.unknown);
1862
1863
  const npmNames=require('./lib/cve-npm-proxy').packageNames(resolved);
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.'});
1864
+ 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);})) noteSourceLimitation('CVEProject','Available native npm records were assessed; this dataset does not certify an exhaustive catalogue.');
1864
1865
  } catch (err) { scanWarnings.push({type:'source-unavailable',message:`CVEProject npm: ${err.message}; advisory coverage is incomplete.`}); }
1865
1866
  }
1866
1867
 
@@ -2064,7 +2065,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2064
2065
  const unindexed = result.coverage.reduce((n,c)=>n+(c.unindexed || 0),0);
2065
2066
  if (!result.sourceCoverage?.complete || (index && (!index.directory?.verified || !result.coverage.length || result.coverage.some(c=>!c.complete) || skipped || unindexed)))
2066
2067
  noteSourceLimitation('GCVE',`Partial source coverage: ${skipped ?? 'unknown'} GNA source(s) not collected; ${unindexed} source records lack explicit package coordinates. These records are not necessarily relevant to this project.`);
2067
- if (result.unknown.length) scanWarnings.push({type:'source-unavailable',message:`GCVE: ${result.unknown.length} package/version comparison(s) are undecidable; advisory coverage is incomplete.`});
2068
+ undecidableAdvisories.push(...result.unknown);
2068
2069
  st.done(`${result.matches.length} matched · +${cveMatches.length-before} new`);
2069
2070
  } catch (err) {
2070
2071
  st.fail(err.message);
@@ -2092,7 +2093,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2092
2093
  }
2093
2094
  const native = require('./lib/native-advisories').matchNativePackages(resolved,cveStore,{sources});
2094
2095
  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
+ undecidableAdvisories.push(...native.unknown);
2096
2097
  } catch (err) { scanWarnings.push({type:'source-unavailable',message:`Native advisories: ${err.message}; coverage is incomplete.`}); }
2097
2098
  }
2098
2099
 
@@ -2171,7 +2172,9 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2171
2172
  st.done(`${uniqueCves} CVE${nvdAdded ? ` · +${nvdAdded} via NVD ranges` : ""}${filtered ? ` · ${filtered} false-positive(s) filtered` : ""}${hasNvdKey || options.vigievulnProxy ? "" : " · no key (slow)"}`);
2172
2173
  } catch (err) {
2173
2174
  st.fail(err.message);
2174
- scanWarnings.push({type:'source-unavailable',message:`NVD: ${err.message}; enrichment and additional version-range coverage are incomplete.`});
2175
+ scanWarnings.push(nvdBindings.length || options.nvdCpeMatch
2176
+ ? {type:'source-unavailable',message:`NVD: ${err.message}; additional version-range coverage is incomplete.`}
2177
+ : {type:'cve-record-source',source:'nvd',affectsCompleteness:false,message:err.message});
2175
2178
  }
2176
2179
  }
2177
2180
  }
@@ -2306,12 +2309,13 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2306
2309
  europeanAdapters:[adapter,...europeanAdapters.filter(a=>a.parent===adapter.id)],
2307
2310
  onEnrichmentProgress:event=>st?.tick(`${event.source} ${event.completed}/${event.total}`),
2308
2311
  });
2309
- sourceConsultations.push(...result.coverage);
2310
- scanWarnings.push(...result.warnings);
2312
+ const recordEnrichment = adapter.id === 'euvd';
2313
+ sourceConsultations.push(...result.coverage.map(c => ({...c,...(recordEnrichment?{affectsCompleteness:false,diagnostics:result.warnings.filter(w=>w.source===c.collector)}:{})})));
2314
+ if (!recordEnrichment) scanWarnings.push(...result.warnings);
2311
2315
  const status = result.coverage[0];
2312
2316
  if (status?.execution === 'not-applicable') st?.skip('no CVE');
2313
2317
  else if (status?.execution === 'failed') st?.fail(status.reason);
2314
- else st?.done(`${status?.count || 0} CVE(s) enriched${status?.execution === 'partial' ? ' · incomplete coverage' : ''}`);
2318
+ else st?.done(`${status?.count || 0} CVE(s) enriched${status?.execution === 'partial' ? (recordEnrichment ? ' · some enrichment unavailable' : ' · incomplete coverage') : ''}`);
2315
2319
  }
2316
2320
  }
2317
2321
 
@@ -2533,8 +2537,18 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2533
2537
  if (retireMatches.length > 8) console.log(chalk.dim(` …and ${retireMatches.length - 8} more`));
2534
2538
  }
2535
2539
 
2540
+ if (undecidableAdvisories.length) scanWarnings.push(require('./lib/diagnostics').advisoryEvidenceDiagnostic(undecidableAdvisories));
2536
2541
  const durableIssues = require('./lib/package-versions').drainIssues();
2537
2542
  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});
2543
+ // Reconcile source and image enrichment by CVE identity, once for the whole scan.
2544
+ const recordSummary = require('./lib/cve-record-coverage').summarizeCveRecords([...cveMatches, ...retireMatches], {
2545
+ ...options, nvd:willNvd, euvd:willEuvd, offline,
2546
+ coverage:[...sourceConsultations,...imageState.artifacts.flatMap(a=>a.coverage||[])],
2547
+ });
2548
+ const enrichmentRequestKeys = recordSummary.requestKeys;
2549
+ scanWarnings = scanWarnings.filter(w=>w.type!=='cve-enrichment-summary' && w.type!=='cve-record-source');
2550
+ if (recordSummary.warning) scanWarnings.push(recordSummary.warning);
2551
+ sourceConsultations.push(recordSummary.coverage);
2538
2552
  { const split=require('./lib/diagnostics').partitionDiagnostics(scanWarnings); scanWarnings=split.warnings; scanNotices.push(...split.notices); }
2539
2553
  if (scanWarnings.length) {
2540
2554
  console.log();
@@ -2633,9 +2647,9 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2633
2647
 
2634
2648
  const reportWarnings = [
2635
2649
  ...triageWarnings,
2636
- ...sourceHealth.unreportedOutages(scanWarnings.flatMap(w=>w.requestKeys||[])).map(s => ({type:"source-unavailable",count:1,
2650
+ ...sourceHealth.unreportedOutages([...enrichmentRequestKeys,...scanWarnings.flatMap(w=>w.requestKeys||[])]).map(s => ({type:"source-unavailable",count:1,
2637
2651
  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}:{}),
2652
+ ...sourceHealth.unreportedStale([...enrichmentRequestKeys,...scanWarnings.flatMap(w=>w.requestKeys||[])]).map(s => ({ type:"source-stale", count:1,...(!s.blocking?{severity:'info'}:{}),...(s.refreshFailure?{refreshFailure:s.refreshFailure}:{}),
2639
2653
  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.` })),
2640
2654
  // A project already on a vendor build of an open-source-EOL cycle: covered by the paid
2641
2655
  // support that build comes from, so it is a note, not an EOL finding.
@@ -2750,7 +2764,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2750
2764
  const wrote = [];
2751
2765
  let exportFailed = false;
2752
2766
  // Announce coverage gaps for every output combination, including JSON-only.
2753
- warnIfDegraded();
2767
+ warnIfDegraded(enrichmentRequestKeys);
2754
2768
  for (const [format, label] of [["html", "HTML report"], ["doc", "Word .doc"]]) {
2755
2769
  if (!out[format]) continue;
2756
2770
  try {
@@ -2883,7 +2897,7 @@ async function runReportFlow(resolved, ecoFlags = {}) {
2883
2897
  if (!required.length || required.some(x => !known.has(x))) {
2884
2898
  console.error(chalk.red(`❌ invalid --fail-on-incomplete capabilities: ${raw}`));
2885
2899
  process.exitCode = 2;
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"))) {
2900
+ } 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.unreportedOutages(enrichmentRequestKeys).length || sourceHealth.unreportedStale(enrichmentRequestKeys).some(s=>s.blocking) || reportWarnings.some(w => w.affectsCompleteness !== false && (w.type === "source-unavailable" || w.type === "source-stale" || w.type === "osv-coverage")))) || !requiredCoverageComplete(appState.coverage, required.filter(x => x !== "sources"))) {
2887
2901
  ui.section("Coverage gate");
2888
2902
  console.log(chalk.red(`✗ required scan checks incomplete: ${required.join(", ")}`));
2889
2903
  process.exitCode = 2;