vigievuln 1.3.2 → 1.3.3

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.
Files changed (98) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/data/fingerprints/index.js +80 -0
  4. package/data/fingerprints/interpreters/javascript/bun.json +23 -0
  5. package/data/fingerprints/interpreters/javascript/deno.json +10 -0
  6. package/data/fingerprints/interpreters/javascript/electron.json +20 -0
  7. package/data/fingerprints/interpreters/javascript/gjs.json +8 -0
  8. package/data/fingerprints/interpreters/javascript/javascriptcore.json +14 -0
  9. package/data/fingerprints/interpreters/javascript/jscgtk.json +10 -0
  10. package/data/fingerprints/interpreters/javascript/node.json +26 -0
  11. package/data/fingerprints/interpreters/javascript/nwjs.json +8 -0
  12. package/data/fingerprints/interpreters/javascript/webkitgtk.json +10 -0
  13. package/data/fingerprints/interpreters/javascript/wpewebkit.json +10 -0
  14. package/data/fingerprints/interpreters/languages/dotnet.json +8 -0
  15. package/data/fingerprints/interpreters/languages/erlang.json +9 -0
  16. package/data/fingerprints/interpreters/languages/gawk.json +10 -0
  17. package/data/fingerprints/interpreters/languages/guile.json +9 -0
  18. package/data/fingerprints/interpreters/languages/java.json +8 -0
  19. package/data/fingerprints/interpreters/languages/julia.json +9 -0
  20. package/data/fingerprints/interpreters/languages/lua.json +11 -0
  21. package/data/fingerprints/interpreters/languages/luajit.json +10 -0
  22. package/data/fingerprints/interpreters/languages/perl.json +11 -0
  23. package/data/fingerprints/interpreters/languages/php.json +22 -0
  24. package/data/fingerprints/interpreters/languages/powershell.json +17 -0
  25. package/data/fingerprints/interpreters/languages/pypy.json +8 -0
  26. package/data/fingerprints/interpreters/languages/python.json +24 -0
  27. package/data/fingerprints/interpreters/languages/r.json +9 -0
  28. package/data/fingerprints/interpreters/languages/racket.json +9 -0
  29. package/data/fingerprints/interpreters/languages/raku.json +8 -0
  30. package/data/fingerprints/interpreters/languages/ruby.json +21 -0
  31. package/data/fingerprints/interpreters/languages/tcl.json +9 -0
  32. package/data/fingerprints/interpreters/shells/bash.json +10 -0
  33. package/data/fingerprints/interpreters/shells/dash.json +8 -0
  34. package/data/fingerprints/interpreters/shells/fish.json +9 -0
  35. package/data/fingerprints/interpreters/shells/ksh.json +8 -0
  36. package/data/fingerprints/interpreters/shells/zsh.json +9 -0
  37. package/data/fingerprints/services/databases/clickhouse.json +8 -0
  38. package/data/fingerprints/services/databases/elasticsearch.json +8 -0
  39. package/data/fingerprints/services/databases/etcd.json +9 -0
  40. package/data/fingerprints/services/databases/mariadb.json +9 -0
  41. package/data/fingerprints/services/databases/memcached.json +9 -0
  42. package/data/fingerprints/services/databases/mongo.json +8 -0
  43. package/data/fingerprints/services/databases/mysql.json +9 -0
  44. package/data/fingerprints/services/databases/opensearch.json +8 -0
  45. package/data/fingerprints/services/databases/postgres.json +18 -0
  46. package/data/fingerprints/services/databases/redis.json +9 -0
  47. package/data/fingerprints/services/databases/valkey.json +8 -0
  48. package/data/fingerprints/services/dns-directory/bind.json +8 -0
  49. package/data/fingerprints/services/dns-directory/dnsmasq.json +8 -0
  50. package/data/fingerprints/services/dns-directory/slapd.json +8 -0
  51. package/data/fingerprints/services/dns-directory/unbound.json +8 -0
  52. package/data/fingerprints/services/mail/cyrus.json +8 -0
  53. package/data/fingerprints/services/mail/dovecot.json +8 -0
  54. package/data/fingerprints/services/mail/exim.json +9 -0
  55. package/data/fingerprints/services/mail/opendkim.json +8 -0
  56. package/data/fingerprints/services/mail/opensmtpd.json +8 -0
  57. package/data/fingerprints/services/mail/postfix.json +8 -0
  58. package/data/fingerprints/services/mail/rspamd.json +8 -0
  59. package/data/fingerprints/services/mail/sendmail.json +8 -0
  60. package/data/fingerprints/services/messaging/kafka.json +8 -0
  61. package/data/fingerprints/services/messaging/mosquitto.json +8 -0
  62. package/data/fingerprints/services/messaging/nats.json +9 -0
  63. package/data/fingerprints/services/messaging/rabbitmq.json +8 -0
  64. package/data/fingerprints/services/remote-access/dropbear.json +8 -0
  65. package/data/fingerprints/services/remote-access/openssh.json +10 -0
  66. package/data/fingerprints/services/remote-access/proftpd.json +8 -0
  67. package/data/fingerprints/services/remote-access/samba.json +8 -0
  68. package/data/fingerprints/services/remote-access/vsftpd.json +8 -0
  69. package/data/fingerprints/services/web-proxies/apache.json +18 -0
  70. package/data/fingerprints/services/web-proxies/caddy.json +9 -0
  71. package/data/fingerprints/services/web-proxies/envoy.json +8 -0
  72. package/data/fingerprints/services/web-proxies/haproxy.json +10 -0
  73. package/data/fingerprints/services/web-proxies/lighttpd.json +8 -0
  74. package/data/fingerprints/services/web-proxies/nginx.json +14 -0
  75. package/data/fingerprints/services/web-proxies/squid.json +8 -0
  76. package/data/fingerprints/services/web-proxies/tomcat.json +8 -0
  77. package/data/fingerprints/services/web-proxies/traefik.json +9 -0
  78. package/data/fingerprints/services/web-proxies/varnish.json +8 -0
  79. package/lib/artifacts/component-scope.js +1 -1
  80. package/lib/artifacts/elf-product.js +215 -0
  81. package/lib/artifacts/image-products.js +180 -0
  82. package/lib/artifacts/install-version.js +44 -0
  83. package/lib/artifacts/pe-product.js +28 -0
  84. package/lib/artifacts/product-advisories.js +207 -0
  85. package/lib/artifacts/product-catalog.js +62 -0
  86. package/lib/artifacts/report-inventory.js +2 -0
  87. package/lib/artifacts/report.js +27 -4
  88. package/lib/artifacts/scan.js +25 -6
  89. package/lib/cli-image.js +1 -1
  90. package/lib/codecs/binary/elf-metadata.js +6 -0
  91. package/lib/codecs/binary/metadata.js +1 -1
  92. package/lib/codecs/binary/pe-metadata.js +47 -11
  93. package/lib/codecs/binary/scan.js +1 -1
  94. package/lib/json-export.js +1 -1
  95. package/lib/providers/nvd.js +16 -2
  96. package/lib/resource-cache/engine.js +3 -2
  97. package/lib/resource-cache/validate.js +1 -0
  98. package/package.json +1 -1
