vigievuln 1.3.3 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (293) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +34 -19
  3. package/completions/vigievuln.bash +14 -3
  4. package/completions/vigievuln.zsh +11 -8
  5. package/lib/README.md +51 -0
  6. package/lib/{coverage-diagnostics.js → advisories/coverage-diagnostics.js} +1 -1
  7. package/lib/{cve-match.js → advisories/cve-match.js} +17 -12
  8. package/lib/{advisory-fixes.js → advisories/fixes.js} +1 -1
  9. package/lib/{advisory-freshness.js → advisories/freshness.js} +5 -1
  10. package/lib/{gap-adjudicate.js → advisories/gap-adjudicate.js} +3 -3
  11. package/lib/{native-package-match.js → advisories/native-package-match.js} +20 -11
  12. package/lib/{native-source-prepare.js → advisories/native-source-prepare.js} +15 -12
  13. package/lib/{native-advisories.js → advisories/native.js} +15 -13
  14. package/lib/{advisory-store-sqlite.js → advisories/store-sqlite.js} +5 -5
  15. package/lib/{advisory-store.js → advisories/store.js} +2 -2
  16. package/lib/{application-exports.js → applications/exports.js} +1 -1
  17. package/lib/{application-inventory.js → applications/inventory.js} +3 -1
  18. package/lib/applications/layout.js +199 -0
  19. package/lib/{application-providers → applications}/live-snapshot.js +10 -10
  20. package/lib/{application-plugins → applications/plugins}/drupal.js +2 -2
  21. package/lib/applications/plugins/ghost.js +36 -0
  22. package/lib/{application-plugins → applications/plugins}/index.js +1 -1
  23. package/lib/{application-plugins → applications/plugins}/prestashop.js +73 -15
  24. package/lib/applications/plugins/redmine.js +24 -0
  25. package/lib/{application-plugins → applications/plugins}/runner.js +89 -59
  26. package/lib/{application-plugins → applications/plugins}/spip.js +4 -4
  27. package/lib/{application-plugins → applications/plugins}/symfony.js +1 -1
  28. package/lib/{application-plugins → applications/plugins}/typo3.js +2 -2
  29. package/lib/{application-plugins → applications/plugins}/wave2-common.js +1 -1
  30. package/lib/{application-plugins → applications/plugins}/wordpress.js +52 -18
  31. package/lib/{application-providers → applications}/snapshot-cache.js +1 -1
  32. package/lib/{cms-snapshot-warm.js → applications/snapshot-warm.js} +21 -8
  33. package/lib/artifacts/access-warnings.js +24 -0
  34. package/lib/artifacts/applications.js +39 -8
  35. package/lib/artifacts/component-scope.js +11 -2
  36. package/lib/artifacts/cve-view.js +8 -5
  37. package/lib/artifacts/disk-wasm.mjs +3 -0
  38. package/lib/artifacts/disk.js +188 -0
  39. package/lib/artifacts/enrichment.js +31 -17
  40. package/lib/artifacts/go-main-identity.js +135 -36
  41. package/lib/artifacts/go-publisher-advisories.js +4 -3
  42. package/lib/artifacts/image-products.js +5 -4
  43. package/lib/artifacts/index.js +36 -13
  44. package/lib/artifacts/inventory-scope.js +53 -3
  45. package/lib/artifacts/product-advisories.js +51 -46
  46. package/lib/artifacts/product-catalog.js +6 -1
  47. package/lib/artifacts/release-catalogues.js +149 -0
  48. package/lib/artifacts/release-versions.js +101 -0
  49. package/lib/artifacts/remediation-report.js +1 -1
  50. package/lib/artifacts/report-inventory.js +15 -2
  51. package/lib/artifacts/report-path.js +29 -0
  52. package/lib/artifacts/report.js +66 -36
  53. package/lib/artifacts/retire.js +3 -3
  54. package/lib/artifacts/risk-report.js +12 -8
  55. package/lib/artifacts/sbom.js +33 -4
  56. package/lib/artifacts/scan.js +295 -67
  57. package/lib/artifacts/system-apps.js +98 -0
  58. package/lib/artifacts/system-maintenance.js +101 -0
  59. package/lib/artifacts/system-module-updates.js +104 -0
  60. package/lib/artifacts/system-report.js +232 -0
  61. package/lib/{airgap-project.js → cache/airgap-project.js} +25 -10
  62. package/lib/{cache-archive-sqlite.js → cache/archive.js} +6 -5
  63. package/lib/{cache-db.js → cache/db.js} +1 -1
  64. package/lib/{dump-format.js → cache/dump-format.js} +2 -2
  65. package/lib/{json-cache.js → cache/json.js} +1 -1
  66. package/lib/{proxy-cache.js → cache/proxy-cache.js} +9 -9
  67. package/lib/{proxy-scope.js → cache/proxy-scope.js} +1 -1
  68. package/lib/{record-freshness.js → cache/record-freshness.js} +1 -1
  69. package/lib/{cache-repository.js → cache/repository.js} +1 -1
  70. package/lib/{resource-cache → cache/resource}/engine.js +20 -14
  71. package/lib/{resource-cache → cache/resource}/fs-store.js +2 -2
  72. package/lib/{resource-cache → cache/resource}/sqlite-store.js +3 -3
  73. package/lib/{resource-cache → cache/resource}/validate.js +20 -6
  74. package/lib/{sqlite-driver.js → cache/sqlite-driver.js} +7 -5
  75. package/lib/certs/scan.js +17 -11
  76. package/lib/cli-collect.js +262 -0
  77. package/lib/cli-command-routing.js +30 -13
  78. package/lib/cli-groups.js +1 -1
  79. package/lib/cli-image.js +157 -46
  80. package/lib/cli-project-commands.js +10 -10
  81. package/lib/cli-setup.js +8 -8
  82. package/lib/cli-watch.js +3 -3
  83. package/lib/codecs/binary/scan.js +11 -3
  84. package/lib/codecs/binary.codec.js +1 -1
  85. package/lib/codecs/composer/platform.js +2 -2
  86. package/lib/codecs/composer/registry.js +12 -18
  87. package/lib/codecs/composer.codec.js +6 -5
  88. package/lib/codecs/go/parse.js +1 -1
  89. package/lib/codecs/go/registry.js +7 -7
  90. package/lib/codecs/go.codec.js +2 -2
  91. package/lib/codecs/gradle/parse.js +1 -1
  92. package/lib/codecs/gradle/versionless.js +2 -2
  93. package/lib/codecs/gradle.codec.js +7 -7
  94. package/lib/codecs/index.js +1 -1
  95. package/lib/{maven-airgap.js → codecs/maven/airgap.js} +4 -4
  96. package/lib/{maven-bom.js → codecs/maven/bom.js} +3 -3
  97. package/lib/codecs/maven/jar-scan.js +4 -4
  98. package/lib/{maven-license.js → codecs/maven/license.js} +2 -2
  99. package/lib/{core.js → codecs/maven/pom.js} +22 -11
  100. package/lib/{maven-reactor.js → codecs/maven/reactor.js} +18 -12
  101. package/lib/{transitive.js → codecs/maven/transitive.js} +79 -34
  102. package/lib/{maven-version.js → codecs/maven/version.js} +1 -1
  103. package/lib/codecs/maven.codec.js +18 -14
  104. package/lib/codecs/npm/collect.js +55 -8
  105. package/lib/codecs/npm/manifest-kind.js +16 -0
  106. package/lib/codecs/npm/parse.js +23 -7
  107. package/lib/codecs/npm/registry.js +28 -14
  108. package/lib/codecs/npm.codec.js +5 -5
  109. package/lib/codecs/nuget/registry.js +7 -7
  110. package/lib/codecs/nuget.codec.js +4 -4
  111. package/lib/codecs/pypi/registry.js +7 -7
  112. package/lib/codecs/pypi.codec.js +4 -4
  113. package/lib/codecs/recipes.js +2 -2
  114. package/lib/codecs/ruby/registry.js +7 -7
  115. package/lib/codecs/ruby.codec.js +2 -2
  116. package/lib/config.js +1 -1
  117. package/lib/{attribution.js → findings/attribution.js} +3 -3
  118. package/lib/findings/cve-descriptions.js +144 -0
  119. package/lib/{cve-record-coverage.js → findings/cve-record-coverage.js} +46 -41
  120. package/lib/{diff.js → findings/diff.js} +0 -0
  121. package/lib/{finding-enrichment.js → findings/enrichment.js} +45 -32
  122. package/lib/{eu-refs.js → findings/eu-refs.js} +3 -3
  123. package/lib/{gate.js → findings/gate.js} +1 -1
  124. package/lib/{malware.js → findings/malware.js} +30 -7
  125. package/lib/{merge-sources.js → findings/merge.js} +57 -9
  126. package/lib/{priority.js → findings/priority.js} +3 -3
  127. package/lib/findings/risk-evidence.js +24 -0
  128. package/lib/findings/severity.js +16 -0
  129. package/lib/{finding-summary.js → findings/summary.js} +5 -2
  130. package/lib/{suppress.js → findings/suppress.js} +2 -2
  131. package/lib/images/local-docker.js +72 -0
  132. package/lib/{image-network.js → images/network.js} +26 -16
  133. package/lib/{image-references.js → images/references.js} +29 -11
  134. package/lib/{image-registry.js → images/registry.js} +18 -9
  135. package/lib/{source-image-scan.js → images/source-scan.js} +3 -3
  136. package/lib/images/temp-roots.js +23 -0
  137. package/lib/{image-update.js → images/update.js} +3 -3
  138. package/lib/{dep-record.js → inventory/dep-record.js} +2 -2
  139. package/lib/{deps-descriptor.js → inventory/deps-descriptor.js} +3 -3
  140. package/lib/{descriptor-refs.js → inventory/descriptor-refs.js} +1 -1
  141. package/lib/{embedded.js → inventory/embedded.js} +4 -3
  142. package/lib/{license-policy.js → inventory/license-policy.js} +2 -2
  143. package/lib/{manifest-copy.js → inventory/manifest-copy.js} +2 -2
  144. package/lib/{module-names.js → inventory/module-names.js} +1 -1
  145. package/lib/{package-versions.js → inventory/package-versions.js} +2 -2
  146. package/lib/{parallel-walk.js → inventory/parallel-walk.js} +1 -1
  147. package/lib/{path-filter.js → inventory/path-filter.js} +1 -1
  148. package/lib/{private-deps.js → inventory/private-deps.js} +1 -1
  149. package/lib/{project-descriptor.js → inventory/project-descriptor.js} +3 -0
  150. package/lib/{purl.js → inventory/purl.js} +2 -2
  151. package/lib/{unmanaged.js → inventory/unmanaged.js} +6 -3
  152. package/lib/{commercial-support.js → maintenance/commercial-support.js} +5 -5
  153. package/lib/{outdated.js → maintenance/outdated.js} +20 -20
  154. package/lib/options-env.js +1 -1
  155. package/lib/{system-inventory/alpine-tracker.js → providers/alpine/tracker.js} +27 -7
  156. package/lib/{certfr.js → providers/certfr/enrich.js} +9 -9
  157. package/lib/{cve-download.js → providers/cveproject/download.js} +56 -36
  158. package/lib/{cve-legacy-ranges.js → providers/cveproject/legacy-ranges.js} +1 -1
  159. package/lib/{cve-npm-proxy.js → providers/cveproject/npm-proxy.js} +5 -5
  160. package/lib/{cve-packages-proxy.js → providers/cveproject/packages-proxy.js} +6 -6
  161. package/lib/{cve-version-verdict.js → providers/cveproject/version-verdict.js} +2 -2
  162. package/lib/{system-inventory/current-debian.js → providers/debian/current.js} +6 -6
  163. package/lib/{system-inventory/historical-debian.js → providers/debian/historical.js} +6 -6
  164. package/lib/providers/{debian.js → debian/index.js} +1 -0
  165. package/lib/{application-providers/drupal-advisories.js → providers/drupal/advisories.js} +13 -36
  166. package/lib/providers/{drupal.js → drupal/index.js} +4 -0
  167. package/lib/providers/{eol.js → eol/index.js} +1 -1
  168. package/lib/{epss.js → providers/epss/enrich.js} +16 -13
  169. package/lib/providers/{epss.js → epss/index.js} +2 -2
  170. package/lib/{euvd.js → providers/euvd/enrich.js} +13 -13
  171. package/lib/{system-inventory/freexian-ela.js → providers/freexian/ela.js} +6 -6
  172. package/lib/providers/{freexian.js → freexian/index.js} +3 -3
  173. package/lib/{system-inventory/freexian-release-evidence.js → providers/freexian/release-evidence.js} +8 -5
  174. package/lib/{system-inventory/freexian-tracker.js → providers/freexian/tracker.js} +33 -9
  175. package/lib/{gcve-feed.js → providers/gcve/feed.js} +4 -4
  176. package/lib/{gcve.js → providers/gcve/id.js} +1 -1
  177. package/lib/{gcve-index.js → providers/gcve/local-index.js} +4 -4
  178. package/lib/{application-providers/github-advisories.js → providers/github/advisories.js} +6 -2
  179. package/lib/providers/{github.js → github/index.js} +3 -1
  180. package/lib/{github-publisher-maven.js → providers/github/publisher-maven.js} +1 -1
  181. package/lib/providers/{go.js → go/index.js} +1 -1
  182. package/lib/{hash-id.js → providers/hashid/identify.js} +7 -7
  183. package/lib/providers/{hashid.js → hashid/index.js} +1 -1
  184. package/lib/providers/index.js +18 -13
  185. package/lib/{kev.js → providers/kev/enrich.js} +12 -9
  186. package/lib/{maven-cache.js → providers/maven/cache.js} +3 -3
  187. package/lib/providers/{maven.js → maven/index.js} +5 -3
  188. package/lib/{maven-presence.js → providers/maven/presence.js} +5 -5
  189. package/lib/{maven-repo.js → providers/maven/repo.js} +38 -21
  190. package/lib/providers/mit-kerberos/index.js +6 -0
  191. package/lib/{system-inventory/nginx-advisories.js → providers/nginx/advisories.js} +3 -3
  192. package/lib/providers/{npm.js → npm/index.js} +1 -1
  193. package/lib/providers/{nuget.js → nuget/index.js} +1 -1
  194. package/lib/{cpe.js → providers/nvd/cpe.js} +35 -47
  195. package/lib/{nvd.js → providers/nvd/enrich.js} +41 -40
  196. package/lib/providers/{nvd.js → nvd/index.js} +3 -3
  197. package/lib/{nvd-package-ranges.js → providers/nvd/package-ranges.js} +38 -22
  198. package/lib/{osv-db.js → providers/osv/db.js} +18 -16
  199. package/lib/providers/{osv.js → osv/index.js} +1 -1
  200. package/lib/{osv.js → providers/osv/query.js} +150 -80
  201. package/lib/providers/package-releases/index.js +26 -0
  202. package/lib/{packagist-audit.js → providers/packagist/audit.js} +31 -11
  203. package/lib/providers/{packagist.js → packagist/index.js} +1 -1
  204. package/lib/{proxy-throttle.js → providers/proxy-throttle.js} +17 -9
  205. package/lib/providers/{pypi.js → pypi/index.js} +1 -1
  206. package/lib/providers/redhat/bzip2.js +167 -0
  207. package/lib/providers/redhat/errata.js +75 -0
  208. package/lib/providers/redhat/index.js +10 -0
  209. package/lib/providers/redhat/oval.js +70 -0
  210. package/lib/providers/redhat/unfixed.js +127 -0
  211. package/lib/{registries.js → providers/registries.js} +4 -4
  212. package/lib/{retire.js → providers/retire/scan.js} +18 -18
  213. package/lib/providers/{ruby.js → ruby/index.js} +1 -1
  214. package/lib/providers/rubysec/advisories.js +177 -0
  215. package/lib/providers/rubysec/index.js +9 -0
  216. package/lib/{snyk.js → providers/snyk/client.js} +2 -2
  217. package/lib/{application-providers/spip-advisories.js → providers/spip/advisories.js} +5 -13
  218. package/lib/{vigievuln-advisories.js → providers/vigievuln/advisories.js} +4 -4
  219. package/lib/providers/wolfi/index.js +10 -0
  220. package/lib/providers/wolfi/secdb.js +47 -0
  221. package/lib/{application-providers/wordfence-client.js → providers/wordfence/client.js} +4 -4
  222. package/lib/providers/{wordfence.js → wordfence/index.js} +1 -1
  223. package/lib/{application-providers/wordfence-projection.js → providers/wordfence/projection.js} +14 -5
  224. package/lib/{resource-cache/wordfence.js → providers/wordfence/resource-cache.js} +2 -2
  225. package/lib/{application-providers/wordfence-v3.js → providers/wordfence/v3.js} +4 -5
  226. package/lib/providers/{wordpress.js → wordpress/index.js} +5 -0
  227. package/lib/providers/wpvulnerability/assess.js +181 -0
  228. package/lib/providers/wpvulnerability/index.js +12 -0
  229. package/lib/{charts.js → reports/charts.js} +25 -18
  230. package/lib/{csaf-export.js → reports/csaf-export.js} +16 -11
  231. package/lib/{cve-report.js → reports/cve-report.js} +453 -228
  232. package/lib/reports/detail.js +55 -0
  233. package/lib/{i18n.js → reports/i18n.js} +38 -2
  234. package/lib/{report-integrity.js → reports/integrity.js} +1 -1
  235. package/lib/{json-export.js → reports/json-export.js} +95 -24
  236. package/lib/{report-notices.js → reports/notices.js} +11 -6
  237. package/lib/{sarif-export.js → reports/sarif-export.js} +15 -10
  238. package/lib/{sbom-export.js → reports/sbom-export.js} +16 -11
  239. package/lib/{scan-completeness.js → scan/completeness.js} +1 -1
  240. package/lib/scan/coverage.js +114 -0
  241. package/lib/{provenance.js → scan/provenance.js} +12 -5
  242. package/lib/scan/reliability.js +157 -0
  243. package/lib/{source-health.js → scan/source-health.js} +52 -20
  244. package/lib/{source-profile.js → scan/source-profile.js} +3 -3
  245. package/lib/{hosted-proxy.js → service/hosted-proxy.js} +3 -3
  246. package/lib/{project-client.js → service/project-client.js} +20 -2
  247. package/lib/source-input.js +58 -0
  248. package/lib/system-inventory/advisories.js +89 -16
  249. package/lib/system-inventory/collect.js +33 -10
  250. package/lib/system-inventory/distribution-sources.js +32 -15
  251. package/lib/system-inventory/package-applicability.js +51 -0
  252. package/lib/system-inventory/targeted.js +8 -5
  253. package/lib/ui.js +11 -0
  254. package/package.json +49 -2
  255. package/vigievuln.js +483 -352
  256. package/lib/cache-archive.js +0 -676
  257. package/lib/osv-legacy.js +0 -57
  258. package/lib/risk-evidence.js +0 -18
  259. package/lib/scan-coverage.js +0 -61
  260. /package/lib/{application-plugins → applications/plugins}/joomla.js +0 -0
  261. /package/lib/{application-plugins → applications/plugins}/laravel.js +0 -0
  262. /package/lib/{application-plugins → applications/plugins}/magento.js +0 -0
  263. /package/lib/{application-plugins → applications/plugins}/plugin.interface.js +0 -0
  264. /package/lib/{application-plugins → applications/plugins}/select.js +0 -0
  265. /package/lib/{advisory-compression.js → cache/advisory-compression.js} +0 -0
  266. /package/lib/{compression-dictionary.js → cache/compression-dictionary.js} +0 -0
  267. /package/lib/{cache-directory.js → cache/directory.js} +0 -0
  268. /package/lib/{cache-policy.js → cache/policy.js} +0 -0
  269. /package/lib/{resource-cache → cache/resource}/snapshot-projection.js +0 -0
  270. /package/lib/{cache-startup.js → cache/startup.js} +0 -0
  271. /package/lib/{ruby-version.js → codecs/ruby/version.js} +0 -0
  272. /package/lib/{applicability-evidence.js → findings/applicability-evidence.js} +0 -0
  273. /package/lib/{line-stream.js → inventory/line-stream.js} +0 -0
  274. /package/lib/{package-metadata.js → inventory/package-metadata.js} +0 -0
  275. /package/lib/providers/{alpine.js → alpine/index.js} +0 -0
  276. /package/lib/providers/{certfr.js → certfr/index.js} +0 -0
  277. /package/lib/{native-cna-identities.js → providers/cveproject/cna-identities.js} +0 -0
  278. /package/lib/providers/{euvd.js → euvd/index.js} +0 -0
  279. /package/lib/providers/{gcve.js → gcve/index.js} +0 -0
  280. /package/lib/providers/{kev.js → kev/index.js} +0 -0
  281. /package/lib/providers/{nginx.js → nginx/index.js} +0 -0
  282. /package/lib/{nvd-bulk.js → providers/nvd/bulk.js} +0 -0
  283. /package/lib/providers/{osvdb.js → osvdb/index.js} +0 -0
  284. /package/lib/{request-failure.js → providers/request-failure.js} +0 -0
  285. /package/lib/providers/{retire.js → retire/index.js} +0 -0
  286. /package/lib/providers/{vigievuln.js → vigievuln/index.js} +0 -0
  287. /package/lib/{application-providers/wp-checksums.js → providers/wordpress/checksums.js} +0 -0
  288. /package/lib/{report-time.js → reports/time.js} +0 -0
  289. /package/lib/{xlsx-export.js → reports/xlsx-export.js} +0 -0
  290. /package/lib/{diagnostics.js → scan/diagnostics.js} +0 -0
  291. /package/lib/{account-client.js → service/account-client.js} +0 -0
  292. /package/lib/{account-session.js → service/account-session.js} +0 -0
  293. /package/lib/{account-terms.js → service/account-terms.js} +0 -0
