@cdxgen/cdxgen 13.2.0 → 13.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 (311) hide show
  1. package/README.md +33 -14
  2. package/bin/cdxgen.js +310 -138
  3. package/bin/evinse.js +22 -0
  4. package/bin/repl.js +86 -0
  5. package/bin/sign.js +119 -15
  6. package/bin/tracebom.js +69 -5
  7. package/bin/validate.js +107 -19
  8. package/bin/verify.js +172 -63
  9. package/data/helpers/init.gradle +46 -21
  10. package/data/remediations.json +85 -0
  11. package/data/rules/dependency-sources.yaml +67 -0
  12. package/data/rules/scala-evidence.yaml +115 -0
  13. package/lib/audit/index.js +38 -6
  14. package/lib/cli/bomAssembly.js +105 -15
  15. package/lib/cli/cliOptions.js +93 -1
  16. package/lib/cli/index.js +156 -58
  17. package/lib/cli/jsBom.js +99 -53
  18. package/lib/cli/jvmBom.js +708 -147
  19. package/lib/cli/managedBom.js +415 -224
  20. package/lib/cli/nativeBom.js +264 -44
  21. package/lib/core/activity.js +12 -0
  22. package/lib/core/env.js +22 -15
  23. package/lib/core/fs.js +176 -7
  24. package/lib/core/httpClient.js +159 -24
  25. package/lib/core/metadataProperties.js +97 -0
  26. package/lib/core/pluginRun.js +184 -0
  27. package/lib/core/processTree.js +100 -0
  28. package/lib/core/projectConfig.js +31 -4
  29. package/lib/core/runState.js +39 -0
  30. package/lib/core/toml.js +72 -0
  31. package/lib/ecosystems/asarutils.js +4 -2
  32. package/lib/ecosystems/bunutils.js +274 -108
  33. package/lib/ecosystems/cargoCache.js +231 -8
  34. package/lib/ecosystems/caxa.js +434 -2
  35. package/lib/ecosystems/cmakeResolver.js +76 -21
  36. package/lib/ecosystems/cppBuildContext.js +631 -0
  37. package/lib/ecosystems/cppEvidence.js +399 -51
  38. package/lib/ecosystems/cppIncludeResolver.js +294 -0
  39. package/lib/ecosystems/denoutils.js +93 -66
  40. package/lib/ecosystems/ecosystems.js +1983 -793
  41. package/lib/ecosystems/golem.js +28 -12
  42. package/lib/ecosystems/gradleutils.js +356 -37
  43. package/lib/ecosystems/jsEvidence.js +104 -44
  44. package/lib/ecosystems/kosi.js +31 -7
  45. package/lib/ecosystems/npmutils.js +174 -9
  46. package/lib/ecosystems/parsers-dotnet.js +616 -159
  47. package/lib/ecosystems/parsers-elm.js +46 -28
  48. package/lib/ecosystems/parsers-gleam.js +3 -4
  49. package/lib/ecosystems/parsers-go.js +371 -70
  50. package/lib/ecosystems/parsers-js.js +263 -76
  51. package/lib/ecosystems/parsers-julia.js +2 -3
  52. package/lib/ecosystems/parsers-jvm.js +204 -12
  53. package/lib/ecosystems/parsers-misc.js +929 -216
  54. package/lib/ecosystems/parsers-python.js +167 -24
  55. package/lib/ecosystems/parsers-rust.js +28 -22
  56. package/lib/ecosystems/parsers-terraform.js +1573 -19
  57. package/lib/ecosystems/pythonutils.js +102 -6
  58. package/lib/ecosystems/remote/huggingface.js +3 -0
  59. package/lib/ecosystems/rubyutils.js +1492 -182
  60. package/lib/ecosystems/rusi.js +54 -10
  61. package/lib/ecosystems/sbtutils.js +243 -187
  62. package/lib/ecosystems/scalacliutils.js +342 -0
  63. package/lib/ecosystems/scalasem.js +2618 -0
  64. package/lib/ecosystems/terraformRegistry.js +288 -0
  65. package/lib/ecosystems/utils.js +2 -0
  66. package/lib/ecosystems/vendoredCode.js +156 -0
  67. package/lib/evinser/evinser.js +1008 -191
  68. package/lib/evinser/swiftsem.js +1914 -302
  69. package/lib/helpers/agenticToolutils.js +2 -2
  70. package/lib/helpers/bomSigner.js +1101 -222
  71. package/lib/inventory/aiCollector.js +4 -1
  72. package/lib/inventory/analyzer.js +110 -127
  73. package/lib/inventory/atomUtils.js +703 -43
  74. package/lib/inventory/auditCategories.js +7 -0
  75. package/lib/inventory/buildToolRateLimit.js +144 -0
  76. package/lib/inventory/cacheCommands.js +2 -1
  77. package/lib/inventory/cdxrs.js +103 -12
  78. package/lib/inventory/cmakeBuildDirs.js +254 -0
  79. package/lib/inventory/deps.js +501 -124
  80. package/lib/inventory/depsUtils.js +183 -11
  81. package/lib/inventory/display.js +4 -5
  82. package/lib/inventory/dosai.js +798 -57
  83. package/lib/inventory/dosaiParsers.js +310 -15
  84. package/lib/inventory/dynamic.js +90 -6
  85. package/lib/inventory/evidenceUtils.js +166 -113
  86. package/lib/inventory/fetchBatch.js +690 -55
  87. package/lib/inventory/fetchDiskCache.js +597 -0
  88. package/lib/inventory/forgeEnricher.js +14 -5
  89. package/lib/inventory/jvmLocalRepos.js +917 -0
  90. package/lib/inventory/mcpConfigParser.js +2 -3
  91. package/lib/inventory/parentSelection.js +146 -0
  92. package/lib/inventory/protobom.js +8 -1
  93. package/lib/inventory/purl.js +152 -3
  94. package/lib/inventory/rustFormulationParser.js +3 -4
  95. package/lib/inventory/sbomDocument.js +2 -70
  96. package/lib/inventory/scalaCoords.js +153 -0
  97. package/lib/inventory/source.js +45 -27
  98. package/lib/inventory/spdx.js +101 -0
  99. package/lib/inventory/traceRunner.js +295 -25
  100. package/lib/inventory/tracedCrypto.js +294 -0
  101. package/lib/managers/binary.js +115 -24
  102. package/lib/managers/docker.js +467 -46
  103. package/lib/managers/oci.js +63 -3
  104. package/lib/parsers/cmakeCache.js +69 -0
  105. package/lib/parsers/cmakeLists.js +466 -0
  106. package/lib/parsers/cmakePresets.js +400 -0
  107. package/lib/parsers/compileCommands.js +557 -0
  108. package/lib/parsers/largeJson.js +454 -0
  109. package/lib/parsers/npmrc.js +19 -1
  110. package/lib/parsers/strictJson.js +322 -0
  111. package/lib/parsers/terraformConfig.js +1073 -0
  112. package/lib/parsers/terraformSource.js +652 -0
  113. package/lib/server/server.js +23 -0
  114. package/lib/stages/postgen/introspection/markers.js +1 -1
  115. package/lib/stages/postgen/postgen.js +83 -16
  116. package/lib/stages/postgen/specVersionCompat.js +32 -0
  117. package/lib/validator/bomValidator.js +6 -16
  118. package/lib/validator/index.js +64 -11
  119. package/lib/validator/reporters/console.js +3 -0
  120. package/lib/validator/reporters/json.js +2 -0
  121. package/lib/validator/reporters/sarif.js +7 -0
  122. package/package.json +23 -23
  123. package/types/lib/audit/index.d.ts.map +1 -1
  124. package/types/lib/cli/bomAssembly.d.ts +2 -1
  125. package/types/lib/cli/bomAssembly.d.ts.map +1 -1
  126. package/types/lib/cli/cliOptions.d.ts +33 -1
  127. package/types/lib/cli/cliOptions.d.ts.map +1 -1
  128. package/types/lib/cli/index.d.ts.map +1 -1
  129. package/types/lib/cli/jsBom.d.ts.map +1 -1
  130. package/types/lib/cli/jvmBom.d.ts +24 -1
  131. package/types/lib/cli/jvmBom.d.ts.map +1 -1
  132. package/types/lib/cli/managedBom.d.ts +7 -4
  133. package/types/lib/cli/managedBom.d.ts.map +1 -1
  134. package/types/lib/cli/nativeBom.d.ts +3 -1
  135. package/types/lib/cli/nativeBom.d.ts.map +1 -1
  136. package/types/lib/core/activity.d.ts.map +1 -1
  137. package/types/lib/core/env.d.ts +9 -0
  138. package/types/lib/core/env.d.ts.map +1 -1
  139. package/types/lib/core/fs.d.ts +55 -0
  140. package/types/lib/core/fs.d.ts.map +1 -1
  141. package/types/lib/core/httpClient.d.ts +13 -8
  142. package/types/lib/core/httpClient.d.ts.map +1 -1
  143. package/types/lib/core/metadataProperties.d.ts +39 -0
  144. package/types/lib/core/metadataProperties.d.ts.map +1 -0
  145. package/types/lib/core/pluginRun.d.ts +97 -0
  146. package/types/lib/core/pluginRun.d.ts.map +1 -0
  147. package/types/lib/core/processTree.d.ts +36 -0
  148. package/types/lib/core/processTree.d.ts.map +1 -0
  149. package/types/lib/core/projectConfig.d.ts +6 -2
  150. package/types/lib/core/projectConfig.d.ts.map +1 -1
  151. package/types/lib/core/runState.d.ts +29 -0
  152. package/types/lib/core/runState.d.ts.map +1 -0
  153. package/types/lib/core/toml.d.ts +20 -0
  154. package/types/lib/core/toml.d.ts.map +1 -0
  155. package/types/lib/ecosystems/asarutils.d.ts.map +1 -1
  156. package/types/lib/ecosystems/bunutils.d.ts +12 -5
  157. package/types/lib/ecosystems/bunutils.d.ts.map +1 -1
  158. package/types/lib/ecosystems/cargoCache.d.ts +12 -0
  159. package/types/lib/ecosystems/cargoCache.d.ts.map +1 -1
  160. package/types/lib/ecosystems/caxa.d.ts +14 -0
  161. package/types/lib/ecosystems/caxa.d.ts.map +1 -1
  162. package/types/lib/ecosystems/cmakeResolver.d.ts +28 -3
  163. package/types/lib/ecosystems/cmakeResolver.d.ts.map +1 -1
  164. package/types/lib/ecosystems/cppBuildContext.d.ts +55 -0
  165. package/types/lib/ecosystems/cppBuildContext.d.ts.map +1 -0
  166. package/types/lib/ecosystems/cppEvidence.d.ts +17 -1
  167. package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
  168. package/types/lib/ecosystems/cppIncludeResolver.d.ts +92 -0
  169. package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -0
  170. package/types/lib/ecosystems/denoutils.d.ts +9 -3
  171. package/types/lib/ecosystems/denoutils.d.ts.map +1 -1
  172. package/types/lib/ecosystems/ecosystems.d.ts +62 -13
  173. package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
  174. package/types/lib/ecosystems/golem.d.ts.map +1 -1
  175. package/types/lib/ecosystems/gradleutils.d.ts +70 -4
  176. package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
  177. package/types/lib/ecosystems/jsEvidence.d.ts +5 -2
  178. package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -1
  179. package/types/lib/ecosystems/kosi.d.ts +13 -0
  180. package/types/lib/ecosystems/kosi.d.ts.map +1 -1
  181. package/types/lib/ecosystems/npmutils.d.ts +57 -0
  182. package/types/lib/ecosystems/npmutils.d.ts.map +1 -1
  183. package/types/lib/ecosystems/parsers-dotnet.d.ts +118 -4
  184. package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
  185. package/types/lib/ecosystems/parsers-elm.d.ts.map +1 -1
  186. package/types/lib/ecosystems/parsers-gleam.d.ts.map +1 -1
  187. package/types/lib/ecosystems/parsers-go.d.ts +54 -2
  188. package/types/lib/ecosystems/parsers-go.d.ts.map +1 -1
  189. package/types/lib/ecosystems/parsers-js.d.ts +16 -5
  190. package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
  191. package/types/lib/ecosystems/parsers-julia.d.ts.map +1 -1
  192. package/types/lib/ecosystems/parsers-jvm.d.ts +46 -1
  193. package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
  194. package/types/lib/ecosystems/parsers-misc.d.ts +70 -4
  195. package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
  196. package/types/lib/ecosystems/parsers-python.d.ts +53 -3
  197. package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
  198. package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
  199. package/types/lib/ecosystems/parsers-terraform.d.ts +38 -21
  200. package/types/lib/ecosystems/parsers-terraform.d.ts.map +1 -1
  201. package/types/lib/ecosystems/pythonutils.d.ts +27 -2
  202. package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
  203. package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -1
  204. package/types/lib/ecosystems/rubyutils.d.ts +164 -3
  205. package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
  206. package/types/lib/ecosystems/rusi.d.ts +13 -0
  207. package/types/lib/ecosystems/rusi.d.ts.map +1 -1
  208. package/types/lib/ecosystems/sbtutils.d.ts +88 -2
  209. package/types/lib/ecosystems/sbtutils.d.ts.map +1 -1
  210. package/types/lib/ecosystems/scalacliutils.d.ts +56 -0
  211. package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -0
  212. package/types/lib/ecosystems/scalasem.d.ts +311 -0
  213. package/types/lib/ecosystems/scalasem.d.ts.map +1 -0
  214. package/types/lib/ecosystems/terraformRegistry.d.ts +9 -0
  215. package/types/lib/ecosystems/terraformRegistry.d.ts.map +1 -0
  216. package/types/lib/ecosystems/utils.d.ts +2 -2
  217. package/types/lib/ecosystems/utils.d.ts.map +1 -1
  218. package/types/lib/ecosystems/vendoredCode.d.ts +32 -0
  219. package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -0
  220. package/types/lib/evinser/evinser.d.ts +132 -15
  221. package/types/lib/evinser/evinser.d.ts.map +1 -1
  222. package/types/lib/evinser/swiftsem.d.ts +280 -15
  223. package/types/lib/evinser/swiftsem.d.ts.map +1 -1
  224. package/types/lib/helpers/bomSigner.d.ts +182 -13
  225. package/types/lib/helpers/bomSigner.d.ts.map +1 -1
  226. package/types/lib/inventory/aiCollector.d.ts.map +1 -1
  227. package/types/lib/inventory/analyzer.d.ts.map +1 -1
  228. package/types/lib/inventory/atomUtils.d.ts +219 -5
  229. package/types/lib/inventory/atomUtils.d.ts.map +1 -1
  230. package/types/lib/inventory/auditCategories.d.ts +3 -0
  231. package/types/lib/inventory/auditCategories.d.ts.map +1 -1
  232. package/types/lib/inventory/buildToolRateLimit.d.ts +38 -0
  233. package/types/lib/inventory/buildToolRateLimit.d.ts.map +1 -0
  234. package/types/lib/inventory/cacheCommands.d.ts +2 -1
  235. package/types/lib/inventory/cacheCommands.d.ts.map +1 -1
  236. package/types/lib/inventory/cdxrs.d.ts +8 -3
  237. package/types/lib/inventory/cdxrs.d.ts.map +1 -1
  238. package/types/lib/inventory/cmakeBuildDirs.d.ts +58 -0
  239. package/types/lib/inventory/cmakeBuildDirs.d.ts.map +1 -0
  240. package/types/lib/inventory/deps.d.ts +59 -1
  241. package/types/lib/inventory/deps.d.ts.map +1 -1
  242. package/types/lib/inventory/depsUtils.d.ts +15 -0
  243. package/types/lib/inventory/depsUtils.d.ts.map +1 -1
  244. package/types/lib/inventory/display.d.ts.map +1 -1
  245. package/types/lib/inventory/dosai.d.ts +121 -9
  246. package/types/lib/inventory/dosai.d.ts.map +1 -1
  247. package/types/lib/inventory/dosaiParsers.d.ts +53 -7
  248. package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
  249. package/types/lib/inventory/dynamic.d.ts +10 -0
  250. package/types/lib/inventory/dynamic.d.ts.map +1 -1
  251. package/types/lib/inventory/evidenceUtils.d.ts +19 -4
  252. package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
  253. package/types/lib/inventory/fetchBatch.d.ts +83 -14
  254. package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
  255. package/types/lib/inventory/fetchDiskCache.d.ts +169 -0
  256. package/types/lib/inventory/fetchDiskCache.d.ts.map +1 -0
  257. package/types/lib/inventory/forgeEnricher.d.ts.map +1 -1
  258. package/types/lib/inventory/jvmLocalRepos.d.ts +178 -0
  259. package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -0
  260. package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
  261. package/types/lib/inventory/parentSelection.d.ts +34 -0
  262. package/types/lib/inventory/parentSelection.d.ts.map +1 -0
  263. package/types/lib/inventory/plugins.d.ts.map +1 -1
  264. package/types/lib/inventory/protobom.d.ts.map +1 -1
  265. package/types/lib/inventory/purl.d.ts +71 -2
  266. package/types/lib/inventory/purl.d.ts.map +1 -1
  267. package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
  268. package/types/lib/inventory/sbomDocument.d.ts.map +1 -1
  269. package/types/lib/inventory/scalaCoords.d.ts +80 -0
  270. package/types/lib/inventory/scalaCoords.d.ts.map +1 -0
  271. package/types/lib/inventory/source.d.ts.map +1 -1
  272. package/types/lib/inventory/spdx.d.ts +9 -0
  273. package/types/lib/inventory/spdx.d.ts.map +1 -1
  274. package/types/lib/inventory/traceRunner.d.ts +59 -1
  275. package/types/lib/inventory/traceRunner.d.ts.map +1 -1
  276. package/types/lib/inventory/tracedCrypto.d.ts +42 -0
  277. package/types/lib/inventory/tracedCrypto.d.ts.map +1 -0
  278. package/types/lib/managers/binary.d.ts +30 -1
  279. package/types/lib/managers/binary.d.ts.map +1 -1
  280. package/types/lib/managers/docker.d.ts +29 -0
  281. package/types/lib/managers/docker.d.ts.map +1 -1
  282. package/types/lib/managers/oci.d.ts +17 -1
  283. package/types/lib/managers/oci.d.ts.map +1 -1
  284. package/types/lib/parsers/cmakeCache.d.ts +16 -0
  285. package/types/lib/parsers/cmakeCache.d.ts.map +1 -1
  286. package/types/lib/parsers/cmakeLists.d.ts +77 -0
  287. package/types/lib/parsers/cmakeLists.d.ts.map +1 -0
  288. package/types/lib/parsers/cmakePresets.d.ts +78 -0
  289. package/types/lib/parsers/cmakePresets.d.ts.map +1 -0
  290. package/types/lib/parsers/compileCommands.d.ts +115 -0
  291. package/types/lib/parsers/compileCommands.d.ts.map +1 -0
  292. package/types/lib/parsers/largeJson.d.ts +52 -0
  293. package/types/lib/parsers/largeJson.d.ts.map +1 -0
  294. package/types/lib/parsers/npmrc.d.ts +5 -0
  295. package/types/lib/parsers/npmrc.d.ts.map +1 -1
  296. package/types/lib/parsers/strictJson.d.ts +46 -0
  297. package/types/lib/parsers/strictJson.d.ts.map +1 -0
  298. package/types/lib/parsers/terraformConfig.d.ts +70 -0
  299. package/types/lib/parsers/terraformConfig.d.ts.map +1 -0
  300. package/types/lib/parsers/terraformSource.d.ts +66 -0
  301. package/types/lib/parsers/terraformSource.d.ts.map +1 -0
  302. package/types/lib/server/server.d.ts.map +1 -1
  303. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  304. package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
  305. package/types/lib/validator/bomValidator.d.ts.map +1 -1
  306. package/types/lib/validator/index.d.ts +18 -1
  307. package/types/lib/validator/index.d.ts.map +1 -1
  308. package/types/lib/validator/reporters/console.d.ts.map +1 -1
  309. package/types/lib/validator/reporters/json.d.ts.map +1 -1
  310. package/types/lib/validator/reporters/sarif.d.ts.map +1 -1
  311. package/lib/third-party/arborist/snapshots/calc-dep-flags.test.cjs +0 -462
