vigievuln 1.3.2 → 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 (375) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/README.md +34 -19
  3. package/completions/vigievuln.bash +14 -3
  4. package/completions/vigievuln.zsh +11 -8
  5. package/data/fingerprints/index.js +80 -0
  6. package/data/fingerprints/interpreters/javascript/bun.json +23 -0
  7. package/data/fingerprints/interpreters/javascript/deno.json +10 -0
  8. package/data/fingerprints/interpreters/javascript/electron.json +20 -0
  9. package/data/fingerprints/interpreters/javascript/gjs.json +8 -0
  10. package/data/fingerprints/interpreters/javascript/javascriptcore.json +14 -0
  11. package/data/fingerprints/interpreters/javascript/jscgtk.json +10 -0
  12. package/data/fingerprints/interpreters/javascript/node.json +26 -0
  13. package/data/fingerprints/interpreters/javascript/nwjs.json +8 -0
  14. package/data/fingerprints/interpreters/javascript/webkitgtk.json +10 -0
  15. package/data/fingerprints/interpreters/javascript/wpewebkit.json +10 -0
  16. package/data/fingerprints/interpreters/languages/dotnet.json +8 -0
  17. package/data/fingerprints/interpreters/languages/erlang.json +9 -0
  18. package/data/fingerprints/interpreters/languages/gawk.json +10 -0
  19. package/data/fingerprints/interpreters/languages/guile.json +9 -0
  20. package/data/fingerprints/interpreters/languages/java.json +8 -0
  21. package/data/fingerprints/interpreters/languages/julia.json +9 -0
  22. package/data/fingerprints/interpreters/languages/lua.json +11 -0
  23. package/data/fingerprints/interpreters/languages/luajit.json +10 -0
  24. package/data/fingerprints/interpreters/languages/perl.json +11 -0
  25. package/data/fingerprints/interpreters/languages/php.json +22 -0
  26. package/data/fingerprints/interpreters/languages/powershell.json +17 -0
  27. package/data/fingerprints/interpreters/languages/pypy.json +8 -0
  28. package/data/fingerprints/interpreters/languages/python.json +24 -0
  29. package/data/fingerprints/interpreters/languages/r.json +9 -0
  30. package/data/fingerprints/interpreters/languages/racket.json +9 -0
  31. package/data/fingerprints/interpreters/languages/raku.json +8 -0
  32. package/data/fingerprints/interpreters/languages/ruby.json +21 -0
  33. package/data/fingerprints/interpreters/languages/tcl.json +9 -0
  34. package/data/fingerprints/interpreters/shells/bash.json +10 -0
  35. package/data/fingerprints/interpreters/shells/dash.json +8 -0
  36. package/data/fingerprints/interpreters/shells/fish.json +9 -0
  37. package/data/fingerprints/interpreters/shells/ksh.json +8 -0
  38. package/data/fingerprints/interpreters/shells/zsh.json +9 -0
  39. package/data/fingerprints/services/databases/clickhouse.json +8 -0
  40. package/data/fingerprints/services/databases/elasticsearch.json +8 -0
  41. package/data/fingerprints/services/databases/etcd.json +9 -0
  42. package/data/fingerprints/services/databases/mariadb.json +9 -0
  43. package/data/fingerprints/services/databases/memcached.json +9 -0
  44. package/data/fingerprints/services/databases/mongo.json +8 -0
  45. package/data/fingerprints/services/databases/mysql.json +9 -0
  46. package/data/fingerprints/services/databases/opensearch.json +8 -0
  47. package/data/fingerprints/services/databases/postgres.json +18 -0
  48. package/data/fingerprints/services/databases/redis.json +9 -0
  49. package/data/fingerprints/services/databases/valkey.json +8 -0
  50. package/data/fingerprints/services/dns-directory/bind.json +8 -0
  51. package/data/fingerprints/services/dns-directory/dnsmasq.json +8 -0
  52. package/data/fingerprints/services/dns-directory/slapd.json +8 -0
  53. package/data/fingerprints/services/dns-directory/unbound.json +8 -0
  54. package/data/fingerprints/services/mail/cyrus.json +8 -0
  55. package/data/fingerprints/services/mail/dovecot.json +8 -0
  56. package/data/fingerprints/services/mail/exim.json +9 -0
  57. package/data/fingerprints/services/mail/opendkim.json +8 -0
  58. package/data/fingerprints/services/mail/opensmtpd.json +8 -0
  59. package/data/fingerprints/services/mail/postfix.json +8 -0
  60. package/data/fingerprints/services/mail/rspamd.json +8 -0
  61. package/data/fingerprints/services/mail/sendmail.json +8 -0
  62. package/data/fingerprints/services/messaging/kafka.json +8 -0
  63. package/data/fingerprints/services/messaging/mosquitto.json +8 -0
  64. package/data/fingerprints/services/messaging/nats.json +9 -0
  65. package/data/fingerprints/services/messaging/rabbitmq.json +8 -0
  66. package/data/fingerprints/services/remote-access/dropbear.json +8 -0
  67. package/data/fingerprints/services/remote-access/openssh.json +10 -0
  68. package/data/fingerprints/services/remote-access/proftpd.json +8 -0
  69. package/data/fingerprints/services/remote-access/samba.json +8 -0
  70. package/data/fingerprints/services/remote-access/vsftpd.json +8 -0
  71. package/data/fingerprints/services/web-proxies/apache.json +18 -0
  72. package/data/fingerprints/services/web-proxies/caddy.json +9 -0
  73. package/data/fingerprints/services/web-proxies/envoy.json +8 -0
  74. package/data/fingerprints/services/web-proxies/haproxy.json +10 -0
  75. package/data/fingerprints/services/web-proxies/lighttpd.json +8 -0
  76. package/data/fingerprints/services/web-proxies/nginx.json +14 -0
  77. package/data/fingerprints/services/web-proxies/squid.json +8 -0
  78. package/data/fingerprints/services/web-proxies/tomcat.json +8 -0
  79. package/data/fingerprints/services/web-proxies/traefik.json +9 -0
  80. package/data/fingerprints/services/web-proxies/varnish.json +8 -0
  81. package/lib/README.md +51 -0
  82. package/lib/{coverage-diagnostics.js → advisories/coverage-diagnostics.js} +1 -1
  83. package/lib/{cve-match.js → advisories/cve-match.js} +17 -12
  84. package/lib/{advisory-fixes.js → advisories/fixes.js} +1 -1
  85. package/lib/{advisory-freshness.js → advisories/freshness.js} +5 -1
  86. package/lib/{gap-adjudicate.js → advisories/gap-adjudicate.js} +3 -3
  87. package/lib/{native-package-match.js → advisories/native-package-match.js} +20 -11
  88. package/lib/{native-source-prepare.js → advisories/native-source-prepare.js} +15 -12
  89. package/lib/{native-advisories.js → advisories/native.js} +15 -13
  90. package/lib/{advisory-store-sqlite.js → advisories/store-sqlite.js} +5 -5
  91. package/lib/{advisory-store.js → advisories/store.js} +2 -2
  92. package/lib/{application-exports.js → applications/exports.js} +1 -1
  93. package/lib/{application-inventory.js → applications/inventory.js} +3 -1
  94. package/lib/applications/layout.js +199 -0
  95. package/lib/{application-providers → applications}/live-snapshot.js +10 -10
  96. package/lib/{application-plugins → applications/plugins}/drupal.js +2 -2
  97. package/lib/applications/plugins/ghost.js +36 -0
  98. package/lib/{application-plugins → applications/plugins}/index.js +1 -1
  99. package/lib/{application-plugins → applications/plugins}/prestashop.js +73 -15
  100. package/lib/applications/plugins/redmine.js +24 -0
  101. package/lib/{application-plugins → applications/plugins}/runner.js +89 -59
  102. package/lib/{application-plugins → applications/plugins}/spip.js +4 -4
  103. package/lib/{application-plugins → applications/plugins}/symfony.js +1 -1
  104. package/lib/{application-plugins → applications/plugins}/typo3.js +2 -2
  105. package/lib/{application-plugins → applications/plugins}/wave2-common.js +1 -1
  106. package/lib/{application-plugins → applications/plugins}/wordpress.js +52 -18
  107. package/lib/{application-providers → applications}/snapshot-cache.js +1 -1
  108. package/lib/{cms-snapshot-warm.js → applications/snapshot-warm.js} +21 -8
  109. package/lib/artifacts/access-warnings.js +24 -0
  110. package/lib/artifacts/applications.js +39 -8
  111. package/lib/artifacts/component-scope.js +12 -3
  112. package/lib/artifacts/cve-view.js +8 -5
  113. package/lib/artifacts/disk-wasm.mjs +3 -0
  114. package/lib/artifacts/disk.js +188 -0
  115. package/lib/artifacts/elf-product.js +215 -0
  116. package/lib/artifacts/enrichment.js +31 -17
  117. package/lib/artifacts/go-main-identity.js +135 -36
  118. package/lib/artifacts/go-publisher-advisories.js +4 -3
  119. package/lib/artifacts/image-products.js +181 -0
  120. package/lib/artifacts/index.js +36 -13
  121. package/lib/artifacts/install-version.js +44 -0
  122. package/lib/artifacts/inventory-scope.js +53 -3
  123. package/lib/artifacts/pe-product.js +28 -0
  124. package/lib/artifacts/product-advisories.js +212 -0
  125. package/lib/artifacts/product-catalog.js +67 -0
  126. package/lib/artifacts/release-catalogues.js +149 -0
  127. package/lib/artifacts/release-versions.js +101 -0
  128. package/lib/artifacts/remediation-report.js +1 -1
  129. package/lib/artifacts/report-inventory.js +17 -2
  130. package/lib/artifacts/report-path.js +29 -0
  131. package/lib/artifacts/report.js +85 -32
  132. package/lib/artifacts/retire.js +3 -3
  133. package/lib/artifacts/risk-report.js +12 -8
  134. package/lib/artifacts/sbom.js +33 -4
  135. package/lib/artifacts/scan.js +316 -69
  136. package/lib/artifacts/system-apps.js +98 -0
  137. package/lib/artifacts/system-maintenance.js +101 -0
  138. package/lib/artifacts/system-module-updates.js +104 -0
  139. package/lib/artifacts/system-report.js +232 -0
  140. package/lib/{airgap-project.js → cache/airgap-project.js} +25 -10
  141. package/lib/{cache-archive-sqlite.js → cache/archive.js} +6 -5
  142. package/lib/{cache-db.js → cache/db.js} +1 -1
  143. package/lib/{dump-format.js → cache/dump-format.js} +2 -2
  144. package/lib/{json-cache.js → cache/json.js} +1 -1
  145. package/lib/{proxy-cache.js → cache/proxy-cache.js} +9 -9
  146. package/lib/{proxy-scope.js → cache/proxy-scope.js} +1 -1
  147. package/lib/{record-freshness.js → cache/record-freshness.js} +1 -1
  148. package/lib/{cache-repository.js → cache/repository.js} +1 -1
  149. package/lib/{resource-cache → cache/resource}/engine.js +23 -16
  150. package/lib/{resource-cache → cache/resource}/fs-store.js +2 -2
  151. package/lib/{resource-cache → cache/resource}/sqlite-store.js +3 -3
  152. package/lib/{resource-cache → cache/resource}/validate.js +20 -5
  153. package/lib/{sqlite-driver.js → cache/sqlite-driver.js} +7 -5
  154. package/lib/certs/scan.js +17 -11
  155. package/lib/cli-collect.js +262 -0
  156. package/lib/cli-command-routing.js +30 -13
  157. package/lib/cli-groups.js +1 -1
  158. package/lib/cli-image.js +158 -47
  159. package/lib/cli-project-commands.js +10 -10
  160. package/lib/cli-setup.js +8 -8
  161. package/lib/cli-watch.js +3 -3
  162. package/lib/codecs/binary/elf-metadata.js +6 -0
  163. package/lib/codecs/binary/metadata.js +1 -1
  164. package/lib/codecs/binary/pe-metadata.js +47 -11
  165. package/lib/codecs/binary/scan.js +12 -4
  166. package/lib/codecs/binary.codec.js +1 -1
  167. package/lib/codecs/composer/platform.js +2 -2
  168. package/lib/codecs/composer/registry.js +12 -18
  169. package/lib/codecs/composer.codec.js +6 -5
  170. package/lib/codecs/go/parse.js +1 -1
  171. package/lib/codecs/go/registry.js +7 -7
  172. package/lib/codecs/go.codec.js +2 -2
  173. package/lib/codecs/gradle/parse.js +1 -1
  174. package/lib/codecs/gradle/versionless.js +2 -2
  175. package/lib/codecs/gradle.codec.js +7 -7
  176. package/lib/codecs/index.js +1 -1
  177. package/lib/{maven-airgap.js → codecs/maven/airgap.js} +4 -4
  178. package/lib/{maven-bom.js → codecs/maven/bom.js} +3 -3
  179. package/lib/codecs/maven/jar-scan.js +4 -4
  180. package/lib/{maven-license.js → codecs/maven/license.js} +2 -2
  181. package/lib/{core.js → codecs/maven/pom.js} +22 -11
  182. package/lib/{maven-reactor.js → codecs/maven/reactor.js} +18 -12
  183. package/lib/{transitive.js → codecs/maven/transitive.js} +79 -34
  184. package/lib/{maven-version.js → codecs/maven/version.js} +1 -1
  185. package/lib/codecs/maven.codec.js +18 -14
  186. package/lib/codecs/npm/collect.js +55 -8
  187. package/lib/codecs/npm/manifest-kind.js +16 -0
  188. package/lib/codecs/npm/parse.js +23 -7
  189. package/lib/codecs/npm/registry.js +28 -14
  190. package/lib/codecs/npm.codec.js +5 -5
  191. package/lib/codecs/nuget/registry.js +7 -7
  192. package/lib/codecs/nuget.codec.js +4 -4
  193. package/lib/codecs/pypi/registry.js +7 -7
  194. package/lib/codecs/pypi.codec.js +4 -4
  195. package/lib/codecs/recipes.js +2 -2
  196. package/lib/codecs/ruby/registry.js +7 -7
  197. package/lib/codecs/ruby.codec.js +2 -2
  198. package/lib/config.js +1 -1
  199. package/lib/{attribution.js → findings/attribution.js} +3 -3
  200. package/lib/findings/cve-descriptions.js +144 -0
  201. package/lib/{cve-record-coverage.js → findings/cve-record-coverage.js} +46 -41
  202. package/lib/{diff.js → findings/diff.js} +0 -0
  203. package/lib/{finding-enrichment.js → findings/enrichment.js} +45 -32
  204. package/lib/{eu-refs.js → findings/eu-refs.js} +3 -3
  205. package/lib/{gate.js → findings/gate.js} +1 -1
  206. package/lib/{malware.js → findings/malware.js} +30 -7
  207. package/lib/{merge-sources.js → findings/merge.js} +57 -9
  208. package/lib/{priority.js → findings/priority.js} +3 -3
  209. package/lib/findings/risk-evidence.js +24 -0
  210. package/lib/findings/severity.js +16 -0
  211. package/lib/{finding-summary.js → findings/summary.js} +5 -2
  212. package/lib/{suppress.js → findings/suppress.js} +2 -2
  213. package/lib/images/local-docker.js +72 -0
  214. package/lib/{image-network.js → images/network.js} +26 -16
  215. package/lib/{image-references.js → images/references.js} +29 -11
  216. package/lib/{image-registry.js → images/registry.js} +18 -9
  217. package/lib/{source-image-scan.js → images/source-scan.js} +3 -3
  218. package/lib/images/temp-roots.js +23 -0
  219. package/lib/{image-update.js → images/update.js} +3 -3
  220. package/lib/{dep-record.js → inventory/dep-record.js} +2 -2
  221. package/lib/{deps-descriptor.js → inventory/deps-descriptor.js} +3 -3
  222. package/lib/{descriptor-refs.js → inventory/descriptor-refs.js} +1 -1
  223. package/lib/{embedded.js → inventory/embedded.js} +4 -3
  224. package/lib/{license-policy.js → inventory/license-policy.js} +2 -2
  225. package/lib/{manifest-copy.js → inventory/manifest-copy.js} +2 -2
  226. package/lib/{module-names.js → inventory/module-names.js} +1 -1
  227. package/lib/{package-versions.js → inventory/package-versions.js} +2 -2
  228. package/lib/{parallel-walk.js → inventory/parallel-walk.js} +1 -1
  229. package/lib/{path-filter.js → inventory/path-filter.js} +1 -1
  230. package/lib/{private-deps.js → inventory/private-deps.js} +1 -1
  231. package/lib/{project-descriptor.js → inventory/project-descriptor.js} +3 -0
  232. package/lib/{purl.js → inventory/purl.js} +2 -2
  233. package/lib/{unmanaged.js → inventory/unmanaged.js} +6 -3
  234. package/lib/{commercial-support.js → maintenance/commercial-support.js} +5 -5
  235. package/lib/{outdated.js → maintenance/outdated.js} +20 -20
  236. package/lib/options-env.js +1 -1
  237. package/lib/{system-inventory/alpine-tracker.js → providers/alpine/tracker.js} +27 -7
  238. package/lib/{certfr.js → providers/certfr/enrich.js} +9 -9
  239. package/lib/{cve-download.js → providers/cveproject/download.js} +56 -36
  240. package/lib/{cve-legacy-ranges.js → providers/cveproject/legacy-ranges.js} +1 -1
  241. package/lib/{cve-npm-proxy.js → providers/cveproject/npm-proxy.js} +5 -5
  242. package/lib/{cve-packages-proxy.js → providers/cveproject/packages-proxy.js} +6 -6
  243. package/lib/{cve-version-verdict.js → providers/cveproject/version-verdict.js} +2 -2
  244. package/lib/{system-inventory/current-debian.js → providers/debian/current.js} +6 -6
  245. package/lib/{system-inventory/historical-debian.js → providers/debian/historical.js} +6 -6
  246. package/lib/providers/{debian.js → debian/index.js} +1 -0
  247. package/lib/{application-providers/drupal-advisories.js → providers/drupal/advisories.js} +13 -36
  248. package/lib/providers/{drupal.js → drupal/index.js} +4 -0
  249. package/lib/providers/{eol.js → eol/index.js} +1 -1
  250. package/lib/{epss.js → providers/epss/enrich.js} +16 -13
  251. package/lib/providers/{epss.js → epss/index.js} +2 -2
  252. package/lib/{euvd.js → providers/euvd/enrich.js} +13 -13
  253. package/lib/{system-inventory/freexian-ela.js → providers/freexian/ela.js} +6 -6
  254. package/lib/providers/{freexian.js → freexian/index.js} +3 -3
  255. package/lib/{system-inventory/freexian-release-evidence.js → providers/freexian/release-evidence.js} +8 -5
  256. package/lib/{system-inventory/freexian-tracker.js → providers/freexian/tracker.js} +33 -9
  257. package/lib/{gcve-feed.js → providers/gcve/feed.js} +4 -4
  258. package/lib/{gcve.js → providers/gcve/id.js} +1 -1
  259. package/lib/{gcve-index.js → providers/gcve/local-index.js} +4 -4
  260. package/lib/{application-providers/github-advisories.js → providers/github/advisories.js} +6 -2
  261. package/lib/providers/{github.js → github/index.js} +3 -1
  262. package/lib/{github-publisher-maven.js → providers/github/publisher-maven.js} +1 -1
  263. package/lib/providers/{go.js → go/index.js} +1 -1
  264. package/lib/{hash-id.js → providers/hashid/identify.js} +7 -7
  265. package/lib/providers/{hashid.js → hashid/index.js} +1 -1
  266. package/lib/providers/index.js +18 -13
  267. package/lib/{kev.js → providers/kev/enrich.js} +12 -9
  268. package/lib/{maven-cache.js → providers/maven/cache.js} +3 -3
  269. package/lib/providers/{maven.js → maven/index.js} +5 -3
  270. package/lib/{maven-presence.js → providers/maven/presence.js} +5 -5
  271. package/lib/{maven-repo.js → providers/maven/repo.js} +38 -21
  272. package/lib/providers/mit-kerberos/index.js +6 -0
  273. package/lib/{system-inventory/nginx-advisories.js → providers/nginx/advisories.js} +3 -3
  274. package/lib/providers/{npm.js → npm/index.js} +1 -1
  275. package/lib/providers/{nuget.js → nuget/index.js} +1 -1
  276. package/lib/{cpe.js → providers/nvd/cpe.js} +35 -47
  277. package/lib/{nvd.js → providers/nvd/enrich.js} +41 -40
  278. package/lib/providers/{nvd.js → nvd/index.js} +18 -4
  279. package/lib/{nvd-package-ranges.js → providers/nvd/package-ranges.js} +38 -22
  280. package/lib/{osv-db.js → providers/osv/db.js} +18 -16
  281. package/lib/providers/{osv.js → osv/index.js} +1 -1
  282. package/lib/{osv.js → providers/osv/query.js} +150 -80
  283. package/lib/providers/package-releases/index.js +26 -0
  284. package/lib/{packagist-audit.js → providers/packagist/audit.js} +31 -11
  285. package/lib/providers/{packagist.js → packagist/index.js} +1 -1
  286. package/lib/{proxy-throttle.js → providers/proxy-throttle.js} +17 -9
  287. package/lib/providers/{pypi.js → pypi/index.js} +1 -1
  288. package/lib/providers/redhat/bzip2.js +167 -0
  289. package/lib/providers/redhat/errata.js +75 -0
  290. package/lib/providers/redhat/index.js +10 -0
  291. package/lib/providers/redhat/oval.js +70 -0
  292. package/lib/providers/redhat/unfixed.js +127 -0
  293. package/lib/{registries.js → providers/registries.js} +4 -4
  294. package/lib/{retire.js → providers/retire/scan.js} +18 -18
  295. package/lib/providers/{ruby.js → ruby/index.js} +1 -1
  296. package/lib/providers/rubysec/advisories.js +177 -0
  297. package/lib/providers/rubysec/index.js +9 -0
  298. package/lib/{snyk.js → providers/snyk/client.js} +2 -2
  299. package/lib/{application-providers/spip-advisories.js → providers/spip/advisories.js} +5 -13
  300. package/lib/{vigievuln-advisories.js → providers/vigievuln/advisories.js} +4 -4
  301. package/lib/providers/wolfi/index.js +10 -0
  302. package/lib/providers/wolfi/secdb.js +47 -0
  303. package/lib/{application-providers/wordfence-client.js → providers/wordfence/client.js} +4 -4
  304. package/lib/providers/{wordfence.js → wordfence/index.js} +1 -1
  305. package/lib/{application-providers/wordfence-projection.js → providers/wordfence/projection.js} +14 -5
  306. package/lib/{resource-cache/wordfence.js → providers/wordfence/resource-cache.js} +2 -2
  307. package/lib/{application-providers/wordfence-v3.js → providers/wordfence/v3.js} +4 -5
  308. package/lib/providers/{wordpress.js → wordpress/index.js} +5 -0
  309. package/lib/providers/wpvulnerability/assess.js +181 -0
  310. package/lib/providers/wpvulnerability/index.js +12 -0
  311. package/lib/{charts.js → reports/charts.js} +25 -18
  312. package/lib/{csaf-export.js → reports/csaf-export.js} +16 -11
  313. package/lib/{cve-report.js → reports/cve-report.js} +453 -228
  314. package/lib/reports/detail.js +55 -0
  315. package/lib/{i18n.js → reports/i18n.js} +38 -2
  316. package/lib/{report-integrity.js → reports/integrity.js} +1 -1
  317. package/lib/{json-export.js → reports/json-export.js} +95 -24
  318. package/lib/{report-notices.js → reports/notices.js} +11 -6
  319. package/lib/{sarif-export.js → reports/sarif-export.js} +15 -10
  320. package/lib/{sbom-export.js → reports/sbom-export.js} +16 -11
  321. package/lib/{scan-completeness.js → scan/completeness.js} +1 -1
  322. package/lib/scan/coverage.js +114 -0
  323. package/lib/{provenance.js → scan/provenance.js} +12 -5
  324. package/lib/scan/reliability.js +157 -0
  325. package/lib/{source-health.js → scan/source-health.js} +52 -20
  326. package/lib/{source-profile.js → scan/source-profile.js} +3 -3
  327. package/lib/{hosted-proxy.js → service/hosted-proxy.js} +3 -3
  328. package/lib/{project-client.js → service/project-client.js} +20 -2
  329. package/lib/source-input.js +58 -0
  330. package/lib/system-inventory/advisories.js +89 -16
  331. package/lib/system-inventory/collect.js +33 -10
  332. package/lib/system-inventory/distribution-sources.js +32 -15
  333. package/lib/system-inventory/package-applicability.js +51 -0
  334. package/lib/system-inventory/targeted.js +8 -5
  335. package/lib/ui.js +11 -0
  336. package/package.json +49 -2
  337. package/vigievuln.js +483 -352
  338. package/lib/cache-archive.js +0 -676
  339. package/lib/osv-legacy.js +0 -57
  340. package/lib/risk-evidence.js +0 -18
  341. package/lib/scan-coverage.js +0 -61
  342. /package/lib/{application-plugins → applications/plugins}/joomla.js +0 -0
  343. /package/lib/{application-plugins → applications/plugins}/laravel.js +0 -0
  344. /package/lib/{application-plugins → applications/plugins}/magento.js +0 -0
  345. /package/lib/{application-plugins → applications/plugins}/plugin.interface.js +0 -0
  346. /package/lib/{application-plugins → applications/plugins}/select.js +0 -0
  347. /package/lib/{advisory-compression.js → cache/advisory-compression.js} +0 -0
  348. /package/lib/{compression-dictionary.js → cache/compression-dictionary.js} +0 -0
  349. /package/lib/{cache-directory.js → cache/directory.js} +0 -0
  350. /package/lib/{cache-policy.js → cache/policy.js} +0 -0
  351. /package/lib/{resource-cache → cache/resource}/snapshot-projection.js +0 -0
  352. /package/lib/{cache-startup.js → cache/startup.js} +0 -0
  353. /package/lib/{ruby-version.js → codecs/ruby/version.js} +0 -0
  354. /package/lib/{applicability-evidence.js → findings/applicability-evidence.js} +0 -0
  355. /package/lib/{line-stream.js → inventory/line-stream.js} +0 -0
  356. /package/lib/{package-metadata.js → inventory/package-metadata.js} +0 -0
  357. /package/lib/providers/{alpine.js → alpine/index.js} +0 -0
  358. /package/lib/providers/{certfr.js → certfr/index.js} +0 -0
  359. /package/lib/{native-cna-identities.js → providers/cveproject/cna-identities.js} +0 -0
  360. /package/lib/providers/{euvd.js → euvd/index.js} +0 -0
  361. /package/lib/providers/{gcve.js → gcve/index.js} +0 -0
  362. /package/lib/providers/{kev.js → kev/index.js} +0 -0
  363. /package/lib/providers/{nginx.js → nginx/index.js} +0 -0
  364. /package/lib/{nvd-bulk.js → providers/nvd/bulk.js} +0 -0
  365. /package/lib/providers/{osvdb.js → osvdb/index.js} +0 -0
  366. /package/lib/{request-failure.js → providers/request-failure.js} +0 -0
  367. /package/lib/providers/{retire.js → retire/index.js} +0 -0
  368. /package/lib/providers/{vigievuln.js → vigievuln/index.js} +0 -0
  369. /package/lib/{application-providers/wp-checksums.js → providers/wordpress/checksums.js} +0 -0
  370. /package/lib/{report-time.js → reports/time.js} +0 -0
  371. /package/lib/{xlsx-export.js → reports/xlsx-export.js} +0 -0
  372. /package/lib/{diagnostics.js → scan/diagnostics.js} +0 -0
  373. /package/lib/{account-client.js → service/account-client.js} +0 -0
  374. /package/lib/{account-session.js → service/account-session.js} +0 -0
  375. /package/lib/{account-terms.js → service/account-terms.js} +0 -0