@@ -1,8 +1,8 @@
1
1
  const fs = require("node:fs");
2
2
  const path = require("node:path");
3
3
  const yaml = require("js-yaml");
4
- const { fetchGithubAdvisories, writeSnapshotAtomically } = require("../application-providers/live-snapshot");
5
- const { assessGithubAdvisories, prestashopRangeGrammar } = require("../application-providers/github-advisories");
4
+ const { fetchGithubAdvisories, writeSnapshotAtomically } = require("../live-snapshot");
5
+ const { assessGithubAdvisories, prestashopRangeGrammar } = require("../../providers/github/advisories");
6
6
  const { join, within, readJson, composerOccurrences, composerComponent, composerCoverageDiagnostic, finishInventory, localSourceSnapshot } = require("./wave2-common");
7
7
 
8
8
  const GITHUB_REPO = "PrestaShop/PrestaShop";
@@ -25,7 +25,7 @@ function moduleAt(ctx, app, dir) {
25
25
  if (!ctx.index.hasFile(relative)) continue;
26
26
  let source;
27
27
  try { source = ctx.readPrefix(relative, 65536); } catch { continue; }
28
- if (!/\bextends\s+\\?[A-Za-z_\\]*Module\b/i.test(source)) continue;
28
+ if (!/\bextends\s+\\?[A-Za-z_\\]*Module(?:Graph(?:Engine)?|Grid(?:Engine)?)?\b/i.test(source)) continue;
29
29
  const declared = source.match(/\$this->name\s*=\s*['"]([^'"\r\n]+)['"]\s*;/)?.[1];
30
30
  if (!declared || declared.toLowerCase() !== candidate.slice(0, -4).toLowerCase()) continue;
31
31
  file = relative; name = declared;
@@ -61,13 +61,41 @@ function themeAt(ctx, app, dir) {
61
61
  ...(observedVersion ? [{ path: file, field: "version" }] : [])] };
