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
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ const fs=require('node:fs');
4
+ const os=require('node:os');
5
+ const path=require('node:path');
6
+ const {Unzip,UnzipInflate}=require('fflate');
7
+
8
+ async function prepareSource(input) {
9
+ const absolute=path.resolve(input),stat=await fs.promises.stat(absolute);
10
+ if(stat.isDirectory())return {root:absolute,name:path.basename(absolute)||absolute,cleanup:async()=>{}};
11
+ if(!stat.isFile() || !/\.zip$/i.test(absolute))throw Error('scan expects a source directory, project ZIP or dependency descriptor JSON');
12
+ const root=await fs.promises.mkdtemp(path.join(os.tmpdir(),'vigievuln-source-'));
13
+ const cleanup=()=>fs.promises.rm(root,{recursive:true,force:true});
14
+ let entries=0,bytes=0,failure;
15
+ const seen=new Set();
16
+ const unzip=new Unzip(file=>{
17
+ try {
18
+ if(++entries>1000000)throw Error('Source ZIP contains too many entries');
19
+ const name=file.name;
20
+ if(name.includes('\0') || name.includes('\\') || name.startsWith('/') || /^[A-Za-z]:/.test(name) || name.split('/').includes('..'))
21
+ throw Error('Unsafe source ZIP path');
22
+ const parts=name.split('/').filter(p=>p && p!=='.');
23
+ if(parts.length>256)throw Error('Source ZIP path is too deep');
24
+ const relative=parts.join('/');
25
+ if(!relative)return;
26
+ if(seen.has(relative))throw Error('Duplicate source ZIP entry');
27
+ seen.add(relative);
28
+ const output=path.join(root,...parts);
29
+ if(name.endsWith('/')){fs.mkdirSync(output,{recursive:true});file.ondata=error=>{if(error)failure=error;};file.start();return;}
30
+ fs.mkdirSync(path.dirname(output),{recursive:true});
31
+ fs.writeFileSync(output,'',{flag:'wx',mode:0o600});
32
+ file.ondata=(error,data)=>{
33
+ if(failure)return;
34
+ try{
35
+ if(error)throw error;
36
+ bytes+=data.length;
37
+ if(bytes>20*1024**3)throw Error('Source ZIP exceeds extracted size limit');
38
+ fs.appendFileSync(output,data);
39
+ }catch(error){failure=error;file.terminate();}
40
+ };
41
+ file.start();
42
+ }catch(error){failure=error;file.terminate();}
43
+ });
44
+ unzip.register(UnzipInflate);
45
+ try {
46
+ for await(const chunk of fs.createReadStream(absolute)){
47
+ unzip.push(chunk);
48
+ if(failure)throw failure;
49
+ }
50
+ unzip.push(new Uint8Array(),true);
51
+ if(failure)throw failure;
52
+ if(!seen.size)throw Error('Source ZIP is empty');
53
+ const children=await fs.promises.readdir(root,{withFileTypes:true});
54
+ const source=children.length===1 && children[0].isDirectory()?path.join(root,children[0].name):root;
55
+ return {root:source,name:path.basename(absolute),archive:absolute,cleanup};
56
+ }catch(error){await cleanup();throw error;}
57
+ }
58
+ module.exports={prepareSource};
@@ -1,20 +1,59 @@
1
1
  'use strict';
2
2
  const fs=require('node:fs');
3
3
  const {unzipSync}=require('fflate');
4
- const {createCacheRepository}=require('../cache-repository');
4
+ const {createCacheRepository}=require('../cache/repository');
5
5
  const versions=require('./versions');
6
- const {severityFromOsv}=require('../osv');
6
+ const {severityFromOsv}=require('../providers/osv/query');
7
+ // One entry per distribution: the os-release ids it answers to, the OSV archive that holds its
8
+ // advisories (`base`), how its package versions compare, and which OSV ecosystem(s) describe
9
+ // an installed release: one name (`release`) or, for a product whose packages are published
10
+ // under several names (RHEL repositories, SUSE modules), a `label` and a predicate (`accepts`).
11
+ // `fixedOnly`: the distribution publishes errata, so a vulnerability it has not fixed yet has
12
+ // no record (Debian, Ubuntu and Alpine track those; Azure Linux records them too).
13
+ const escape=text=>text.replace(/[.*+?^${}()|[\]\\]/g,'\\$&');
14
+ const servicePack=v=>{const [major,minor]=v.split('.');return minor && minor!=='0' ? `${major} SP${minor}` : major;};
7
15
  const DISTRIBUTIONS=[
8
16
  {ids:['debian'],base:'Debian',scheme:'debian',release:v=>v.split('.')[0]},
9
17
  {ids:['ubuntu'],base:'Ubuntu',scheme:'debian',release:v=>{const p=v.split('.');const release=p.slice(0,2).join('.');return p[1]==='04' && Number(p[0])%2===0 ? release+':LTS' : release;}},
10
18
  {ids:['alpine'],base:'Alpine',scheme:'apk',release:v=>'v'+v.replace(/^v/,'').split('.').slice(0,2).join('.')},
11
- ...[['almalinux','AlmaLinux'],['rocky','Rocky Linux']].map(([id,base])=>({ids:[id],base,scheme:'rpm',release:v=>v.split('.')[0]})),
19
+ ...[['almalinux','AlmaLinux'],['rocky','Rocky Linux']].map(([id,base])=>({ids:[id],base,scheme:'rpm',release:v=>v.split('.')[0],fixedOnly:true})),
20
+ {ids:['mageia'],base:'Mageia',scheme:'rpm',release:v=>v.split('.')[0],fixedOnly:true},
21
+ {ids:['azurelinux','mariner'],base:'Azure Linux',scheme:'rpm',release:v=>v.split('.')[0]},
22
+ {ids:['opensuse-leap'],base:'openSUSE',scheme:'rpm',release:v=>'Leap '+v,fixedOnly:true},
23
+ {ids:['opensuse-tumbleweed'],base:'openSUSE',scheme:'rpm',release:()=>'Tumbleweed',fixedOnly:true},
24
+ // os-release gives VERSION_ID="24.03" and the service pack only in its name: "openEuler 24.03 (LTS-SP1)", "openEuler 22.03 LTS".
25
+ {ids:['openeuler'],base:'openEuler',scheme:'rpm',fixedOnly:true,release:(v,d)=>{const pack=/\b(LTS(?:-SP\d+)?)\b/.exec(String(d.name||''));return pack ? `${v}-${pack[1]}` : v;}},
26
+ // Red Hat files an erratum under the repository that ships the package (baseos, appstream,
27
+ // crb…), and under the extended-support stream of one minor release when it only fixes that.
28
+ // CentOS Linux and Oracle Linux rebuild the same packages and have no feed of their own
29
+ // here: they are assessed against the Red Hat errata of the release they rebuild (CentOS
30
+ // Stream is not a rebuild of a released RHEL and is left out).
31
+ {ids:['rhel','centos','ol'],applies:d=>String(d.id).toLowerCase()!=='centos' || !/stream/i.test(String(d.name||'')),
32
+ base:'Red Hat',scheme:'rpm',fixedOnly:true,label:v=>'enterprise_linux:'+v.split('.')[0],accepts(v){
33
+ const [major,minor]=v.split('.'),m=escape(major),own=minor===undefined?null:Number(minor);
34
+ const general=new RegExp(`^Red Hat:enterprise_linux:${m}(?:\\.(\\d+))?(?:::[a-z0-9_]+)?$`),stream=new RegExp(`^Red Hat:rhel_[a-z0-9_]+:${m}\\.(\\d+)(?:::[a-z0-9_]+)?$`);
35
+ return ecosystem=>{const g=general.exec(ecosystem);if(g)return g[1]===undefined || own===null || Number(g[1])<=own;const e=stream.exec(ecosystem);return !!e && own!==null && Number(e[1])===own;};
36
+ }},
37
+ // SUSE Linux Enterprise ships its packages through the product and its modules, each an
38
+ // ecosystem of its own: "Linux Enterprise Server 15 SP5", "…Module for Basesystem 15 SP5".
39
+ {ids:['sles','sled','sles_sap','sle_hpc'],base:'SUSE',scheme:'rpm',fixedOnly:true,label:v=>'Linux Enterprise '+servicePack(v),accepts(v){
40
+ const pattern=new RegExp(`^SUSE:Linux Enterprise (?!Micro\\b).*\\b${escape(servicePack(v))}(?:-[A-Z]+)?$`);return ecosystem=>pattern.test(ecosystem);
41
+ }},
42
+ {ids:['sle-micro','sl-micro'],base:'SUSE',scheme:'rpm',fixedOnly:true,release:v=>'Linux Enterprise Micro '+v},
43
+ // Rolling distributions without releases. Their advisories come from the security database of
44
+ // their package repositories (lib/providers/wolfi), not from an OSV archive of several hundred MB.
45
+ {ids:['wolfi'],base:'Wolfi',scheme:'apk',fixedOnly:true,rolling:true,secdb:['wolfi']},
46
+ {ids:['chainguard'],base:'Chainguard',scheme:'apk',fixedOnly:true,rolling:true,secdb:['chainguard','wolfi']},
12
47
  ];