@@ -51,7 +51,16 @@ async function inventoryTarget(target, options = {}) {
51
51
  const system = await collectSystemInventory(target.root, options);
52
52
  const applications = await collectInstalledApplications(target.root, options);
53
53
  const imageJs = options.imageRetire ? await require('./retire').collectImageJs(target.root,options,system.packages.flatMap(p=>p.ownedPaths || [])) : null;
54
- const binaries = await require('../codecs/binary.codec').collect(target.root, { ...options, defaultExcludes: false, srcRoot: target.root });
54
+ const binaries = await require('../codecs/binary.codec').collect(target.root, { ...options, defaultExcludes: false, imageProducts:true, srcRoot: target.root });
55
+ for (const dep of binaries.deps.values()) {
56
+ const product=require('./product-catalog').binaryProduct(dep.name);
57
+ if (!['tcl','java'].includes(product?.id) || dep.binaryMetadata?.format!=='elf') continue;
58
+ const location=path.relative(target.root,dep.manifestPaths[0]);
59
+ try {
60
+ const evidence=require('./install-version').installedVersion(target.root,location,dep.binaryMetadata,product);
61
+ if (evidence) (dep.binaryMetadata.products ||= []).push(evidence);
62
+ } catch { dep.binaryMetadata.productReadError=true; }
63
+ }
55
64
  const order = (a, b) => JSON.stringify([a.ecosystem, a.manager, a.namespace, a.name, a.version, a.architecture, a.manifestPath, a.manifestPaths]).localeCompare(JSON.stringify([b.ecosystem, b.manager, b.namespace, b.name, b.version, b.architecture, b.manifestPath, b.manifestPaths]));
56
65
  const packages = portable(system.packages, target.root).map(p => ({ ...p, ...(p.ownedPaths ? { ownedPaths: [...p.ownedPaths].sort() } : {}) })).sort(order);
57
66
  const appDeps = portable([...applications.deps.values(), ...binaries.deps.values(), ...(imageJs?.deps || [])], target.root).sort(order);
@@ -80,10 +89,16 @@ async function inventoryTarget(target, options = {}) {
80
89
  const owned = evidence && !aggregate ? owners.get(pathKey(evidence)) : null;
81
90
  return qualify(owned?.length ? { ...d, osPackageOwners: owned } : d, id);
82
91
  })];