62
62
  }
63
63
 
64
+ function adminThemeAt(ctx, app, dir) {
65
+ const admin = path.posix.dirname(path.posix.dirname(dir));
66
+ if (!ctx.index.hasFile(join(admin, "index.php")) || !ctx.index.directories.includes(join(dir, "template"))) return null;
67
+ for (const filename of ["package.json", "package-lock.json"]) {
68
+ const file = join(dir, filename);
69
+ if (!ctx.index.hasFile(file)) continue;
70
+ const data = readJson(ctx, file);
71
+ const metadata = data?.packages?.[""] || data;
72
+ if (metadata?.name !== path.posix.basename(dir)) continue;
73
+ const version = typeof metadata.version === "string" ? metadata.version : null;
74
+ return { id:`${app.id}:theme:${dir}`, applicationId:app.id, kind:"theme", path:dir,
75
+ name:metadata.name, version, versionStatus:version ? "observed" : "unknown",
76
+ visibility:ctx.isPrivatePath(dir) ? "private" : "unknown", activation:"unknown",
77
+ evidence:[{path:file,field:data?.packages?.[""] ? 'packages[""].name' : "name"},
78
+ ...(version ? [{path:file,field:data?.packages?.[""] ? 'packages[""].version' : "version"}] : [])] };
79
+ }
80
+ return null;
81
+ }
82
+
64
83
  function componentAt(ctx, app) { return moduleAt(ctx, app, ".") || themeAt(ctx, app, "."); }