@@ -10,11 +10,13 @@
10
10
  * read instead of the network.
11
11
  *
12
12
  * There is one policy layer (`fetchRate.js`, mirrored by the Rust `rate.rs`)
13
- * and two transports. When the `cdxrs` binary is available it is preferred,
14
- * because it brings an on-disk conditional cache (D26) the JS pool does not
15
- * have. When it is absent, disabled, or unusable, the JS pool runs every
16
- * request through `cdxgenAgent` so the secure-mode host allowlist, the
17
- * activity recorder and the test cassette interceptor all still apply.
13
+ * and two transports. When the `cdxrs` binary is available it is preferred for
14
+ * the JSON it can carry. When it is absent, disabled, or unusable, and whenever
15
+ * a dry run, secure mode or a host allowlist is in force, the JS pool runs
16
+ * every request through `cdxgenAgent` so those policies, the activity recorder
17
+ * and the test cassette interceptor all still apply. The JS pool keeps the same
18
+ * on-disk conditional cache as cdxrs (`fetchDiskCache.js`), in the same
19
+ * directory and layout.
18
20
  *
19
21
  * Two properties are deliberate and load-bearing:
20
22
  *
@@ -27,11 +29,43 @@
27
29
  * JS on all three registries it covered.
28
30
  *
29
31
  * 2. **Fallback is per URL, not per run.** A URL that the batch could not
