vigievuln 1.3.3 → 1.4.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.
Files changed (293) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +34 -19
  3. package/completions/vigievuln.bash +14 -3
  4. package/completions/vigievuln.zsh +11 -8
  5. package/lib/README.md +51 -0
  6. package/lib/{coverage-diagnostics.js → advisories/coverage-diagnostics.js} +1 -1
  7. package/lib/{cve-match.js → advisories/cve-match.js} +17 -12
  8. package/lib/{advisory-fixes.js → advisories/fixes.js} +1 -1
  9. package/lib/{advisory-freshness.js → advisories/freshness.js} +5 -1
  10. package/lib/{gap-adjudicate.js → advisories/gap-adjudicate.js} +3 -3
  11. package/lib/{native-package-match.js → advisories/native-package-match.js} +20 -11
  12. package/lib/{native-source-prepare.js → advisories/native-source-prepare.js} +15 -12
  13. package/lib/{native-advisories.js → advisories/native.js} +15 -13
  14. package/lib/{advisory-store-sqlite.js → advisories/store-sqlite.js} +5 -5
  15. package/lib/{advisory-store.js → advisories/store.js} +2 -2
  16. package/lib/{application-exports.js → applications/exports.js} +1 -1
  17. package/lib/{application-inventory.js → applications/inventory.js} +3 -1
  18. package/lib/applications/layout.js +199 -0
  19. package/lib/{application-providers → applications}/live-snapshot.js +10 -10
  20. package/lib/{application-plugins → applications/plugins}/drupal.js +2 -2
  21. package/lib/applications/plugins/ghost.js +36 -0
  22. package/lib/{application-plugins → applications/plugins}/index.js +1 -1
  23. package/lib/{application-plugins → applications/plugins}/prestashop.js +73 -15
  24. package/lib/applications/plugins/redmine.js +24 -0
  25. package/lib/{application-plugins → applications/plugins}/runner.js +89 -59
  26. package/lib/{application-plugins → applications/plugins}/spip.js +4 -4
  27. package/lib/{application-plugins → applications/plugins}/symfony.js +1 -1
  28. package/lib/{application-plugins → applications/plugins}/typo3.js +2 -2
  29. package/lib/{application-plugins → applications/plugins}/wave2-common.js +1 -1
  30. package/lib/{application-plugins → applications/plugins}/wordpress.js +52 -18
  31. package/lib/{application-providers → applications}/snapshot-cache.js +1 -1
  32. package/lib/{cms-snapshot-warm.js → applications/snapshot-warm.js} +21 -8
  33. package/lib/artifacts/access-warnings.js +24 -0
  34. package/lib/artifacts/applications.js +39 -8
  35. package/lib/artifacts/component-scope.js +11 -2
  36. package/lib/artifacts/cve-view.js +8 -5
  37. package/lib/artifacts/disk-wasm.mjs +3 -0
  38. package/lib/artifacts/disk.js +188 -0
  39. package/lib/artifacts/enrichment.js +31 -17
  40. package/lib/artifacts/go-main-identity.js +135 -36
  41. package/lib/artifacts/go-publisher-advisories.js +4 -3
  42. package/lib/artifacts/image-products.js +5 -4
  43. package/lib/artifacts/index.js +36 -13
  44. package/lib/artifacts/inventory-scope.js +53 -3
  45. package/lib/artifacts/product-advisories.js +51 -46
  46. package/lib/artifacts/product-catalog.js +6 -1
  47. package/lib/artifacts/release-catalogues.js +149 -0
  48. package/lib/artifacts/release-versions.js +101 -0
  49. package/lib/artifacts/remediation-report.js +1 -1
  50. package/lib/artifacts/report-inventory.js +15 -2
  51. package/lib/artifacts/report-path.js +29 -0
  52. package/lib/artifacts/report.js +66 -36
  53. package/lib/artifacts/retire.js +3 -3
  54. package/lib/artifacts/risk-report.js +12 -8
  55. package/lib/artifacts/sbom.js +33 -4
  56. package/lib/artifacts/scan.js +295 -67
  57. package/lib/artifacts/system-apps.js +98 -0
  58. package/lib/artifacts/system-maintenance.js +101 -0
  59. package/lib/artifacts/system-module-updates.js +104 -0
  60. package/lib/artifacts/system-report.js +232 -0
  61. package/lib/{airgap-project.js → cache/airgap-project.js} +25 -10
  62. package/lib/{cache-archive-sqlite.js → cache/archive.js} +6 -5
  63. package/lib/{cache-db.js → cache/db.js} +1 -1
  64. package/lib/{dump-format.js → cache/dump-format.js} +2 -2
  65. package/lib/{json-cache.js → cache/json.js} +1 -1
  66. package/lib/{proxy-cache.js → cache/proxy-cache.js} +9 -9
  67. package/lib/{proxy-scope.js → cache/proxy-scope.js} +1 -1
  68. package/lib/{record-freshness.js → cache/record-freshness.js} +1 -1
  69. package/lib/{cache-repository.js → cache/repository.js} +1 -1
  70. package/lib/{resource-cache → cache/resource}/engine.js +20 -14
  71. package/lib/{resource-cache → cache/resource}/fs-store.js +2 -2
  72. package/lib/{resource-cache → cache/resource}/sqlite-store.js +3 -3
  73. package/lib/{resource-cache → cache/resource}/validate.js +20 -6
  74. package/lib/{sqlite-driver.js → cache/sqlite-driver.js} +7 -5
  75. package/lib/certs/scan.js +17 -11
  76. package/lib/cli-collect.js +262 -0
  77. package/lib/cli-command-routing.js +30 -13
  78. package/lib/cli-groups.js +1 -1
  79. package/lib/cli-image.js +157 -46
  80. package/lib/cli-project-commands.js +10 -10
  81. package/lib/cli-setup.js +8 -8
  82. package/lib/cli-watch.js +3 -3
  83. package/lib/codecs/binary/scan.js +11 -3
  84. package/lib/codecs/binary.codec.js +1 -1
  85. package/lib/codecs/composer/platform.js +2 -2
  86. package/lib/codecs/composer/registry.js +12 -18
  87. package/lib/codecs/composer.codec.js +6 -5
  88. package/lib/codecs/go/parse.js +1 -1
  89. package/lib/codecs/go/registry.js +7 -7
  90. package/lib/codecs/go.codec.js +2 -2
  91. package/lib/codecs/gradle/parse.js +1 -1
  92. package/lib/codecs/gradle/versionless.js +2 -2
  93. package/lib/codecs/gradle.codec.js +7 -7
  94. package/lib/codecs/index.js +1 -1
  95. package/lib/{maven-airgap.js → codecs/maven/airgap.js} +4 -4
  96. package/lib/{maven-bom.js → codecs/maven/bom.js} +3 -3
  97. package/lib/codecs/maven/jar-scan.js +4 -4
  98. package/lib/{maven-license.js → codecs/maven/license.js} +2 -2
  99. package/lib/{core.js → codecs/maven/pom.js} +22 -11
  100. package/lib/{maven-reactor.js → codecs/maven/reactor.js} +18 -12
  101. package/lib/{transitive.js → codecs/maven/transitive.js} +79 -34
  102. package/lib/{maven-version.js → codecs/maven/version.js} +1 -1
  103. package/lib/codecs/maven.codec.js +18 -14
  104. package/lib/codecs/npm/collect.js +55 -8
  105. package/lib/codecs/npm/manifest-kind.js +16 -0
  106. package/lib/codecs/npm/parse.js +23 -7
  107. package/lib/codecs/npm/registry.js +28 -14
  108. package/lib/codecs/npm.codec.js +5 -5
  109. package/lib/codecs/nuget/registry.js +7 -7
  110. package/lib/codecs/nuget.codec.js +4 -4
  111. package/lib/codecs/pypi/registry.js +7 -7
  112. package/lib/codecs/pypi.codec.js +4 -4
  113. package/lib/codecs/recipes.js +2 -2
  114. package/lib/codecs/ruby/registry.js +7 -7
  115. package/lib/codecs/ruby.codec.js +2 -2
  116. package/lib/config.js +1 -1
  117. package/lib/{attribution.js → findings/attribution.js} +3 -3
  118. package/lib/findings/cve-descriptions.js +144 -0
  119. package/lib/{cve-record-coverage.js → findings/cve-record-coverage.js} +46 -41
  120. package/lib/{diff.js → findings/diff.js} +0 -0
  121. package/lib/{finding-enrichment.js → findings/enrichment.js} +45 -32
  122. package/lib/{eu-refs.js → findings/eu-refs.js} +3 -3
  123. package/lib/{gate.js → findings/gate.js} +1 -1
  124. package/lib/{malware.js → findings/malware.js} +30 -7
  125. package/lib/{merge-sources.js → findings/merge.js} +57 -9
  126. package/lib/{priority.js → findings/priority.js} +3 -3
  127. package/lib/findings/risk-evidence.js +24 -0
  128. package/lib/findings/severity.js +16 -0
  129. package/lib/{finding-summary.js → findings/summary.js} +5 -2
  130. package/lib/{suppress.js → findings/suppress.js} +2 -2
  131. package/lib/images/local-docker.js +72 -0
  132. package/lib/{image-network.js → images/network.js} +26 -16
  133. package/lib/{image-references.js → images/references.js} +29 -11
  134. package/lib/{image-registry.js → images/registry.js} +18 -9
  135. package/lib/{source-image-scan.js → images/source-scan.js} +3 -3
  136. package/lib/images/temp-roots.js +23 -0
  137. package/lib/{image-update.js → images/update.js} +3 -3
  138. package/lib/{dep-record.js → inventory/dep-record.js} +2 -2
  139. package/lib/{deps-descriptor.js → inventory/deps-descriptor.js} +3 -3
  140. package/lib/{descriptor-refs.js → inventory/descriptor-refs.js} +1 -1
  141. package/lib/{embedded.js → inventory/embedded.js} +4 -3
  142. package/lib/{license-policy.js → inventory/license-policy.js} +2 -2
  143. package/lib/{manifest-copy.js → inventory/manifest-copy.js} +2 -2
  144. package/lib/{module-names.js → inventory/module-names.js} +1 -1
  145. package/lib/{package-versions.js → inventory/package-versions.js} +2 -2
  146. package/lib/{parallel-walk.js → inventory/parallel-walk.js} +1 -1
  147. package/lib/{path-filter.js → inventory/path-filter.js} +1 -1
  148. package/lib/{private-deps.js → inventory/private-deps.js} +1 -1
  149. package/lib/{project-descriptor.js → inventory/project-descriptor.js} +3 -0
  150. package/lib/{purl.js → inventory/purl.js} +2 -2
  151. package/lib/{unmanaged.js → inventory/unmanaged.js} +6 -3
  152. package/lib/{commercial-support.js → maintenance/commercial-support.js} +5 -5
  153. package/lib/{outdated.js → maintenance/outdated.js} +20 -20
  154. package/lib/options-env.js +1 -1
  155. package/lib/{system-inventory/alpine-tracker.js → providers/alpine/tracker.js} +27 -7
  156. package/lib/{certfr.js → providers/certfr/enrich.js} +9 -9
  157. package/lib/{cve-download.js → providers/cveproject/download.js} +56 -36
  158. package/lib/{cve-legacy-ranges.js → providers/cveproject/legacy-ranges.js} +1 -1
  159. package/lib/{cve-npm-proxy.js → providers/cveproject/npm-proxy.js} +5 -5
  160. package/lib/{cve-packages-proxy.js → providers/cveproject/packages-proxy.js} +6 -6
  161. package/lib/{cve-version-verdict.js → providers/cveproject/version-verdict.js} +2 -2
  162. package/lib/{system-inventory/current-debian.js → providers/debian/current.js} +6 -6
  163. package/lib/{system-inventory/historical-debian.js → providers/debian/historical.js} +6 -6
  164. package/lib/providers/{debian.js → debian/index.js} +1 -0
  165. package/lib/{application-providers/drupal-advisories.js → providers/drupal/advisories.js} +13 -36
  166. package/lib/providers/{drupal.js → drupal/index.js} +4 -0
  167. package/lib/providers/{eol.js → eol/index.js} +1 -1
  168. package/lib/{epss.js → providers/epss/enrich.js} +16 -13
  169. package/lib/providers/{epss.js → epss/index.js} +2 -2
  170. package/lib/{euvd.js → providers/euvd/enrich.js} +13 -13
  171. package/lib/{system-inventory/freexian-ela.js → providers/freexian/ela.js} +6 -6
  172. package/lib/providers/{freexian.js → freexian/index.js} +3 -3
  173. package/lib/{system-inventory/freexian-release-evidence.js → providers/freexian/release-evidence.js} +8 -5
  174. package/lib/{system-inventory/freexian-tracker.js → providers/freexian/tracker.js} +33 -9
  175. package/lib/{gcve-feed.js → providers/gcve/feed.js} +4 -4
  176. package/lib/{gcve.js → providers/gcve/id.js} +1 -1
  177. package/lib/{gcve-index.js → providers/gcve/local-index.js} +4 -4
  178. package/lib/{application-providers/github-advisories.js → providers/github/advisories.js} +6 -2
  179. package/lib/providers/{github.js → github/index.js} +3 -1
  180. package/lib/{github-publisher-maven.js → providers/github/publisher-maven.js} +1 -1
  181. package/lib/providers/{go.js → go/index.js} +1 -1
  182. package/lib/{hash-id.js → providers/hashid/identify.js} +7 -7
  183. package/lib/providers/{hashid.js → hashid/index.js} +1 -1
  184. package/lib/providers/index.js +18 -13
  185. package/lib/{kev.js → providers/kev/enrich.js} +12 -9
  186. package/lib/{maven-cache.js → providers/maven/cache.js} +3 -3
  187. package/lib/providers/{maven.js → maven/index.js} +5 -3
  188. package/lib/{maven-presence.js → providers/maven/presence.js} +5 -5
  189. package/lib/{maven-repo.js → providers/maven/repo.js} +38 -21
  190. package/lib/providers/mit-kerberos/index.js +6 -0
  191. package/lib/{system-inventory/nginx-advisories.js → providers/nginx/advisories.js} +3 -3
  192. package/lib/providers/{npm.js → npm/index.js} +1 -1
  193. package/lib/providers/{nuget.js → nuget/index.js} +1 -1
  194. package/lib/{cpe.js → providers/nvd/cpe.js} +35 -47
  195. package/lib/{nvd.js → providers/nvd/enrich.js} +41 -40
  196. package/lib/providers/{nvd.js → nvd/index.js} +3 -3
  197. package/lib/{nvd-package-ranges.js → providers/nvd/package-ranges.js} +38 -22
  198. package/lib/{osv-db.js → providers/osv/db.js} +18 -16
  199. package/lib/providers/{osv.js → osv/index.js} +1 -1
  200. package/lib/{osv.js → providers/osv/query.js} +150 -80
  201. package/lib/providers/package-releases/index.js +26 -0
  202. package/lib/{packagist-audit.js → providers/packagist/audit.js} +31 -11
  203. package/lib/providers/{packagist.js → packagist/index.js} +1 -1
  204. package/lib/{proxy-throttle.js → providers/proxy-throttle.js} +17 -9
  205. package/lib/providers/{pypi.js → pypi/index.js} +1 -1
  206. package/lib/providers/redhat/bzip2.js +167 -0
  207. package/lib/providers/redhat/errata.js +75 -0
  208. package/lib/providers/redhat/index.js +10 -0
  209. package/lib/providers/redhat/oval.js +70 -0
  210. package/lib/providers/redhat/unfixed.js +127 -0
  211. package/lib/{registries.js → providers/registries.js} +4 -4
  212. package/lib/{retire.js → providers/retire/scan.js} +18 -18
  213. package/lib/providers/{ruby.js → ruby/index.js} +1 -1
  214. package/lib/providers/rubysec/advisories.js +177 -0
  215. package/lib/providers/rubysec/index.js +9 -0
  216. package/lib/{snyk.js → providers/snyk/client.js} +2 -2
  217. package/lib/{application-providers/spip-advisories.js → providers/spip/advisories.js} +5 -13
  218. package/lib/{vigievuln-advisories.js → providers/vigievuln/advisories.js} +4 -4
  219. package/lib/providers/wolfi/index.js +10 -0
  220. package/lib/providers/wolfi/secdb.js +47 -0
  221. package/lib/{application-providers/wordfence-client.js → providers/wordfence/client.js} +4 -4
  222. package/lib/providers/{wordfence.js → wordfence/index.js} +1 -1
  223. package/lib/{application-providers/wordfence-projection.js → providers/wordfence/projection.js} +14 -5
  224. package/lib/{resource-cache/wordfence.js → providers/wordfence/resource-cache.js} +2 -2
  225. package/lib/{application-providers/wordfence-v3.js → providers/wordfence/v3.js} +4 -5
  226. package/lib/providers/{wordpress.js → wordpress/index.js} +5 -0
  227. package/lib/providers/wpvulnerability/assess.js +181 -0
  228. package/lib/providers/wpvulnerability/index.js +12 -0
  229. package/lib/{charts.js → reports/charts.js} +25 -18
  230. package/lib/{csaf-export.js → reports/csaf-export.js} +16 -11
  231. package/lib/{cve-report.js → reports/cve-report.js} +453 -228
  232. package/lib/reports/detail.js +55 -0
  233. package/lib/{i18n.js → reports/i18n.js} +38 -2
  234. package/lib/{report-integrity.js → reports/integrity.js} +1 -1
  235. package/lib/{json-export.js → reports/json-export.js} +95 -24
  236. package/lib/{report-notices.js → reports/notices.js} +11 -6
  237. package/lib/{sarif-export.js → reports/sarif-export.js} +15 -10
  238. package/lib/{sbom-export.js → reports/sbom-export.js} +16 -11
  239. package/lib/{scan-completeness.js → scan/completeness.js} +1 -1
  240. package/lib/scan/coverage.js +114 -0
  241. package/lib/{provenance.js → scan/provenance.js} +12 -5
  242. package/lib/scan/reliability.js +157 -0
  243. package/lib/{source-health.js → scan/source-health.js} +52 -20
  244. package/lib/{source-profile.js → scan/source-profile.js} +3 -3
  245. package/lib/{hosted-proxy.js → service/hosted-proxy.js} +3 -3
  246. package/lib/{project-client.js → service/project-client.js} +20 -2
  247. package/lib/source-input.js +58 -0
  248. package/lib/system-inventory/advisories.js +89 -16
  249. package/lib/system-inventory/collect.js +33 -10
  250. package/lib/system-inventory/distribution-sources.js +32 -15
  251. package/lib/system-inventory/package-applicability.js +51 -0
  252. package/lib/system-inventory/targeted.js +8 -5
  253. package/lib/ui.js +11 -0
  254. package/package.json +49 -2
  255. package/vigievuln.js +483 -352
  256. package/lib/cache-archive.js +0 -676
  257. package/lib/osv-legacy.js +0 -57
  258. package/lib/risk-evidence.js +0 -18
  259. package/lib/scan-coverage.js +0 -61
  260. /package/lib/{application-plugins → applications/plugins}/joomla.js +0 -0
  261. /package/lib/{application-plugins → applications/plugins}/laravel.js +0 -0
  262. /package/lib/{application-plugins → applications/plugins}/magento.js +0 -0
  263. /package/lib/{application-plugins → applications/plugins}/plugin.interface.js +0 -0
  264. /package/lib/{application-plugins → applications/plugins}/select.js +0 -0
  265. /package/lib/{advisory-compression.js → cache/advisory-compression.js} +0 -0
  266. /package/lib/{compression-dictionary.js → cache/compression-dictionary.js} +0 -0
  267. /package/lib/{cache-directory.js → cache/directory.js} +0 -0
  268. /package/lib/{cache-policy.js → cache/policy.js} +0 -0
  269. /package/lib/{resource-cache → cache/resource}/snapshot-projection.js +0 -0
  270. /package/lib/{cache-startup.js → cache/startup.js} +0 -0
  271. /package/lib/{ruby-version.js → codecs/ruby/version.js} +0 -0
  272. /package/lib/{applicability-evidence.js → findings/applicability-evidence.js} +0 -0
  273. /package/lib/{line-stream.js → inventory/line-stream.js} +0 -0
  274. /package/lib/{package-metadata.js → inventory/package-metadata.js} +0 -0
  275. /package/lib/providers/{alpine.js → alpine/index.js} +0 -0
  276. /package/lib/providers/{certfr.js → certfr/index.js} +0 -0
  277. /package/lib/{native-cna-identities.js → providers/cveproject/cna-identities.js} +0 -0
  278. /package/lib/providers/{euvd.js → euvd/index.js} +0 -0
  279. /package/lib/providers/{gcve.js → gcve/index.js} +0 -0
  280. /package/lib/providers/{kev.js → kev/index.js} +0 -0
  281. /package/lib/providers/{nginx.js → nginx/index.js} +0 -0
  282. /package/lib/{nvd-bulk.js → providers/nvd/bulk.js} +0 -0
  283. /package/lib/providers/{osvdb.js → osvdb/index.js} +0 -0
  284. /package/lib/{request-failure.js → providers/request-failure.js} +0 -0
  285. /package/lib/providers/{retire.js → retire/index.js} +0 -0
  286. /package/lib/providers/{vigievuln.js → vigievuln/index.js} +0 -0
  287. /package/lib/{application-providers/wp-checksums.js → providers/wordpress/checksums.js} +0 -0
  288. /package/lib/{report-time.js → reports/time.js} +0 -0
  289. /package/lib/{xlsx-export.js → reports/xlsx-export.js} +0 -0
  290. /package/lib/{diagnostics.js → scan/diagnostics.js} +0 -0
  291. /package/lib/{account-client.js → service/account-client.js} +0 -0
  292. /package/lib/{account-session.js → service/account-session.js} +0 -0
  293. /package/lib/{account-terms.js → service/account-terms.js} +0 -0