65
84
 
85
+ function distributionVersion(dir, ctx) {
86
+ const file = join(dir, "src/Core/Version.php");
87
+ if (!ctx.index.hasFile(file)) return null;
88
+ let text;
89
+ try { text = ctx.readPrefix(file, 16384); } catch { return null; }
90
+ if (!/namespace\s+PrestaShop\\PrestaShop\\Core\s*;/.test(text)) return null;
91
+ return text.match(/\bpublic\s+const\s+VERSION\s*=\s*['"]([0-9]+(?:\.[0-9]+){1,3}(?:[-+][\w.-]+)?)['"]/)?.[1] || null;
92
+ }
93
+
66
94
  function isSite(dir, ctx) {
67
95
  if (!ctx.index.hasFile(join(dir, "config/config.inc.php"))) return false;
68
96
  const manifest = join(dir, "composer.json");
69
97
  if (ctx.index.hasFile(manifest) && readJson(ctx, manifest)?.name?.toLowerCase() === "prestashop/prestashop") return true;
70
- return ctx.index.hasFile(join(dir, "config/settings.inc.php")) && ctx.index.hasFile(join(dir, "classes/Tools.php"));
98
+ return ctx.index.hasFile(join(dir, "classes/Tools.php")) && (ctx.index.hasFile(join(dir, "config/settings.inc.php")) || !!distributionVersion(dir, ctx));
71
99
  }
72
100
 
73
101
  module.exports = {
@@ -81,10 +109,20 @@ module.exports = {
81
109
  return component ? [{ root: ".", layout: "component", componentKind: component.kind,
82
110
  evidence: component.evidence }] : [];
83
111
  }
84
- return ctx.index.directories.filter(dir => isSite(dir, ctx)).map(dir => ({ root: dir,
112
+ return ctx.index.directories.filter(dir => isSite(dir, ctx)).map(dir => {
113
+ const script = "tmp/docker_run.sh";
114
+ let template = false;
115
+ if (ctx.scanContext === "installation" && dir === "tmp/data-ps/prestashop" && ctx.index.hasFile(script)) {
116
+ try {
117
+ template = /^\s*cp\s+(?:-[A-Za-z]+\s+)*\/tmp\/data-ps\/prestashop\/?\s+\/var\/www\/html\/?\s*$/m.test(ctx.readText(script, 65536));
118
+ } catch { /* Keep the role unknown when the script cannot be read. */ }
119
+ }
120
+ return { root: dir,
121
+ ...(template ? {deploymentRole:"installation-template"} : {}),
85
122
  layout: ctx.index.hasFile(join(dir, "composer.json")) ? "composer" : "legacy",
86
123
  evidence: [{ path: join(dir, "config/config.inc.php") },
87
- { path: ctx.index.hasFile(join(dir, "composer.json")) ? join(dir, "composer.json") : join(dir, "classes/Tools.php") }] }));
124
+ { path: ctx.index.hasFile(join(dir, "composer.json")) ? join(dir, "composer.json") : join(dir, "classes/Tools.php") }, ...(template ? [{path:script,field:"installation copy source"}] : [])] };
125
+ });
88
126
  },
89
127
  collect(app, ctx) {
90
128
  if (app.layout === "component") return finishInventory(app, [componentAt(ctx, app)].filter(Boolean),
@@ -94,32 +132,52 @@ module.exports = {
94
132
  const sourceFile = join(app.root, "install-dev/install_version.php");
95
133
  const installed = literalVersion(ctx, installedFile, "_PS_VERSION_");
96
134
  const source = literalVersion(ctx, sourceFile, "_PS_INSTALL_VERSION_");
97
- const version = installed || source;
135
+ const release = distributionVersion(app.root, ctx);
136
+ const version = installed || release || source;
98
137
  if (installed && source && installed !== source) diagnostics.push({ code: "CMS_VERSION_CONFLICT",
99
138
  applicationId: app.id, path: installedFile,
100
139
  message: `installed PrestaShop version ${installed} differs from source installer version ${source}` });
101
140
  components.push({ id: `${app.id}:core`, applicationId: app.id, kind: "core", path: app.root,
102
141
  name: "PrestaShop", coord: "prestashop/prestashop", version, rawVersion: version,
103
- versionStatus: installed ? "observed" : source ? "source-observed" : "unknown",
142
+ versionStatus: installed || release ? "observed" : source ? "source-observed" : "unknown",
104
143
  visibility: "public", identityStatus: "verified", activation: "unknown",
105
- evidence: [{ path: installed ? installedFile : source ? sourceFile : join(app.root, "composer.json"),
106
- field: installed ? "_PS_VERSION_" : source ? "_PS_INSTALL_VERSION_" : "name" }] });
144
+ evidence: [{ path: installed ? installedFile : release ? join(app.root, "src/Core/Version.php") : source ? sourceFile : join(app.root, "composer.json"),
145
+ field: installed ? "_PS_VERSION_" : release ? "Version::VERSION" : source ? "_PS_INSTALL_VERSION_" : "name" }] });
107
146
  for (const dir of ctx.index.directories) {
108
147
  if (!within(dir, app.root) || dir === app.root) continue;
109
148
  const relative = app.root === "." ? dir : dir.slice(app.root.length + 1);
110
149
  if (/^modules\/[^/]+$/.test(relative)) {
111
150
  const module = moduleAt(ctx, app, dir);
112
151
  if (module) components.push(module);
113
- } else if (/^themes\/[^/]+$/.test(relative)) {
114
- const theme = themeAt(ctx, app, dir);
152
+ } else if (/^(?:admin[^/]*\/)?themes\/[^/]+$/.test(relative)) {
153
+ const theme = themeAt(ctx, app, dir) || (relative.startsWith("admin") && adminThemeAt(ctx, app, dir));
115
154
  if (theme) components.push(theme);
116
155
  }
117
156
  }
118
- for (const entry of composerOccurrences(app, ctx)) {
119
- if (components.some(c => c.coord?.toLowerCase() === entry.coord)) continue;
157
+ const entries = composerOccurrences(app, ctx);
158
+ for (const entry of entries) {
120
159
  const kind = entry.occurrence.packageType === "prestashop-module" ? "module" :
121
160
  entry.occurrence.packageType === "prestashop-theme" ? "theme" : "library";
122
- components.push(composerComponent(app, entry, kind));
161
+ const locked = composerComponent(app, entry, kind);
162
+ // Distribution builds can strip each module's composer.json. The official
163
+ // installer places a typed prestashop/<slug> under modules/ or themes/.
164
+ const slug = entry.coord.split("/")[1];
165
+ const installDir = join(app.root,(kind === "theme" ? "themes/" : "modules/") + slug);
166
+ const installed = components.find(c => c.coord?.toLowerCase() === entry.coord ||
167
+ (kind !== "library" && entry.coord.startsWith("prestashop/") && c.kind === kind &&
168
+ !c.coord && c.path === installDir && c.name?.toLowerCase() === slug));
169
+ if (!installed) { components.push(locked); continue; }
170
+ installed.coord = entry.coord;
171
+ installed.managerRelation = locked.managerRelation;
172
+ installed.evidence.push(...locked.evidence);
173
+ if (installed.version && installed.version !== locked.version) {
174
+ installed.versionConflict = {observed:installed.version,locked:locked.version};
175
+ diagnostics.push({code:"CMS_VERSION_CONFLICT",applicationId:app.id,componentId:installed.id,
176
+ path:installed.path,message:`Installed ${entry.coord} ${installed.version} differs from composer.lock ${locked.version}`});
177
+ } else if (!installed.version) {
178
+ installed.version = locked.version;
179
+ installed.versionStatus = "locked";
180
+ }
123
181
  }
124
182
  return finishInventory(app, components, diagnostics, undefined, { advisories: false });
125
183
  },
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+ const path=require('node:path').posix;
3
+ const versionFile='lib/redmine/version.rb';
4
+ function versionFrom(text){
5
+ if(!/^\s*module Redmine\s*$/m.test(text) || !/^\s*module VERSION\s*$/m.test(text))return null;
6
+ const values=['MAJOR','MINOR','TINY'].map(key=>new RegExp('^\\s*'+key+'\\s*=\\s*(\\d+)\\s*$','m').exec(text)?.[1]);
7
+ return values.every(Boolean)?values.join('.'):null;
8
+ }
9
+ module.exports={
10
+ id:'redmine',apiVersion:1,version:'1.0.0',label:'Redmine',supportedLayouts:['installation','source'],
11
+ requiredCodecs:[],providerIds:[],capabilities:{inventory:'qualified'},upstreamCpe:'redmine:redmine',
12
+ discover(ctx){
13
+ return ctx.index.directories.filter(root=>[versionFile,'config/application.rb','Gemfile'].every(file=>ctx.index.hasFile(path.join(root,file))) &&
14
+ versionFrom(ctx.readText(path.join(root,versionFile),256*1024)))
15
+ .map(root=>({root,evidence:[{path:path.join(root,versionFile),field:'Redmine::VERSION'},{path:path.join(root,'config/application.rb')}]}));
16
+ },
17
+ collect(app,ctx){
18
+ const file=path.join(app.root,versionFile),version=versionFrom(ctx.readText(file,256*1024));
19
+ return {components:[{id:app.id+':core',applicationId:app.id,kind:'core',name:'Redmine',coord:'redmine',version,
20
+ visibility:'public',path:app.root,evidence:[{path:file,field:'Redmine::VERSION (MAJOR, MINOR, TINY)'}]}],
21
+ coverage:[{applicationId:app.id,capability:'inventory',execution:'completed',result:'not-applicable',expected:1,executed:1}],diagnostics:[]};
22
+ },
23
+ assess(){return [];},remediation(){return null;},
24
+ };
@@ -1,8 +1,8 @@
1
1
  const fs = require("node:fs");
2
2
  const path = require("node:path");
3
- const { walkDirs } = require("../parallel-walk");
4
- const { makeDirFilter } = require("../path-filter");
5
- const { createCoverage } = require("../scan-coverage");
3
+ const { walkDirs } = require("../../inventory/parallel-walk");
4
+ const { makeDirFilter } = require("../../inventory/path-filter");
5
+ const { createCoverage } = require("../../scan/coverage");
6
6
  const { selectPlugins } = require("./select");
7
7
 
8
8
  const DEFAULT_SKIP = new Set([".git", ".idea", ".vscode", "node_modules", "vendor", "dist", "build", "out", "target"]);
@@ -37,7 +37,7 @@ async function indexApplicationTree(root, opts = {}) {
37
37
  useDefaults: opts.defaultExcludes !== false,
38
38
  onSkip(abs, reason) { skipped.push({ path: posix(path.relative(srcRoot, abs)), reason }); },
39
39
  });
40
- await walkDirs(srcRoot, { skipDir, onDir(abs, entries) {
40
+ await walkDirs(srcRoot, { skipDir: (child, name) => opts.skipInventoryDir?.(child) || skipDir(child, name), onDir(abs, entries) {
41
41
  const rel = posix(path.relative(srcRoot, abs)) || ".";
42
42
  byDir.set(rel, new Set(entries.filter(e => e.isFile()).map(e => e.name)));
43
43
  } });
@@ -57,11 +57,11 @@ async function indexApplicationTree(root, opts = {}) {
57
57
  function checkedFile(root, relativePath) {
58
58
  if (typeof relativePath !== "string" || path.isAbsolute(relativePath)) throw new Error("application plugin read requires a relative path");
59
59
  const abs = path.resolve(root, relativePath);
60
- if (abs !== root && !abs.startsWith(root + path.sep)) throw new Error("application plugin read escaped scan root");
60
+ if (abs !== root && !abs.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) throw new Error("application plugin read escaped scan root");
61
61
  const stat = fs.lstatSync(abs);
62
62
  if (!stat.isFile() || stat.isSymbolicLink()) throw new Error("application plugin read requires a regular file");
63
63
  const real = fs.realpathSync(abs);
64
- if (!real.startsWith(root + path.sep)) throw new Error("application plugin read escaped scan root");
64
+ if (!real.startsWith(root.endsWith(path.sep) ? root : root + path.sep)) throw new Error("application plugin read escaped scan root");
65
65
  return { abs, stat };
66
66
  }
67
67
 
@@ -109,27 +109,32 @@ async function runApplicationPlugins(root, opts = {}) {
109
109
  // application plugin is selected, and the file goes through the same validation
110
110
  // (schema, freshness) as an operator-supplied one.
111
111
  const selectedPluginIds = new Set(plugins.map(plugin => plugin.id));
112
- const hostedOnline = !opts.offline && require("../providers").hasHostedProxy();
113
- const wordfenceProxyOnline = !opts.offline && require("../providers").hasProxyRoute();
112
+ const hostedOnline = !opts.offline && require("../../providers").hasHostedProxy();
113
+ const wordfenceProxyOnline = !opts.offline && require("../../providers").hasProxyRoute();
114
114
  const liveWordfenceUrl = opts.offline ? null : opts.liveWordfenceUrl || null;
115
115
  const forceCachedSource = (pluginId,file,configured,live,defaultUrl) => {
116
- if (opts.offline || configured || live || !opts.advisoryCacheDir || !selectedPluginIds.has(pluginId) || !require('../cache-policy').shouldForceUpdate()) return live || null;
117
- return require('../application-providers/snapshot-cache').exists(path.join(opts.advisoryCacheDir,file)) ? defaultUrl : null;
116
+ if (opts.offline || configured || live || !opts.advisoryCacheDir || !selectedPluginIds.has(pluginId) || !require('../../cache/policy').shouldForceUpdate()) return live || null;
117
+ return require('../snapshot-cache').exists(path.join(opts.advisoryCacheDir,file)) ? defaultUrl : null;
118
118
  };
119
+ // The publisher advisories of a selected CMS are consulted by default when the scan is
120
+ // online: there is no flag to know. A local snapshot or an explicit URL wins, and
121
+ // --offline never fetches.
122
+ const automatic = (pluginId, configured, live, defaultUrl) => live ||
123
+ (opts.automaticLiveSources && !opts.offline && !configured && selectedPluginIds.has(pluginId) ? defaultUrl : null);
119
124
  // Drupal's live operation is scoped to the inventoried public package identities.
120
125
  // Never refresh a bulk catalogue here, and never replace an operator-selected file.
121
- const liveDrupalAdvisoriesUrl = opts.offline ? null : (opts.liveDrupalAdvisoriesUrl ||
122
- (hostedOnline && !opts.drupalAdvisoriesPath && selectedPluginIds.has("drupal")
123
- ? require("../application-providers/live-snapshot").DRUPAL_ADVISORIES_URL : null) ||
124
- forceCachedSource('drupal','drupal-security-advisories.json',opts.drupalAdvisoriesPath,null,require('../application-providers/live-snapshot').DRUPAL_ADVISORIES_URL));
125
- const livePrestashopAdvisoriesUrl=forceCachedSource('prestashop','github-prestashop-advisories.json',opts.prestashopAdvisoriesPath,opts.livePrestashopAdvisoriesUrl,require('../application-providers/live-snapshot').PRESTASHOP_GITHUB_ADVISORIES_URL);
126
- const liveTypo3AdvisoriesUrl=forceCachedSource('typo3','github-typo3-advisories.json',opts.typo3AdvisoriesPath,opts.liveTypo3AdvisoriesUrl,require('../application-providers/live-snapshot').TYPO3_GITHUB_ADVISORIES_URL);
127
- const liveSpipAdvisoriesUrl=forceCachedSource('spip','spip-security-advisories.json',opts.spipAdvisoriesPath,opts.liveSpipAdvisoriesUrl,require('../application-providers/spip-advisories').SPIP_ADVISORIES_URL);
126
+ const SNAPSHOT_URLS = require("../live-snapshot");
127
+ const liveDrupalAdvisoriesUrl = opts.offline ? null : automatic('drupal', opts.drupalAdvisoriesPath, opts.liveDrupalAdvisoriesUrl ||
128
+ (hostedOnline && !opts.drupalAdvisoriesPath && selectedPluginIds.has("drupal") ? SNAPSHOT_URLS.DRUPAL_ADVISORIES_URL : null) ||
129
+ forceCachedSource('drupal','drupal-security-advisories.json',opts.drupalAdvisoriesPath,null,SNAPSHOT_URLS.DRUPAL_ADVISORIES_URL), SNAPSHOT_URLS.DRUPAL_ADVISORIES_URL);
130
+ const livePrestashopAdvisoriesUrl=automatic('prestashop',opts.prestashopAdvisoriesPath,forceCachedSource('prestashop','github-prestashop-advisories.json',opts.prestashopAdvisoriesPath,opts.livePrestashopAdvisoriesUrl,SNAPSHOT_URLS.PRESTASHOP_GITHUB_ADVISORIES_URL),SNAPSHOT_URLS.PRESTASHOP_GITHUB_ADVISORIES_URL);
131
+ const liveTypo3AdvisoriesUrl=automatic('typo3',opts.typo3AdvisoriesPath,forceCachedSource('typo3','github-typo3-advisories.json',opts.typo3AdvisoriesPath,opts.liveTypo3AdvisoriesUrl,SNAPSHOT_URLS.TYPO3_GITHUB_ADVISORIES_URL),SNAPSHOT_URLS.TYPO3_GITHUB_ADVISORIES_URL);
132
+ const liveSpipAdvisoriesUrl=automatic('spip',opts.spipAdvisoriesPath,forceCachedSource('spip','spip-security-advisories.json',opts.spipAdvisoriesPath,opts.liveSpipAdvisoriesUrl,require('../../providers/spip/advisories').SPIP_ADVISORIES_URL),require('../../providers/spip/advisories').SPIP_ADVISORIES_URL);
128
133
  const autoCachedSources = new Set();
129
134
  const withCachedFallback = (configured, liveUrl, pluginId, file) => {
130
135
  if (configured || liveUrl || !opts.advisoryCacheDir || !selectedPluginIds.has(pluginId)) return configured || null;
131
136
  const cached = path.join(opts.advisoryCacheDir, file);
132
- if (!require('../application-providers/snapshot-cache').exists(cached)) return configured || null;
137
+ if (!require('../snapshot-cache').exists(cached)) return configured || null;
133
138
  autoCachedSources.add(cached);
134
139
  return cached;
135
140
  };
@@ -147,7 +152,7 @@ async function runApplicationPlugins(root, opts = {}) {
147
152
  const validatedLocalSources = new Map();
148
153
  const validateLocalSource = (snapshotPath, label, validate) => {
149
154
  if (!snapshotPath || validatedLocalSources.has(snapshotPath)) return;
150
- const {stat,bytes}=require('../application-providers/snapshot-cache').read(snapshotPath,
155
+ const {stat,bytes}=require('../snapshot-cache').read(snapshotPath,
151
156
  {preferCache:autoCachedSources.has(snapshotPath)});
152
157
  if (!stat.isFile() || stat.size > 128 * 1024 * 1024)
153
158
  throw new Error(`${label} advisory snapshot must be a JSON file of at most 128 MiB`);
@@ -158,31 +163,31 @@ async function runApplicationPlugins(root, opts = {}) {
158
163
  const revalidateWordfence = snapshotPath === wordfenceFeedPath && wordfenceProxyOnline &&
159
164
  staleWordfenceSnapshot(snapshot._fadSnapshot, opts.now || Date.now(), autoCachedSources.has(snapshotPath));
160
165
  if (opts.maxAdvisoryAgeMs && !revalidateWordfence) {
161
- const { assertFresh } = require("../advisory-freshness");
166
+ const { assertFresh } = require("../../advisories/freshness");
162
167
  assertFresh(snapshot, label, opts.maxAdvisoryAgeMs, opts.now || Date.now());
163
168
  }
164
169
  validatedLocalSources.set(snapshotPath, { stat, bytes, snapshot });
165
170
  };
166
- validateLocalSource(wordfenceFeedPath, "Wordfence", feed => require("../application-providers/wordfence-v3").indexFeed(feed));
167
- validateLocalSource(drupalAdvisoriesPath, "Drupal advisories", require("../application-providers/drupal-advisories").validateSnapshot);
171
+ validateLocalSource(wordfenceFeedPath, "Wordfence", feed => require("../../providers/wordfence/v3").indexFeed(feed));
172
+ validateLocalSource(drupalAdvisoriesPath, "Drupal advisories", require("../../providers/drupal/advisories").validateSnapshot);
168
173
  validateLocalSource(prestashopAdvisoriesPath, "PrestaShop advisories",
169
- feed => require("../application-providers/github-advisories").validateSnapshot(feed, { fallbackCoord: "prestashop/prestashop" }));
174
+ feed => require("../../providers/github/advisories").validateSnapshot(feed, { fallbackCoord: "prestashop/prestashop" }));
170
175
  validateLocalSource(typo3AdvisoriesPath, "TYPO3 advisories",
171
- feed => require("../application-providers/github-advisories").validateSnapshot(feed));
176
+ feed => require("../../providers/github/advisories").validateSnapshot(feed));
172
177
  validateLocalSource(spipAdvisoriesPath, "SPIP advisories",
173
- require("../application-providers/spip-advisories").validateSnapshot);
178
+ require("../../providers/spip/advisories").validateSnapshot);
174
179
  validateLocalSource(opts.wpChecksumsPath, "WordPress checksums",
175
- require("../application-providers/wp-checksums").validateChecksums);
180
+ require("../../providers/wordpress/checksums").validateChecksums);
176
181
  const result = { applications: [], inventory: [], findings: [], coverage: [], diagnostics: [] };
177
182
  if (!plugins.length) return result;
178
- const index = await indexApplicationTree(root, opts);
183
+ const index = opts.savedInventory ? null : await indexApplicationTree(root, opts);
179
184
  const journal = createCoverage();
180
185
  const privatePaths = new Set((opts.privateComponentPaths || []).map(privatePath));
181
186
  const publicSlugs = new Map((opts.publicComponents || []).map(publicComponent));
182
187
  for (const relative of publicSlugs.keys()) if (privatePaths.has(relative))
183
188
  throw new Error(`component cannot be both private and public: ${relative}`);
184
189
  const context = {
185
- srcRoot: index.srcRoot, index, resolvedDeps: opts.resolvedDeps || new Map(),
190
+ srcRoot: index?.srcRoot, index, inventoryReplay: !!opts.savedInventory, resolvedDeps: opts.resolvedDeps || new Map(),
186
191
  activeCodecIds: opts.activeCodecIds || [],
187
192
  readText: (rel, maxBytes) => boundedRead(index.srcRoot, rel, maxBytes),
188
193
  readPrefix: (rel, maxBytes) => boundedPrefix(index.srcRoot, rel, maxBytes),
@@ -218,14 +223,14 @@ async function runApplicationPlugins(root, opts = {}) {
218
223
  const local = validatedLocalSources.get(wordfenceFeedPath)?.snapshot;
219
224
  const localStale = staleWordfenceSnapshot(local?._fadSnapshot, context.now,
220
225
  autoCachedSources.has(wordfenceFeedPath));
221
- const forceRefresh = !opts.offline && autoCachedSources.has(wordfenceFeedPath) && require('../cache-policy').shouldForceUpdate();
226
+ const forceRefresh = !opts.offline && autoCachedSources.has(wordfenceFeedPath) && require('../../cache/policy').shouldForceUpdate();
222
227
  let assessed;
223
228
  let refreshError;
224
229
  let usedLocal = true;
225
230
  if (plugin.id === "wordpress" && wordfenceProxyOnline && (localStale || forceRefresh)) {
226
231
  try {
227
232
  assessed = await plugin.assess(app, components, { ...context, wordfenceFeedPath: null,
228
- liveWordfenceUrl: require("../application-providers/wordfence-projection").SOURCE_URL });
233
+ liveWordfenceUrl: require("../../providers/wordfence/projection").SOURCE_URL });
229
234
  usedLocal = false;
230
235
  } catch (error) {
231
236
  if (requiredProviderIds.has("wordfence-v3") && !opts.reportProviderFailures) throw error;
@@ -248,6 +253,54 @@ async function runApplicationPlugins(root, opts = {}) {
248
253
  message: `Wordfence snapshot is stale; advisory coverage is indeterminate${refreshError
249
254
  ? ` (targeted revalidation failed: ${refreshError.message})` : ""}` }] : [])] };
250
255
  }
256
+ async function recordAssessment(plugin, app, components) {
257
+ try {
258
+ const assessed = await assessApplication(plugin, app, components) || [];
259
+ if (Array.isArray(assessed)) result.findings.push(...assessed);
260
+ else {
261
+ result.findings.push(...(assessed.findings || []));
262
+ result.diagnostics.push(...(assessed.diagnostics || []));
263
+ for (const check of assessed.coverage || []) {
264
+ if (context.maxAdvisoryAgeMs && check.sourceSnapshot)
265
+ require("../../advisories/freshness").assertFresh(check.sourceSnapshot,
266
+ check.sourceId || plugin.id, context.maxAdvisoryAgeMs, context.now);
267
+ journal.record(check);
268
+ }
269
+ }
270
+ } catch (error) {
271
+ const required = plugin.providerIds.filter(id => requiredProviderIds.has(id));
272
+ // Retain inventory and failure diagnostics for the CLI. Its
273
+ // coverage gate runs after export; library callers retain fail-fast semantics.
274
+ if (required.length && (!opts.reportProviderFailures || context.maxAdvisoryAgeMs))
275
+ throw new Error(`${plugin.id} advisory source failed: ${error.message}`);
276
+ result.diagnostics.push({ code: "CMS_PLUGIN_FAILED", applicationId: app.id,
277
+ sourceIds: required, message: `assessment failed: ${error.message}` });
278
+ if (!journal.records.some(c => c.applicationId === app.id && c.capability === "advisories")) {
279
+ for (const sourceId of required.length ? required : [null])
280
+ journal.record({ applicationId: app.id, ...(sourceId ? { sourceId } : {}),
281
+ capability: "advisories", execution: "failed", result: "indeterminate", diagnostic: "CMS_PLUGIN_FAILED" });
282
+ }
283
+ }
284
+ }
285
+ if (opts.savedInventory) {
286
+ const components = new Map();
287
+ for (const item of opts.savedInventory.inventory) {
288
+ if (!components.has(item.applicationId)) components.set(item.applicationId, []);
289
+ components.get(item.applicationId).push(item);
290
+ }
291
+ for (const app of opts.savedInventory.applications) {
292
+ const plugin = plugins.find(p => p.id === app.pluginId);
293
+ if (plugin) await recordAssessment(plugin, app, components.get(app.id) || []);
294
+ }
295
+ const embedded = opts.savedInventory.embeddedApplications || [];
296
+ for (const entry of embedded) {
297
+ const plugin = plugins.find(p => p.id === entry.app.pluginId);
298
+ if (plugin) await recordAssessment(plugin, entry.app, entry.inventory);
299
+ }
300
+ result.coverage = journal.records;
301
+ require('../layout').reparentAssessments(result,embedded);
302
+ return result;
303
+ }
251
304
  // discover returns candidates, and may add diagnostics (e.g. recognized-but-invalid input);
252
305
  // a bare candidate array stays the documented simple form.
253
306
  function discovered(plugin) {
@@ -271,15 +324,16 @@ async function runApplicationPlugins(root, opts = {}) {
271
324
  for (const candidate of candidates || []) {
272
325
  const relativeRoot = posix(candidate.root || ".").replace(/^\.\//, "") || ".";
273
326
  const abs = path.resolve(index.srcRoot, relativeRoot);
274
- if (path.isAbsolute(candidate.root || "") || (abs !== index.srcRoot && !abs.startsWith(index.srcRoot + path.sep))) {
327
+ if (path.isAbsolute(candidate.root || "") || (abs !== index.srcRoot && !abs.startsWith(index.srcRoot.endsWith(path.sep) ? index.srcRoot : index.srcRoot + path.sep))) {
275
328
  result.diagnostics.push({ code: "CMS_UNSUPPORTED_LAYOUT", pluginId: plugin.id, path: relativeRoot, message: "candidate root escapes scan root" });
276
329
  continue;
277
330
  }
278
- const app = { id: `${plugin.id}:${relativeRoot}`, type: plugin.id, root: relativeRoot, pluginId: plugin.id,
331
+ const app = { id: [opts.artifactTargetId, plugin.id, relativeRoot].filter(Boolean).join(":"), type: plugin.id, root: relativeRoot, pluginId: plugin.id,
279
332
  pluginVersion: plugin.version, scanContext: context.scanContext, evidence: candidate.evidence || [],
280
333
  ...(candidate.layout ? { layout: candidate.layout } : {}),
281
334
  ...(candidate.documentRoot ? { documentRoot: candidate.documentRoot } : {}),
282
335
  ...(candidate.contentRoot ? { contentRoot: candidate.contentRoot } : {}) };
336
+ if (candidate.deploymentRole) app.deploymentRole = candidate.deploymentRole;
283
337
  if (candidate.componentKind) app.componentKind = candidate.componentKind;
284
338
  if (candidate.edition) app.edition = candidate.edition;
285
339
  if (seen.has(app.id)) continue;
@@ -306,33 +360,8 @@ async function runApplicationPlugins(root, opts = {}) {
306
360
  journal.record({ applicationId: app.id, capability: "inventory", execution: "failed", result: "indeterminate", diagnostic: "CMS_PLUGIN_FAILED" });
307
361
  continue;
308
362
  }
309
- try {
310
- const assessed = await assessApplication(plugin, app, collected.components || []) || [];
311
- if (Array.isArray(assessed)) result.findings.push(...assessed);
312
- else {
313
- result.findings.push(...(assessed.findings || []));
314
- result.diagnostics.push(...(assessed.diagnostics || []));
315
- for (const check of assessed.coverage || []) {
316
- if (context.maxAdvisoryAgeMs && check.sourceSnapshot)
317
- require("../advisory-freshness").assertFresh(check.sourceSnapshot,
318
- check.sourceId || plugin.id, context.maxAdvisoryAgeMs, context.now);
319
- journal.record(check);
320
- }
321
- }
322
- } catch (error) {
323
- const required = plugin.providerIds.filter(id => requiredProviderIds.has(id));
324
- // A CLI scan must retain its inventory and write partial reports. Its explicit
325
- // coverage gate runs after export; library callers retain fail-fast semantics.
326
- if (required.length && (!opts.reportProviderFailures || context.maxAdvisoryAgeMs))
327
- throw new Error(`${plugin.id} advisory source failed: ${error.message}`);
328
- result.diagnostics.push({ code: "CMS_PLUGIN_FAILED", applicationId: app.id,
329
- sourceIds: required, message: `assessment failed: ${error.message}` });
330
- if (!journal.records.some(c => c.applicationId === app.id && c.capability === "advisories")) {
331
- for (const sourceId of required.length ? required : [null])
332
- journal.record({ applicationId: app.id, ...(sourceId ? { sourceId } : {}),
333
- capability: "advisories", execution: "failed", result: "indeterminate", diagnostic: "CMS_PLUGIN_FAILED" });
334
- }
335
- }
363
+ if (opts.inventoryOnly) continue;
364
+ await recordAssessment(plugin, app, collected.components || []);
336
365
  }
337
366
  }
338
367
  for (const relative of privatePaths) if (!result.inventory.some(component => component.path && privatePath(component.path) === relative))
@@ -351,6 +380,7 @@ async function runApplicationPlugins(root, opts = {}) {
351
380
  message: "component scan context recognized no supported application component in the scan root; " +
352
381
  "point --src at a plugin, theme, module or profile with valid metadata, or select the matching --app-plugins" });
353
382
  result.coverage = journal.records;
383
+ require('../layout').reconcileApplications(result);
354
384
  return result;
355
385
  }
356
386
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * lib/application-plugins/spip.js — the SPIP application plugin.
2
+ * lib/applications/plugins/spip.js — the SPIP application plugin.
3
3
  *
4
4
  * SPIP is a French-CMS staple with a layout no other product shares: the front
5
5
  * controller `spip.php` next to `ecrire/inc_version.php` (which carries
@@ -10,15 +10,15 @@
10
10
  * Detection is conjunctive (`spip.php` AND `ecrire/inc_version.php`) and the core
11
11
  * version is only reported when the version constant is actually readable in the
12
12
  * marker file — a bare file name never creates an application. The advisory lane is
13
- * NVD's `cpe:2.3:a:spip:spip` (see lib/application-providers/spip-advisories.js):
13
+ * NVD's `cpe:2.3:a:spip:spip` (see lib/providers/spip/advisories.js):
14
14
  * no publisher API exists. SPIP plugins have no advisory source at all — their rows
15
15
  * say so. The composer lock of a SPIP tree is scanned by the standard lanes like
16
16
  * any library tree; this plugin adds the instance view on top.
17
17
  */
18
18
  const path = require("node:path");
19
19
  const fs = require("node:fs");
20
- const { SPIP_ADVISORIES_URL, fetchSpipAdvisories, assessSpipAdvisories } = require("../application-providers/spip-advisories");
21
- const { writeSnapshotAtomically } = require("../application-providers/live-snapshot");
20
+ const { SPIP_ADVISORIES_URL, fetchSpipAdvisories, assessSpipAdvisories } = require("../../providers/spip/advisories");
21
+ const { writeSnapshotAtomically } = require("../live-snapshot");
22
22
  const { localSourceSnapshot } = require("./wave2-common");
23
23
 
24
24
  /** Attributes of a `paquet.xml` (SPIP ≥3) or legacy `plugin.xml` root element. */
@@ -1,5 +1,5 @@
1
1
  const path = require("node:path");
2
- const frameworkMap = require("../../data/eol-composer-frameworks.json");
2
+ const frameworkMap = require("../../../data/eol-composer-frameworks.json");
3
3
 
4
4
  const FRAMEWORK_COMPONENTS = new Set(frameworkMap.symfony.components);
5
5
  const join = (dir, file) => dir === "." ? file : `${dir}/${file}`;
@@ -1,7 +1,7 @@
1
1
  const fs = require("node:fs");
2
2
  const path = require("node:path");
3
- const { fetchGithubAdvisories, writeSnapshotAtomically } = require("../application-providers/live-snapshot");
4
- const { assessGithubAdvisories, typo3RangeGrammar } = require("../application-providers/github-advisories");
3
+ const { fetchGithubAdvisories, writeSnapshotAtomically } = require("../live-snapshot");
4
+ const { assessGithubAdvisories, typo3RangeGrammar } = require("../../providers/github/advisories");
5
5
  const { join, within, readJson, composerOccurrences, composerComponent, composerCoverageDiagnostic, finishInventory, localSourceSnapshot } = require("./wave2-common");
6
6
 
7
7
  const GITHUB_REPO = "TYPO3/typo3";
@@ -106,7 +106,7 @@ function finishInventory(app, components, diagnostics = [], sourceId = "applicat
106
106
  */
107
107
  function localSourceSnapshot(ctx, snapshotPath, bytes, stat, snapshot) {
108
108
  const { createHash } = require("node:crypto");
109
- const { declaredCollectedAt } = require("../advisory-freshness");
109
+ const { declaredCollectedAt } = require("../../advisories/freshness");
110
110
  const declared = declaredCollectedAt(snapshot);
111
111
  const autoCached = ctx.autoCachedSources?.has(snapshotPath) || false;
112
112
  const stamp = snapshot && typeof snapshot === "object" ? snapshot._fadSnapshot : null;