30
- * resolve for a transport reason is simply absent from the map, and the
31
- * caller's own `cdxgenAgent.get` runs for it exactly as before. A URL that
32
- * resolved to a definite HTTP error is recorded as such, so the caller does
33
- * not re-request it only to get the same 404.
32
+ * resolve for a transport reason is left to the caller, whose own request
33
+ * goes through {@link gatedGet} and the same per-host gate. A URL the server
34
+ * answered with an error status, after the batch's retries, is recorded as
35
+ * such, so the caller does not ask again only to get the same answer, and a
36
+ * 404 or 410 is remembered for the rest of the run.
34
37
  */
38
+ /**
39
+ * Whether requests to a host are paused.
40
+ *
41
+ * @param {string|null} host Hostname.
42
+ * @returns {boolean}
43
+ */
44
+ export declare function isHostCircuitOpen(host: string | null): boolean;
45
+ /**
46
+ * Pause requests to a host, for at least {@link DEFAULT_CIRCUIT_OPEN_MS} or for
47
+ * as long as the server asked. Warns once per pause.
48
+ *
49
+ * @param {string} host Hostname.
50
+ * @param {{delayMs?: number|null, cause?: string, quiet?: boolean, minimumMs?: number}} [details]
51
+ * Server-supplied delay, a short description of what happened, whether to
52
+ * pause without a warning or a degradation record (for failures that are not
53
+ * the host's doing, such as a dry run or an allowlist block), and the
54
+ * shortest pause, which a host that says exactly when it recovers sets to 0.
55
+ * @returns {void}
56
+ */
57
+ export declare function openHostCircuit(host: string, { delayMs, cause, quiet, minimumMs }?: {
58
+ delayMs?: number | null;
59
+ cause?: string;
60
+ quiet?: boolean;
61
+ minimumMs?: number;
62
+ }): void;
63
+ /**
64
+ * Clear every paused host. Tests only.
65
+ *
66
+ * @returns {void}
67
+ */
68
+ export declare function resetHostCircuits(): void;
35
69
  /**
36
70
  * @returns {Object|null} Stats from the last batch (requests, unique, ok,
37
71
  * failures, cacheHits, elapsedMs, peakConcurrency), or null.
@@ -69,6 +103,11 @@ export type BatchEntry = {
69
103
  * other than 429) and re-requesting it in JS would be pointless.
70
104
  */