92
+ require('./image-products').applyProductVersions(deps);
83
93
  for(const dep of deps){dep.imageRole=imageComponentRole(dep);dep.imageSource=imageComponentSource(dep);dep.scope=dep.imageRole==='transitive'?'transitive':'runtime';}
84
94
  const warnings = portable(normalizeWarnings([...(system.warnings || []), ...applications.warnings, ...binaries.warnings, ...(imageJs?.warnings || []),
85
95
  ...(target.metadata.warnings || [])]), target.root);
86
96
  const coverage = coverageRecords(system.coverage, id, 'inventory');
97
+ const productErrors=deps.filter(d=>d.binaryMetadata?.productReadError || d.binaryMetadata?.partial);
98
+ if(productErrors.length) {
99
+ coverage.push({artifactTargetId:id,capability:'inventory',collector:'image-product-metadata',execution:'partial',result:'indeterminate',count:productErrors.length});
100
+ warnings.push({capability:'inventory',type:'dependency-coverage',reason:'image-product-metadata-incomplete',message:'Product metadata could not be fully read in '+productErrors.length+' executable(s).'});
101
+ }
87
102
  if(imageJs)coverage.push({...imageJs.coverage,artifactTargetId:id});
88
103
  coverage.push({ artifactTargetId: id, capability: 'inventory', collector: 'installed-applications',
89
104
  execution: applications.warnings.length ? 'partial' : 'completed', result: 'indeterminate', count: applications.deps.size });
@@ -243,7 +258,7 @@ async function assessInventories(targets, options = {}) {
243
258
  }
244
259
  const resolvedDeps = new Map(), cveMatches = [], warnings = [], artifacts = [], warmed = new Set();
245
260
  const nativeDeps=new Map();
246
- for(const target of targets)for(const dep of target.deps||[])if(dep.ecosystem!=='binary' && dep.installEvidence?.source!=='retire' && (!dep.osPackageOwners?.length || dep.binaryEvidence))nativeDeps.set(dep.coordKey,dep);
261
+ for(const target of targets)for(const dep of target.deps||[])if(dep.ecosystem!=='binary' && dep.ecosystem!=='image-product' && dep.installEvidence?.source!=='retire' && (!dep.osPackageOwners?.length || dep.binaryEvidence))nativeDeps.set(dep.coordKey,dep);
247
262
  let native={matches:[],unknown:[],coverage:{status:'not-applicable'}},nativePreparation={sources:[],coverage:[],warnings:[]};