13
48
  const defaultAdapters=DISTRIBUTIONS.map(d=>({id:d.base,resolveScope(distribution){
14
- if(!d.ids.includes(String(distribution?.id||'').toLowerCase()) || !distribution?.versionId)return null;
49
+ if(!d.ids.includes(String(distribution?.id||'').toLowerCase()) || (!distribution?.versionId && !d.rolling) || (d.applies && !d.applies(distribution)))return null;
50
+ if(d.rolling)return {base:d.base,ecosystem:d.base,compare:versions[d.scheme],fixedOnly:!!d.fixedOnly,secdb:d.secdb};
15
51
  const v=String(distribution.versionId);if(!/^[A-Za-z0-9._-]+$/.test(v))return null;
16
- return {base:d.base,ecosystem:d.base+':'+d.release(v),compare:versions[d.scheme]};
52
+ return {base:d.base,ecosystem:d.base+':'+(d.label ? d.label(v,distribution) : d.release(v,distribution)),compare:versions[d.scheme],fixedOnly:!!d.fixedOnly,
53
+ ...(d.accepts ? {accepts:d.accepts(v,distribution)} : {})};
17
54
  }}));
55
+ // The OSV ecosystems a scope covers: its own name, or every name its predicate accepts.
56
+ const inScope=(s,ecosystem)=>typeof ecosystem==='string' && (s.accepts ? s.accepts(ecosystem) : ecosystem===s.ecosystem);
18
57
  function scope(d,opts={}) {
19
58
  if(opts.advisoryConfig) {
20
59
  const c=opts.advisoryConfig;
@@ -40,7 +79,7 @@ function scope(d,opts={}) {
40
79
  function repo(opts){return opts.repository || createCacheRepository(opts.cacheDir);}
41
80
  function namespace(s){return 'system-osv:'+s.ecosystem;}
42
81
  function recordsFrom(input,opts={}) {
43
- const maxEntries=opts.maxEntries ?? 500000, maxEntryBytes=opts.maxEntryBytes ?? 16*1024*1024, maxExpandedBytes=opts.maxExpandedBytes ?? 1024*1024*1024;
82
+ const maxEntries=opts.maxEntries ?? 500000, maxEntryBytes=opts.maxEntryBytes ?? 64*1024*1024, maxExpandedBytes=opts.maxExpandedBytes ?? 1024*1024*1024;
44
83
  if(Array.isArray(input))return input;
45
84
  if(input && typeof input==='object' && !Buffer.isBuffer(input) && !(input instanceof Uint8Array))return input.records || [input];
46
85
  const b=Buffer.isBuffer(input)?input:Buffer.from(input);
@@ -63,9 +102,11 @@ async function importSystemAdvisories(file,opts={}) {
63
102
  if(!record || typeof record.id!=='string' || !Array.isArray(record.affected))throw Error('invalid OSV advisory');
64
103
  if(record.withdrawn)continue;
65
104
  for(const a of record.affected) {
66
- if(a?.package?.ecosystem!==s.ecosystem || !a.package.name)continue;
105
+ if(!inScope(s,a?.package?.ecosystem) || !a.package.name)continue;
67
106
  const name=a.package.name; if(!grouped.has(name))grouped.set(name,[]);
68
- grouped.get(name).push({...record,affected:[a]});
107
+ // Some feeds publish a bound with stray whitespace (" 1.57.0-1"): it is the version, not an unknown one.
108
+ const ranges=Array.isArray(a.ranges) ? a.ranges.map(r=>Array.isArray(r?.events) ? {...r,events:r.events.map(e=>e && typeof e==='object' ? Object.fromEntries(Object.entries(e).map(([k,v])=>[k,typeof v==='string'?v.trim():v])) : e)} : r) : a.ranges;
109
+ grouped.get(name).push({...record,affected:[{...a,...(ranges ? {ranges} : {})}]});
69
110
  }
70
111
  }
71
112
  if(!grouped.size)throw Error(`OSV snapshot contains no records for ${s.ecosystem}`);
@@ -82,6 +123,10 @@ async function importSystemAdvisories(file,opts={}) {
82
123
  async function syncSystemAdvisories(distribution,opts={}) {
83
124
  const s=scope(distribution,opts);if(!s)throw Error('unsupported or missing distribution identity');
84
125
  if(opts.offline)throw Error('cannot sync system advisories offline');
126
+ if(s.secdb && !s.sourceUrl){
127
+ let records;try{records=await require('../providers/wolfi/secdb').fetchRecords(s,opts);}catch(error){throw Error(`system advisory download failed: ${error.message}`);}
128
+ return importSystemAdvisories(records,{...opts,distribution,complete:true,source:s.secdb.map(r=>require('../providers/wolfi').REPOSITORIES[r]).join(' ')});
129
+ }
85
130
  const url=s.sourceUrl || `https://osv-vulnerabilities.storage.googleapis.com/${encodeURIComponent(s.base)}/all.zip`;
86
131
  const source=new URL(url);source.search='';source.hash='';
87
132
  const timeout=opts.systemAdvisoryTimeoutMs??120000;
@@ -98,10 +143,26 @@ async function syncSystemAdvisories(distribution,opts={}) {
98
143
  if(!bytes.length)throw Error('empty OSV snapshot');
99
144
  return importSystemAdvisories(bytes,{...opts,distribution,complete:true,source:source.toString()});
100
145
  }
146
+ // RPM modularity. An erratum built for a module stream (release ".module+el8…", summary
147
+ // "php:7.4 security update") states the fix of that stream only. It does not describe a
148
+ // non-modular package of the same name, nor a package installed from another stream.
149
+ function rpmModuleApplies(dep,version,record,affected) {
150
+ const modular=value=>/\.module[+_]/.test(String(value||''));
151
+ const bounds=(affected.ranges||[]).flatMap(r=>r.events||[]).flatMap(e=>[e.fixed,e.last_affected]).filter(v=>typeof v==='string');
152
+ if(!bounds.length)return true;
153
+ const advisoryModular=bounds.every(modular);
154
+ if(advisoryModular!==modular(dep.version) && bounds.every(v=>modular(v)===advisoryModular))return false;
155
+ if(!advisoryModular || !dep.modularityLabel)return true;
156
+ const stream=String(record.summary||'').match(/(?:^|[\s:])([A-Za-z0-9][A-Za-z0-9_+.-]*):([A-Za-z0-9][A-Za-z0-9_.+-]*)\s+(?:security|bug fix|enhancement)/);
157
+ if(!stream)return true;
158
+ const [name,installed]=dep.modularityLabel.split(':');
159
+ return name===stream[1] && installed===stream[2];
160
+ }
101
161
  function verdict(version,affected,compare) {
102
162
  if(!version || compare(version,version)!==0)return null;
103
163
  let unknown=false;
104
- if(!(affected.ranges||[]).length && Array.isArray(affected.versions))for(const v of affected.versions)if(compare(version,v)===0)return true;
164
+ // OSV: affected when listed in versions[] OR inside a range — the list counts even beside ranges.
165
+ if(Array.isArray(affected.versions))for(const v of affected.versions)if(compare(version,v)===0)return true;
105
166
  for(const range of affected.ranges||[]) {
106
167
  if(range.type!=='ECOSYSTEM' || !Array.isArray(range.events) || !range.events.length){unknown=true;continue;}
107
168
  let active=false,valid=true;
@@ -137,24 +198,35 @@ async function assessSystemInventory(inventory,opts={}) {
137
198
  if(!s)return {matches,coverage:[{source:'system-osv',status:'unknown',reason:'unsupported or missing distribution identity'}],warnings};
138
199
  const cache=opts.records?null:repo(opts),ns=namespace(s),snapshot=opts.records?{complete:opts.complete===true,fetchedAt:opts.fetchedAt}:cache.getSnapshot(ns);
139
200
  if(!snapshot)return {matches,coverage:[{source:'system-osv',status:'missing',ecosystem:s.ecosystem}],warnings:['No offline system advisory snapshot for '+s.ecosystem]};
140
- let uncertain=0; const uncertainItems=[];
201
+ let uncertain=0; const uncertainItems=[], assessedPackages=[];
141
202
  const unknown=(dep,reason,id)=>{uncertain++;uncertainItems.push({id,package:dep.name,version:dep.version,reason});};
142
203
  for(const dep of inventory.packages||[]) {
204
+ const before=uncertain;
143
205
  const names=[...new Set([dep.sourceName,dep.name].filter(Boolean))];
144
206
  if(!dep.sourceName)unknown(dep,'Source package identity is not declared in the installed metadata.');
145
- const records=opts.records ? opts.records.filter(r=>r.affected?.some(a=>a.package?.ecosystem===s.ecosystem && names.includes(a.package?.name))) : names.flatMap(name=>{const entry=cache.get(ns,name);return entry && entry.fetchedAt===snapshot.fetchedAt ? entry.value : [];});
207
+ const records=opts.records ? opts.records.filter(r=>r.affected?.some(a=>inScope(s,a.package?.ecosystem) && names.includes(a.package?.name))) : names.flatMap(name=>{const entry=cache.get(ns,name);return entry && entry.fetchedAt===snapshot.fetchedAt ? entry.value : [];});
146
208
  for(const record of records)for(const a of record.affected||[]) {
147
- if(a.package?.ecosystem!==s.ecosystem || !names.includes(a.package?.name))continue;
209
+ if(!inScope(s,a.package?.ecosystem) || !names.includes(a.package?.name))continue;
148
210
  const purl=a.package.purl||'', arch=(purl.match(/[?&]arch=([^&]+)/)||[])[1];
149
211
  const sourceArch=arch==='source' || (a.package.name===dep.sourceName && dep.sourceName!==dep.name);
150
212
  if(arch && arch!=='source' && dep.architecture && arch!==dep.architecture)continue;
151
213
  if(arch && arch!=='source' && !dep.architecture){unknown(dep,'Installed architecture is not declared.',record.id);continue;}
152
- const ver=sourceArch ? dep.sourceVersion : dep.version;
214
+ let ver=sourceArch ? dep.sourceVersion : dep.version;
215
+ // An RPM subpackage with its own version does not reveal its source epoch. The advisory
216
+ // names that source package: its bounds carry the epoch, when they agree on one.
217
+ if(dep.manager==='rpm' && sourceArch && dep.sourceEpochUnknown && ver){
218
+ const epochs=new Set((a.ranges||[]).flatMap(r=>r.events||[]).flatMap(e=>[e.introduced,e.fixed,e.last_affected]).filter(v=>typeof v==='string' && v!=='0').map(v=>(v.match(/^(\d+):/)||[,'0'])[1]));
219
+ ver=epochs.size===1 ? ([...epochs][0]==='0' ? ver : [...epochs][0]+':'+ver) : epochs.size ? null : ver;
220
+ }
221
+ if(dep.manager==='rpm' && !rpmModuleApplies(dep,ver,record,a))continue;
153
222
  const result=verdict(ver,a,s.compare);
154
223
  if(result===null){unknown(dep,'The available version range or installed source version does not establish applicability.',record.id);continue;}if(!result)continue;
155
- const severity=severityFromOsv(record), id=(record.aliases||[]).find(x=>/^CVE-/.test(x))||record.id;
224
+ // A per-CVE distribution record (DEBIAN-CVE-…, UBUNTU-CVE-…, ALPINE-CVE-…) is shown under its CVE id.
225
+ const severity=severityFromOsv(record), id=(record.aliases||[]).find(x=>/^CVE-/.test(x))||(/^[A-Z]+-(CVE-\d{4}-\d{4,})$/.exec(record.id)||[])[1]||record.id;
156
226
  const fixes=(a.ranges||[]).flatMap(r=>r.events||[]).map(e=>e.fixed).filter(v=>typeof v==='string' && s.compare(v,ver)>0).sort((x,y)=>s.compare(x,y));
157
227
  matches.push({dep,cve:{id,summary:record.summary||'',description:record.details||record.summary||'',severity:severity.severity,score:severity.score,
228
+ sourceAdvisoryId:record.id,distributionAdvisory:{source:s.base,release:s.ecosystem},
229
+ ...(typeof a.ecosystem_specific?.urgency==='string' ? {distributionUrgency:{source:s.base,release:s.ecosystem,value:a.ecosystem_specific.urgency}} : {}),
158
230
  published:record.published||null,modified:record.modified||null,
159
231
  aliases:Array.isArray(record.aliases)?record.aliases.filter(id=>typeof id==='string'):[],
160
232
  upstream:Array.isArray(record.upstream)?record.upstream.filter(id=>typeof id==='string'):[],
@@ -162,9 +234,10 @@ async function assessSystemInventory(inventory,opts={}) {
162
234
  advisorySource:typeof a.database_specific?.source==='string'?a.database_specific.source:typeof record.database_specific?.source==='string'?record.database_specific.source:null,
163
235
  osvRefs:Array.isArray(record.references)?record.references:[],fixVersion:fixes[0]||null},source:'osv',advisoryId:record.id});
164
236
  }
237
+ if(snapshot.complete && before===uncertain)assessedPackages.push(dep);
165
238
  }
166
239
  coverage.push({source:'system-osv',ecosystem:s.ecosystem,status:snapshot.complete && !uncertain?'complete':'incomplete',result:snapshot.complete && !uncertain?(matches.length?'affected':'no-match'):'indeterminate',complete:!!snapshot.complete,...(snapshot.complete?{affectsCompleteness:false}:{}),affectsAssessment:uncertain>0,fetchedAt:snapshot.fetchedAt||null,unknown:uncertain});
167
- if(uncertain)warnings.push({...require('../diagnostics').advisoryEvidenceDiagnostic(uncertainItems),source:'system-osv'});
168
- return {matches,coverage,warnings};
240
+ if(uncertain)warnings.push({...require('../scan/diagnostics').advisoryEvidenceDiagnostic(uncertainItems),source:'system-osv'});
241
+ return {matches,coverage,warnings,assessedPackages};
169
242
  }
170
243
  module.exports={scope,defaultAdapters,recordsFrom,verdict,importSystemAdvisories,syncSystemAdvisories,assessSystemInventory};
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
  const fs = require('node:fs');
3
3
  const path = require('node:path');
4
- const {openSqlite} = require('../sqlite-driver');
4
+ const {openSqlite} = require('../cache/sqlite-driver');
5
5
 
6
6
  function safeFile(root, name) {
7
7
  const base = fs.realpathSync(root), candidate = path.join(base, name.replace(/^\/+/, ''));
8
- try { const real = fs.realpathSync(candidate); return real === base || real.startsWith(base + path.sep) ? real : null; }
8
+ try { const real = fs.realpathSync(candidate); return real === base || real.startsWith(base.endsWith(path.sep) ? base : base + path.sep) ? real : null; }
9
9
  catch { return null; }
10
10
  }
11
11
  function read(root, name, opts={}) { const limit=opts.maxSystemMetadataBytes ?? 64*1024*1024; if(!Number.isSafeInteger(limit)||limit<1)throw Error('invalid system metadata size limit');const file=safeFile(root,name);if(!file)return null;const st=fs.statSync(file);if(!st.isFile()||st.size>limit)throw Error(`system metadata is not a bounded regular file: ${name}`);return fs.readFileSync(file,'utf8'); }
@@ -30,19 +30,34 @@ function fields(text) {
30
30
  }
31
31
  function base(name,version,architecture,manager,manifestPath,extra={}) {return {name,version,architecture:architecture || null,manager,manifestPath,ecosystem:'system',provenance:'installed',...extra};}
32
32
  const dpkg={id:'dpkg', async collect(root,opts={}) {
33
- const p='/var/lib/dpkg/status', text=read(root,p,opts); if(text===null)return null;
34
- const packages=[], warnings=[];
35
- for(const stanza of text.split(/\r?\n\r?\n/)) {
33
+ const p='/var/lib/dpkg/status', text=read(root,p,opts), sources=text===null?[]:[[p,text,false]], packages=[], warnings=[];
34
+ // Distroless images keep one control file per package in status.d/, usually without Status.
35
+ const dir=safeFile(root,'/var/lib/dpkg/status.d'), hasDir=!!dir && fs.statSync(dir).isDirectory();
36
+ if(hasDir)for(const entry of fs.readdirSync(dir,{withFileTypes:true}).sort((a,b)=>a.name<b.name?-1:a.name>b.name?1:0)) {
37
+ if(entry.name.startsWith('.') || entry.name.endsWith('.md5sums') || !(entry.isFile() || entry.isSymbolicLink()))continue;
38
+ const name=`/var/lib/dpkg/status.d/${entry.name}`;
39
+ try{const body=read(root,name,opts);if(body!==null)sources.push([name,body,true]);}catch(e){warnings.push('dpkg status.d: '+e.message);}
40
+ }
41
+ if(text===null && !hasDir)return null;
42
+ const seen=new Set();
43
+ for(const [p,text,statusOptional] of sources)for(const stanza of text.split(/\r?\n\r?\n/)) {
36
44
  if(!stanza.trim())continue;const f=fields(stanza);
45
+ if(statusOptional && f.Status===undefined)f.Status='install ok installed';
37
46
  if(!f.Package || !/^(unknown|install|hold|deinstall|purge) (ok|reinstreq) (not-installed|config-files|half-installed|unpacked|half-configured|triggers-awaited|triggers-pending|installed)$/.test(f.Status || '') || (!f.Version && /\binstalled$/.test(f.Status))){warnings.push('Malformed dpkg status record');continue;}
38
47
  if(!/^\S+\s+\S+\s+installed$/.test(f.Status))continue;
48
+ const key=f.Package+':'+(f.Architecture||'');if(seen.has(key))continue;seen.add(key);
39
49
  const s=(f.Source || '').match(/^([^\s(]+)(?:\s*\(([^)]+)\))?$/);
40
50
  if(f.Source && !s)warnings.push('Malformed dpkg source identity');
41
51
  const binaryRebuild=/\+b\d+$/.test(f.Version);
42
52
  const infoName=/^[a-z0-9][a-z0-9+.-]*$/.test(f.Package) ? f.Package : null;
43
53
  let list=null;try{if(infoName)list=read(root,`/var/lib/dpkg/info/${infoName}:${f.Architecture}.list`,opts) ?? read(root,`/var/lib/dpkg/info/${infoName}.list`,opts);}catch(e){warnings.push('dpkg file ownership: '+e.message);}
44
54
  const ownedPaths=list ? list.split(/\r?\n/).filter(line=>line.startsWith('/') && !line.split('/').includes('..')) : [];
45
- packages.push(base(f.Package,f.Version,f.Architecture,'dpkg',p,{sourceName:f.Source ? s?.[1] || null : f.Package,sourceVersion:f.Source && !s ? null : s?.[2] || (binaryRebuild ? null : f.Version),ownedPaths,packageMetadata:{origin:f.Origin||null,maintainer:f.Maintainer||null,homepage:f.Homepage||null}}));
55
+ // A signed kernel image declares the signing source (linux-signed-amd64 6.1.69+1), but
56
+ // Debian and Ubuntu track kernel advisories under the kernel source it was built from,
57
+ // whose version is the binary package's own (linux 6.1.69-1). The versionless metapackage
58
+ // (linux-image-amd64) ships no kernel and keeps its declared source.
59
+ const signedKernel=/^linux-image-\d/.test(f.Package) && s && /^linux-signed(?:-|$)/.test(s[1]) ? s[1].replace(/^linux-signed(?:-(?:amd64|arm64|i386))?/,'linux') : null;
60
+ packages.push(base(f.Package,f.Version,f.Architecture,'dpkg',p,{sourceName:signedKernel || (f.Source ? s?.[1] || null : f.Package),sourceVersion:signedKernel ? f.Version : f.Source && !s ? null : s?.[2] || (binaryRebuild ? null : f.Version),ownedPaths,packageMetadata:{origin:f.Origin||null,maintainer:f.Maintainer||null,homepage:f.Homepage||null}}));
46
61
  }
47
62
  return {packages,coverage:{collector:'dpkg',status:warnings.length?'incomplete':'complete',count:packages.length},warnings};
48
63
  }};
@@ -53,7 +68,7 @@ const apk={id:'apk', async collect(root,opts={}) {
53
68
  if(!stanza.trim())continue;const f=fields(stanza); if(!f.P || !f.V){warnings.push('Malformed APK installed record');continue;}
54
69
  let dir='';const ownedPaths=[];
55
70
  for(const line of stanza.split(/\r?\n/)){if(line.startsWith('F:'))dir=line.slice(2);else if(line.startsWith('R:')){const name=line.slice(2),fp='/'+[dir,name].filter(Boolean).join('/');if(!fp.split('/').includes('..'))ownedPaths.push(fp);}}
56
- packages.push(base(f.P,f.V,f.A,'apk',p,{sourceName:f.o || f.P,sourceVersion:f.V,ownedPaths,packageMetadata:{maintainer:f.m||null,homepage:f.U||null}}));
71
+ packages.push(base(f.P,f.V,f.A,'apk',p,{sourceName:f.o || f.P,sourceVersion:f.V,ownedPaths,packageMetadata:{...(f.T==='virtual meta package' && !ownedPaths.length ? {virtual:true} : {}),maintainer:f.m||null,homepage:f.U||null}}));
57
72
  }
58
73
  return {packages,coverage:{collector:'apk',status:warnings.length?'incomplete':'complete',count:packages.length},warnings};
59
74
  }};
@@ -68,7 +83,7 @@ function rpmHeader(input) {
68
83
  const tags={};
69
84
  for(let i=0;i<n;i++) {
70
85
  const pos=start+8+i*16, tag=b.readUInt32BE(pos), type=b.readUInt32BE(pos+4), off=b.readUInt32BE(pos+8), count=b.readUInt32BE(pos+12);
71
- if(![1000,1001,1002,1003,1022,1044,1116,1117,1118].includes(tag))continue;
86
+ if(![1000,1001,1002,1003,1022,1044,1116,1117,1118,5096].includes(tag))continue;
72
87
  if(off>=size)throw Error('invalid RPM tag offset');
73
88
  if(count>1000000)throw Error('RPM tag count limit exceeded');
74
89
  if(type===6 || type===8 || type===9) {
@@ -93,10 +108,18 @@ function rpmHeader(input) {
93
108
  ownedPaths.push(path.posix.join(dir,name));
94
109
  }
95
110
  }
96
- return {name:tags[1000],version,architecture:tags[1022] || null,sourceName:source?.[1] || null,sourceVersion:source && !tags[1003] ? source[2]+'-'+source[3] : null,ownedPaths,...(ownershipIncomplete?{ownershipIncomplete:true}:{})};
111
+ // SOURCERPM carries no epoch. A package built at its source's own version-release shares the
112
+ // source epoch; a subpackage with its own version (perl-Errno from perl) leaves it unknown,
113
+ // and the advisory that names the source package then supplies it.
114
+ const sourceVr=source ? source[2]+'-'+source[3] : null, ownVr=tags[1001]+'-'+tags[1002];
115
+ const sourceVersion=!source ? null : sourceVr===ownVr ? (tags[1003] ? tags[1003]+':' : '')+sourceVr : sourceVr;
116
+ const sourceEpochUnknown=!!source && sourceVr!==ownVr;
117
+ // MODULARITYLABEL (name:stream:version:context) identifies the module stream of the build.
118
+ const modularityLabel=typeof tags[5096]==='string' && tags[5096] ? tags[5096] : null;
119
+ return {name:tags[1000],version,architecture:tags[1022] || null,sourceName:source?.[1] || null,sourceVersion,...(sourceEpochUnknown?{sourceEpochUnknown}:{}),...(modularityLabel?{modularityLabel}:{}),ownedPaths,...(ownershipIncomplete?{ownershipIncomplete:true}:{})};
97
120
  }
98
121
  const rpm={id:'rpm',async collect(root,opts={}) {
99
- const result=await require('./rpm-storage').readRpmStorage(root,{safeFile,openSqlite,rpmHeader,rpmStorageAdapters:opts.rpmStorageAdapters,limits:opts.rpmStorageLimits});
122
+ const result=await require('./rpm-storage').readRpmStorage(root,{safeFile,openSqlite:opts.openRpmSqlite || openSqlite,rpmHeader,rpmStorageAdapters:opts.rpmStorageAdapters,limits:opts.rpmStorageLimits});
100
123
  if(!result)return null;
101
124
  return {...result,packages:result.packages.map(h=>base(h.name,h.version,h.architecture,'rpm',h.manifestPath,h))};
102
125
  }};
@@ -1,16 +1,19 @@
1
1
  'use strict';
2
- const {createCacheRepository}=require('../cache-repository');
2
+ const {createCacheRepository}=require('../cache/repository');
3
3
  // Each adapter owns its scope, comparisons and evidence. Failed consultations
4
4
  // never prevent the independent adapters or OSV from returning their results.
5
5
  const adapters=[
6
- {id:'nginx-vendor-advisories',supports:(d,inventory)=>inventory?.packages?.some(require('./nginx-advisories').isNginxPackage),identifyPackageOrigin:(pkg,options)=>require('./nginx-advisories').nginxPackageOrigin(pkg,options),async assess(inventory,options){return require('./nginx-advisories').assessNginxAdvisories(inventory.packages,options);}},
6
+ {id:'nginx-vendor-advisories',supports:(d,inventory)=>inventory?.packages?.some(require('../providers/nginx/advisories').isNginxPackage),identifyPackageOrigin:(pkg,options)=>require('../providers/nginx/advisories').nginxPackageOrigin(pkg,options),async assess(inventory,options){return require('../providers/nginx/advisories').assessNginxAdvisories(inventory.packages,options);}},
7
7
  {id:'debian-security-tracker-history',supports:d=>d?.id==='debian',async assess(inventory,options){
8
- const source=require('./historical-debian');
8
+ const source=require('../providers/debian/historical');
9
9
  try{source.checkDistribution(inventory.distribution);}catch{return {matches:[],observations:[],warnings:[],coverage:[{source:this.id,execution:'not-applicable',result:'indeterminate',reason:'Exact Debian release codename is unavailable.'}]};}
10
10
  const repository=options.repository||createCacheRepository(options.cacheDir);
11
11
  const packages=[...new Set(inventory.packages.map(p=>p.sourceName).filter(Boolean))].sort();
12
12
  if(!packages.length)return {matches:[],observations:[],warnings:[],coverage:[{source:this.id,execution:'not-applicable',result:'indeterminate',reason:'Source package identities are unavailable.'}]};
13
13
  const d=inventory.distribution,ns=`system-debian-history:${String(d.versionId).split('.')[0]}:${d.codename}`,snapshot=repository.getSnapshot(ns);
14
+ const lifecycle=repository.get('catalogue',`freexian-lifecycle-${String(d.versionId).split('.')[0]}-${d.codename}`)?.value;
15
+ if(!snapshot && options.offline && Date.parse(lifecycle?.cutoff+'T23:59:59Z')>Date.now())
16
+ return {matches:[],observations:[],warnings:[],coverage:[{source:this.id,execution:'not-applicable',result:'not-applicable',reason:'Release has not reached its historical cutoff.'}]};
14
17
  let failure=null;
15
18
  if(!options.offline && (!snapshot || snapshot.metadata?.parserVersion!==source.PARSER_VERSION || options.refresh || (!snapshot.complete && packages.some(p=>!snapshot.metadata?.queriedPackages?.includes(p))))){
16
19
  try{const result=await source.syncHistoricalDebian(d,{...options,repository,packages});if(result.notApplicable)return {matches:[],observations:[],warnings:[],coverage:[{source:this.id,execution:'not-applicable',result:'not-applicable',reason:result.reason}]};}
@@ -20,11 +23,13 @@ const adapters=[
20
23
  if(failure){result.warnings=[...(result.warnings||[]),failure];result.coverage=result.coverage.map(c=>({...c,execution:'partial',reason:failure.message}));}
21
24
  return result;
22
25
  }},
23
- {id:'freexian-ela',operatorRegion:'eu',supports:d=>d?.id==='debian',async assess(inventory,options){return require('./freexian-ela').assessFreexianEla(inventory,options);}},
24
- {id:'freexian-tracker',operatorRegion:'eu',supports:d=>d?.id==='debian',async assess(inventory,options){return require('./freexian-tracker').assessFreexianTracker(inventory,options);},async refine(result,inventory,options){return refineFreexianEvidence(result,inventory,options);}},
25
- {id:'debian-security-tracker-current-candidates',supports:d=>d?.id==='debian',async assess(inventory,options){return require('./current-debian').assessCurrentDebianCandidates(inventory,options);}},
26
+ {id:'freexian-ela',operatorRegion:'eu',supports:d=>d?.id==='debian',async assess(inventory,options){return require('../providers/freexian/ela').assessFreexianEla(inventory,options);}},
27
+ {id:'freexian-tracker',operatorRegion:'eu',supports:d=>d?.id==='debian',async assess(inventory,options){return require('../providers/freexian/tracker').assessFreexianTracker(inventory,options);},async refine(result,inventory,options){return refineFreexianEvidence(result,inventory,options);}},
28
+ {id:'debian-security-tracker-current-candidates',supports:d=>d?.id==='debian',async assess(inventory,options){return require('../providers/debian/current').assessCurrentDebianCandidates(inventory,options);}},
29
+ {id:'redhat-errata',operatorRegion:'us',supports:d=>!!require('../providers/redhat/unfixed').family(d)?.ownErrata,async assess(inventory,options){return require('../providers/redhat/errata').assessRedHatErrata(inventory,options);}},
30
+ {id:'redhat-oval',operatorRegion:'us',supports:d=>!!require('../providers/redhat/unfixed').family(d),async assess(inventory,options){return require('../providers/redhat/unfixed').assessRedHatUnfixed(inventory,options);}},
26
31
  {id:'alpine-tracker',supports:d=>d?.id==='alpine',async assess(inventory,options){
27
- const result=await require('./alpine-tracker').assessAlpineTracker(inventory.packages,inventory.distribution,options);
32
+ const result=await require('../providers/alpine/tracker').assessAlpineTracker(inventory.packages,inventory.distribution,options);
28
33
  return {matches:[],observations:result.observations,coverage:[result.coverage],warnings:result.diagnostics.map(d=>({type:'source-unavailable',source:this.id,code:d.code,...(d.code==='record-not-listed'?{affectsCompleteness:false}:{}),items:(d.resources||[]).map(id=>({id})),message:d.reason}))};
29
34
  }},
30
35
  ];
@@ -37,12 +42,14 @@ async function assessDistributionSources(inventory,options={}){
37
42
  if(!adapter.supports(inventory.distribution,inventory))continue;
38
43
  if(['eu','us'].includes(options.distributionSourceRegion) && adapter.operatorRegion!==options.distributionSourceRegion){result.coverage.push({source:adapter.id,execution:'not-applicable',result:'not-consulted',expected:false,reason:'Source operator is outside the selected region or its region is not established.'});continue;}
39
44
  active.push(adapter);
40
- try{const answer=await adapter.assess(inventory,{...options,confirmedMatches:[...(options.confirmedMatches||[]),...result.matches]});for(const key of Object.keys(result))result[key].push(...(answer[key]||[]));}
45
+ // Appended one by one: a spread call passes each element as an argument, and a host with
46
+ // thousands of packages yields enough assessments to overflow the stack.
47
+ try{const answer=await adapter.assess(inventory,{...options,confirmedMatches:[...(options.confirmedMatches||[]),...result.matches]});for(const key of Object.keys(result))for(const item of answer[key]||[])result[key].push(item);}
41
48
  catch(error){result.warnings.push({type:'source-unavailable',source:adapter.id,message:`${adapter.id}: ${error.message}`});result.coverage.push({source:adapter.id,execution:'failed',result:'indeterminate',reason:error.message});}
42
49
  }
43
50
  for(const adapter of active)if(typeof adapter.refine==='function')try{
44
51
  const refined=await adapter.refine(result,inventory,options);if(refined?.assessments)result.assessments=refined.assessments;
45
- for(const key of ['observations','coverage','warnings'])if(Array.isArray(refined?.[key]))result[key].push(...refined[key]);
52
+ for(const key of ['observations','coverage','warnings'])if(Array.isArray(refined?.[key]))for(const item of refined[key])result[key].push(item);
46
53
  }catch(error){if(options.signal?.aborted || error?.name==='AbortError')throw error;result.warnings.push({type:'source-unavailable',source:adapter.id,message:`${adapter.id} evidence refinement: ${error.message}`});result.coverage.push({source:`${adapter.id}-refinement`,execution:'failed',result:'indeterminate',reason:error.message});}
47
54
  return reconcileAssessments(result,inventory,options.confirmedMatches||[]);
48
55
  }
@@ -64,24 +71,34 @@ async function refineFreexianEvidence(result,inventory,options={}){
64
71
  const ids=[...new Set(selected.map(a=>a.cveId))],allowed=new Set(ids.slice(0,limit)),groups=new Map();
65
72
  for(const a of selected){if(!allowed.has(a.cveId))continue;const key=JSON.stringify([a.cveId,a.dep.sourceName,a.dep.sourceVersion]);const group=groups.get(key)||[];group.push(a);groups.set(key,group);}
66
73
  const byId=new Map();for(const group of groups.values()){const id=group[0].cveId,items=byId.get(id)||[];items.push(group);byId.set(id,items);}
67
- const limiter=options.freexianReleaseThrottle||require('../proxy-throttle').createProxyThrottle({intervalMs:interval,maxWaitMs:45000,maxRateRetries:15});
74
+ const limiter=options.freexianReleaseThrottle||require('../providers/proxy-throttle').createProxyThrottle({intervalMs:interval,maxWaitMs:45000,maxRateRetries:15});
68
75
  const resolverOptions={...options,freexianReleaseThrottle:limiter};
69
- const resolve=options.resolveReleaseEvidence||require('./freexian-release-evidence').resolveReleaseEvidence,work=require('p-limit')(concurrency);let failures=0,outages=0,checked=0,resolved=0;const reasons=new Set();
76
+ const resolve=options.resolveReleaseEvidence||require('../providers/freexian/release-evidence').resolveReleaseEvidence,work=require('p-limit')(concurrency);let failures=0,outages=0,checked=0,resolved=0,cacheOnly=false,cacheOnlyCves=0;const reasons=new Set();
70
77
  await Promise.all([...byId.values()].map(groupList=>work(async()=>{
78
+ const afterRateLimit=cacheOnly;
79
+ if(afterRateLimit)cacheOnlyCves++;
71
80
  let first=true,failed=false,outage=false;
72
81
  for(const group of groupList){const a=group[0];try{
73
82
  // One fetch per CVE; subsequent source-package evaluations use the same
74
83
  // locally cached page, including when the caller requested a refresh.
75
- const proof=await resolve({id:a.cveId,sourceName:a.dep.sourceName,sourceVersion:a.dep.sourceVersion,distribution:d},first?resolverOptions:{...resolverOptions,offline:true});checked++;first=false;
84
+ const proof=await resolve({id:a.cveId,sourceName:a.dep.sourceName,sourceVersion:a.dep.sourceVersion,distribution:d},first && !afterRateLimit ? resolverOptions : {...resolverOptions,offline:true});checked++;first=false;
76
85
  if(!proof || !['not-affected','fixed','unknown'].includes(proof.status))throw Error('invalid release evidence result');
86
+ if(!options.offline && !cacheOnly && /rate limit|HTTP 429/i.test(proof.evidence?.failure || '')){
87
+ cacheOnly=true;
88
+ options.onSourceWarning?.(options.lang==='fr'
89
+ ? 'Freexian limite les requêtes. Les vérifications Freexian restantes utilisent le cache. L’analyse des autres sources continue.'
90
+ : 'Freexian rate limit reached. Remaining Freexian checks use the cache. Analysis continues with the other sources.');
91
+ }
77
92
  if(proof.evidence?.failure){failed=true;if(!options.offline){outage=true;reasons.add(String(proof.evidence.failure).slice(0,300));}}
78
93
  const p=proof.evidence||{},pd=p.distribution,exact=p.id===a.cveId && p.sourceName===a.dep.sourceName && p.sourceVersion===a.dep.sourceVersion && pd?.id===d.id && pd.versionId===d.versionId && pd.codename===d.codename;
79
94
  for(const row of group){if(proof.status!=='unknown'&&exact){row.status=proof.status;resolved++;}row.evidence={...row.evidence,releaseEvidence:proof.evidence||null};}
80
95
  }catch(error){if(options.signal?.aborted || error?.name==='AbortError')throw error;failed=true;first=false;if(!options.offline){outage=true;reasons.add(String(error?.message||'consultation failed').slice(0,300));}}}
81
96
  if(failed)failures++;if(outage)outages++;
82
97
  })));
83
- const limited=ids.length>limit,coverage=[{source,execution:failures||limited?'partial':'completed',result:'consulted',candidateCves:ids.length,queriedCves:allowed.size,checked,resolved,failed:failures,...(limited?{reason:'Optional release evidence CVE limit reached.'}:{})}];
84
- const warnings=outages?[{type:'source-unavailable',source,message:`${outages} Freexian release evidence consultation(s) failed: ${[...reasons].slice(0,3).join('; ')}.`}]:[];
98
+ const limited=ids.length>limit,coverage=[{source,execution:failures||limited?'partial':'completed',result:'consulted',candidateCves:ids.length,queriedCves:allowed.size-cacheOnlyCves,checked,resolved,failed:failures,...(cacheOnly?{rateLimitFallback:"cache-only",cacheOnlyCves}:{}),affectsCompleteness:false,affectsAssessment:true,...(limited?{reason:`Additional release evidence considered for ${allowed.size} of ${ids.length} candidate CVEs.`}:{})}];
99
+ const fallback=cacheOnly ? (options.lang==='fr' ? ` Après limitation du débit, ${cacheOnlyCves} CVE vérifiées uniquement dans le cache Freexian.` : ` After rate limiting, ${cacheOnlyCves} CVEs checked only in the Freexian cache.`) : '';
100
+ const warnings=outages?[{type:'source-unavailable',source,message:options.lang==='fr' ?
101
+ `Vérification Freexian partielle pour ${d.id} ${d.versionId} : échec de consultation pour ${outages} CVE. ${[...reasons].slice(0,3).join('; ')}.${fallback}` :`${outages} Freexian release evidence consultation(s) failed: ${[...reasons].slice(0,3).join('; ')}.${fallback}`}]:[];
85
102
  return {assessments:result.assessments,coverage,warnings};
86
103
  }
87
104
  function reconcileAssessments(result,inventory,existingMatches=[]){
@@ -112,7 +129,7 @@ function reconcileAssessments(result,inventory,existingMatches=[]){
112
129
  result.observations=result.observations.filter(item=>{
113
130
  if(!['unknown','possible'].includes(item.status) || item.evidence?.conflictingFinding)return true;
114
131
  const matches=confirmed.get(assessmentKey(item.dep,item.cveId||item.id,d));if(!matches?.length)return true;
115
- for(const match of matches){const evidence={source:item.source,status:item.status,reason:item.reason||null,details:item.evidence||{}};match.cve.applicabilityEvidence=require('../applicability-evidence').applicabilityEvidence(match.cve,{applicabilityEvidence:[{kind:'source-observation',evidence}]});}
132
+ for(const match of matches){const evidence={source:item.source,status:item.status,reason:item.reason||null,details:item.evidence||{}};match.cve.applicabilityEvidence=require('../findings/applicability-evidence').applicabilityEvidence(match.cve,{applicabilityEvidence:[{kind:'source-observation',evidence}]});}
116
133
  return false;
117
134
  });
118
135
  result.matches=result.matches.map(match=>{
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ const headerPackages = {
4
+ deb:/^linux-(?:libc-dev|headers(?:-|$))/,
5
+ apk:/^linux-headers$/,
6
+ rpm:/^kernel-(?:headers|devel)(?:-|$)/,
7
+ };
8
+ const distributions = new Map([
9
+ ['ubuntu','ubuntu'],['debian','debian'],['alpine linux','alpine'],
10
+ ['red hat enterprise linux','rhel'],['suse linux enterprise','sles'],
11
+ ]);
12
+
13
+ function sourceOnlyReason(match, record) {
14
+ const dep=match.dep,manager=dep?.packageType || ({dpkg:'deb',apk:'apk',rpm:'rpm'})[dep?.manager];
15
+ if(dep?.ecosystem!=='system')return null;
16
+ const affected=record?.cveMetadata?.state==='PUBLISHED' ? record.containers?.cna?.affected || [] : [];
17
+ // Distribution identity describes the package implementation and its patches.
18
+ // It is independent of the runtime prerequisites assumed by the CPE policy.
19
+ const declared=affected.map(a=>distributions.get(String(a.vendor||'').toLowerCase()));
20
+ const installed=dep.distribution?.id;
21
+ // The installed distribution's own advisory for this release is its statement about its own
22
+ // package: a CNA record that lists another vendor's builds (CVE-2026-3497 names Ubuntu's
23
+ // OpenSSH, Debian tracks the same GSSAPI patch) does not withdraw it.
24
+ const releaseProof=match.cve?.historicalEvidence?.scope==='release-specific' || match.cve?.vendorEvidence || match.cve?.distributionAdvisory;
25
+ if(installed && declared.length && declared.every(Boolean) && !declared.includes(installed) && !releaseProof)
26
+ return {code:'different-package-distribution',message:'The advisory identifies '+[...new Set(declared)].join(', ')+' packages; the installed package is from '+installed+'.'};
27
+ if(!headerPackages[manager]?.test(dep.name||''))return null;
28
+ const explicit=affected.some(a=>[a.packageName,a.product].includes(dep.name));
29
+ if(explicit)return null;
30
+ return {code:'kernel-headers-source-association',message:'The installed package supplies kernel development headers. A source-package kernel advisory alone does not identify vulnerable executable code in these headers.'};
31
+ }
32
+
33
+ function reconcileSystemFindings(matches,store) {
34
+ const accepted=[],observations=[],records=new Map();
35
+ for(const match of matches){
36
+ if(match.dep?.ecosystem!=='system'){accepted.push(match);continue;}
37
+ const ids=[...new Set([match.cve?.id,...(match.cve?.upstream||[]),...(match.cve?.aliases||[])].filter(id=>/^CVE-\d{4}-\d+$/.test(id||'')))];
38
+ let reason;
39
+ if(ids.length===1){
40
+ const id=ids[0];
41
+ if(!records.has(id))records.set(id,store.getRecord('cveproject',id)?.document);
42
+ reason=sourceOnlyReason(match,records.get(id));
43
+ }else reason=sourceOnlyReason(match,null);
44
+ if(!reason){accepted.push(match);continue;}
45
+ observations.push({dep:match.dep,cveId:match.cve.id,source:match.source,status:'source-package-only',reason:reason.message,
46
+ evidence:{code:reason.code,distribution:match.dep.distribution,sourceName:match.dep.sourceName,sourceVersion:match.dep.sourceVersion,
47
+ historicalEvidence:match.cve.historicalEvidence || null,sourceAdvisoryId:match.cve.sourceAdvisoryId || match.advisoryId || null}});
48
+ }
49
+ return {matches:accepted,observations};
50
+ }
51
+ module.exports={sourceOnlyReason,reconcileSystemFindings};
@@ -3,7 +3,7 @@
3
3
  // they never claim the whole distribution corpus was imported.
4
4
  const crypto=require('node:crypto');
5
5
  const {scope,assessSystemInventory}=require('./advisories');
6
- const {createCacheRepository}=require('../cache-repository');
6
+ const {createCacheRepository}=require('../cache/repository');
7
7
  const {getResource}=require('../providers');
8
8
  const idOk=id=>typeof id==='string' && /^[A-Za-z0-9][A-Za-z0-9._:+-]{0,255}$/.test(id);
9
9
  const key=q=>crypto.createHash('sha256').update(JSON.stringify(q)).digest('hex');
@@ -13,8 +13,10 @@ const observed=response=>{
13
13
  return {fetchedAt:Number.isFinite(stamp)&&stamp>0&&stamp<=Date.now()+300000?stamp:proxy?1:Date.now(),stale:response.headers?.get?.('x-fad-proxy')==='stale' || (proxy&&!Number.isFinite(stamp))};
14
14
  };
15
15
  async function assessTargetedSystemInventory(inventory,opts={}){
16
- const s=scope(inventory.distribution,opts),matches=[],warnings=[];
16
+ const s=scope(inventory.distribution,opts),matches=[],warnings=[],assessedPackages=[];
17
17
  if(!s)return {matches,coverage:[{source:'system-osv-targeted',status:'unknown',reason:'unsupported or missing distribution identity'}],warnings};
18
+ // A product published under several ecosystems cannot be asked one exact (ecosystem, package, version) question.
19
+ if(s.accepts||s.secdb)return {matches,assessedPackages,coverage:[{source:'system-osv-targeted',status:'unknown',reason:'targeted queries do not apply to this distribution: its advisories are taken in bulk'}],warnings};
18
20
  const repo=opts.repository || createCacheRepository(opts.cacheDir),ns='system-osv-query:'+s.ecosystem,items=[],unique=new Map();let unknown=0;
19
21
  for(const dep of inventory.packages||[]){
20
22
  const source=dep.manager==='dpkg'||dep.manager==='apk';
@@ -22,7 +24,7 @@ async function assessTargetedSystemInventory(inventory,opts={}){
22
24
  if(!name||!version||s.compare(version,version)!==0){unknown++;continue;}
23
25
  const query={ecosystem:s.ecosystem,name,version},k=key(query);items.push({dep,query,k});if(!unique.has(k))unique.set(k,query);
24
26
  }
25
- const pending=[...unique].filter(([k])=>{const entry=repo.get(ns,k);return !opts.offline && (!entry || entry.stale || Date.now()-entry.fetchedAt>=require('../cache-policy').DEFAULT_TTL_MS || opts.refresh);});
27
+ const pending=[...unique].filter(([k])=>{const entry=repo.get(ns,k);return !opts.offline && (!entry || entry.stale || Date.now()-entry.fetchedAt>=require('../cache/policy').DEFAULT_TTL_MS || opts.refresh);});
26
28
  let error=null;
27
29
  if(pending.length){
28
30
  try{
@@ -59,12 +61,13 @@ async function assessTargetedSystemInventory(inventory,opts={}){
59
61
  for(const item of items){
60
62
  const entry=repo.get(ns,item.k);
61
63
  if(!entry || !entry.value?.complete || JSON.stringify(entry.value.query)!==JSON.stringify(item.query)){unknown++;continue;}
62
- if(entry.stale || (!opts.offline && Date.now()-entry.fetchedAt>require('../cache-policy').DEFAULT_TTL_MS))warnings.push('System OSV targeted consultation is stale');
64
+ if(entry.stale || (!opts.offline && Date.now()-entry.fetchedAt>require('../cache/policy').DEFAULT_TTL_MS))warnings.push('System OSV targeted consultation is stale');
63
65
  const queryDep={...item.dep,version:item.query.version};
64
66
  const result=await assessSystemInventory({distribution:inventory.distribution,packages:[queryDep]},{...opts,records:entry.value.records,complete:true});
67
+ if(result.assessedPackages?.length && !entry.stale)assessedPackages.push(item.dep);
65
68
  matches.push(...result.matches.map(match=>({...match,dep:item.dep})));unknown+=result.coverage[0]?.unknown||0;
66
69
  }
67
70
  const incomplete=unknown>0 || !!error || warnings.length>0;
68
- return {matches,coverage:[{source:'system-osv-targeted',ecosystem:s.ecosystem,status:incomplete?'incomplete':'complete',result:incomplete?'indeterminate':matches.length?'affected':'no-match',scope:'consulted-package-versions',consulted:items.length,unknown}],warnings:[...new Set(warnings)]};
71
+ return {matches,assessedPackages,coverage:[{source:'system-osv-targeted',ecosystem:s.ecosystem,status:incomplete?'incomplete':'complete',result:incomplete?'indeterminate':matches.length?'affected':'no-match',scope:'consulted-package-versions',consulted:items.length,unknown}],warnings:[...new Set(warnings)]};
69
72
  }
70
73
  module.exports={assessTargetedSystemInventory};
package/lib/ui.js CHANGED
@@ -102,6 +102,17 @@ class Step {
102
102
  const live = this.live ? chalk.dim(" " + this.live) : chalk.dim(" …");
103
103
  process.stdout.write(`\r${fitLine(` ${this.prefix} ${sp} ${this.label}${live}`)}\x1b[K`);
104
104
  }
105
+ phase(label, detail = "") {
106
+ if (this.ended) return;
107
+ const changed = this.phaseLabel !== label;
108
+ this.phaseLabel = label;
109
+ this.live = detail ? `${label} · ${detail}` : label;
110
+ const now = Date.now();
111
+ if (!changed && !shouldBeat(this.live, this.lastBeat, now, this.lastBeatAt, isTTY ? 250 : HEARTBEAT_MS)) return;
112
+ this.lastBeat = this.live; this.lastBeatAt = now;
113
+ if (isTTY) this._render();
114
+ else console.log(` ${this.prefix} ${chalk.dim("…")} ${this.label} ${chalk.dim(this.live)}`);
115
+ }
105
116
  tick(processed, total) {
106
117
  this.live = total ? `(${processed} / ${total})` : String(processed || "");
107
118
  if (isTTY) return; // the spinner timer already rewrites the line in place