@@ -1,11 +1,13 @@
1
1
  'use strict';
2
2
 
3
3
  const { imageProduct } = require('./product-catalog');
4
- const { createCacheRepository } = require('../cache-repository');
5
- const { extractFromNvdRecord } = require('../nvd');
4
+ const { getApplicationPlugin } = require('../applications/plugins');
5
+ const { makeDepRecord } = require('../inventory/dep-record');
6
+ const { createCacheRepository } = require('../cache/repository');
7
+ const { extractFromNvdRecord } = require('../providers/nvd/enrich');
6
8
  const { getResource } = require('../providers');
7
- const { validateResourceJson, DEFAULT_MAX_BODY_BYTES } = require('../resource-cache/engine');
8
- const { fresh } = require('../cache-policy');
9
+ const { validateResourceJson, DEFAULT_MAX_BODY_BYTES } = require('../cache/resource/engine');
10
+ const { fresh } = require('../cache/policy');
9
11
 
10
12
  const VERSION = /^\d{1,8}(?:\.\d{1,8}){1,3}$/;
11
13
  const bounds = ['versionStartIncluding', 'versionStartExcluding', 'versionEndIncluding', 'versionEndExcluding'];
@@ -19,43 +21,22 @@ function compare(a, b) {
19
21
  return 0;
20
22
  }