71
105
  definite?: boolean;
106
+ /**
107
+ * Response headers of a failed request, when the
108
+ * JS pool made it. cdxrs reports no headers.
109
+ */
110
+ headers?: Object;
72
111
  };
73
112
  /**
74
113
  * Fetch a batch of registry URLs concurrently.
@@ -132,12 +171,40 @@ export declare function recordPolicyDegradationFromError(err: Error): void;
132
171
  * The per-host semaphore and limiter are module state, so this shares one gate
133
172
  * per host for the life of the process.
134
173
  *
174
+ * A host paused by its circuit breaker fails at once with a 429-shaped error,
175
+ * and a 429 from a breaker host pauses it.
176
+ *
177
+ * With `deferGate`, `issue` receives request options carrying a
178
+ * `beforeNetwork` hook and must pass them to `cdxgenAgent`. The rate limiter
179
+ * then runs only when the request misses the response cache, so a cached
180
+ * answer does not wait for a slot. Without it, the limiter runs before
181
+ * `issue`, as before.
182
+ *
135
183
  * @template T
136
184
  * @param {string} url The URL about to be requested.
137
- * @param {() => Promise<T>} issue Issues the request and resolves its result.
185
+ * @param {(gate: Object) => Promise<T>} issue Issues the request and resolves its result.
186
+ * @param {{deferGate?: boolean}} [opts]
138
187
  * @returns {Promise<T>} Whatever `issue` resolves to.
139
188
  */
140
- export declare function withHostRateLimit<T>(url: string, issue: () => Promise<T>): Promise<T>;
189
+ export declare function withHostRateLimit<T>(url: string, issue: (gate: Object) => Promise<T>, { deferGate }?: {
190
+ deferGate?: boolean;
191
+ }): Promise<T>;
192
+ /**
193
+ * Request a URL the batch did not answer, the way the pool would have: behind
194
+ * the per-host gate, failing at once for a document that already answered 404
195
+ * or 410 this run, and remembering such an answer for the next pass.
196
+ *
197
+ * This is the fallback every metadata function uses after a prefetch. Without
198
+ * it, a URL the batch left open went straight to the network with no rate gate,
199
+ * and the same miss was asked again on every pass.
200
+ *
201
+ * @param {string} url URL to request.
202
+ * @param {Object} [options] `cdxgenAgent.get` options.
203
+ * @returns {Promise<Object>} The response.
204
+ * @throws {Error} The request's own error, or a 404-shaped error for a
205
+ * remembered miss, so the caller's `catch` runs as it would for the network.
206
+ */
207
+ export declare function gatedGet(url: string, options?: Object): Promise<Object>;
141
208
  /**
142
209
  * Read a prefetched response, or signal that the caller should fetch it itself.
143
210
  *
@@ -145,9 +212,11 @@ export declare function withHostRateLimit<T>(url: string, issue: () => Promise<T
145
212
  * @param {string} url The URL the caller is about to request.
146
213
  * @returns {{body: *}|undefined} A response-shaped object when the body is
147
214
  * available, or `undefined` when the caller should issue its own request.
148
- * @throws {Error} When the batch established a definite HTTP error for this
149
- * URL, so that the caller's existing `catch` treats it exactly as it treats a
150
- * failed `cdxgenAgent.get`.
215
+ * @throws {Error} When the server answered with an error status, so that the
216
+ * caller's existing `catch` treats it exactly as it treats a failed
217
+ * `cdxgenAgent.get`. A 5xx or a 429 is the answer after the batch's own
218
+ * retries, and asking once more at once would only add to the load. Only a
219
+ * transport failure, with no status, is left to the caller to retry.
151
220
  */