248
263
  if(nativeDeps.size){
249
264
  const nativeOptions={...options};
@@ -323,7 +338,7 @@ async function assessInventories(targets, options = {}) {
323
338
  coverage.push(imageJsAssessment.coverage);
324
339
  targetWarnings.push(...imageJsAssessment.warnings);
325
340
  options.onArtifactProgress?.({stage:'Application advisories'});
326
- const appDeps = new Map(target.deps.filter(d => d.ecosystem !== 'system' && d.ecosystem !== 'binary' && d.installEvidence?.source !== 'retire' && (!d.osPackageOwners?.length || !!d.binaryEvidence)).map(d => [d.coordKey, d]));
341
+ const appDeps = new Map(target.deps.filter(d => d.ecosystem !== 'system' && d.ecosystem !== 'binary' && d.ecosystem !== 'image-product' && d.installEvidence?.source !== 'retire' && (!d.osPackageOwners?.length || !!d.binaryEvidence)).map(d => [d.coordKey, d]));
327
342
  if (appDeps.size && options.osv === false) {
328
343
  coverage.push({ artifactTargetId: target.id, capability:'advisories',collector:'osv-application',execution:'not-applicable',result:'not-consulted',expected:false,reason:'OSV is excluded by source configuration.' });
329
344
  } else if (appDeps.size) {
@@ -346,7 +361,11 @@ async function assessInventories(targets, options = {}) {
346
361
  cveMatches.push(...publisher.matches);
347
362
  coverage.push(...coverageRecords(publisher.coverage,target.id,'advisories'));
348
363
  targetWarnings.push(...normalizeWarnings(publisher.warnings,'advisories'));
349
- const identifiedBinaryPaths=new Set(target.deps.filter(d=>d.binaryEvidence?.source==='go-vcs-and-module-proxy').map(d=>d.binaryEvidence.binaryPath));
364
+ const products=await require('./product-advisories').assessProductAdvisories(target,options);
365
+ cveMatches.push(...products.matches);
366
+ coverage.push(...coverageRecords(products.coverage,target.id,'advisories'));
367
+ const productInventory=require('./image-products').productCoverage(target,products.coverage,assessedPackages,[...cveMatches,...native.matches]);
368
+ const identifiedBinaryPaths=new Set(target.deps.filter(d=>(d.ecosystem==='binary' && d.binaryEvidence?.product && d.version) || d.binaryEvidence?.source==='go-vcs-and-module-proxy').map(d=>d.binaryEvidence.binaryPath));
350
369
  const unknownBinaries = target.deps.filter(d => d.ecosystem === 'binary' && !d.osPackageOwners?.length && !identifiedBinaryPaths.has(d.artifactPath));
351
370
  if (unknownBinaries.length) {
352
371
  coverage.push({ artifactTargetId: target.id, capability: 'advisories', collector: 'native-binaries', execution: 'partial', result: 'indeterminate', count: unknownBinaries.length, reason: 'Native binary identities cannot all be established from embedded metadata.' });
@@ -372,9 +391,9 @@ async function assessInventories(targets, options = {}) {
372
391
  warnings.push(...targetWarnings.map(w => ({ artifactTargetId: target.id, ...w })));
373
392
  artifacts.push({ id: target.id, kind: target.kind, metadata: target.metadata, evidence: target.evidence,
374
393
  originalEvidence: target.originalEvidence, distribution: target.distribution, inventoryAt: target.inventoryAt,
375
- componentCount: target.deps.length, coverage, advisoryObservations:distribution.observations, components: target.deps.map(d => ({ ecosystem: d.ecosystem, packageType: d.packageType,
394
+ componentCount: target.deps.length, coverage, productInventory, advisoryObservations:distribution.observations, components: target.deps.map(d => ({ ecosystem: d.ecosystem, packageType: d.packageType,
376
395
  namespace: d.namespace, name: d.name, version: d.version, sourceName:d.sourceName || null, sourceVersion:d.sourceVersion || null, packageOrigin:d.packageOrigin || null, architecture: d.architecture, artifactPath: d.artifactPath,
377
- provenance: d.provenance, imageRole:d.imageRole || null, imageSource:d.imageSource || imageComponentSource(d), installEvidence:d.installEvidence, manager:d.manager, coordKey: d.coordKey, binaryEvidence:d.binaryEvidence, osPackageOwners: d.osPackageOwners || [],
396
+ imageProduct:require('./image-products').describe(d), provenance: d.provenance, imageRole:d.imageRole || null, imageSource:d.imageSource || imageComponentSource(d), installEvidence:d.installEvidence, manager:d.manager, coordKey: d.coordKey, binaryEvidence:d.binaryEvidence, osPackageOwners: d.osPackageOwners || [],
378
397
  purl: require('../purl').purlFor(d) })) });
379
398
  }
380
399
  const combined=require('../merge-sources').mergeBySource(cveMatches,native.matches);
package/lib/cli-image.js CHANGED
@@ -77,7 +77,7 @@ function makeCommand() {
77
77
  .option('--no-osv', 'exclude OSV advisory matching')
78
78
  .option('--no-distro-advisories', 'exclude independent distribution tracker consultations')
79
79
  .option('--no-publisher-advisories', 'exclude publisher advisory feeds')
80
- .option('--no-nvd', 'exclude NVD enrichment')
80
+ .option('--no-nvd', 'exclude NVD enrichment and image product CVE checks')
81
81
  .option('--no-kev', 'exclude CISA KEV enrichment')
82
82
  .option('--no-epss', 'exclude EPSS enrichment')
83
83
  .option('--no-gcve', 'exclude native GCVE advisory matching and derived aliases')
@@ -36,6 +36,12 @@ function extractElfMetadataFile(fd, size, options = {}) {
36
36
  }
37
37
  result.go = require('./go-buildinfo').extractGoBuildInfo({read, segments, mapped, max});
38
38
  if (!result.go) delete result.go;
39
+ if (options.imageBinaryName) {
40
+ try {
41
+ const products = require('../../artifacts/elf-product').embeddedProducts(options.imageBinaryName, {read, header, size, bits, word, u16, u32, mapped, max, segments, machine:result.machine, soname:result.soname});
42
+ if (products.length) result.products = products;
43
+ } catch { result.productReadError = true; }
44
+ }
39
45
  return result;
40
46
  } catch (error) { return { format:'elf', status:'unavailable', reason:error.message }; }
41
47
  }
@@ -1,6 +1,6 @@
1
1
  // Format registry keeps new binary parsers independent of the walker.
2
2
  const extractors = new Map([
3
- ['pe', (fd,size) => require('./pe-metadata').extractPeMetadataFile(fd,size)],
3
+ ['pe', (fd,size,opts) => require('./pe-metadata').extractPeMetadataFile(fd,size,opts)],
4
4
  ['elf', (fd,size,opts) => require('./elf-metadata').extractElfMetadataFile(fd,size,opts)],
5
5
  ]);
6
6
  function extractMetadata(kind,fd,size,opts) { const fn=extractors.get(kind); return fn ? fn(fd,size,opts) : {format:kind,status:'unsupported'}; }
@@ -4,7 +4,7 @@
4
4
  const MAX_RESOURCE = 64 * 1024 * 1024;
5
5
  const MAX_VERSION_INFO = 1024 * 1024;
6
6
 
7
- function extractPeMetadata(buf) {
7
+ function extractPeMetadata(buf, options = {}) {
8
8
  try {
9
9
  const ok = (p, n, end = buf.length) => Number.isSafeInteger(p) && p >= 0 && n >= 0 && p + n <= end;
10
10
  const u16 = p => { if (!ok(p, 2)) throw Error('bounds'); return buf.readUInt16LE(p); };
@@ -17,7 +17,7 @@ function extractPeMetadata(buf) {
17
17
  const magic = u16(opt), dir = opt + (magic === 0x10b ? 96 : magic === 0x20b ? 112 : optSize);
18
18
  if (dir + 24 > opt + optSize) return null;
19
19
  const resourceRva = u32(dir + 16), resourceSize = u32(dir + 20);
20
- if (!resourceRva || !resourceSize || resourceSize > MAX_RESOURCE) return null;
20
+ if (!resourceRva || !resourceSize || resourceSize > (options.imageProducts ? 512 * 1024 * 1024 : MAX_RESOURCE)) return null;
21
21
  const sec = opt + optSize;
22
22
  if (!ok(sec, sections * 40)) return null;
23
23
  function rvaOffset(rva, length) {
@@ -40,9 +40,35 @@ function extractPeMetadata(buf) {
40
40
  if (count > 1024 || !ok(p + 16, count * 8, end)) throw Error('entries');
41
41
  return Array.from({length: count}, (_, i) => [u32(p + 16 + i * 8), u32(p + 20 + i * 8)]);
42
42
  }
43
- const version = directory(0).find(([id, ref]) => id === 16 && (ref & 0x80000000));
44
- if (!version) return null;
45
- const values = [];
43
+ const rootEntries=directory(0);
44
+ const products=[];
45
+ let partial=false;
46
+ // Inspect direct, uncompressed PE payloads in RT_RCDATA. Keep the host's
47
+ // resources independent and bound traversal to one embedding level.
48
+ if (options.imageProducts && !options.child) {
49
+ const rcdata=rootEntries.find(([id,ref])=>id===10 && (ref & 0x80000000));
50
+ let examined=0;
51
+ const inspected=new Set();
52
+ for (const [resourceId,name] of rcdata ? directory(rcdata[1]&0x7fffffff) : []) {
53
+ if (!(name & 0x80000000)) continue;
54
+ for (const [,lang] of directory(name&0x7fffffff)) {
55
+ if ((lang & 0x80000000) || !ok(root+lang,16,end)) continue;
56
+ const entry=root+lang, length=u32(entry+4), start=rvaOffset(u32(entry),length);
57
+ if (start===null || length<64 || buf.toString('ascii',start,start+2)!=='MZ') continue;
58
+ if (inspected.has(start)) continue;
59
+ inspected.add(start);
60
+ if (++examined>16) { partial=true; break; }
61
+ const nested={length,readUInt16LE:p=>u16(start+p),readUInt32LE:p=>u32(start+p),
62
+ toString:(enc,a,b)=>buf.toString(enc,start+a,start+b)};
63
+ const child=extractPeMetadata(nested,{...options,child:true});
64
+ if (!child?.products?.length) partial=true;
65
+ for (const item of child?.products||[]) products.push({...item,source:'pe-rcdata-version-info',resourceId,resourceOffset:start});
66
+ }
67
+ }
68
+ }
69
+ const version = rootEntries.find(([id, ref]) => id === 16 && (ref & 0x80000000));
70
+ if (!version) return products.length || partial ? {format:'pe',products,partial} : null;
71
+ const values = [], versionTables=[];
46
72
  for (const [, nameRef] of directory(version[1] & 0x7fffffff)) {
47
73
  if (!(nameRef & 0x80000000)) continue;
48
74
  for (const [, langRef] of directory(nameRef & 0x7fffffff)) {
@@ -51,9 +77,9 @@ function extractPeMetadata(buf) {
51
77
  if (!ok(entry, 16, end)) continue;
52
78
  const size = u32(entry + 4), data = rvaOffset(u32(entry), size);
53
79
  if (data === null || size > MAX_VERSION_INFO || size < 6) continue;
54
- const strings = {};
80
+ const strings = {}, tables=[];
55
81
  const align = n => Math.ceil(n / 4) * 4;
56
- function block(p, limit, depth) {
82
+ function block(p, limit, depth, table=null, parent='') {
57
83
  if (depth > 5 || !ok(p, 6, limit)) return;
58
84
  const length = u16(p), valueLength = u16(p + 2), type = u16(p + 4), stop = p + length;
59
85
  if (length < 6 || stop > limit) return;
@@ -61,24 +87,34 @@ function extractPeMetadata(buf) {
61
87
  while (ok(q, 2, stop) && u16(q) !== 0) q += 2;
62
88
  if (!ok(q, 2, stop)) return;
63
89
  const key = buf.toString('utf16le', p + 6, q); q = align(q + 2);
90
+ if (options.imageProducts && depth===2 && parent==='StringFileInfo' && /^[0-9a-f]{8}$/i.test(key)) { table={}; tables.push(table); }
64
91
  const bytes = type === 1 ? valueLength * 2 : valueLength;
65
92
  if (!ok(q, bytes, stop)) return;
66
- if (type === 1 && key.length <= 256 && bytes > 0 && bytes <= 8192)
93
+ if (type === 1 && key.length <= 256 && bytes > 0 && bytes <= 8192) {
67
94
  Object.defineProperty(strings, key, { value: buf.toString('utf16le', q, q + bytes).replace(/\0+$/, ''), enumerable: true, configurable: true, writable: true });
95
+ if (table && depth===3)
96
+ Object.defineProperty(table,key,{value:strings[key],enumerable:true,configurable:true});
97
+ }
68
98
  q = align(q + bytes);
69
- while (ok(q, 6, stop)) { const n = u16(q); if (!n || q + n > stop) break; block(q, stop, depth + 1); q = align(q + n); }
99
+ while (ok(q, 6, stop)) { const n = u16(q); if (!n || q + n > stop) break; block(q, stop, depth + 1,table,key); q = align(q + n); }
70
100
  }
71
101
  block(data, data + size, 0);
72
102
  if (Object.keys(strings).length) values.push(strings);
103
+ if (options.imageProducts && tables.length) versionTables.push(...tables);
73
104
  }
74
105
  }
106
+ if (options.imageProducts) {
107
+ const item=require('../../artifacts/pe-product').versionResource(versionTables);
108
+ if (item) products.push(item);
109
+ if (products.length || partial) return {format:'pe',versionStrings:values,products,partial};
110
+ }
75
111
  return values.length ? { versionStrings: values } : null;
76
112
  } catch { return null; }
77
113
  }
78
114
 
79
115
  // Adapt the bounded parser to a file descriptor. One 64 KiB cache serves the
80
116
  // many small header/string reads; even a distant resource never loads the file.
81
- function extractPeMetadataFile(fd, size) {
117
+ function extractPeMetadataFile(fd, size, options = {}) {
82
118
  const fs = require("node:fs");
83
119
  let start = -1, cache = Buffer.alloc(0);
84
120
  const read = (offset, length) => {
@@ -99,7 +135,7 @@ function extractPeMetadataFile(fd, size) {
99
135
  readUInt16LE: offset => read(offset, 2).readUInt16LE(0),
100
136
  readUInt32LE: offset => read(offset, 4).readUInt32LE(0),
101
137
  toString: (encoding, begin, end) => read(begin, end - begin).toString(encoding),
102
- });
138
+ },options);
103
139
  }
104
140
 
105
141
  module.exports = { extractPeMetadata, extractPeMetadataFile };
@@ -50,7 +50,7 @@ function inspectFile(fp, kind, detectOnly, opts = {}) {
50
50
  sha1.update(chunk.subarray(0, count)); sha256.update(chunk.subarray(0, count));
51
51
  offset += count;
52
52
  }
53
- const metadata = require("./metadata").extractMetadata(kind, fd, before.size, opts);
53
+ const metadata = require("./metadata").extractMetadata(kind, fd, before.size, opts.imageProducts ? { ...opts, imageBinaryName: path.basename(fp) } : opts);
54
54
  const after = fs.fstatSync(fd);
55
55
  if (after.size !== before.size || after.mtimeMs !== before.mtimeMs || after.ctimeMs !== before.ctimeMs)
56
56
  throw Error("file changed during binary scan");
@@ -86,7 +86,7 @@ function depBrief(dep) {
86
86
  installEvidence: dep.installEvidence || null,
87
87
  sbomEvidence: dep.sbomEvidence || null,
88
88
  artifactTargetId: dep.artifactTargetId || null,
89
- ...(dep.artifactTargetId ? {imageRole:dep.imageRole || null,imageSource:require('./artifacts/component-scope').imageComponentSource(dep)} : {}),
89
+ ...(dep.artifactTargetId ? {imageProduct:require('./artifacts/image-products').describe(dep),imageRole:dep.imageRole || null,imageSource:require('./artifacts/component-scope').imageComponentSource(dep)} : {}),
90
90
  artifactPath: dep.artifactPath || null,
91
91
  packageType: dep.packageType || null,
92
92
  manager: dep.manager || null,
@@ -1,8 +1,22 @@
1
1
  const { cveId, requestKey } = require("./common");
2
2
  module.exports = {
3
- id: "nvd", ttlMs: 7 * 24 * 3600 * 1000, revalidateTypes: ['cve','cve-mirror'],
4
- key(type, params, scope) { return requestKey("nvd", type, type === "spip-advisories" ? {} : { id: cveId(params?.id) }, scope); },
3
+ id: "nvd", ttlMs: 7 * 24 * 3600 * 1000, revalidateTypes: ['cve','cve-mirror','image-product'],
4
+ key(type, params, scope) {
5
+ if (type === "image-product") {
6
+ const { product, version, cpe } = params;
7
+ return requestKey("nvd", type, { product, version, cpe }, scope);
8
+ }
9
+ return requestKey("nvd", type, type === "spip-advisories" ? {} : { id: cveId(params?.id) }, scope);
10
+ },
5
11
  build(operation, params) {
12
+ if (operation === "image-product") {
13
+ const product = require("../artifacts/product-catalog").catalog.get(params?.product);
14
+ const cpe = params?.cpe;
15
+ if (!cpe || !product || ![product.cpe, ...(product.cpeAliases || [])].includes(cpe)) throw Error("Unknown image product CPE");
16
+ if (typeof params.version !== "string" || !/^\d{1,8}(?:\.\d{1,8}){1,3}$/.test(params.version)) throw Error("Invalid image product version");
17
+ const query = new URLSearchParams({virtualMatchString: "cpe:2.3:a:" + cpe + ":" + params.version, resultsPerPage: "2000", startIndex: "0"});
18
+ return {url: "https://services.nvd.nist.gov/rest/json/cves/2.0?" + query};
19
+ }
6
20
  if (operation === "spip-advisories") return {
7
21
  url: "https://services.nvd.nist.gov/rest/json/cves/2.0?virtualMatchString=cpe:2.3:a:spip:spip&resultsPerPage=2000&startIndex=0",
8
22
  };
@@ -93,7 +93,7 @@ function validateResourceJson(resource, data) {
93
93
  const text = v => typeof v === "string";
94
94
  const language = v => object(v) && text(v.lang) && text(v.value);
95
95
  const date = v => text(v) && /^\d{4}-\d{2}-\d{2}T/.test(v) && Number.isFinite(Date.parse(v));
96
- const expectedId = resource.type === "spip-advisories" ? null : String(resource.params?.id || "").toUpperCase();
96
+ const expectedId = ["spip-advisories","image-product"].includes(resource.type) ? null : String(resource.params?.id || "").toUpperCase();
97
97
  const node = (v, depth = 0) => {
98
98
  if (!object(v) || depth > 64 || (v.operator !== undefined && !["AND", "OR"].includes(v.operator)) ||
99
99
  (v.negate !== undefined && typeof v.negate !== "boolean")) return false;
@@ -128,7 +128,7 @@ function validateResourceJson(resource, data) {
128
128
  if (!record(data)) invalid();
129
129
  return;
130
130
  }
131
- if (!["cve", "cve-mirror", "spip-advisories"].includes(resource.type) ||
131
+ if (!["cve", "cve-mirror", "spip-advisories", "image-product"].includes(resource.type) ||
132
132
  !array(data.vulnerabilities, row => object(row) && record(row.cve))) invalid();
133
133
  const count = data.vulnerabilities.length;
134
134
  if (expectedId && count > 1) invalid();
@@ -773,6 +773,7 @@ function createResourceEngine(opts = {}) {
773
773
  }
774
774
 
775
775
  module.exports = {
776
+ validateResourceJson,
776
777
  createResourceEngine, upstreamHeadersFor, ttlForUrl, sendJson, UpstreamDenied,
777
778
  DEFAULT_TTL_MS, TTL_BY_SOURCE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_TRANSFER_BYTES, DEFAULT_MAX_STORE_BYTES,
778
779
  DEFAULT_UPSTREAM_TIMEOUT_MS, DEFAULT_MAX_CONCURRENT, DEFAULT_MAX_ENTRIES, FAILURE_RETRY_MS,
@@ -73,6 +73,7 @@ const RESOURCES = {
73
73
  "nvd/cve": T.obj({ id: CVE }),
74
74
  "nvd/cve-mirror": T.obj({ id: CVE }),
75
75
  "nvd/spip-advisories": NONE,
76
+ "nvd/image-product": T.obj({product:T.oneOf([...require('../artifacts/product-catalog').catalog.values()].filter(p=>p.cpe).map(p=>p.id)),cpe:T.str(/^[a-z0-9_.-]+:[a-z0-9_.-]+$/,100),version:T.str(/^\d+(?:\.\d+){1,3}$/,40)}),
76
77
  "osv/vuln": T.obj({ id: T.str(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, 100) }),
77
78
  "osv/packages": T.obj({ queries: T.arr(OSV_QUERY, 1, 1000) }),
78
79
  "epss/scores": T.obj({ ids: T.arr(CVE, 1, 100) }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vigievuln",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Polyglot dependency auditor for Maven, Gradle, JavaScript, Composer, PyPI, NuGet, Go, Ruby and 9 CMS/frameworks, with offline scans and audit reports.",
5
5
  "keywords": [
6
6
  "sca",