21
23
 
22
- // Only an independently sufficient configuration can confirm the finding. An
23
- // AND with hardware/OS constraints or an unmodelled version remains unknown.
24
+ // Product/version applicability is independent of deployment prerequisites.
25
+ // Platform and build-environment restrictions remain in the source advisory.
24
26
  function evaluateConfiguration(node, product, version) {
25
- if (!node || node.negate || !['OR', 'AND', undefined].includes(node.operator)) return null;
26
- const values = [];
27
- for (const leaf of node.cpeMatch || []) {
28
- const fields = String(leaf.criteria).split(':');
29
- if (
30
- fields.length !== 13 ||
31
- fields.slice(0, 5).join(':') !== 'cpe:2.3:a:' + product ||
32
- leaf.vulnerable !== true
33
- ) {
34
- values.push(null);
35
- continue;
36
- }
37
- const pin = fields[5];
38
- if (
39
- !fields.slice(6).every((value) => value === '*' || value === '-') ||
40
- (pin !== '*' && !VERSION.test(pin)) ||
41
- bounds.some((k) => leaf[k] != null && !VERSION.test(leaf[k]))
42
- ) {
43
- values.push(null);
44
- continue;
45
- }
46
- values.push(
47
- (pin === '*' || compare(version, pin) === 0) &&
48
- (!leaf.versionStartIncluding || compare(version, leaf.versionStartIncluding) >= 0) &&
49
- (!leaf.versionStartExcluding || compare(version, leaf.versionStartExcluding) > 0) &&
50
- (!leaf.versionEndIncluding || compare(version, leaf.versionEndIncluding) <= 0) &&
51
- (!leaf.versionEndExcluding || compare(version, leaf.versionEndExcluding) < 0)
52
- );
53
- }
54
- for (const child of [...(node.nodes || []), ...(node.children || [])])
55
- values.push(evaluateConfiguration(child, product, version));
56
- if (!values.length) return null;
57
- if (node.operator === 'AND') return values.includes(false) ? false : values.includes(null) ? null : true;
58
- return values.includes(true) ? true : values.includes(null) ? null : false;
27
+ return require('../providers/nvd/cpe').evaluateProductConfiguration(node,
28
+ leaf => String(leaf.criteria).split(':').slice(0,5).join(':') === 'cpe:2.3:a:' + product,
29
+ leaf => {
30
+ const fields=String(leaf.criteria).split(':'),pin=fields[5];
31
+ // CPE update identifies the release itself (for example alpha1).
32
+ if(fields.length!==13 || !['*','-'].includes(fields[6]) ||
33
+ (pin!=='*' && !VERSION.test(pin)) || bounds.some(k=>leaf[k]!=null && !VERSION.test(leaf[k])))return null;
34
+ return (pin==='*' || compare(version,pin)===0) &&
35
+ (!leaf.versionStartIncluding || compare(version,leaf.versionStartIncluding)>=0) &&
36
+ (!leaf.versionStartExcluding || compare(version,leaf.versionStartExcluding)>0) &&
37
+ (!leaf.versionEndIncluding || compare(version,leaf.versionEndIncluding)<=0) &&
38
+ (!leaf.versionEndExcluding || compare(version,leaf.versionEndExcluding)<0);
39
+ });
59
40
  }