152
221
  export declare function prefetchedResponse(prefetched: Map<string, BatchEntry>, url: string): {
153
222
  body: any;
@@ -1 +1 @@
1
- {"version":3,"file":"fetchBatch.d.ts","sourceRoot":"","sources":["../../../lib/inventory/fetchBatch.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AA8EH;;;GAGG;AACH,wBAAgB,cAAc,IAHjB,MAAM,GAAC,IAAI,CAKvB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAFtB,OAAO,CASnB;AAED;;;GAGG;AACH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H,wBAAgB,kBAAkB,CAAC,UAAU,EAVlC,GAAG,CAAC,MAAM,EAAE,UAAU,CAUY,EAAE,GAAG,EATvC,MASuC,GARrC;IAAC,IAAI,EAAE,GAAC,CAAA;CAAC,GAAC,SAAS,CAoB/B;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,IAFlB,OAAO,CAOnB"}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * The on-disk response cache of the JS batch pool.
3
+ *
4
+ * cdxrs keeps registry JSON on disk between runs. The requests it cannot carry
5
+ * run on the JS pool instead: crates.io and package.elm-lang.org, which have
6
+ * one rate gate in JS; the GitHub API, whose quota headers cdxrs does not
7
+ * report; HTML pages such as pkg.go.dev and podspecs; and POMs. Without a disk
8
+ * cache of their own, the most tightly limited hosts were asked again on every
9
+ * run. All of them are kept here, in the cdxrs layout and under the same rules:
10
+ *
11
+ * - `<cacheDir>/cdxrs-fetch/<host>/<hash>.json`, written atomically, mode 0600,
12
+ * with the URL redacted;
13
+ * - keyed by URL, method, `Accept` and the auth realm, hashed as cdxrs hashes
14
+ * them, so a JSON entry either side writes serves the other. A text body adds
15
+ * its type to the key, so cdxrs never reads it as JSON;
16
+ * - fresh for `CDXGEN_CACHE_TTL` seconds (24 hours by default, 0 for never);
17
+ * a stale entry with an ETag or Last-Modified is revalidated, and is served
18
+ * when the server fails;
19
+ * - loopback hosts are not cached unless `CDXGEN_CACHE_LOOPBACK=1`;
20
+ * - least recently used entries are removed past 256 MB.
21
+ *
22
+ * Two rules are the JS pool's own. A release POM never changes once published,
23
+ * so it does not expire. A 404 or 410 is kept for the same TTL, or for 24
24
+ * hours when the TTL is 0, under a key of its own that cdxrs never reads.
25
+ *
26
+ * Requests that carry their own headers, such as a registry token, are never
27
+ * cached here, and nothing is read or written during a dry run, for a host
28
+ * outside `CDXGEN_ALLOWED_HOSTS`, or over plain HTTP in secure mode, so the
29
+ * cache never answers a request the policy would have refused. The directory
30
+ * is cdxgen's own, and its files are written as cdxrs writes them, without an
31
+ * activity record per entry.
32
+ */
33
+ export type DiskCacheKey = {
34
+ /**
35
+ * Request URL.
36
+ */
37
+ url: string;
38
+ /**
39
+ * `Accept` header.
40
+ */
41
+ accept?: string;
42
+ /**
43
+ * Identity of the credential, never itself.
44
+ */
45
+ authRealm?: string;
46
+ /**
47
+ * `json`, `text` or `buffer`.
48
+ */
49
+ responseType?: string;
50
+ };
51
+ export type DiskCacheEntry = {
52
+ /**
53
+ * Schema version.
54
+ */
55
+ v: number;
56
+ /**
57
+ * Redacted URL.
58
+ */
59
+ url: string;
60
+ /**
61
+ * Always `GET`.
62
+ */
63
+ method: string;
64
+ /**
65
+ * HTTP status.
66
+ */
67
+ status: number;
68
+ /**
69
+ * ETag validator.
70
+ */
71
+ etag: string | null;
72
+ /**
73
+ * Last-Modified validator.
74
+ */
75
+ last_modified: string | null;
76
+ /**
77
+ * Unix seconds when fetched or revalidated.
78
+ */
79
+ fetched_at: number;
80
+ /**
81
+ * Response body.
82
+ */
83
+ body: any;
84
+ /**
85
+ * Never expires.
86
+ */
87
+ immutable?: boolean;
88
+ };
89
+ /**
90
+ * Hash of a cache key, as cdxrs computes it for a JSON response.
91
+ *
92
+ * @param {DiskCacheKey} key Cache key.
93
+ * @param {{miss?: boolean}} [opts] Whether this is the key of a recorded miss.
94
+ * @returns {string}
95
+ */
96
+ export declare function diskCacheKeyHash(key: DiskCacheKey, { miss }?: {
97
+ miss?: boolean;
98
+ }): string;
99
+ /**
100
+ * Whether the disk cache may serve or store a request.
101
+ *
102
+ * @param {{url: string, headers?: Object, responseType?: string}} request
103
+ * @returns {boolean}
104
+ */
105
+ export declare function diskCacheable(request: {
106
+ url: string;
107
+ headers?: Object;
108
+ responseType?: string;
109
+ }): boolean;
110
+ export type DiskCacheLookup = {
111
+ /**
112
+ * `fresh` and `miss` are
113
+ * answers; `stale` needs revalidation; `none` means nothing is stored.
114
+ */
115
+ state: "fresh" | "stale" | "miss" | "none";
116
+ /**
117
+ * The stored entry.
118
+ */
119
+ entry?: DiskCacheEntry;
120
+ };
121
+ /**
122
+ * @typedef {Object} DiskCacheLookup
123
+ * @property {"fresh"|"stale"|"miss"|"none"} state `fresh` and `miss` are
124
+ * answers; `stale` needs revalidation; `none` means nothing is stored.
125
+ * @property {DiskCacheEntry} [entry] The stored entry.
126
+ */
127
+ /**
128
+ * Look a request up.
129
+ *
130
+ * @param {DiskCacheKey} key Cache key.
131
+ * @returns {DiskCacheLookup}
132
+ */
133
+ export declare function diskCacheGet(key: DiskCacheKey): DiskCacheLookup;
134
+ /**
135
+ * Store a successful response.
136
+ *
137
+ * @param {DiskCacheKey} key Cache key.
138
+ * @param {{statusCode: number, headers?: Object, body: *}} response Response.
139
+ * @returns {void}
140
+ */
141
+ export declare function diskCachePut(key: DiskCacheKey, response: {
142
+ statusCode: number;
143
+ headers?: Object;
144
+ body: any;
145
+ }): void;
146
+ /**
147
+ * Record that a request answered 404 or 410, and forget any body stored for it.
148
+ *
149
+ * @param {DiskCacheKey} key Cache key.
150
+ * @param {number} status HTTP status.
151
+ * @returns {void}
152
+ */
153
+ export declare function diskCachePutMiss(key: DiskCacheKey, status: number): void;
154
+ /**
155
+ * Mark a stale entry fresh again after a 304.
156
+ *
157
+ * @param {DiskCacheKey} key Cache key.
158
+ * @param {DiskCacheEntry} entry The stale entry.
159
+ * @param {Object} [headers] Headers of the 304, which may carry new validators.
160
+ * @returns {void}
161
+ */
162
+ export declare function diskCacheRefresh(key: DiskCacheKey, entry: DiskCacheEntry, headers?: Object): void;
163
+ /**
164
+ * Forget which host directories were swept. Tests only.
165
+ *
166
+ * @returns {void}
167
+ */
168
+ export declare function resetDiskCacheState(): void;
169
+ //# sourceMappingURL=fetchDiskCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchDiskCache.d.ts","sourceRoot":"","sources":["../../../lib/inventory/fetchDiskCache.js"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAgDA,YAAkB,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gB,YAAY,CAAC,GAAG,EAJrB,YAIqB,EAAE,QAAQ,EAH/B;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAC,CAAA;CAGf,GAF7B,IAAI,CAwBhB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAJzB,YAIyB,EAAE,MAAM,EAHjC,MAGiC,GAF/B,IAAI,CAqBhB;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EALzB,YAKyB,EAAE,KAAK,EAJhC,cAIgC,EAAE,OAAO,AAHjD,CACA,EADQ,MAG8C,GAF5C,IAAI,CAahB;AAyGD;;;;GAIG;AACH,wBAAgB,mBAAmB,IAFtB,IAAI,CAKhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"forgeEnricher.d.ts","sourceRoot":"","sources":["../../../lib/inventory/forgeEnricher.js"],"names":[],"mappings":"AAkDA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAHvB,MAGuB,GAFrB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAC,IAAI,CAa9C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAHvB,MAGuB,GAFrB,MAAM,GAAC,IAAI,CAWvB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAL9B,MAK8B,EAAE,SAAS,EAJzC,KAAK,CAAC,MAAM,CAI6B,EAAE,OAAO,GAHlD,MAGuD,GAFrD,OAAO,CAAC,MAAM,CAAC,CA4M3B"}
1
+ {"version":3,"file":"forgeEnricher.d.ts","sourceRoot":"","sources":["../../../lib/inventory/forgeEnricher.js"],"names":[],"mappings":"AA2DA;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAHvB,MAGuB,GAFrB;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAC,IAAI,CAa9C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAHvB,MAGuB,GAFrB,MAAM,GAAC,IAAI,CAWvB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAL9B,MAK8B,EAAE,SAAS,EAJzC,KAAK,CAAC,MAAM,CAI6B,EAAE,OAAO,GAHlD,MAGuD,GAFrD,OAAO,CAAC,MAAM,CAAC,CA4M3B"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Forget every memoised lookup. A long-lived process (server mode) calls this
3
+ * per scan so that artifacts a build downloaded in the meantime are found, and
4
+ * tests call it after changing the cache environment variables.
5
+ *
6
+ * @returns {void}
7
+ */
8
+ export declare function resetJvmLocalRepoCaches(): void;
9
+ /**
10
+ * Read `<localRepository>` from a Maven settings file.
11
+ *
12
+ * @param {string} settingsFile Path to settings.xml.
13
+ * @returns {string|undefined} Absolute local repository path.
14
+ */
15
+ export declare function localRepositoryFromSettings(settingsFile: string): string | undefined;
16
+ /**
17
+ * Pull the values cdxgen needs out of a Maven argument list: the
18
+ * `maven.repo.local` system property and the user settings file.
19
+ *
20
+ * @param {string[]} args Parsed arguments.
21
+ * @param {string} [baseDir] Directory relative paths resolve against.
22
+ * @returns {{repoLocal?: string, settingsFile?: string}}
23
+ */
24
+ export declare function mavenRepoArgs(args: string[], baseDir?: string): {
25
+ repoLocal?: string;
26
+ settingsFile?: string;
27
+ };
28
+ /**
29
+ * The arguments that hand a scanned project's own `settings.xml` to Maven.
30
+ *
31
+ * The file is passed as global settings (`-gs`), so the user's
32
+ * `~/.m2/settings.xml` still applies and wins on mirrors, servers and proxies.
33
+ * Nothing is added, and `skipped` says why, in secure mode, where a scanned
34
+ * repository must not choose Maven's repositories, proxies or credentials, or
35
+ * when MVN_ARGS or MAVEN_ARGS already names a settings file.
36
+ *
37
+ * @param {string} projectDir Directory holding the project's pom.xml.
38
+ * @param {{secureMode?: boolean}} [opts]
39
+ * @returns {{settingsFile?: string, args: string[], skipped?: "secure-mode"|"user-settings"}}
40
+ */
41
+ export declare function projectSettingsArgs(projectDir: string, { secureMode }?: {
42
+ secureMode?: boolean;
43
+ }): {
44
+ settingsFile?: string;
45
+ args: string[];
46
+ skipped?: "secure-mode" | "user-settings";
47
+ };
48
+ /**
49
+ * Every Maven local repository this run may have populated, most specific
50
+ * first: MAVEN_CACHE_DIR, then an explicit `-Dmaven.repo.local` (from
51
+ * MVN_ARGS, MAVEN_ARGS, MAVEN_OPTS or the project's `.mvn/maven.config`), then
52
+ * `<localRepository>` from the settings Maven would read, then
53
+ * `~/.m2/repository`.
54
+ *
55
+ * @param {Object} [opts]
56
+ * @param {string} [opts.projectDir] Project directory, for `.mvn/maven.config`.
57
+ * @returns {string[]} Absolute paths. Not filtered for existence.
58
+ */
59
+ export declare function mavenLocalRepositories({ projectDir }?: {
60
+ projectDir?: string;
61
+ }): string[];
62
+ /**
63
+ * Gradle module cache directories (`.../modules-2/files-2.1`): the one under
64
+ * GRADLE_USER_HOME, the cdxgen-specific GRADLE_CACHE_DIR, the default
65
+ * `~/.gradle` when neither is set, and the read-only shared cache named by
66
+ * GRADLE_RO_DEP_CACHE.
67
+ *
68
+ * @returns {string[]} Absolute paths. Not filtered for existence.
69
+ */
70
+ export declare function gradleCacheRoots(): string[];
71
+ /**
72
+ * The Coursier cache directory used by sbt, Mill and scala-cli: COURSIER_CACHE
73
+ * when set, otherwise the platform default (XDG_CACHE_HOME is honoured on
74
+ * Linux).
75
+ *
76
+ * @returns {string|undefined} Absolute path. Not checked for existence.
77
+ */
78
+ export declare function coursierCacheDir(): string | undefined;
79
+ /**
80
+ * Convert a Coursier repository prefix into the repository URL it caches.
81
+ *
82
+ * @param {string[]} parts Prefix segments relative to the cache root.
83
+ * @returns {string|null} Repository URL.
84
+ */
85
+ export declare function coursierPrefixToUrl(parts: string[]): string | null;
86
+ /**
87
+ * Locate a Maven coordinate's directory in the Coursier cache.
88
+ *
89
+ * @param {string} group Maven groupId.
90
+ * @param {string} name Maven artifactId, including any Scala suffix.
91
+ * @param {string} version Version.
92
+ * @returns {{repoUrl: string, dir: string}|null} Repository URL and directory.
93
+ */
94
+ export declare function locateInCoursierCache(group: string, name: string, version: string): {
95
+ repoUrl: string;
96
+ dir: string;
97
+ } | null;
98
+ /**
99
+ * Locate a Maven artifact and its POM in the local caches.
100
+ *
101
+ * Only the exact file names Maven, Gradle and Coursier use are accepted, so a
102
+ * classifier jar (`-sources`, `-javadoc`, `-linux-x86_64`) is never mistaken
103
+ * for the main artifact. Results, including misses, are memoised until
104
+ * {@link resetJvmLocalRepoCaches}.
105
+ *
106
+ * @param {string} group Maven groupId.
107
+ * @param {string} name Maven artifactId.
108
+ * @param {string} version Version.
109
+ * @param {Object} [opts]
110
+ * @param {string} [opts.classifier] Classifier of the wanted jar.
111
+ * @param {string} [opts.extension] Artifact extension. Defaults to jar.
112
+ * @param {string} [opts.projectDir] Project directory, for `.mvn/maven.config`.
113
+ * @returns {{jarPath?: string, pomPath?: string, sha1?: string, repoUrl?: string}|null}
114
+ */
115
+ export declare function findLocalMavenArtifact(group: string, name: string, version: string, opts?: {
116
+ classifier?: string;
117
+ extension?: string;
118
+ projectDir?: string;
119
+ }): {
120
+ jarPath?: string;
121
+ pomPath?: string;
122
+ sha1?: string;
123
+ repoUrl?: string;
124
+ } | null;
125
+ /**
126
+ * Split an artifact file name into its classifier and extension, given the
127
+ * artifactId and version it belongs to.
128
+ *
129
+ * @param {string} fileName File name, for example `netty-4.1.1-linux.jar`.
130
+ * @param {string} name artifactId.
131
+ * @param {string} version Version.
132
+ * @returns {{classifier: string, extension: string}|undefined} Undefined when
133
+ * the name does not belong to the coordinate.
134
+ */
135
+ export declare function splitArtifactFileName(fileName: string, name: string, version: string): {
136
+ classifier: string;
137
+ extension: string;
138
+ } | undefined;
139
+ /**
140
+ * Infer Maven coordinates from where an artifact sits on disk.
141
+ *
142
+ * Paths inside a configured Maven repository or Gradle cache are read by
143
+ * their layout. Paths elsewhere are recognised by the conventional
144
+ * `.m2/repository` and `files-2.1` segments, so a copied cache still works. A
145
+ * Coursier path is resolved through its sibling POM, because the repository
146
+ * prefix and the group path cannot be told apart from the path alone.
147
+ *
148
+ * @param {string} filePath Absolute path of a jar or other artifact.
149
+ * @returns {{group: string, name: string, version: string, classifier: string, extension: string, sha1?: string}|undefined}
150
+ */
151
+ export declare function inferMavenCoordinatesFromPath(filePath: string): {
152
+ group: string;
153
+ name: string;
154
+ version: string;
155
+ classifier: string;
156
+ extension: string;
157
+ sha1?: string;
158
+ } | undefined;
159
+ /**
160
+ * Look up the Maven coordinates of a jar by its SHA-1 in the local caches.
161
+ *
162
+ * The index is built once, on first use, from the Gradle module cache (whose
163
+ * directory names are SHA-1s) and from the `*.jar.sha1` files Maven writes
164
+ * next to every downloaded jar. It answers the question cdxgen would otherwise
165
+ * send to the Maven Central search API.
166
+ *
167
+ * @param {string} sha1 Hex SHA-1 of the jar.
168
+ * @returns {{group: string, name: string, version: string, classifier: string, extension: string, path: string}|undefined}
169
+ */
170
+ export declare function findMavenCoordinatesBySha1(sha1: string): {
171
+ group: string;
172
+ name: string;
173
+ version: string;
174
+ classifier: string;
175
+ extension: string;
176
+ path: string;
177
+ } | undefined;
178
+ //# sourceMappingURL=jvmLocalRepos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jvmLocalRepos.d.ts","sourceRoot":"","sources":["../../../lib/inventory/jvmLocalRepos.js"],"names":[],"mappings":"AA2CA;;;;;;GAMG;AACH,wBAAgB,uBAAuB,IAF1B,IAAI,CAShB;AAuDD;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,YAAY,EAH7C,MAG6C,GAF3C,MAAM,GAAC,SAAS,CAkC5B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAJvB,MAAM,EAIiB,EAAE,OAAO,AAHxC,CACA,EADQ,MAGgD,GAF9C;IAAC,SAAS,CAAC,EAAE,M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AAE,CAAC;IAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG;QAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAC,CAAA;CAiD9H,CAAC"}
1
+ {"version":3,"file":"mcpConfigParser.d.ts","sourceRoot":"","sources":["../../../lib/inventory/mcpConfigParser.js"],"names":[],"mappings":"AAmxBA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAFlB;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG;QAAC,UAAU,EAAE,MAAM,EAAE,CAAC;QAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAC,CAAA;CAiD9H,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Which detected project becomes the parent (`metadata.component`) when one
3
+ * scan covers several ecosystems and no parent was given.
4
+ *
5
+ * Each ecosystem detects its own project from its own manifest. The project
6
+ * whose manifest sits at the scan root describes the repository; one found
7
+ * deeper is a part of it (a web client in `tools/ui/`, a helper script's
8
+ * `pyproject.toml`). So candidates are ordered by how deep their ecosystem's
9
+ * manifests sit, the scan root first, and ties keep the ecosystem order the
10
+ * scan ran in.
11
+ */
12
+ /**
13
+ * How deep the shallowest manifest of an ecosystem sits under a scan root:
14
+ * 0 for one at the root itself, `Infinity` when there is none (or the
15
+ * ecosystem is not one this module knows).
16
+ *
17
+ * @param {string} root Scan root
18
+ * @param {string} purlType Purl type of the ecosystem
19
+ * @param {Object} options CLI options (exclusions)
20
+ * @returns {number}
21
+ */
22
+ export declare function manifestDepth(root: string, purlType: string, options?: Object): number;
23
+ /**
24
+ * Order parent candidates by the depth of their ecosystem's manifests under
25
+ * the scan roots (the shallowest first). The sort is stable, so candidates of
26
+ * equal depth keep the order the ecosystems were scanned in.
27
+ *
28
+ * @param {Object[]} candidates Detected parent components, in scan order
29
+ * @param {string[]} roots Scan roots
30
+ * @param {Object} options CLI options
31
+ * @returns {Object[]} The candidates, reordered
32
+ */
33
+ export declare function orderParentCandidates(candidates: Object[], roots: string[], options?: Object): Object[];
34
+ //# sourceMappingURL=parentSelection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parentSelection.d.ts","sourceRoot":"","sources":["../../../lib/inventory/parentSelection.js"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA8DH;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EALvB,MAKuB,EAAE,QAAQ,EAJjC,MAIiC,EAAE,OAAO,GAH1C,MAG+C,GAF7C,MAAM,CA2BlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,UAAU,EALrC,MAAM,EAK+B,EAAE,KAAK,EAJ5C,MAAM,EAIsC,EAAE,OAAO,GAHrD,MAG0D,GAFxD,MAAM,EAAE,CA4BpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","sourceRoot":"","sources":["../../../lib/inventory/plugins.js"],"names":[],"mappings":"AAiDA;;;;GAIG;AACH,wBAAgB,mBAAmB,IAFtB;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAC,CAgCpF;AA8DD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,oBAAoB,IAXvB;IACR,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,MAAM,GAAC,SAAS,CAAC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,GAAC,SAAS,CAAC;IACrC,aAAa,EAAE,MAAM,GAAC,SAAS,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB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AF9C,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAWnD;AAyDD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAJjC,MAIiC,EAAE,aAAa,AAHxD,CACA,EADQ,UAAU,CAAC,OAAO,oBAAoB,CAGsB,GAF1D,MAAM,GAAC,SAAS,CAS5B"}
@@ -1 +1 @@
1
- {"version":3,"file":"protobom.d.ts","sourceRoot":"","sources":["../../../lib/inventory/protobom.js"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,cAAc,EAAE,CAAC;AAsB1B;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,gBAH7B,MAAM,GAAC,SAAS,KACd,OAGgE,CAAC;AAE9E;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,gBAHjC,MAAM,GAAC,SAAS,cAChB,MAAM,SAYhB,CAAC;AAgCF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,YAJb,MAAM,GAAG,MAAM,WACf,MAAM,gBACN,MAAM,GAAG,MAAM,SAezB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,YAJZ,MAAM,UACN,OAAO,gBACP,MAAM,GAAG,MAAM,4FAiBzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,YAJb,MAAM,GAAG,MAAM,gBACf,MAAM,GAAG,MAAM,KACb,MAKV,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,YALvB,MAAM,GAAG,MAAM,qBACf,MAAM,GAAG,MAAM,gBACf,MAAM,GAAG,MAAM,KACb;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAahD,CAAC"}
1
+ {"version":3,"file":"protobom.d.ts","sourceRoot":"","sources":["../../../lib/inventory/protobom.js"],"names":[],"mappings":"AAaA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAIxD,OAAO,EAAE,cAAc,EAAE,CAAC;AAsB1B;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,gBAH7B,MAAM,GAAC,SAAS,KACd,OAGgE,CAAC;AAE9E;;;;;;;;;GASG;AACH,eAAO,MAAM,+BAA+B,gBAHjC,MAAM,GAAC,SAAS,cAChB,MAAM,SAYhB,CAAC;AAgCF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,YAJb,MAAM,GAAG,MAAM,WACf,MAAM,gBACN,MAAM,GAAG,MAAM,SAezB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,YAJZ,MAAM,UACN,OAAO,gBACP,MAAM,GAAG,MAAM,4FAwBzB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,YAJb,MAAM,GAAG,MAAM,gBACf,MAAM,GAAG,MAAM,KACb,MAKV,CAAC;AAEJ;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,qBAAqB,YALvB,MAAM,GAAG,MAAM,qBACf,MAAM,GAAG,MAAM,gBACf,MAAM,GAAG,MAAM,KACb;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAahD,CAAC"}
@@ -35,8 +35,17 @@ export declare function purlTypeIsRegistered(type: string): boolean;
35
35
  */
36
36
  export declare function purlTypeIsRegisteredString(purlString: string): boolean;
37
37
  /**
38
- * Encode a string for safe inclusion in a PackageURL, percent-encoding special characters
39
- * while preserving already-encoded `%40` sequences and keeping `:` and `/` unencoded.
38
+ * Encode a string for inclusion in a hand-written PackageURL string,
39
+ * percent-encoding every character the purl grammar does not allow literally,
40
+ * while preserving already-encoded `%40` sequences and keeping `:` and `/`
41
+ * unencoded.
42
+ *
43
+ * `encodeURIComponent` alone leaves `!`, `'`, `(`, `)` and `*` literal, and the
44
+ * purl grammar requires them escaped, so they are escaped here as well.
45
+ *
46
+ * Only for comparing against or assembling purl text. Never pass the result to
47
+ * `build()`, `new Purl()` or one of the helpers in this module: they escape
48
+ * their inputs themselves, and escaping twice turns `+` into `%252B`.
40
49
  *
41
50
  * @param {string} s String to encode
42
51
  * @returns {string} Encoded string suitable for use in a PackageURL component
@@ -195,6 +204,66 @@ export declare function genericPurl(name: string): string | null;
195
204
  * @returns {boolean} true when cdx-purl parses it
196
205
  */
197
206
  export declare function isValidPurl(candidate: string): boolean;
207
+ /**
208
+ * Split a purl into its components without requiring it to be well-formed.
209
+ *
210
+ * `Purl.parse` rejects a purl whose parts are not already escaped, which is the
211
+ * case this exists to handle: a `bom-ref` (cdxgen writes the decoded form of the
212
+ * purl there), a `go mod graph` token such as `github.com/Azure/go-autorest@v14.2.0+incompatible`,
213
+ * or a purl from a third-party document that left a `+` or a `://` unescaped.
214
+ * The separators (`:`, `/`, `@`, `?`, `#`, `&`, `=`) are structural and are read
215
+ * positionally; everything between them is decoded and handed back raw, ready
216
+ * for `build` to escape correctly.
217
+ *
218
+ * The version is taken after the last `@` of the path, so a scoped npm name
219
+ * (`@scope/name@1.0.0`) and a composer branch version (`dev-feature/x`) both
220
+ * split correctly.
221
+ *
222
+ * @param {string} purl Purl to split
223
+ * @returns {{type: string, namespace: (string|null), name: string, version: (string|null), qualifiers: (Object|null), subpath: (string|null)}|null} Parts, or null when the purl has no type and name
224
+ */
225
+ export declare function splitPurlLoose(purl: string): {
226
+ type: string;
227
+ namespace: (string | null);
228
+ name: string;
229
+ version: (string | null);
230
+ qualifiers: (Object | null);
231
+ subpath: (string | null);
232
+ } | null;
233
+ /**
234
+ * Parse a purl string that may carry unescaped reserved characters.
235
+ *
236
+ * A well-formed purl is parsed strictly, so its components come back exactly as
237
+ * cdx-purl reads them. Anything else is split structurally by
238
+ * {@link splitPurlLoose}. Use this where the input is known to be a decoded or
239
+ * hand-written purl (a `bom-ref`, a workspace reference, a package manager's
240
+ * `name@version` token), never to accept an invalid purl into a `purl` field:
241
+ * pass the parts to `build()` instead, which escapes them.
242
+ *
243
+ * @param {string} purlString Purl or decoded purl
244
+ * @returns {{type: string, namespace: (string|null), name: string, version: (string|null), qualifiers: (Object|null), subpath: (string|null)}|null} Raw components, or null when nothing purl-shaped remains
245
+ */
246
+ export declare function parsePurlLoose(purlString: string): {
247
+ type: string;
248
+ namespace: (string | null);
249
+ name: string;
250
+ version: (string | null);
251
+ qualifiers: (Object | null);
252
+ subpath: (string | null);
253
+ } | null;
254
+ /**
255
+ * Turn a decoded or hand-written purl into a canonical, correctly escaped one.
256
+ *
257
+ * `bom-ref` values are the decoded form of a purl
258
+ * (`pkg:npm/foo@1.0.0+build`), which cdx-purl rightly rejects as a purl. This
259
+ * recovers the purl the ref was made from by splitting it structurally and
260
+ * rebuilding it with `build()`, so every reserved character is escaped exactly
261
+ * once.
262
+ *
263
+ * @param {string} purlString Purl or decoded purl
264
+ * @returns {string|null} Canonical purl string, or `null` when no valid purl can be built
265
+ */
266
+ export declare function canonicalPurlFromLooseString(purlString: string): string | null;
198
267
  /**
199
268
  * Parse a purl string, returning `null` instead of throwing when it is invalid.
200
269
  *