@@ -1,4 +1,4 @@
1
- const { encodePath, requestKey } = require("./common");
1
+ const { encodePath, requestKey } = require("../common");
2
2
  module.exports = {
3
3
  id: "packagist", ttlMs: 24 * 3600 * 1000,
4
4
  key(type, params, scope) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  // The hosted service permits 7200 requests/minute per key. Leave headroom for
4
4
  // concurrent scans and preflight, and coordinate all providers in this process.
5
- function createProxyThrottle({ intervalMs = 10, maxPerMinute = 6000, maxWaitMs = 45000, maxRateRetries = 15, sleep = (ms, signal) => require('node:timers/promises').setTimeout(ms, undefined, {signal}), now = Date.now, warn = msg => require('./ui').networkNotice(msg), subscribeSkip = ttySkipSubscription } = {}) {
5
+ function createProxyThrottle({ intervalMs = 10, maxPerMinute = 6000, maxWaitMs = 45000, maxRateRetries = 15, sleep = (ms, signal) => require('node:timers/promises').setTimeout(ms, undefined, {signal}), now = Date.now, warn = msg => require('../ui').networkNotice(msg), subscribeSkip = ttySkipSubscription } = {}) {
6
6
  let next = 0, blockedUntil = 0, warnedPacing = false, requests = 0, window = -1, count = 0, skipped = false, stopListening = null;
7
7
  const skipWaiters=new Set();
8
8
  function skipRetries() { skipped=true;next=now();for(const resolve of skipWaiters)resolve(); }
@@ -72,27 +72,35 @@ function createProxyThrottle({ intervalMs = 10, maxPerMinute = 6000, maxWaitMs =
72
72
  if(skipped){const error=new Error('Proxy rate-limit retry skipped by user.');error.code='PROXY_RETRY_SKIPPED';if(lastLimited)error.status=lastLimited.status;throw error;}
73
73
  continue;
74
74
  }
75
- let response;
75
+ let response, transportError;
76
76
  try { response=await fetcher(); }
77
77
  catch(error) {
78
78
  if(signal?.aborted)throw abortError();
79
79
  if(error?.name==='AbortError')throw error;
80
80
  if(lastLimited?.status===200)return lastLimited;
81
- throw error;
81
+ if (!retryTransient || skipped || error?.code === 'PROXY_RETRY_SKIPPED') throw error;
82
+ transportError = error;
82
83
  }
83
- const stale=response.status===200 && response.headers?.get?.('x-fad-proxy')==='stale' && response.headers?.get?.('x-fad-proxy-reason')==='refresh-failed';
84
- const cause=response.headers?.get?.('x-fad-proxy-refresh-cause'), refreshStatus=response.headers?.get?.('x-fad-proxy-refresh-status');
84
+ const stale=response?.status===200 && response.headers?.get?.('x-fad-proxy')==='stale' && response.headers?.get?.('x-fad-proxy-reason')==='refresh-failed';
85
+ const cause=response?.headers?.get?.('x-fad-proxy-refresh-cause'), refreshStatus=response?.headers?.get?.('x-fad-proxy-refresh-status');
85
86
  const staleLimit=stale && ((cause==='rate-limit' && refreshStatus==='429') || (retryDenied && cause==='admission' && refreshStatus==='503'));
86
- const limited = staleLimit || response.status === 429 || (retryDenied && response.status === 503 && response.headers?.get?.('x-fad-proxy') === 'denied');
87
+ const limited = staleLimit || response?.status === 429 || (retryDenied && response?.status === 503 && response.headers?.get?.('x-fad-proxy') === 'denied');
87
88
  if (!limited) {
88
- if (skipped || !retryTransient || ![502,503,504].includes(response.status) || transientRetries >= 2 || limitRetries + transientRetries >= rateRetries || (response.status === 503 && !retryDenied && response.headers?.get?.('x-fad-proxy') === 'denied')) {
89
+ if (skipped || !retryTransient || (!transportError && ![500,502,503,504].includes(response.status)) || transientRetries >= 2 || limitRetries + transientRetries >= rateRetries || (response?.status === 503 && !retryDenied && response.headers?.get?.('x-fad-proxy') === 'denied')) {
90
+ if (transportError) throw transportError;
89
91
  if(response.status!==200 && lastLimited?.status===200)return lastLimited;
90
92
  if (lastLimited?.body && !lastLimited.body.locked) void lastLimited.body.cancel().catch(()=>{});
91
93
  return response;
92
94
  }
93
- if(!scheduleCooldown(3000))return lastLimited?.status===200?lastLimited:response;
95
+ const delay = response ? delayFrom(response) : 3000;
96
+ if (!scheduleCooldown(delay)) {
97
+ if (transportError) throw transportError;
98
+ return lastLimited?.status===200 ? lastLimited : response;
99
+ }
94
100
  transientRetries++;
95
- if (response.body && !response.body.locked) void response.body.cancel().catch(() => {});
101
+ const failure = transportError ? 'transport failure' : `HTTP ${response.status}`;
102
+ warn(`Proxy unavailable${context} (${failure}): waiting ${Math.ceil(delay / 1000)}s before retrying (retry ${transientRetries}/${Math.min(2, rateRetries)} transient retries).`);
103
+ if (response?.body && !response.body.locked) void response.body.cancel().catch(() => {});
96
104
  continue;
97
105
  }
98
106
  if (skipped) {
@@ -1,4 +1,4 @@
1
- const { requestKey } = require("./common");
1
+ const { requestKey } = require("../common");
2
2
  module.exports = {
3
3
  id: "pypi", ttlMs: 24 * 3600 * 1000,
4
4
  key(type, params, scope) { return requestKey("pypi", type, { name: String(params?.name || "").toLowerCase().replace(/[-_.]+/g, "-") }, scope); },
@@ -0,0 +1,167 @@
1
+ 'use strict';
2
+ // bzip2 decompression. Red Hat publishes its OVAL definitions only as .bz2 and Node has no
3
+ // decoder for that format. Decoding is block by block (at most 900 kB of state), each block
4
+ // and each stream is checked against its CRC, and every length read from the input is
5
+ // bounded before use. Reference: the bzip2 1.0 format (Julian Seward).
6
+ const BLOCK_MAGIC_HI = 0x314159, BLOCK_MAGIC_LO = 0x265359, END_MAGIC_HI = 0x177245, END_MAGIC_LO = 0x385090;
7
+ const MAX_GROUPS = 6, GROUP_SIZE = 50, MAX_CODE_LENGTH = 20, RUN_A = 0, RUN_B = 1;
8
+ const CRC = (() => {
9
+ const table = new Int32Array(256);
10
+ for (let i = 0; i < 256; i++) { let c = i << 24; for (let k = 0; k < 8; k++) c = c < 0 ? (c << 1) ^ 0x04c11db7 : c << 1; table[i] = c; }
11
+ return table;
12
+ })();
13
+ const corrupt = what => Error(`invalid bzip2 data: ${what}`);
14
+
15
+ class Bits {
16
+ constructor(bytes) { this.bytes = bytes; this.offset = 0; this.held = 0; this.count = 0; }
17
+ // Up to 24 bits, most significant first.
18
+ read(n) {
19
+ while (this.count < n) {
20
+ if (this.offset >= this.bytes.length) throw corrupt('unexpected end of input');
21
+ this.held = ((this.held << 8) | this.bytes[this.offset++]) >>> 0; this.count += 8;
22
+ }
23
+ this.count -= n;
24
+ const value = (this.held >>> this.count) & ((1 << n) - 1);
25
+ this.held &= (1 << this.count) - 1;
26
+ return value;
27
+ }
28
+ align() { this.held = 0; this.count = 0; }
29
+ get remaining() { return this.bytes.length - this.offset; }
30
+ }
31
+
32
+ function decodeTables(lengths, alphabet) {
33
+ let min = MAX_CODE_LENGTH, max = 0;
34
+ for (let i = 0; i < alphabet; i++) { if (lengths[i] > max) max = lengths[i]; if (lengths[i] < min) min = lengths[i]; }
35
+ const perm = new Uint16Array(alphabet), base = new Int32Array(MAX_CODE_LENGTH + 2), limit = new Int32Array(MAX_CODE_LENGTH + 2);
36
+ let next = 0;
37
+ for (let length = min; length <= max; length++) for (let symbol = 0; symbol < alphabet; symbol++) if (lengths[symbol] === length) perm[next++] = symbol;
38
+ const counts = new Int32Array(MAX_CODE_LENGTH + 2);
39
+ for (let i = 0; i < alphabet; i++) counts[lengths[i] + 1]++;
40
+ for (let i = 1; i < counts.length; i++) counts[i] += counts[i - 1];
41
+ // counts[length] is now the number of symbols with a shorter code. limit[length] is the
42
+ // largest code of that length; base[length] turns a code of that length into its rank in perm.
43
+ let code = 0;
44
+ for (let length = min; length <= max; length++) {
45
+ code += counts[length + 1] - counts[length];
46
+ limit[length] = code - 1;
47
+ code <<= 1;
48
+ }
49
+ for (let length = min; length <= max; length++) base[length] = (length === min ? 0 : ((limit[length - 1] + 1) << 1)) - counts[length];
50
+ return { perm, base, limit, min, max };
51
+ }
52
+
53
+ function readBlock(bits, blockSize, tt) {
54
+ const storedCrc = (bits.read(16) << 16 | bits.read(16)) | 0;
55
+ if (bits.read(1)) throw corrupt('randomised blocks are not supported');
56
+ const origin = bits.read(24);
57
+ // Symbols in use.
58
+ const used = bits.read(16), symbols = [];
59
+ for (let group = 0; group < 16; group++) if (used & (0x8000 >> group)) {
60
+ const map = bits.read(16);
61
+ for (let k = 0; k < 16; k++) if (map & (0x8000 >> k)) symbols.push(group * 16 + k);
62
+ }
63
+ if (!symbols.length) throw corrupt('block without symbols');
64
+ const alphabet = symbols.length + 2, endOfBlock = symbols.length + 1;
65
+ const groups = bits.read(3), selectorCount = bits.read(15);
66
+ if (groups < 2 || groups > MAX_GROUPS || selectorCount < 1) throw corrupt('coding tables');
67
+ const order = Array.from({ length: groups }, (_, i) => i), selectors = new Uint8Array(selectorCount);
68
+ for (let i = 0; i < selectorCount; i++) {
69
+ let j = 0;
70
+ while (bits.read(1)) if (++j >= groups) throw corrupt('selector');
71
+ const chosen = order[j]; order.splice(j, 1); order.unshift(chosen);
72
+ selectors[i] = chosen;
73
+ }
74
+ const tables = [];
75
+ for (let t = 0; t < groups; t++) {
76
+ const lengths = new Uint8Array(alphabet);
77
+ let length = bits.read(5);
78
+ for (let i = 0; i < alphabet; i++) {
79
+ for (;;) {
80
+ if (length < 1 || length > MAX_CODE_LENGTH) throw corrupt('code length');
81
+ if (!bits.read(1)) break;
82
+ length += bits.read(1) ? -1 : 1;
83
+ }
84
+ lengths[i] = length;
85
+ }
86
+ tables.push(decodeTables(lengths, alphabet));
87
+ }
88
+ // Huffman → move-to-front and zero-run decoding, straight into the BWT vector.
89
+ const mtf = Uint8Array.from({ length: 256 }, (_, i) => i), counts = new Int32Array(256);
90
+ let length = 0, group = -1, left = 0, table = null;
91
+ const symbol = () => {
92
+ if (!left) { if (++group >= selectorCount) throw corrupt('selector overrun'); table = tables[selectors[group]]; left = GROUP_SIZE; }
93
+ left--;
94
+ let size = table.min, code = bits.read(size);
95
+ while (code > table.limit[size]) { if (++size > table.max) throw corrupt('Huffman code'); code = (code << 1) | bits.read(1); }
96
+ const index = code - table.base[size];
97
+ if (index < 0 || index >= alphabet) throw corrupt('Huffman code');
98
+ return table.perm[index];
99
+ };
100
+ let next = symbol();
101
+ while (next !== endOfBlock) {
102
+ if (next === RUN_A || next === RUN_B) {
103
+ let run = 0, weight = 1;
104
+ do { run += next === RUN_A ? weight : 2 * weight; weight *= 2; if (run > blockSize) throw corrupt('run length'); next = symbol(); } while (next === RUN_A || next === RUN_B);
105
+ const byte = symbols[mtf[0]];
106
+ if (length + run > blockSize) throw corrupt('block overflow');
107
+ counts[byte] += run;
108
+ tt.fill(byte, length, length + run); length += run;
109
+ continue;
110
+ }
111
+ const position = next - 1, value = mtf[position];
112
+ mtf.copyWithin(1, 0, position); mtf[0] = value;
113
+ const byte = symbols[value];
114
+ if (length >= blockSize) throw corrupt('block overflow');
115
+ counts[byte]++; tt[length++] = byte;
116
+ next = symbol();
117
+ }
118
+ if (origin >= length) throw corrupt('origin pointer');
119
+ // Inverse Burrows–Wheeler transform.
120
+ let sum = 0;
121
+ for (let i = 0; i < 256; i++) { const count = counts[i]; counts[i] = sum; sum += count; }
122
+ for (let i = 0; i < length; i++) { const byte = tt[i] & 0xff; tt[counts[byte]++] |= i << 8; }
123
+ // Undo the initial run-length encoding (four equal bytes, then a count) and check the CRC.
124
+ let out = Buffer.allocUnsafe(Math.max(1024, length + (length >> 2))), written = 0, crc = -1;
125
+ const emit = (byte, times) => {
126
+ if (written + times > out.length) { const larger = Buffer.allocUnsafe(Math.max(out.length * 2, written + times)); out.copy(larger, 0, 0, written); out = larger; }
127
+ for (let k = 0; k < times; k++) { out[written++] = byte; crc = (crc << 8) ^ CRC[((crc >>> 24) ^ byte) & 0xff]; }
128
+ };
129
+ let position = tt[origin] >>> 8, previous = -1, repeat = 0;
130
+ for (let i = 0; i < length; i++) {
131
+ const entry = tt[position], byte = entry & 0xff;
132
+ position = entry >>> 8;
133
+ if (repeat === 4) { emit(previous, byte); repeat = 0; previous = -1; continue; }
134
+ emit(byte, 1);
135
+ if (byte === previous) repeat++; else { previous = byte; repeat = 1; }
136
+ }
137
+ if ((~crc | 0) !== storedCrc) throw corrupt('block checksum');
138
+ return { data: out.subarray(0, written), crc: storedCrc };
139
+ }
140
+
141
+ /** Decompress a bzip2 buffer (one or several concatenated streams): yields decoded blocks. */
142
+ function* decompressBlocks(bytes) {
143
+ const bits = new Bits(bytes);
144
+ let streams = 0;
145
+ while (bits.remaining > 0 || bits.count >= 8) {
146
+ if (bits.read(8) !== 0x42 || bits.read(8) !== 0x5a || bits.read(8) !== 0x68) { if (streams) return; throw corrupt('not a bzip2 stream'); }
147
+ const level = bits.read(8) - 0x30;
148
+ if (level < 1 || level > 9) throw corrupt('block size');
149
+ const blockSize = level * 100000, tt = new Uint32Array(blockSize);
150
+ let combined = 0;
151
+ for (;;) {
152
+ const high = bits.read(24), low = bits.read(24);
153
+ if (high === BLOCK_MAGIC_HI && low === BLOCK_MAGIC_LO) {
154
+ const block = readBlock(bits, blockSize, tt);
155
+ combined = ((combined << 1) | (combined >>> 31)) ^ block.crc;
156
+ yield block.data;
157
+ } else if (high === END_MAGIC_HI && low === END_MAGIC_LO) {
158
+ const stored = (bits.read(16) << 16 | bits.read(16)) | 0;
159
+ if (stored !== (combined | 0)) throw corrupt('stream checksum');
160
+ break;
161
+ } else throw corrupt('block header');
162
+ }
163
+ bits.align(); streams++;
164
+ }
165
+ }
166
+
167
+ module.exports = { decompressBlocks };
@@ -0,0 +1,75 @@
1
+ 'use strict';
2
+ /**
3
+ * Red Hat errata, for the distributions rebuilt from Red Hat Enterprise Linux sources.
4
+ *
5
+ * AlmaLinux and Rocky Linux publish their own errata, but not for every update: packages
6
+ * refreshed with a minor release, and some kernel updates, have none, or one that lists
7
+ * fewer CVEs. Measured on a Rocky Linux 8.6 image: 795 (package, CVE) pairs fixed by a Red
8
+ * Hat erratum that Rocky's feed does not mention. A rebuilt package keeps the version of the
9
+ * Red Hat package it rebuilds, so the Red Hat erratum's fixed version compares with it.
10
+ *
11
+ * The distribution's own errata decide for every CVE they mention for a package: a Red Hat
12
+ * erratum is reported only for the CVEs they do not mention.
13
+ */
14
+ const { family } = require('./unfixed');
15
+
16
+ const SOURCE = 'redhat-errata', TTL_MS = 24 * 3600 * 1000;
17
+ const isCve = id => /^CVE-\d{4}-\d{4,}$/.test(id);
18
+ const empty = () => ({ matches: [], observations: [], coverage: [], warnings: [], assessments: [] });
19
+
20
+ async function assessRedHatErrata(inventory, opts = {}) {
21
+ const result = empty(), scope = family(inventory?.distribution);
22
+ if (!scope?.ownErrata || opts.osv === false) return result;
23
+ const advisories = require('../../system-inventory/advisories');
24
+ const rhel = { id: 'rhel', versionId: String(inventory.distribution.versionId), name: `Red Hat Enterprise Linux ${inventory.distribution.versionId}` };
25
+ const options = { ...opts, advisoryConfig: undefined, adapters: undefined, records: undefined };
26
+ const redhat = advisories.scope(rhel, options);
27
+ const built = new RegExp(`[.+]el${scope.major}(?![0-9])`);
28
+ const packages = (inventory.packages || []).filter(p => p.manager === 'rpm' && p.name && !['third-party', 'ambiguous'].includes(p.packageOrigin?.status) && built.test(`${p.version || ''} ${p.release || ''}`));
29
+ if (!redhat || !packages.length) { result.coverage.push({ source: SOURCE, execution: 'not-applicable', result: 'not-applicable' }); return result; }
30
+
31
+ const repository = opts.repository || require('../../cache/repository').createCacheRepository(opts.cacheDir || require('../../cache/directory').getCacheDir());
32
+ const namespace = 'system-osv:' + redhat.ecosystem;
33
+ let failure = null;
34
+ const snapshot = () => repository.getSnapshot(namespace);
35
+ const stale = s => !s?.complete || s.stale || !(Date.now() - (s.fetchedAt || 0) < TTL_MS);
36
+ if (!opts.offline && (stale(snapshot()) || opts.refresh || opts.forceUpdate)) {
37
+ try { await advisories.syncSystemAdvisories(rhel, options); }
38
+ catch (error) { if (opts.signal?.aborted) throw error; failure = error; result.warnings.push({ type: 'source-unavailable', source: SOURCE, message: `Red Hat errata: ${error.message}${snapshot() ? '; saved data retained.' : ''}` }); }
39
+ }
40
+ if (!snapshot()) {
41
+ result.coverage.push({ source: SOURCE, execution: failure ? 'failed' : 'not-run', result: 'indeterminate', reason: failure?.message || 'No Red Hat errata cached for this release.' });
42
+ return result;
43
+ }
44
+ const assessed = await advisories.assessSystemInventory({ distribution: rhel, packages }, options);
45
+
46
+ // What the distribution's own errata already say of each package.
47
+ const own = advisories.scope(inventory.distribution, opts), ownNamespace = own ? 'system-osv:' + own.ecosystem : null, known = new Map();
48
+ const mentioned = name => {
49
+ if (!known.has(name)) {
50
+ const ids = new Set();
51
+ for (const record of (ownNamespace && repository.get(ownNamespace, name)?.value) || []) for (const id of [record.id, ...(record.aliases || []), ...(record.related || []), ...(record.upstream || [])]) ids.add(id);
52
+ known.set(name, ids);
53
+ }
54
+ return known.get(name);
55
+ };
56
+ let superseded = 0;
57
+ for (const match of assessed.matches) {
58
+ const dep = match.dep, seen = new Set([...mentioned(dep.name), ...(dep.sourceName && dep.sourceName !== dep.name ? mentioned(dep.sourceName) : [])]);
59
+ const cves = [...new Set([match.cve.id, ...match.cve.aliases, ...match.cve.upstream, ...match.cve.related].filter(isCve))];
60
+ const missing = cves.filter(id => !seen.has(id));
61
+ // Same erratum number under the rebuild's prefix (RLSA-2024:1234 for RHSA-2024:1234): its own record.
62
+ const number = /:(\d+)$/.exec(match.cve.sourceAdvisoryId || '')?.[0];
63
+ const rebuilt = number && [...seen].some(id => !isCve(id) && id.endsWith(number));
64
+ if (cves.length ? !missing.length : rebuilt) { superseded++; continue; }
65
+ const keep = list => list.filter(id => !isCve(id) || missing.includes(id));
66
+ result.matches.push({ ...match, source: SOURCE, cve: { ...match.cve, aliases: keep(match.cve.aliases), upstream: keep(match.cve.upstream), related: keep(match.cve.related),
67
+ distributionAdvisory: { source: 'Red Hat', release: redhat.ecosystem, appliedTo: scope.rebuild } } });
68
+ }
69
+ const partial = failure || assessed.coverage.some(c => c.status !== 'complete');
70
+ result.coverage.push({ source: SOURCE, execution: partial ? 'partial' : 'completed', result: result.matches.length ? 'affected' : 'no-match', release: redhat.ecosystem, appliedTo: scope.rebuild,
71
+ count: packages.length, superseded, fetchedAt: snapshot().fetchedAt || null, ...(failure ? { reason: failure.message } : {}) });
72
+ return result;
73
+ }
74
+
75
+ module.exports = { assessRedHatErrata, SOURCE };
@@ -0,0 +1,10 @@
1
+ 'use strict';
2
+ // Red Hat security data. OVAL "including unpatched" definitions, one file per major release
3
+ // of Red Hat Enterprise Linux: they state which CVEs affect which packages without a fix.
4
+ const MAJORS = new Set(['6', '7', '8', '9']);
5
+
6
+ module.exports = { id: 'redhat', ttlMs: 24 * 3600 * 1000, MAJORS, build(type, params) {
7
+ const major = String(params?.major ?? '');
8
+ if (type !== 'oval-unpatched' || !MAJORS.has(major)) throw Error('invalid Red Hat OVAL request');
9
+ return { url: `https://security.access.redhat.com/data/oval/v2/RHEL${major}/rhel-${major}-including-unpatched.oval.xml.bz2`, init: { headers: { accept: 'application/x-bzip2' } } };
10
+ } };
@@ -0,0 +1,70 @@
1
+ 'use strict';
2
+ // Reads the unpatched-vulnerability definitions of a Red Hat OVAL file: for each CVE, the
3
+ // packages Red Hat states are affected and why no fix is available. Only that is kept; the
4
+ // patch definitions (errata) come from another source and the OVAL tests are not evaluated.
5
+ const { StringDecoder } = require('node:string_decoder');
6
+ const { decompressBlocks } = require('./bzip2');
7
+
8
+ const MAX_DEFINITION_CHARS = 4 * 1024 * 1024, MAX_ADVISORIES = 200000;
9
+ const STATES = ['Affected', 'Fix deferred', 'Will not fix', 'Out of support scope', 'Under investigation'];
10
+ const SEVERITY = { low: 'LOW', moderate: 'MEDIUM', important: 'HIGH', critical: 'CRITICAL' };
11
+ const ENTITIES = { '&amp;': '&', '&lt;': '<', '&gt;': '>', '&quot;': '"', '&apos;': "'" };
12
+ const unescape = text => text.replace(/&(?:amp|lt|gt|quot|apos);/g, entity => ENTITIES[entity]);
13
+ const COMPONENT = /^(?:[A-Za-z0-9][A-Za-z0-9._+-]*:[A-Za-z0-9._+-]+\/)?[A-Za-z0-9][A-Za-z0-9._+-]*$/;
14
+
15
+ function parseDefinition(xml) {
16
+ const cve = /<cve\b([^>]*)>\s*(CVE-\d{4}-\d{4,})\s*<\/cve>/.exec(xml);
17
+ if (!cve) return null;
18
+ const attribute = name => (new RegExp(`\\b${name}="([^"]*)"`).exec(cve[1]) || [])[1] || null;
19
+ const cvss = /^(\d+(?:\.\d+)?)\/(CVSS:3\.[01]\/[A-Za-z:/]+)$/.exec(attribute('cvss3') || '');
20
+ const title = (/<title>([^<]*)<\/title>/.exec(xml) || [])[1];
21
+ const published = /^(\d{4})(\d{2})(\d{2})$/.exec(attribute('public') || '');
22
+ const components = [];
23
+ for (const resolution of xml.matchAll(/<resolution state="([^"]+)">([\s\S]*?)<\/resolution>/g)) {
24
+ const state = STATES.indexOf(resolution[1]);
25
+ if (state < 0) continue;
26
+ for (const component of resolution[2].matchAll(/<component>([^<]+)<\/component>/g)) if (COMPONENT.test(component[1])) components.push([component[1], state]);
27
+ }
28
+ if (!components.length) return null;
29
+ return { id: cve[2], components, advisory: {
30
+ title: title ? unescape(title).replace(/\s*\((?:low|moderate|important|critical)\)\s*$/i, '').slice(0, 500) : null,
31
+ severity: SEVERITY[String(attribute('impact') || (/<severity>([^<]+)<\/severity>/.exec(xml) || [])[1] || '').toLowerCase()] || 'UNKNOWN',
32
+ score: cvss ? Number(cvss[1]) : null, vector: cvss ? cvss[2] : null,
33
+ published: published ? `${published[1]}-${published[2]}-${published[3]}` : null,
34
+ updated: (/<updated date="(\d{4}-\d{2}-\d{2})"/.exec(xml) || [])[1] || null } };
35
+ }
36
+
37
+ /**
38
+ * Decompress and read an OVAL file. → { timestamp, advisories: { CVE: {...} },
39
+ * components: { package or "module:stream/package": [[CVE, state index], …] }, states }
40
+ */
41
+ function readUnpatched(compressed) {
42
+ const decoder = new StringDecoder('utf8'), advisories = Object.create(null), components = Object.create(null);
43
+ let pending = '', count = 0, timestamp = null, done = false;
44
+ const take = definition => {
45
+ // Unpatched vulnerabilities only: errata (rhsa, rhba, rhea) and "unaffected" are other classes.
46
+ if (!/^<definition\b[^>]*\bid="oval:com\.redhat\.cve:def:/.test(definition)) return;
47
+ const parsed = parseDefinition(definition);
48
+ if (!parsed || advisories[parsed.id] || count >= MAX_ADVISORIES) return;
49
+ advisories[parsed.id] = parsed.advisory; count++;
50
+ for (const [name, state] of parsed.components) (components[name] ||= []).push([parsed.id, state]);
51
+ };
52
+ for (const block of decompressBlocks(compressed)) {
53
+ pending += decoder.write(block);
54
+ if (timestamp === null) { const stamp = /<oval:timestamp>([^<]+)<\/oval:timestamp>/.exec(pending); if (stamp) timestamp = stamp[1]; }
55
+ for (;;) {
56
+ const start = pending.indexOf('<definition ');
57
+ if (start < 0) { if (pending.includes('</definitions>')) done = true; pending = pending.slice(-16); break; }
58
+ const end = pending.indexOf('</definition>', start);
59
+ if (end < 0) { pending = pending.slice(start); if (pending.length > MAX_DEFINITION_CHARS) throw Error('Red Hat OVAL definition exceeds its size limit'); break; }
60
+ take(pending.slice(start, end));
61
+ pending = pending.slice(end + 13);
62
+ }
63
+ // Tests, objects and states follow the definitions: nothing more to read.
64
+ if (done) break;
65
+ }
66
+ if (!count) throw Error('Red Hat OVAL file holds no unpatched definition');
67
+ return { timestamp, advisories, components, states: STATES, count };
68
+ }
69
+
70
+ module.exports = { readUnpatched, parseDefinition, STATES };
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+ /**
3
+ * Vulnerabilities Red Hat states are present without a fix. Errata only describe what was
4
+ * fixed: on an up-to-date RHEL 8 image half of what Red Hat itself tracks has no erratum
5
+ * ("Affected", "Fix deferred", "Will not fix", "Out of support scope").
6
+ *
7
+ * The statement is made for a package of one major release of Red Hat Enterprise Linux. It
8
+ * holds for the distributions rebuilt from the same sources (AlmaLinux, Rocky Linux, CentOS
9
+ * Linux, Oracle Linux) unless their own errata mention that CVE for the package: their own
10
+ * record then decides. "Under investigation" is reported as an observation, not a finding.
11
+ */
12
+ const { MAJORS } = require('./index');
13
+ const { STATES } = require('./oval');
14
+
15
+ const SOURCE = 'redhat-oval', FORMAT = 1, TTL_MS = 24 * 3600 * 1000, MAX_DOWNLOAD_BYTES = 128 * 1024 * 1024;
16
+ const REBUILDS = new Map([['almalinux', 'AlmaLinux'], ['rocky', 'Rocky Linux'], ['centos', 'CentOS Linux'], ['ol', 'Oracle Linux']]);
17
+ // Rebuilds that publish errata of their own, which then decide for the CVEs they mention.
18
+ const OWN_ERRATA = new Set(['almalinux', 'rocky']);
19
+ const UNDER_INVESTIGATION = STATES.indexOf('Under investigation');
20
+
21
+ /** The Red Hat Enterprise Linux release whose statements describe this distribution, or null. */
22
+ function family(distribution) {
23
+ const id = String(distribution?.id || '').toLowerCase(), major = String(distribution?.versionId || '').split('.')[0];
24
+ if (!/^\d+$/.test(major)) return null;
25
+ if (id === 'rhel') return { major, rebuild: null, ownErrata: false };
26
+ // CentOS Stream is the upstream of the next minor release, not a rebuild of a released one.
27
+ if (!REBUILDS.has(id) || (id === 'centos' && /stream/i.test(String(distribution.name || '')))) return null;
28
+ return { major, rebuild: REBUILDS.get(id), ownErrata: OWN_ERRATA.has(id) };
29
+ }
30
+ const repositoryOf = opts => opts.repository || require('../../cache/repository').createCacheRepository(opts.cacheDir || require('../../cache/directory').getCacheDir());
31
+
32
+ async function refresh(major, opts) {
33
+ const response = await require('..').getResource('redhat', 'oval-unpatched', { major }, { fetcher: opts.fetcher, noStore: true, streaming: true, signal: opts.signal });
34
+ if (!response.ok) throw Error(`Red Hat OVAL HTTP ${response.status}`);
35
+ const bytes = Buffer.from(await response.arrayBuffer());
36
+ if (!bytes.length || bytes.length > MAX_DOWNLOAD_BYTES) throw Error('Red Hat OVAL file is empty or exceeds its size limit');
37
+ const parsed = require('./oval').readUnpatched(bytes);
38
+ return { format: FORMAT, fetchedAt: Date.now(), published: parsed.timestamp, count: parsed.count, advisories: parsed.advisories, components: parsed.components };
39
+ }
40
+
41
+ // CVEs the distribution's own errata mention for a package: its own record decides for those.
42
+ function ownErrata(inventory, opts) {
43
+ const scope = require('../../system-inventory/advisories').scope(inventory.distribution, opts);
44
+ if (!scope) return () => new Set();
45
+ const cache = repositoryOf(opts), namespace = 'system-osv:' + scope.ecosystem, seen = new Map();
46
+ return name => {
47
+ if (!seen.has(name)) {
48
+ const ids = new Set();
49
+ for (const record of cache.get(namespace, name)?.value || []) for (const id of [record.id, ...(record.aliases || []), ...(record.related || []), ...(record.upstream || [])]) ids.add(id);
50
+ seen.set(name, ids);
51
+ }
52
+ return seen.get(name);
53
+ };
54
+ }
55
+
56
+ async function assessRedHatUnfixed(inventory, opts = {}) {
57
+ const result = { matches: [], observations: [], coverage: [], warnings: [], assessments: [] };
58
+ const scope = family(inventory?.distribution);
59
+ if (!scope) return result;
60
+ const release = `enterprise_linux:${scope.major}`;
61
+ if (!MAJORS.has(scope.major)) {
62
+ result.coverage.push({ source: SOURCE, execution: 'not-applicable', result: 'not-consulted', expected: false, reason: `Red Hat publishes no OVAL data for Enterprise Linux ${scope.major}.` });
63
+ return result;
64
+ }
65
+ const packages = (inventory.packages || []).filter(p => p.manager === 'rpm' && p.name && !['third-party', 'ambiguous'].includes(p.packageOrigin?.status));
66
+ if (!packages.length) { result.coverage.push({ source: SOURCE, execution: 'not-applicable', result: 'not-applicable' }); return result; }
67
+
68
+ const repository = repositoryOf(opts), namespace = `${SOURCE}:${scope.major}`;
69
+ let saved = repository.get(namespace, 'unfixed')?.value, failure = null;
70
+ if (saved?.format !== FORMAT) saved = null;
71
+ const stale = () => !saved || !(Date.now() - saved.fetchedAt < TTL_MS) || saved.fetchedAt > Date.now();
72
+ if (!opts.offline && (stale() || opts.forceUpdate || opts.refresh)) {
73
+ try { saved = await refresh(scope.major, opts); repository.put(namespace, 'unfixed', saved, { fetchedAt: saved.fetchedAt }); }
74
+ catch (error) { if (opts.signal?.aborted) throw error; failure = error; result.warnings.push({ type: 'source-unavailable', source: SOURCE, message: `Red Hat OVAL: ${error.message}${saved ? '; saved data retained.' : ''}` }); }
75
+ }
76
+ if (!saved) {
77
+ result.coverage.push({ source: SOURCE, execution: failure ? 'failed' : 'not-run', result: 'indeterminate', reason: failure?.message || 'No Red Hat OVAL data cached for this release.' });
78
+ return result;
79
+ }
80
+ const mentionedByOwnErrata = scope.ownErrata ? ownErrata(inventory, opts) : () => new Set();
81
+ const built = new RegExp(`[.+]el${scope.major}(?![0-9])`);
82
+ // Red Hat lists every binary package of a source package (kernel, kernel-core, kernel-modules…)
83
+ // for the same CVE. One finding per source package says it, naming the packages concerned,
84
+ // instead of one per binary package: a kernel carries several thousand such CVEs.
85
+ let examined = 0, skipped = 0;
86
+ const groups = new Map();
87
+ for (const dep of packages) {
88
+ // A package of another origin carrying a Red Hat name is not the package Red Hat describes.
89
+ if (!built.test(`${dep.version || ''} ${dep.release || ''}`)) { skipped++; continue; }
90
+ examined++;
91
+ const module = String(dep.modularityLabel || '').split(':').slice(0, 2).join(':');
92
+ const listed = [...(dep.modularityLabel ? [] : saved.components[dep.name] || []), ...(module ? saved.components[`${module}/${dep.name}`] || [] : [])];
93
+ if (!listed.length) continue;
94
+ const own = new Set([...mentionedByOwnErrata(dep.name), ...(dep.sourceName && dep.sourceName !== dep.name ? mentionedByOwnErrata(dep.sourceName) : [])]);
95
+ const key = `${dep.sourceName || dep.name}\0${dep.sourceVersion || dep.version}`;
96
+ let group = groups.get(key);
97
+ if (!group) groups.set(key, group = new Map());
98
+ for (const [id, state] of listed) {
99
+ if (!saved.advisories[id] || own.has(id)) continue;
100
+ let entry = group.get(id);
101
+ if (!entry) group.set(id, entry = { state, deps: [] });
102
+ entry.deps.push(dep);
103
+ }
104
+ }
105
+ for (const group of groups.values()) for (const [id, { state, deps }] of group) {
106
+ const advisory = saved.advisories[id];
107
+ // The package named after its source speaks for the group, else the first by name.
108
+ const sorted = [...deps].sort((a, b) => a.name.localeCompare(b.name)), dep = sorted.find(d => d.name === d.sourceName) || sorted[0];
109
+ const status = { source: 'Red Hat', release, state: STATES[state], ...(scope.rebuild ? { appliedTo: scope.rebuild } : {}),
110
+ packages: sorted.map(d => d.name), observedAt: saved.fetchedAt };
111
+ const url = `https://access.redhat.com/security/cve/${id}`;
112
+ if (state === UNDER_INVESTIGATION) {
113
+ result.observations.push({ dep, cveId: id, source: SOURCE, status: 'possible', sourceUrl: url, reason: 'Red Hat is investigating whether this package is affected.', evidence: status });
114
+ continue;
115
+ }
116
+ result.matches.push({ dep, source: SOURCE, cve: { id, summary: advisory.title || '', description: advisory.title || '', severity: advisory.severity, score: advisory.score,
117
+ ...(advisory.vector ? { cvssVector: advisory.vector } : {}), fixVersion: null, published: advisory.published, modified: advisory.updated,
118
+ distributionAdvisory: { source: 'Red Hat', release }, distributionStatus: status, osvRefs: [{ type: 'ADVISORY', url }] } });
119
+ }
120
+ const old = stale();
121
+ if (old && !failure && !opts.offline) result.warnings.push({ type: 'source-stale', source: SOURCE, message: 'Red Hat OVAL data is older than a day.' });
122
+ result.coverage.push({ source: SOURCE, execution: failure ? 'partial' : 'completed', result: result.matches.length ? 'affected' : 'no-match', release, count: examined,
123
+ ...(skipped ? { skipped } : {}), advisories: saved.count, fetchedAt: saved.fetchedAt, published: saved.published, ...(scope.rebuild ? { appliedTo: scope.rebuild } : {}), ...(failure ? { reason: failure.message } : {}) });
124
+ return result;
125
+ }
126
+
127
+ module.exports = { assessRedHatUnfixed, family, SOURCE };
@@ -1,7 +1,7 @@
1
1
  /**
2
- * lib/registries.js — per-ecosystem registry list assembly + auth + fan-out.
2
+ * lib/providers/registries.js — per-ecosystem registry list assembly + auth + fan-out.
3
3
  *
4
- * Generalizes lib/maven-repo.js's list-building to npm/pypi/ruby/go. Custom
4
+ * Generalizes lib/providers/maven/repo.js's list-building to npm/pypi/ruby/go. Custom
5
5
  * registries are tried first (declared order); callers append the public base
6
6
  * last via withPublic(). Lists are unioned across config layers, deduped by URL.
7
7
  *
@@ -95,7 +95,7 @@ function mergeRegistryMaps(...maps) {
95
95
  */
96
96
  async function fetchFirstOk(bases, buildUrl, opts = {}) {
97
97
  const { fetcher = globalThis.fetch, userAgent = "vigievuln", timeoutMs, onMiss } = opts;
98
- // See lib/maven-repo.js#tryRepos: these carry our own AbortSignal, so the fetch guard
98
+ // See lib/providers/maven/repo.js#tryRepos: these carry our own AbortSignal, so the fetch guard
99
99
  // leaves them alone and this loop reports its own exhaustion. A 404 from every base is
100
100
  // an ANSWER (that is how an internal package is detected), not an outage.
101
101
  const misses = [];
@@ -114,7 +114,7 @@ async function fetchFirstOk(bases, buildUrl, opts = {}) {
114
114
  misses.push(`HTTP ${res.status}`);
115
115
  if (onMiss) onMiss(base, `HTTP ${res.status}`);
116
116
  }
117
- if (firstUrl) require("./source-health").noteFanoutExhausted(firstUrl, misses);
117
+ if (firstUrl) require("../scan/source-health").noteFanoutExhausted(firstUrl, misses);
118
118
  return null;
119
119
  }
120
120