60
41
 
61
42
  async function assessProductAdvisories(target, options) {
@@ -81,9 +62,10 @@ async function assessProductAdvisories(target, options) {
81
62
  if (!product.cpe || !VERSION.test(dep.version)) {
82
63
  coverage.push({
83
64
  collector: 'image-product-applicability',
65
+ affectsCompleteness:false,
84
66
  product: product.id,
85
67
  version: dep.version,
86
- execution: 'partial',
68
+ execution: 'not-applicable',
87
69
  result: 'indeterminate',
88
70
  reason: dep.version
89
71
  ? 'No supported upstream CPE/version comparison.'
@@ -98,6 +80,25 @@ async function assessProductAdvisories(target, options) {
98
80
  groups.set(key, items);
99
81
  }
100
82
  }
83
+ const applications = target.metadata?.systemApplications;
84
+ for (const app of applications?.applications || []) {
85
+ const plugin = getApplicationPlugin(app.pluginId);
86
+ if (!plugin?.upstreamCpe || app.type !== plugin.id) continue;
87
+ const core = applications.inventory.find(c => c.applicationId === app.id && c.kind === 'core');
88
+ const file = core?.evidence?.[0]?.path;
89
+ if (!file || !VERSION.test(core.version)) continue;
90
+ const dep = makeDepRecord({
91
+ ecosystem: 'application', name: plugin.id, version: core.version, manifestPath: file,
92
+ scope: 'prod', provenance: 'application'
93
+ });
94
+ Object.assign(dep, {
95
+ coordKey: JSON.stringify([target.id, app.id, 'core']), artifactTargetId: target.id, artifactPath: file,
96
+ systemSection: 'project', systemApplicationIds: [app.id], applicationEvidence: core.evidence
97
+ });
98
+ const key = JSON.stringify([plugin.id, core.version, plugin.upstreamCpe]);
99
+ if (!groups.has(key)) groups.set(key, []);
100
+ groups.get(key).push(dep);
101
+ }
101
102
  for (const [key, items] of groups) {
102
103
  const [id, version, cpe] = JSON.parse(key);
103
104
  const check = {
@@ -120,16 +121,18 @@ async function assessProductAdvisories(target, options) {
120
121
  }
121
122
  try {
122
123
  const repo = createCacheRepository(options.cacheDir);
123
- const ns = 'image-product-nvd/1',
124
+ const ns = 'image-product-nvd/2',
124
125
  cacheKey = JSON.stringify([cpe, version]);
125
126
  let saved = repo.get(ns, cacheKey),
126
127
  error;
127
128
  if (!options.offline && (!saved || saved.stale || !fresh(saved.fetchedAt) || options.forceUpdate)) {
128
129
  try {
129
130
  const params = { product: id, version, cpe };
131
+ const apiKey = !require('../providers').hasProxyRoute() && require('../config').getNvdApiKey();
130
132
  const response = await getResource('nvd', 'image-product', params, {
133
+ ...(apiKey ? {headers:{apiKey}} : {}),
131
134
  fetcher: options.fetcher,
132
- signal: AbortSignal.timeout(30000),
135
+ requestTimeoutMs: 30000,
133
136
  forceRefresh: options.forceUpdate
134
137
  });
135
138
  if (!response.ok) throw Error('NVD HTTP ' + response.status);
@@ -170,7 +173,7 @@ async function assessProductAdvisories(target, options) {
170
173
  }
171
174
  if (!saved) throw Error(error || 'No cached NVD consultation for this product/version.');
172
175
  const { records, unknown } = saved.value;
173
- const stale = saved.stale || (!fresh(saved.fetchedAt) && !options.forceUpdate);
176
+ const stale = saved.stale || (!options.offline && !fresh(saved.fetchedAt) && !options.forceUpdate);
174
177
  for (const dep of items)
175
178
  for (const record of records)
176
179
  matches.push({
@@ -179,17 +182,19 @@ async function assessProductAdvisories(target, options) {
179
182
  confidence: 'probable',
180
183
  cve: {
181
184
  ...record,
185
+ nvdRecordEvidence: { status: 'available', fetchedAt: saved.fetchedAt, stale: !!stale },
182
186
  fixVersion: null,
183
- identityEvidence: dep.binaryEvidence,
187
+ identityEvidence: dep.binaryEvidence || dep.applicationEvidence,
184
188
  advisorySource: 'https://nvd.nist.gov/vuln/detail/' + record.id
185
189
  }
186
190
  });
187
191
  Object.assign(check, {
188
- execution: error || stale || unknown.length ? 'partial' : 'completed',
192
+ execution: error || stale ? 'partial' : 'completed',
189
193
  result: records.length ? 'affected' : error || stale || unknown.length ? 'indeterminate' : 'no-match',
190
194
  fetchedAt: saved.fetchedAt,
191
195
  count: records.length,
192
196
  unknown: unknown.length,
197
+ ...(unknown.length ? { undecidableIds: unknown, affectsAssessment: true } : {}),
193
198
  reason:
194
199
  error ||
195
200
  (stale
@@ -59,4 +59,9 @@ function imageProduct(dep) {
59
59
  }
60
60
  return null;
61
61
  }
62
- module.exports = { catalog, binaryProduct, imageProduct };
62
+ // Application plugin identities are independent of executable/package-name heuristics.
63
+ const upstreamProducts = new Map(catalog);
64
+ for (const plugin of require('../applications/plugins').allApplicationPlugins()) {
65
+ if (plugin.upstreamCpe) upstreamProducts.set(plugin.id,{id:plugin.id,cpe:plugin.upstreamCpe});
66
+ }
67
+ module.exports = { upstreamProducts, catalog, binaryProduct, imageProduct };
@@ -0,0 +1,149 @@
1
+ 'use strict';
2
+
3
+ const crypto = require('node:crypto');
4
+ const {gunzipSync} = require('node:zlib');
5
+ const {getResource,hasHostedProxy,resourceOrigin} = require('../providers');
6
+ const {debian,apk:compareApk} = require('../system-inventory/versions');
7
+ const {build} = require('../providers/package-releases');
8
+ const {responseFetchedAt} = require('../providers/common');
9
+ const {fresh} = require('../cache/policy');
10
+ const maxBytes = 192 * 1024 ** 2;
11
+ const namespace = 'package-release-catalogue-v1';
12
+
13
+ async function readResource(repo, opts, provider, type, params, parse, revision='') {
14
+ const key = JSON.stringify([provider,type,params]);
15
+ const saved = repo.get(namespace,key);
16
+ const usable = saved && saved.metadata.revision === revision && (opts.offline || !hasHostedProxy() || saved.metadata.origin===resourceOrigin());
17
+ if (usable && (opts.offline || revision || fresh(saved.fetchedAt))) return saved;
18
+ if (opts.offline) return null;
19
+ try {
20
+ const timeout=AbortSignal.timeout(25000);
21
+ const signal=opts.signal ? AbortSignal.any([timeout,opts.signal]) : timeout;
22
+ const response = await getResource(provider,type,params,{fetcher:opts.fetcher,signal});
23
+ if (!response.ok) { await response.body?.cancel(); return null; }
24
+ const value = await parse(response);
25
+ if (value == null) return null;
26
+ const fetchedAt = responseFetchedAt(response);
27
+ repo.put(namespace,key,value,{fetchedAt,metadata:{revision,origin:resourceOrigin()}});
28
+ return {value,fetchedAt};
29
+ } catch (error) { if(opts.signal?.aborted)throw error; return usable ? saved : null; }
30
+ }
31
+
32
+ async function readBytes(response,limit) {
33
+ if(Number(response.headers.get('content-length'))>limit) {
34
+ await response.body?.cancel();
35
+ throw Error('Package index exceeds its size limit');
36
+ }
37
+ const chunks=[];
38
+ let size=0;
39
+ for await(const chunk of response.body) {
40
+ size+=chunk.length;
41
+ if(size>limit)throw Error('Package index exceeds its size limit');
42
+ chunks.push(chunk);
43
+ }
44
+ return Buffer.concat(chunks,size);
45
+ }
46
+
47
+ function manifest(text,arch) {
48
+ const sha = /^SHA256:\n((?: [^\n]+\n)+)/m.exec(text)?.[1];
49
+ if (!sha) return null;
50
+ const files = new Map(), expanded = new Map();
51
+ for (const line of sha.trim().split('\n')) {
52
+ const [hash,n,file] = line.trim().split(/\s+/);
53
+ const match = /^(\w[\w-]*)\/binary-([\w]+)\/Packages(?:\.(gz|xz))?$/.exec(file);
54
+ if (!match || match[2]!==arch || !/^[a-f0-9]{64}$/.test(hash)) continue;
55
+ const [section,ext] = [match[1],match[3]];
56
+ if (!ext) expanded.set(section,Number(n));
57
+ else if (ext==='gz' || !files.has(section)) files.set(section,{file,hash,size:Number(n),ext,section});
58
+ }
59
+ return [...files.values()].map(f=>({...f,expanded:expanded.get(f.section) ?? null}));
60
+ }
61
+
62
+ async function unpack(buffer,file) {
63
+ if (file.ext==='gz') return gunzipSync(buffer,{maxOutputLength:maxBytes});
64
+ // XZ-only pockets exist on Debian. The standalone CLI already embeds 7-Zip.
65
+ const wasm = process.versions.bun ? (await import('./disk-wasm.mjs')).default : require.resolve('7z-wasm/7zz.wasm');
66
+ const z = await require('7z-wasm')({wasmBinary:require('node:fs').readFileSync(wasm),print:()=>{},printErr:()=>{}});
67
+ z.FS.writeFile('/Packages.xz',buffer);
68
+ // Allow expansion only within the uncompressed size published in Release.
69
+ if (file.expanded == null || file.expanded > maxBytes) throw Error('Unbounded package index');
70
+ if (z.callMain(['e','-y','-txz','/Packages.xz','-o/'])!==0 || z.FS.stat('/Packages').size!==file.expanded) throw Error('Invalid XZ index');
71
+ return Buffer.from(z.FS.readFile('/Packages'));
72
+ }
73
+
74
+ function packageIndex(text,arch,apk=false) {
75
+ const packages = Object.create(null);
76
+ const compare = apk ? compareApk : debian;
77
+ for (const stanza of text.split('\n\n')) {
78
+ const name=(apk ? /^P:(.+)$/m : /^Package: (.+)$/m).exec(stanza)?.[1];
79
+ const version=(apk ? /^V:(.+)$/m : /^Version: (.+)$/m).exec(stanza)?.[1];
80
+ const architecture=(apk ? /^A:(.+)$/m : /^Architecture: (.+)$/m).exec(stanza)?.[1];
81
+ if (!name || !version || ![arch,apk?'noarch':'all'].includes(architecture)) continue;
82
+ const source=(apk ? /^o:(\S+)/m : /^Source: (\S+)/m).exec(stanza)?.[1] || name;
83
+ const key=[name,source,architecture].join('/');
84
+ if (!packages[key] || compare(version,packages[key])>0) packages[key]=version;
85
+ }
86
+ return packages;
87
+ }
88
+
89
+ async function aptPocket(repo,opts,p,arch) {
90
+ const load=(type,params,parse,rev)=>readResource(repo,opts,'package-releases',type,params,parse,rev);
91
+ const release=await load('release',p,async r=>(await readBytes(r,8*1024**2)).toString());
92
+ if (!release) return null;
93
+ const entries=manifest(release.value,arch);
94
+ if (!entries?.length) return null;
95
+ const result=[];
96
+ for (const f of entries) {
97
+ const params={...p,file:f.file};
98
+ const entry=await load('index',params,async response=>{
99
+ if(f.size>48*1024**2 || f.expanded>maxBytes) return null;
100
+ const buffer=await readBytes(response,f.size);
101
+ if(buffer.length!==f.size || crypto.createHash('sha256').update(buffer).digest('hex')!==f.hash)return null;
102
+ return packageIndex((await unpack(buffer,f)).toString(),arch);
103
+ },f.hash);
104
+ if (!entry) return null;
105
+ result.push({packages:entry.value,source:p.suite+'/'+f.section,url:build('index',params).url,asOf:release.fetchedAt});
106
+ }
107
+ return result;
108
+ }
109
+
110
+ async function apkIndex(response,arch) {
111
+ const extract=require('tar-stream').extract();
112
+ let packages=null;
113
+ extract.on('entry',(header,stream,next)=>{
114
+ if(header.name!=='APKINDEX') {stream.on('end',next);stream.resume();return;}
115
+ require('node:stream/consumers').text(stream).then(text=>{packages=packageIndex(text,arch,true);next();}).catch(error=>extract.destroy(error));
116
+ });
117
+ const data=gunzipSync(await readBytes(response,32*1024**2),{maxOutputLength:maxBytes});
118
+ await require('node:stream/promises').pipeline(require('node:stream').Readable.from([data]),extract);
119
+ return packages;
120
+ }
121
+
122
+ async function distroCatalogues(repo,opts,d,arch) {
123
+ if(d?.id==='alpine') {
124
+ const series=/^(\d+\.\d+)(?:\.\d+)?$/.exec(d.versionId)?.[1];
125
+ if (!series) return [];
126
+ const out=[];
127
+ for(const section of ['main','community']) {
128
+ const p={series:'v'+series,arch,section};
129
+ const e=await readResource(repo,opts,'package-releases','apk',p,r=>apkIndex(r,arch));
130
+ if(!e)return [];
131
+ out.push({packages:e.value,source:p.series+'/'+section,url:build('apk',p).url,asOf:e.fetchedAt});
132
+ }
133
+ return out;
134
+ }
135
+ if(!['ubuntu','debian'].includes(d?.id) || !/^[a-z]{2,24}$/.test(d.codename || ''))return [];
136
+ const series=d.codename, deb=d.id==='debian';
137
+ const mirror=deb?'debian':['i386','amd64'].includes(arch)?'ubuntu':'ubuntu-ports';
138
+ const archived=deb?'debian-archive':'ubuntu-archive';
139
+ let archive=mirror, base=await aptPocket(repo,opts,{archive,suite:series},arch);
140
+ if (!base) {archive=archived;base=await aptPocket(repo,opts,{archive,suite:series},arch);}
141
+ if (!base)return [];
142
+ const security=deb?archive+'-security':archive==='ubuntu'?'ubuntu-security':archive;
143
+ const oldSecurity=deb && /^\d+$/.test(d.versionId) && Number(d.versionId)<11;
144
+ const patches=await aptPocket(repo,opts,{archive:security,suite:series+(oldSecurity?'/updates':'-security')},arch);
145
+ const updates=await aptPocket(repo,opts,{archive,suite:series+'-updates'},arch);
146
+ if(!patches || !updates)return [];
147
+ return [...base,...updates,...patches];
148
+ }
149
+ module.exports={readResource,distroCatalogues};
@@ -0,0 +1,101 @@
1
+ 'use strict';
2
+
3
+ const {distroCatalogues,readResource} = require('./release-catalogues');
4
+ const {debian,apk} = require('../system-inventory/versions');
5
+
6
+ // Keys identify catalogued products, or source packages in Debian and its Ubuntu derivative.
7
+ // Numeric Anitya IDs distinguish upstream projects with identical names.
8
+ const cycles = {
9
+ apache:'apache-http-server',php:'php',python:'python',node:'nodejs',ruby:'ruby',nginx:'nginx',
10
+ mariadb:'mariadb',postgresql:'postgresql',dotnet:'dotnet',go:'go',perl:'perl',redis:'redis',
11
+ mysql:'mysql',mongo:'mongodb',elasticsearch:'elasticsearch',opensearch:'opensearch',deno:'deno',
12
+ bun:'bun',electron:'electron',powershell:'powershell',erlang:'erlang',julia:'julia',
13
+ };
14
+ const productIds = {bash:166,dash:394,gawk:868};
15
+ const sourceCycles = {apache2:'apache-http-server',mariadb:'mariadb',nginx:'nginx',perl:'perl'};
16
+ const debSources = {
17
+ ...productIds,pam:12244,acl:16,lz4:1865,shadow:4802,rsync:4217,gnupg2:1214,glibc:5401,dpkg:8127,
18
+ sqlite3:4877,elfutils:5679,'libdbi-perl':2811,'util-linux':8179,libtirpc:1740,libbpf:141355,
19
+ tar:4939,libzstd:12083,coreutils:343,krb5:13287,gnutls28:1221,systemd:5440,popt:3689,
20
+ openssl:2566,'xz-utils':5277,pcre2:5832,libxml2:1783,zlib:5303,icu:379847,curl:381,
21
+ };
22
+
23
+ async function upstreamRelease(repo,opts,slug,id) {
24
+ if (slug) {
25
+ if (opts.eol===false) return null;
26
+ const entry=await readResource(repo,opts,'eol','product',{product:slug},r=>r.json());
27
+ const legacy=!entry && opts.offline ? repo.get('auxiliary','eol-cache.json')?.value : null;
28
+ const records=entry?.value || legacy?.entries?.[slug];
29
+ if (!Array.isArray(records))return null;
30
+ const now=Date.now();
31
+ const stable=records.filter(c=>typeof c.latest==='string' && /^\d+(?:\.\d+)+(?:p\d+)?$/.test(c.latest) &&
32
+ (!c.releaseDate || Date.parse(c.releaseDate)<=now) && (!c.latestReleaseDate || Date.parse(c.latestReleaseDate)<=now));
33
+ stable.sort((a,b)=>b.latest.localeCompare(a.latest,'en',{numeric:true}));
34
+ return stable.length ? {version:stable[0].latest,source:'endoflife.date',url:'https://endoflife.date/'+slug,
35
+ asOf:entry?.fetchedAt || legacy?.fetchedAt?.[slug] || legacy?.meta?.fetchedAt} : null;
36
+ }
37
+ if (!id) return null;
38
+ const entry=await readResource(repo,opts,'package-releases','upstream',{project:id},async r=>{
39
+ const {stable_versions}=await r.json();
40
+ return Array.isArray(stable_versions) && typeof stable_versions[0]==='string' ? stable_versions[0] : null;
41
+ });
42
+ return entry ? {version:entry.value,source:'Anitya',url:'https://release-monitoring.org/project/'+id+'/',asOf:entry.fetchedAt} : null;
43
+ }
44
+
45
+ async function attachReleaseVersions(artifact,components,opts={}) {
46
+ if (opts.allLibs===false || !components.length)return;
47
+ const repo=opts.cacheRepository || require('../cache/repository').createCacheRepository(opts.cacheDir || require('../cache/directory').getCacheDir());
48
+ const distro=artifact.distribution;
49
+ const packages=artifact.components.filter(c=>c.ecosystem==='system');
50
+ const nativeArches=new Set(packages.map(c=>c.architecture).filter(a=>a && !['all','noarch'].includes(a)));
51
+ const platform=artifact.metadata?.platform?.architecture;
52
+ const defaultArch=nativeArches.size===1 ? [...nativeArches][0] : platform;
53
+ const owners=new Map();
54
+ const ownerKey=c=>JSON.stringify([c.manager,c.name,c.version]);
55
+ for(const c of packages){
56
+ const key=ownerKey(c);
57
+ if (!owners.has(key))owners.set(key,[]);
58
+ owners.get(key).push(c);
59
+ }
60
+ const indexes=new Map(),upstreams=new Map(),byCoord=new Map();
61
+ for(const c of components) {
62
+ const refs={};
63
+ const product=c.imageProduct?.id;
64
+ let pkg=c.ecosystem==='system' ? c : null;
65
+ if(!pkg && c.osPackageOwners?.length===1 && c.ecosystem==='binary') {
66
+ const owner=c.osPackageOwners[0];
67
+ const candidates=(owners.get(ownerKey(owner)) || []).filter(p=>!owner.architecture || p.architecture===owner.architecture);
68
+ if(candidates.length===1)pkg=candidates[0];
69
+ }
70
+ const isDeb=['ubuntu','debian'].includes(distro?.id) && ['dpkg','deb'].includes(pkg?.manager);
71
+ if(isDeb || (distro?.id==='alpine' && pkg?.manager==='apk')) {
72
+ const arch=['all','noarch'].includes(pkg.architecture) ? defaultArch : pkg.architecture;
73
+ if(arch) {
74
+ if(!indexes.has(arch))indexes.set(arch,await distroCatalogues(repo,opts,distro,arch));
75
+ const key=[pkg.name,pkg.sourceName || pkg.name,pkg.architecture].join('/');
76
+ const compare=isDeb ? debian : apk;
77
+ for (const index of indexes.get(arch)){
78
+ const v=index.packages[key];
79
+ if(v && (!refs.distribution || compare(v,refs.distribution.version)>0))
80
+ refs.distribution={version:v,source:[distro.id,index.source,arch].join(' · '),url:index.url,asOf:index.asOf};
81
+ }
82
+ }
83
+ }
84
+ const source=pkg?.sourceName || pkg?.name;
85
+ const sourceSlug=isDeb && Object.hasOwn(sourceCycles,source) && sourceCycles[source];
86
+ const slug=Object.hasOwn(cycles,product) ? cycles[product] :
87
+ c.ecosystem==='go' && c.name==='stdlib' ? 'go' : sourceSlug;
88
+ const id=Object.hasOwn(productIds,product) ? productIds[product] : isDeb && Object.hasOwn(debSources,source) ? debSources[source] : null;
89
+ if(slug || id) {
90
+ const key=slug||id;
91
+ if(!upstreams.has(key))upstreams.set(key,await upstreamRelease(repo,opts,slug,id));
92
+ if(upstreams.get(key))refs.upstream={...upstreams.get(key),...(!product && pkg ? {sourcePackage:source} : {})};
93
+ }
94
+ if(Object.keys(refs).length){c.releaseVersions=refs;byCoord.set(c.coordKey,refs);}
95
+ }
96
+ for(const e of artifact.productInventory?.entries || []) {
97
+ const refs=byCoord.get(e.componentKey);
98
+ if(refs)e.releaseVersions=refs;
99
+ }
100
+ }
101
+ module.exports={attachReleaseVersions};
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const {renderTime}=require('../report-time');
3
+ const {renderTime}=require('../reports/time');
4
4
  const esc=value=>String(value??'').replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;').replace(/'/g,'&#39;');
5
5
  const tr=locale=>(en,fr)=>locale==='fr'?fr:en;
6
6
  function observation(artifact) {
@@ -7,9 +7,15 @@ const componentIdentity = dep => JSON.stringify([
7
7
  dep.name || dep.artifactId || dep.coord || '', dep.version || '', dep.architecture || '',
8
8
  ...(dep.binaryEvidence?.product ? [dep.artifactPath || dep.binaryEvidence.binaryPath,dep.binaryEvidence.resourceOffset ?? null] : []),
9
9
  ]);
10
+ const occurrence = dep => JSON.stringify([dep.coordKey || componentIdentity(dep),dep.artifactPath || dep.manifestPaths?.[0] || '']);
10
11
  const needsAdvisory = dep => dep.ecosystem === 'system' || dep.ecosystem === 'binary' ||
11
12
  dep.provenance === 'binary' || dep.provenance === 'embedded' || dep.osPackageOwners?.length > 0;
12
13
  function reportedComponents(artifact, matches = []) {
14
+ if (artifact.metadata?.systemApplications) {
15
+ const affected = new Set(matches.filter(m=>m.dep?.artifactTargetId===artifact.id &&
16
+ !m.suppressed && !m.cpeFiltered && (m.cve?.id || m.advisoryId)).map(m=>occurrence(m.dep)));
17
+ return (artifact.components || []).filter(dep=>dep.systemSection==='runtime' || affected.has(occurrence(dep)));
18
+ }
13
19
  const affected = new Set(matches.filter(match =>
14
20
  (match.dep?.artifactTargetId || match.artifactTargetId) === artifact.id &&
15
21
  !match.cpeFiltered && (match.cve?.id || match.advisoryId)
@@ -25,8 +31,15 @@ function reportArtifacts(artifacts, matches) {
25
31
  return artifacts.map(artifact => {
26
32
  if (!Array.isArray(artifact.components)) return artifact;
27
33
  const components = reportedComponents(artifact, matches);
28
- return {...artifact, componentCount:artifact.componentCount ?? artifact.components.length, components,
34
+ // A distribution comparison needs the package database path and package identity.
35
+ // The full installed file list can be megabytes and repeats for each advisory.
36
+ const advisoryObservations = artifact.advisoryObservations?.map(item => {
37
+ if (!item.dep?.ownedPaths) return item;
38
+ const {ownedPaths,...dep} = item.dep;
39
+ return {...item,dep};
40
+ });
41
+ return {...artifact, ...(advisoryObservations ? {advisoryObservations} : {}), componentCount:artifact.componentCount ?? artifact.components.length, components,
29
42
  componentDetailsFiltered:!!artifact.componentDetailsFiltered || components.length !== artifact.components.length};
30
43
  });
31
44
  }
32
- module.exports = {componentIdentity, reportedComponents, reportArtifacts};
45
+ module.exports = {componentIdentity, occurrence, reportedComponents, reportArtifacts};
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const path = require('node:path').posix;
4
+
5
+ // Inventory files are relative to the target root. Resolve only the outer
6
+ // filesystem path. An archive member after "!/" has its own namespace.
7
+ function targetPath(file) {
8
+ if (typeof file !== 'string' || !file) return file;
9
+ const member = file.indexOf('!/');
10
+ const outer = member < 0 ? file : file.slice(0,member);
11
+ return path.resolve('/',outer) + (member < 0 ? '' : file.slice(member));
12
+ }
13
+
14
+ // The namespaced IDs stay in the inventory. Human-facing diagnostics identify
15
+ // the instance by its installed root and locate the evidence within that root.
16
+ function targetWarningMessage(w,formatPath=targetPath,applicationLabel) {
17
+ let message=w.message;
18
+ if (typeof message!=='string') return message;
19
+ if (applicationLabel && w.applicationId && message.startsWith(w.applicationId+':'))
20
+ message=applicationLabel+message.slice(w.applicationId.length);
21
+ const file=w.manifestPath || w.path;
22
+ if (file && message.endsWith(' '+file)) return message.slice(0,-file.length)+formatPath(file);
23
+ if (w.type==='embedded-jar') return message.replace(
24
+ /^(embedded archive with no resolvable Maven coordinate \(not scanned\): )(.+)$/,
25
+ (_,label,path)=>label+formatPath(path));
26
+ return message;
27
+ }
28
+
29
+ module.exports = {targetPath,targetWarningMessage};