@cdxgen/cdxgen 13.3.0 → 13.5.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 (372) hide show
  1. package/README.md +12 -9
  2. package/bin/cdxgen-secure.js +15 -0
  3. package/bin/cdxgen.js +115 -31
  4. package/bin/evinse.js +23 -1
  5. package/bin/hbom.js +15 -7
  6. package/bin/repl.js +115 -0
  7. package/bin/sign.js +45 -15
  8. package/bin/tracebom.js +5 -1
  9. package/bin/validate.js +84 -18
  10. package/bin/verify.js +155 -86
  11. package/data/cbomosdb-queries.json +13 -1
  12. package/data/component-tags.json +8 -0
  13. package/data/helpers/init.gradle +46 -21
  14. package/data/queries-darwin.json +25 -1
  15. package/data/queries-win.json +19 -1
  16. package/data/queries.json +41 -0
  17. package/data/remediations.json +344 -1
  18. package/data/rules/cbom-security.yaml +235 -4
  19. package/data/rules/dependency-sources.yaml +67 -0
  20. package/data/rules/go-binaries.yaml +46 -0
  21. package/data/rules/golem-go.yaml +80 -0
  22. package/data/rules/hbom-compliance.yaml +40 -22
  23. package/data/rules/hbom-performance.yaml +7 -1
  24. package/data/rules/host-topology.yaml +1 -1
  25. package/data/rules/obom-runtime.yaml +31 -2
  26. package/data/rules/php-runtime.yaml +143 -0
  27. package/data/rules/scala-evidence.yaml +115 -0
  28. package/lib/audit/index.js +52 -6
  29. package/lib/cli/bomAssembly.js +28 -3
  30. package/lib/cli/cliOptions.js +110 -3
  31. package/lib/cli/index.js +186 -58
  32. package/lib/cli/jsBom.js +50 -29
  33. package/lib/cli/jvmBom.js +779 -146
  34. package/lib/cli/managedBom.js +1021 -261
  35. package/lib/cli/nativeBom.js +364 -58
  36. package/lib/core/activity.js +12 -0
  37. package/lib/core/env.js +47 -17
  38. package/lib/core/fs.js +31 -21
  39. package/lib/core/httpClient.js +233 -69
  40. package/lib/core/pluginRun.js +184 -0
  41. package/lib/core/processTree.js +100 -0
  42. package/lib/core/projectConfig.js +1 -0
  43. package/lib/core/projectTooling.js +97 -0
  44. package/lib/core/propertySanitizer.js +72 -0
  45. package/lib/core/runState.js +39 -0
  46. package/lib/core/toml.js +72 -0
  47. package/lib/ecosystems/asarutils.js +4 -2
  48. package/lib/ecosystems/bunutils.js +5 -7
  49. package/lib/ecosystems/cargoCache.js +231 -8
  50. package/lib/ecosystems/cmakeResolver.js +10 -21
  51. package/lib/ecosystems/cppBuildContext.js +631 -0
  52. package/lib/ecosystems/cppEvidence.js +337 -22
  53. package/lib/ecosystems/cppIncludeResolver.js +294 -0
  54. package/lib/ecosystems/denoutils.js +93 -66
  55. package/lib/ecosystems/ecosystems.js +1967 -788
  56. package/lib/ecosystems/golem.js +578 -18
  57. package/lib/ecosystems/gradleutils.js +340 -46
  58. package/lib/ecosystems/jsEvidence.js +85 -24
  59. package/lib/ecosystems/kosi.js +21 -4
  60. package/lib/ecosystems/npmutils.js +64 -0
  61. package/lib/ecosystems/parsers-dotnet.js +668 -153
  62. package/lib/ecosystems/parsers-elm.js +46 -28
  63. package/lib/ecosystems/parsers-gleam.js +3 -4
  64. package/lib/ecosystems/parsers-go.js +1283 -297
  65. package/lib/ecosystems/parsers-js.js +92 -26
  66. package/lib/ecosystems/parsers-julia.js +2 -3
  67. package/lib/ecosystems/parsers-jvm.js +463 -29
  68. package/lib/ecosystems/parsers-misc.js +405 -93
  69. package/lib/ecosystems/parsers-python.js +152 -20
  70. package/lib/ecosystems/parsers-rust.js +4 -4
  71. package/lib/ecosystems/parsers-terraform.js +1573 -19
  72. package/lib/ecosystems/pythonutils.js +102 -6
  73. package/lib/ecosystems/remote/huggingface.js +3 -0
  74. package/lib/ecosystems/rubyutils.js +73 -20
  75. package/lib/ecosystems/rusi.js +32 -9
  76. package/lib/ecosystems/sbtutils.js +243 -187
  77. package/lib/ecosystems/scalacliutils.js +343 -0
  78. package/lib/ecosystems/scalasem.js +2620 -0
  79. package/lib/ecosystems/terraformRegistry.js +288 -0
  80. package/lib/ecosystems/utils.js +2 -0
  81. package/lib/ecosystems/vendoredCode.js +156 -0
  82. package/lib/evinser/evinser.js +695 -78
  83. package/lib/evinser/swiftsem.js +68 -5
  84. package/lib/helpers/agenticToolutils.js +2 -2
  85. package/lib/helpers/bomSigner.js +576 -128
  86. package/lib/inventory/agentSkillSpec.js +17 -0
  87. package/lib/inventory/aiCollector.js +4 -1
  88. package/lib/inventory/analyzer.js +110 -127
  89. package/lib/inventory/apkInstalledDb.js +243 -0
  90. package/lib/inventory/atomUtils.js +204 -48
  91. package/lib/inventory/auditCategories.js +10 -3
  92. package/lib/inventory/buildToolRateLimit.js +144 -0
  93. package/lib/inventory/cacheCommands.js +2 -1
  94. package/lib/inventory/cacheDir.js +52 -9
  95. package/lib/inventory/certificates.js +2371 -0
  96. package/lib/inventory/cmakeBuildDirs.js +254 -0
  97. package/lib/inventory/communityAiConfigParser.js +4 -9
  98. package/lib/inventory/deps.js +507 -128
  99. package/lib/inventory/display.js +200 -3
  100. package/lib/inventory/dosai.js +747 -101
  101. package/lib/inventory/dosaiParsers.js +310 -15
  102. package/lib/inventory/dynamic.js +96 -8
  103. package/lib/inventory/envcontext.js +168 -5
  104. package/lib/inventory/evidenceUtils.js +590 -132
  105. package/lib/inventory/fetchBatch.js +574 -38
  106. package/lib/inventory/fetchDiskCache.js +597 -0
  107. package/lib/inventory/forgeEnricher.js +14 -5
  108. package/lib/inventory/formulationParsers.js +3 -2
  109. package/lib/inventory/goBuildInfo.js +140 -0
  110. package/lib/inventory/hbom.js +67 -7
  111. package/lib/inventory/hbomAnalysis.js +16 -0
  112. package/lib/inventory/hostTopology.js +21 -0
  113. package/lib/inventory/jvmLocalRepos.js +917 -0
  114. package/lib/inventory/mcpConfigParser.js +2 -3
  115. package/lib/inventory/osPackagePurl.js +244 -0
  116. package/lib/inventory/osPackageResolver.js +89 -87
  117. package/lib/inventory/osinfo.js +79 -31
  118. package/lib/inventory/osqueryTransform.js +114 -5
  119. package/lib/inventory/parentSelection.js +146 -0
  120. package/lib/inventory/phpBuildInfo.js +487 -0
  121. package/lib/inventory/phpHostProbe.js +641 -0
  122. package/lib/inventory/rootfsCerts.js +426 -0
  123. package/lib/inventory/rustFormulationParser.js +3 -4
  124. package/lib/inventory/scalaCoords.js +153 -0
  125. package/lib/inventory/source.js +215 -11
  126. package/lib/inventory/spdx.js +245 -0
  127. package/lib/inventory/traceRunner.js +93 -8
  128. package/lib/inventory/tracedCrypto.js +423 -0
  129. package/lib/managers/binary.js +529 -183
  130. package/lib/managers/docker.js +199 -44
  131. package/lib/managers/oci.js +24 -2
  132. package/lib/parsers/cmakeCache.js +69 -0
  133. package/lib/parsers/cmakeLists.js +16 -2
  134. package/lib/parsers/cmakePresets.js +400 -0
  135. package/lib/parsers/compileCommands.js +557 -0
  136. package/lib/parsers/email.js +277 -0
  137. package/lib/parsers/largeJson.js +34 -2
  138. package/lib/parsers/strictJson.js +322 -0
  139. package/lib/parsers/terraformConfig.js +1073 -0
  140. package/lib/parsers/terraformSource.js +652 -0
  141. package/lib/server/server.js +209 -1
  142. package/lib/stages/postgen/annotator.js +17 -1
  143. package/lib/stages/postgen/introspection/markers.js +1 -1
  144. package/lib/stages/postgen/introspection/reflect.js +4 -1
  145. package/lib/stages/postgen/postgen.js +20 -6
  146. package/lib/stages/postgen/ruleEngine.js +58 -1
  147. package/lib/stages/postgen/specVersionCompat.js +62 -0
  148. package/lib/stages/pregen/pregen.js +117 -5
  149. package/lib/validator/bomValidator.js +26 -5
  150. package/lib/validator/generated/runtime.mjs +13 -0
  151. package/lib/validator/generated/validate-1.6.mjs +26 -7
  152. package/lib/validator/generated/validate-1.7.mjs +31 -12
  153. package/lib/validator/generated/validate-2.0.mjs +30 -11
  154. package/lib/validator/index.js +25 -10
  155. package/lib/validator/reporters/json.js +1 -0
  156. package/package.json +23 -23
  157. package/types/bin/cdxgen-secure.d.ts +3 -0
  158. package/types/bin/cdxgen-secure.d.ts.map +1 -0
  159. package/types/bin/repl.d.ts.map +1 -1
  160. package/types/lib/audit/index.d.ts.map +1 -1
  161. package/types/lib/cli/bomAssembly.d.ts +9 -2
  162. package/types/lib/cli/bomAssembly.d.ts.map +1 -1
  163. package/types/lib/cli/cliOptions.d.ts +43 -0
  164. package/types/lib/cli/cliOptions.d.ts.map +1 -1
  165. package/types/lib/cli/index.d.ts.map +1 -1
  166. package/types/lib/cli/jsBom.d.ts.map +1 -1
  167. package/types/lib/cli/jvmBom.d.ts +44 -1
  168. package/types/lib/cli/jvmBom.d.ts.map +1 -1
  169. package/types/lib/cli/managedBom.d.ts +7 -4
  170. package/types/lib/cli/managedBom.d.ts.map +1 -1
  171. package/types/lib/cli/nativeBom.d.ts +3 -1
  172. package/types/lib/cli/nativeBom.d.ts.map +1 -1
  173. package/types/lib/core/activity.d.ts.map +1 -1
  174. package/types/lib/core/env.d.ts +27 -2
  175. package/types/lib/core/env.d.ts.map +1 -1
  176. package/types/lib/core/fs.d.ts.map +1 -1
  177. package/types/lib/core/httpClient.d.ts +13 -8
  178. package/types/lib/core/httpClient.d.ts.map +1 -1
  179. package/types/lib/core/pluginRun.d.ts +97 -0
  180. package/types/lib/core/pluginRun.d.ts.map +1 -0
  181. package/types/lib/core/processTree.d.ts +36 -0
  182. package/types/lib/core/processTree.d.ts.map +1 -0
  183. package/types/lib/core/projectConfig.d.ts.map +1 -1
  184. package/types/lib/core/projectTooling.d.ts +41 -0
  185. package/types/lib/core/projectTooling.d.ts.map +1 -0
  186. package/types/lib/core/propertySanitizer.d.ts +26 -0
  187. package/types/lib/core/propertySanitizer.d.ts.map +1 -1
  188. package/types/lib/core/runState.d.ts +29 -0
  189. package/types/lib/core/runState.d.ts.map +1 -0
  190. package/types/lib/core/toml.d.ts +20 -0
  191. package/types/lib/core/toml.d.ts.map +1 -0
  192. package/types/lib/ecosystems/asarutils.d.ts.map +1 -1
  193. package/types/lib/ecosystems/bunutils.d.ts.map +1 -1
  194. package/types/lib/ecosystems/cargoCache.d.ts +12 -0
  195. package/types/lib/ecosystems/cargoCache.d.ts.map +1 -1
  196. package/types/lib/ecosystems/cmakeResolver.d.ts +5 -3
  197. package/types/lib/ecosystems/cmakeResolver.d.ts.map +1 -1
  198. package/types/lib/ecosystems/cppBuildContext.d.ts +55 -0
  199. package/types/lib/ecosystems/cppBuildContext.d.ts.map +1 -0
  200. package/types/lib/ecosystems/cppEvidence.d.ts +19 -3
  201. package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
  202. package/types/lib/ecosystems/cppIncludeResolver.d.ts +92 -0
  203. package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -0
  204. package/types/lib/ecosystems/denoutils.d.ts +9 -3
  205. package/types/lib/ecosystems/denoutils.d.ts.map +1 -1
  206. package/types/lib/ecosystems/ecosystems.d.ts +62 -13
  207. package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
  208. package/types/lib/ecosystems/golem.d.ts +81 -1
  209. package/types/lib/ecosystems/golem.d.ts.map +1 -1
  210. package/types/lib/ecosystems/gradleutils.d.ts +59 -7
  211. package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
  212. package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -1
  213. package/types/lib/ecosystems/kosi.d.ts.map +1 -1
  214. package/types/lib/ecosystems/npmutils.d.ts +15 -0
  215. package/types/lib/ecosystems/npmutils.d.ts.map +1 -1
  216. package/types/lib/ecosystems/parsers-dotnet.d.ts +155 -5
  217. package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
  218. package/types/lib/ecosystems/parsers-elm.d.ts.map +1 -1
  219. package/types/lib/ecosystems/parsers-gleam.d.ts.map +1 -1
  220. package/types/lib/ecosystems/parsers-go.d.ts +119 -5
  221. package/types/lib/ecosystems/parsers-go.d.ts.map +1 -1
  222. package/types/lib/ecosystems/parsers-js.d.ts +6 -1
  223. package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
  224. package/types/lib/ecosystems/parsers-julia.d.ts.map +1 -1
  225. package/types/lib/ecosystems/parsers-jvm.d.ts +74 -3
  226. package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
  227. package/types/lib/ecosystems/parsers-misc.d.ts +21 -59
  228. package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
  229. package/types/lib/ecosystems/parsers-python.d.ts +57 -6
  230. package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
  231. package/types/lib/ecosystems/parsers-terraform.d.ts +38 -21
  232. package/types/lib/ecosystems/parsers-terraform.d.ts.map +1 -1
  233. package/types/lib/ecosystems/pythonutils.d.ts +26 -1
  234. package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
  235. package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -1
  236. package/types/lib/ecosystems/rubyutils.d.ts +21 -1
  237. package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
  238. package/types/lib/ecosystems/rusi.d.ts.map +1 -1
  239. package/types/lib/ecosystems/sbtutils.d.ts +88 -2
  240. package/types/lib/ecosystems/sbtutils.d.ts.map +1 -1
  241. package/types/lib/ecosystems/scalacliutils.d.ts +56 -0
  242. package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -0
  243. package/types/lib/ecosystems/scalasem.d.ts +311 -0
  244. package/types/lib/ecosystems/scalasem.d.ts.map +1 -0
  245. package/types/lib/ecosystems/terraformRegistry.d.ts +9 -0
  246. package/types/lib/ecosystems/terraformRegistry.d.ts.map +1 -0
  247. package/types/lib/ecosystems/utils.d.ts +2 -2
  248. package/types/lib/ecosystems/utils.d.ts.map +1 -1
  249. package/types/lib/ecosystems/vendoredCode.d.ts +32 -0
  250. package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -0
  251. package/types/lib/evinser/evinser.d.ts +100 -8
  252. package/types/lib/evinser/evinser.d.ts.map +1 -1
  253. package/types/lib/evinser/swiftsem.d.ts +10 -0
  254. package/types/lib/evinser/swiftsem.d.ts.map +1 -1
  255. package/types/lib/helpers/bomSigner.d.ts +80 -4
  256. package/types/lib/helpers/bomSigner.d.ts.map +1 -1
  257. package/types/lib/inventory/agentSkillSpec.d.ts +13 -0
  258. package/types/lib/inventory/agentSkillSpec.d.ts.map +1 -0
  259. package/types/lib/inventory/aiCollector.d.ts.map +1 -1
  260. package/types/lib/inventory/analyzer.d.ts.map +1 -1
  261. package/types/lib/inventory/apkInstalledDb.d.ts +42 -0
  262. package/types/lib/inventory/apkInstalledDb.d.ts.map +1 -0
  263. package/types/lib/inventory/atomUtils.d.ts +96 -10
  264. package/types/lib/inventory/atomUtils.d.ts.map +1 -1
  265. package/types/lib/inventory/auditCategories.d.ts +3 -0
  266. package/types/lib/inventory/auditCategories.d.ts.map +1 -1
  267. package/types/lib/inventory/buildToolRateLimit.d.ts +38 -0
  268. package/types/lib/inventory/buildToolRateLimit.d.ts.map +1 -0
  269. package/types/lib/inventory/cacheCommands.d.ts +2 -1
  270. package/types/lib/inventory/cacheCommands.d.ts.map +1 -1
  271. package/types/lib/inventory/cacheDir.d.ts +12 -4
  272. package/types/lib/inventory/cacheDir.d.ts.map +1 -1
  273. package/types/lib/inventory/certificates.d.ts +205 -0
  274. package/types/lib/inventory/certificates.d.ts.map +1 -0
  275. package/types/lib/inventory/cmakeBuildDirs.d.ts +58 -0
  276. package/types/lib/inventory/cmakeBuildDirs.d.ts.map +1 -0
  277. package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
  278. package/types/lib/inventory/deps.d.ts +61 -2
  279. package/types/lib/inventory/deps.d.ts.map +1 -1
  280. package/types/lib/inventory/display.d.ts +18 -0
  281. package/types/lib/inventory/display.d.ts.map +1 -1
  282. package/types/lib/inventory/dosai.d.ts +202 -14
  283. package/types/lib/inventory/dosai.d.ts.map +1 -1
  284. package/types/lib/inventory/dosaiParsers.d.ts +53 -7
  285. package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
  286. package/types/lib/inventory/dynamic.d.ts +16 -1
  287. package/types/lib/inventory/dynamic.d.ts.map +1 -1
  288. package/types/lib/inventory/envcontext.d.ts +40 -2
  289. package/types/lib/inventory/envcontext.d.ts.map +1 -1
  290. package/types/lib/inventory/evidenceUtils.d.ts +48 -14
  291. package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
  292. package/types/lib/inventory/fetchBatch.d.ts +83 -14
  293. package/types/lib/inventory/fetchBatch.d.ts.map +1 -1
  294. package/types/lib/inventory/fetchDiskCache.d.ts +169 -0
  295. package/types/lib/inventory/fetchDiskCache.d.ts.map +1 -0
  296. package/types/lib/inventory/forgeEnricher.d.ts.map +1 -1
  297. package/types/lib/inventory/formulationParsers.d.ts.map +1 -1
  298. package/types/lib/inventory/goBuildInfo.d.ts +10 -0
  299. package/types/lib/inventory/goBuildInfo.d.ts.map +1 -0
  300. package/types/lib/inventory/hbom.d.ts.map +1 -1
  301. package/types/lib/inventory/hbomAnalysis.d.ts +10 -0
  302. package/types/lib/inventory/hbomAnalysis.d.ts.map +1 -1
  303. package/types/lib/inventory/hostTopology.d.ts.map +1 -1
  304. package/types/lib/inventory/jvmLocalRepos.d.ts +178 -0
  305. package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -0
  306. package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
  307. package/types/lib/inventory/osPackagePurl.d.ts +99 -0
  308. package/types/lib/inventory/osPackagePurl.d.ts.map +1 -0
  309. package/types/lib/inventory/osPackageResolver.d.ts +6 -2
  310. package/types/lib/inventory/osPackageResolver.d.ts.map +1 -1
  311. package/types/lib/inventory/osinfo.d.ts +31 -6
  312. package/types/lib/inventory/osinfo.d.ts.map +1 -1
  313. package/types/lib/inventory/osqueryTransform.d.ts +51 -0
  314. package/types/lib/inventory/osqueryTransform.d.ts.map +1 -1
  315. package/types/lib/inventory/parentSelection.d.ts +34 -0
  316. package/types/lib/inventory/parentSelection.d.ts.map +1 -0
  317. package/types/lib/inventory/phpBuildInfo.d.ts +142 -0
  318. package/types/lib/inventory/phpBuildInfo.d.ts.map +1 -0
  319. package/types/lib/inventory/phpHostProbe.d.ts +35 -0
  320. package/types/lib/inventory/phpHostProbe.d.ts.map +1 -0
  321. package/types/lib/inventory/rootfsCerts.d.ts +27 -0
  322. package/types/lib/inventory/rootfsCerts.d.ts.map +1 -0
  323. package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
  324. package/types/lib/inventory/scalaCoords.d.ts +80 -0
  325. package/types/lib/inventory/scalaCoords.d.ts.map +1 -0
  326. package/types/lib/inventory/source.d.ts +28 -0
  327. package/types/lib/inventory/source.d.ts.map +1 -1
  328. package/types/lib/inventory/spdx.d.ts +24 -0
  329. package/types/lib/inventory/spdx.d.ts.map +1 -1
  330. package/types/lib/inventory/traceRunner.d.ts +16 -1
  331. package/types/lib/inventory/traceRunner.d.ts.map +1 -1
  332. package/types/lib/inventory/tracedCrypto.d.ts +64 -0
  333. package/types/lib/inventory/tracedCrypto.d.ts.map +1 -0
  334. package/types/lib/managers/binary.d.ts +10 -0
  335. package/types/lib/managers/binary.d.ts.map +1 -1
  336. package/types/lib/managers/docker.d.ts +12 -0
  337. package/types/lib/managers/docker.d.ts.map +1 -1
  338. package/types/lib/managers/oci.d.ts +3 -1
  339. package/types/lib/managers/oci.d.ts.map +1 -1
  340. package/types/lib/parsers/cmakeCache.d.ts +16 -0
  341. package/types/lib/parsers/cmakeCache.d.ts.map +1 -1
  342. package/types/lib/parsers/cmakeLists.d.ts +2 -1
  343. package/types/lib/parsers/cmakeLists.d.ts.map +1 -1
  344. package/types/lib/parsers/cmakePresets.d.ts +78 -0
  345. package/types/lib/parsers/cmakePresets.d.ts.map +1 -0
  346. package/types/lib/parsers/compileCommands.d.ts +115 -0
  347. package/types/lib/parsers/compileCommands.d.ts.map +1 -0
  348. package/types/lib/parsers/email.d.ts +19 -0
  349. package/types/lib/parsers/email.d.ts.map +1 -0
  350. package/types/lib/parsers/largeJson.d.ts +13 -0
  351. package/types/lib/parsers/largeJson.d.ts.map +1 -1
  352. package/types/lib/parsers/strictJson.d.ts +46 -0
  353. package/types/lib/parsers/strictJson.d.ts.map +1 -0
  354. package/types/lib/parsers/terraformConfig.d.ts +70 -0
  355. package/types/lib/parsers/terraformConfig.d.ts.map +1 -0
  356. package/types/lib/parsers/terraformSource.d.ts +66 -0
  357. package/types/lib/parsers/terraformSource.d.ts.map +1 -0
  358. package/types/lib/server/server.d.ts +8 -0
  359. package/types/lib/server/server.d.ts.map +1 -1
  360. package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
  361. package/types/lib/stages/postgen/introspection/reflect.d.ts.map +1 -1
  362. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  363. package/types/lib/stages/postgen/ruleEngine.d.ts +7 -4
  364. package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
  365. package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
  366. package/types/lib/stages/pregen/pregen.d.ts +14 -1
  367. package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
  368. package/types/lib/validator/bomValidator.d.ts.map +1 -1
  369. package/types/lib/validator/index.d.ts +8 -0
  370. package/types/lib/validator/index.d.ts.map +1 -1
  371. package/types/lib/validator/reporters/json.d.ts.map +1 -1
  372. package/lib/third-party/arborist/snapshots/calc-dep-flags.test.cjs +0 -462
@@ -1,12 +1,11 @@
1
1
  import { readFileSync } from "node:fs";
2
2
  import { basename } from "node:path";
3
3
 
4
- import * as toml from "smol-toml";
5
-
6
4
  import {
7
5
  sanitizeBomPropertyValue,
8
6
  sanitizeBomUrl,
9
7
  } from "../core/propertySanitizer.js";
8
+ import { parseToml } from "../core/toml.js";
10
9
  import { parseJsonLike } from "./jsonLike.js";
11
10
  import { classifyMcpReference } from "./mcp.js";
12
11
  import {
@@ -813,7 +812,7 @@ export const mcpConfigParser = {
813
812
  let configJson;
814
813
  try {
815
814
  configJson = filePath.toLowerCase().endsWith(".toml")
816
- ? toml.parse(raw)
815
+ ? parseToml(raw)
817
816
  : parseJsonLike(raw);
818
817
  } catch {
819
818
  continue;
@@ -0,0 +1,244 @@
1
+ // The one place that decides what purl an operating-system package gets.
2
+ //
3
+ // A package found by `cdxgen -t docker <image>` and by `obom` run inside that
4
+ // image must be the same package, so the OBOM rows, the file-to-package
5
+ // resolver and the container scan all name a deb, an rpm or an apk package with
6
+ // the vendor and the qualifiers set here and in getDistroInfo(): `arch`,
7
+ // `distro`, `distro_name` and, when the package has one, `epoch`. A pacman
8
+ // package has the vendor and only the `arch` qualifier the alpm type defines.
9
+ // Homebrew, MacPorts and snap packages have no distro, so their purl is the
10
+ // name and the version; a flatpak adds the `arch` and `branch` of its ref.
11
+ //
12
+ // None of these purls has a subpath. A subpath names a path inside a package;
13
+ // the dpkg directory or the source rpm of a row is not one.
14
+
15
+ import { getDistroInfo, isCleanDistroQualifier } from "./osinfo.js";
16
+ import { tryBuildPurl } from "./purl.js";
17
+
18
+ /**
19
+ * The purl types an OS scan builds from what a package manager reports.
20
+ * deb, rpm, apk and alpm belong to a distro; brew, macports, snap and flatpak
21
+ * belong to none. brew, macports, snap and flatpak are not purl-spec types;
22
+ * cdx-purl builds them as it builds `pkg:chocolatey`.
23
+ */
24
+ export const OS_PACKAGE_PURL_TYPES = new Set([
25
+ "deb",
26
+ "rpm",
27
+ "apk",
28
+ "alpm",
29
+ "brew",
30
+ "macports",
31
+ "snap",
32
+ "flatpak",
33
+ ]);
34
+
35
+ /**
36
+ * Whether a purl type is one of the OS package managers handled here.
37
+ *
38
+ * @param {string|undefined} type Purl type
39
+ * @returns {boolean} true for the types in OS_PACKAGE_PURL_TYPES
40
+ */
41
+ export function isOsPackagePurlType(type) {
42
+ return OS_PACKAGE_PURL_TYPES.has(type);
43
+ }
44
+
45
+ /**
46
+ * Whether a value names an architecture. rpm says `(none)` and trivy says
47
+ * `None` for a package that has none, such as an rpm's `gpg-pubkey` key record;
48
+ * neither is an architecture, and neither belongs in a purl.
49
+ *
50
+ * @param {string|undefined|null} arch Architecture as a package manager reports it
51
+ * @returns {boolean} true for a real architecture
52
+ */
53
+ export function isRealArchitecture(arch) {
54
+ const value = `${arch ?? ""}`.trim().toLowerCase();
55
+ return value !== "" && value !== "(none)" && value !== "none";
56
+ }
57
+
58
+ function isDigits(text) {
59
+ if (!text) {
60
+ return false;
61
+ }
62
+ for (let i = 0; i < text.length; i++) {
63
+ const code = text.charCodeAt(i);
64
+ if (code < 48 || code > 57) {
65
+ return false;
66
+ }
67
+ }
68
+ return true;
69
+ }
70
+
71
+ // An epoch is a non-negative integer, and 0 is the same as none. Anything else
72
+ // ("", "(none)", "null") is no epoch.
73
+ function normaliseEpoch(value) {
74
+ const text = `${value ?? ""}`.trim();
75
+ if (!isDigits(text)) {
76
+ return undefined;
77
+ }
78
+ const digits = text.replace(/^0+/, "");
79
+ return digits || undefined;
80
+ }
81
+
82
+ // dpkg writes a version as [epoch:]upstream[-revision]. A colon is only ever an
83
+ // epoch's separator when what comes before it is all digits.
84
+ function debVersionEpoch(version) {
85
+ const colon = version.indexOf(":");
86
+ if (colon <= 0) {
87
+ return undefined;
88
+ }
89
+ const prefix = version.slice(0, colon);
90
+ return isDigits(prefix) ? prefix : undefined;
91
+ }
92
+
93
+ /**
94
+ * The epoch of an OS package, as the `epoch` qualifier carries it.
95
+ *
96
+ * An rpm keeps its epoch in a field of its own. A deb keeps it in its version
97
+ * (`2:93`), so the version is read first. Epoch 0 and no epoch are the same,
98
+ * and apk and Homebrew packages have none.
99
+ *
100
+ * @param {{type: string, version?: string, epoch?: string|number}} pkg Package
101
+ * @returns {string|undefined} The epoch without leading zeros, or undefined
102
+ */
103
+ export function osPackageEpoch(pkg) {
104
+ switch (pkg?.type) {
105
+ case "rpm":
106
+ return normaliseEpoch(pkg.epoch);
107
+ case "deb": {
108
+ const fromVersion = debVersionEpoch(`${pkg.version ?? ""}`);
109
+ return fromVersion === undefined
110
+ ? normaliseEpoch(pkg.epoch)
111
+ : normaliseEpoch(fromVersion);
112
+ }
113
+ default:
114
+ return undefined;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * The version an OS package carries on its component and in its purl.
120
+ *
121
+ * - rpm: `[epoch:]version-release`, the form the container scan writes. The
122
+ * purl spec keeps the epoch out of an rpm version, but the container scan
123
+ * puts it in the version as well as in the `epoch` qualifier, and an OBOM must
124
+ * name the package the same way.
125
+ * - deb: the version exactly as dpkg reports it, epoch included.
126
+ * - macports: `version_revision`, the form `port installed` prints.
127
+ * - apk, alpm, brew, snap and flatpak: the version as it is. A pacman version
128
+ * already holds its epoch and release (`1:1.3.2-4`).
129
+ *
130
+ * @param {{type: string, version?: string, release?: string, epoch?: string|number, revision?: string|number}} pkg Package
131
+ * @returns {string} The version, or an empty string when the package has none
132
+ */
133
+ export function osPackageVersion(pkg) {
134
+ const version = `${pkg?.version ?? ""}`;
135
+ if (!version) {
136
+ return "";
137
+ }
138
+ switch (pkg.type) {
139
+ case "rpm": {
140
+ const release = `${pkg.release ?? ""}`;
141
+ const evr = release ? `${version}-${release}` : version;
142
+ const epoch = osPackageEpoch(pkg);
143
+ return epoch ? `${epoch}:${evr}` : evr;
144
+ }
145
+ case "deb": {
146
+ if (debVersionEpoch(version) !== undefined) {
147
+ return version;
148
+ }
149
+ const epoch = normaliseEpoch(pkg.epoch);
150
+ return epoch ? `${epoch}:${version}` : version;
151
+ }
152
+ case "macports": {
153
+ // Revision 0 is a real revision: `port installed` prints `@3.6.0_0`.
154
+ const revision = `${pkg.revision ?? ""}`.trim();
155
+ return isDigits(revision) ? `${version}_${revision}` : version;
156
+ }
157
+ default:
158
+ return version;
159
+ }
160
+ }
161
+
162
+ /**
163
+ * Build the purl of an OS package.
164
+ *
165
+ * deb, rpm and apk purls take their vendor (`ubuntu`, `almalinux`, `alpine`,
166
+ * `wolfi`) and the `distro` and `distro_name` qualifiers from the distro, plus
167
+ * `arch` and `epoch` from the package. alpm purls take the vendor (`arch`,
168
+ * `manjaro`) and `arch` only: that is all the alpm type defines, and an Arch
169
+ * system is rolling, with no release to name. A qualifier with no value is
170
+ * left out. brew, macports and snap purls carry neither vendor nor qualifiers;
171
+ * a flatpak purl carries the `arch` and `branch` of the flatpak ref.
172
+ *
173
+ * @param {Object} pkg The package
174
+ * @param {string} pkg.type One of OS_PACKAGE_PURL_TYPES
175
+ * @param {string} pkg.name Package name; a flatpak's application ID
176
+ * @param {string} [pkg.version] deb: the dpkg version. rpm: the version tag only. apk: version-rN. macports: the version without its revision.
177
+ * @param {string} [pkg.release] rpm release tag
178
+ * @param {string|number} [pkg.epoch] rpm epoch tag
179
+ * @param {string|number} [pkg.revision] MacPorts revision
180
+ * @param {string} [pkg.arch] Package architecture
181
+ * @param {string} [pkg.branch] flatpak branch (`stable`, `48`)
182
+ * @param {{namespace?: string, distroId?: string, distroName?: string}} [distro]
183
+ * What getDistroInfo() reports; read from the host's os-release when left out
184
+ * @returns {string|null} The purl, or null when the parts do not form a valid one
185
+ */
186
+ export function buildOsPackagePurl(pkg, distro) {
187
+ const type = pkg?.type;
188
+ const name = `${pkg?.name ?? ""}`;
189
+ if (!isOsPackagePurlType(type) || !name) {
190
+ return null;
191
+ }
192
+ const version = osPackageVersion(pkg) || null;
193
+ switch (type) {
194
+ case "brew":
195
+ case "macports":
196
+ case "snap":
197
+ return tryBuildPurl({ type, name, version });
198
+ case "flatpak": {
199
+ const qualifiers = {};
200
+ if (isRealArchitecture(pkg.arch)) {
201
+ qualifiers.arch = `${pkg.arch}`.trim();
202
+ }
203
+ const branch = `${pkg.branch ?? ""}`.trim();
204
+ if (branch) {
205
+ qualifiers.branch = branch;
206
+ }
207
+ return tryBuildPurl({
208
+ type,
209
+ name,
210
+ version,
211
+ qualifiers: Object.keys(qualifiers).length ? qualifiers : null,
212
+ });
213
+ }
214
+ default:
215
+ break;
216
+ }
217
+ const { namespace, distroId, distroName } = distro || getDistroInfo();
218
+ if (!namespace) {
219
+ return null;
220
+ }
221
+ const qualifiers = {};
222
+ if (isRealArchitecture(pkg.arch)) {
223
+ qualifiers.arch = `${pkg.arch}`.trim();
224
+ }
225
+ if (type !== "alpm") {
226
+ if (isCleanDistroQualifier(distroId)) {
227
+ qualifiers.distro = distroId;
228
+ }
229
+ if (isCleanDistroQualifier(distroName)) {
230
+ qualifiers.distro_name = distroName;
231
+ }
232
+ const epoch = osPackageEpoch(pkg);
233
+ if (epoch) {
234
+ qualifiers.epoch = epoch;
235
+ }
236
+ }
237
+ return tryBuildPurl({
238
+ type,
239
+ namespace,
240
+ name,
241
+ version,
242
+ qualifiers: Object.keys(qualifiers).length ? qualifiers : null,
243
+ });
244
+ }
@@ -1,13 +1,13 @@
1
1
  import { readFileSync, realpathSync } from "node:fs";
2
2
  import { join, relative } from "node:path";
3
3
 
4
- import { build } from "@cdxgen/cdx-purl";
5
4
  import { globSync } from "glob";
6
5
 
7
6
  import { DEBUG_MODE, recordSymlinkResolution } from "../core/activity.js";
8
7
  import { safeExistsSync, safeSpawnSync } from "../core/fs.js";
9
8
  import { thoughtLog } from "../core/logger.js";
10
9
  import { getDistroInfo } from "./osinfo.js";
10
+ import { buildOsPackagePurl } from "./osPackagePurl.js";
11
11
 
12
12
  // ---------------------------------------------------------------------------
13
13
  // Caches
@@ -48,58 +48,34 @@ function parseAlpinePackage(pkgStr) {
48
48
  // ---------------------------------------------------------------------------
49
49
  // Build a PackageURL string from resolved package info.
50
50
  //
51
- // Distro qualifiers (distro, distro_name) are taken from /etc/os-release via
52
- // getDistroInfo() so they are always accurate, never hardcoded.
51
+ // deb, rpm, apk and Homebrew packages are named by buildOsPackagePurl, the
52
+ // function the OBOM rows use as well, so a file and the package that owns it
53
+ // share one identity with the package an OBOM or a container scan lists. The
54
+ // distro qualifiers come from /etc/os-release via getDistroInfo(), never from
55
+ // a hard-coded table.
53
56
  //
54
- // "brew" is not an official PackageURL type — Homebrew packages are emitted
55
- // as pkg:generic with a package_manager=homebrew qualifier.
57
+ // Homebrew has no official purl type yet, but cdx-purl builds pkg:brew, as the
58
+ // OBOM does for its homebrew_packages rows. A brew purl carries no qualifiers:
59
+ // this used to pass an `arch` that the generic type it fell back to does not
60
+ // allow, so build() threw and a file of a Homebrew package got no purl at all.
56
61
  // ---------------------------------------------------------------------------
57
62
  function buildPurl(pkgInfo) {
58
- let purlType = pkgInfo.type;
59
- let namespace;
60
- const qualifiers = {};
61
-
62
- if (pkgInfo.arch) {
63
- qualifiers.arch = pkgInfo.arch;
64
- }
65
-
66
- if (purlType === "deb" || purlType === "apk" || purlType === "rpm") {
67
- const di = getDistroInfo();
68
- namespace = di.namespace;
69
-
70
- // distro qualifier: ID-VERSION_ID (e.g. "fedora-25", "alpine-3.17")
71
- if (di.distroId) {
72
- qualifiers.distro = di.distroId;
73
- }
74
- // distro_name qualifier: codename (e.g. "jammy", "bookworm")
75
- if (di.distroName) {
76
- qualifiers.distro_name = di.distroName;
77
- }
78
- } else if (purlType === "brew") {
79
- // No official brew purl type — fall back to generic. This used to add a
80
- // `package_manager=homebrew` qualifier, which generic does not allow, so
81
- // build() threw and the catch below swallowed it: Homebrew packages silently
82
- // received no purl at all on macOS. The provenance is instead recorded as a
83
- // property by the caller.
84
- purlType = "generic";
85
- }
63
+ const distro =
64
+ pkgInfo.type === "brew" || !pkgInfo.type ? undefined : getDistroInfo();
65
+ return buildOsPackagePurl(pkgInfo, distro) || "";
66
+ }
86
67
 
87
- const finalQualifiers = Object.keys(qualifiers).length
88
- ? qualifiers
89
- : undefined;
68
+ // apk names an architecture its own way, which is not the way node does.
69
+ const APK_ARCHITECTURES = {
70
+ x64: "x86_64",
71
+ arm64: "aarch64",
72
+ ia32: "x86",
73
+ ppc64: "ppc64le",
74
+ loong64: "loongarch64",
75
+ };
90
76
 
91
- try {
92
- return build({
93
- type: purlType,
94
- namespace: namespace || undefined || null,
95
- name: pkgInfo.name,
96
- version: pkgInfo.version || undefined || null,
97
- qualifiers: finalQualifiers || null,
98
- subpath: undefined || null,
99
- });
100
- } catch (_e) {
101
- return "";
102
- }
77
+ function apkArchitecture() {
78
+ return APK_ARCHITECTURES[process.arch] || process.arch;
103
79
  }
104
80
 
105
81
  // ---------------------------------------------------------------------------
@@ -111,7 +87,7 @@ function buildPurl(pkgInfo) {
111
87
  * correctly computed purl with distro qualifiers derived from /etc/os-release.
112
88
  *
113
89
  * @param {string} filePath - Absolute path to the library file
114
- * @returns {{ name: string, version: string, arch: string, type: string, purl: string } | undefined}
90
+ * @returns {{ name: string, version: string, arch: string, type: string, epoch?: string, purl: string } | undefined}
115
91
  */
116
92
  export function resolvePackageForFile(filePath) {
117
93
  if (!filePath) {
@@ -190,27 +166,30 @@ function _resolveLinux(filePath) {
190
166
  return {
191
167
  name,
192
168
  version,
193
- arch: process.arch === "x64" ? "x86_64" : process.arch,
169
+ arch: apkArchitecture(),
194
170
  type: "apk",
195
171
  };
196
172
  }
197
173
  }
198
174
 
199
- // 3. RPM-based (rpm -qf)
175
+ // 3. RPM-based (rpm -qf). The epoch is part of an rpm's identity; %{EPOCH} is
176
+ // (none) for a package without one, so the conditional makes that a 0, which
177
+ // means the same.
200
178
  const rpmRes = safeSpawnSync("rpm", [
201
179
  "-qf",
202
180
  "--qf",
203
- "%{NAME} %{VERSION}-%{RELEASE} %{ARCH}\n",
181
+ "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION}-%{RELEASE} %{ARCH}\n",
204
182
  filePath,
205
183
  ]);
206
184
  if (rpmRes && rpmRes.status === 0 && rpmRes.stdout) {
207
185
  const line = rpmRes.stdout.split("\n")[0].trim();
208
186
  const parts = line.split(" ");
209
- if (parts.length >= 3) {
187
+ if (parts.length >= 4) {
210
188
  return {
211
189
  name: parts[0],
212
- version: parts[1],
213
- arch: parts[2],
190
+ epoch: parts[1],
191
+ version: parts[2],
192
+ arch: parts[3],
214
193
  type: "rpm",
215
194
  };
216
195
  }
@@ -233,7 +212,7 @@ function _resolveDarwin(filePath) {
233
212
  name: segments[0],
234
213
  version: segments[1],
235
214
  arch: process.arch,
236
- type: "brew", // remapped to pkg:generic in buildPurl
215
+ type: "brew",
237
216
  };
238
217
  }
239
218
  }
@@ -379,6 +358,9 @@ function shouldPreferUsrMergedExecutablePath(file, existingFile) {
379
358
  * @param ldConf {String} Config file used by ldconfig to locate additional paths
380
359
  * @param ldConfDirPattern {String} Config directory that can contain more .conf files for ldconfig
381
360
  * @param excludePaths {Array[String]} Container-relative paths that should be excluded from the result set
361
+ * @param extraLibGlobs {Array[String]} Extra container-relative globs for files
362
+ * the default paths miss, such as libphp*.so under Apache's modules
363
+ * directory. The existing globs are unchanged; this adds candidates only.
382
364
  *
383
365
  * @return {Array[String]} List of executables
384
366
  */
@@ -388,6 +370,7 @@ export function collectSharedLibs(
388
370
  ldConf,
389
371
  ldConfDirPattern,
390
372
  excludePaths = [],
373
+ extraLibGlobs = [],
391
374
  ) {
392
375
  if (!libPaths) {
393
376
  return [];
@@ -399,6 +382,37 @@ export function collectSharedLibs(
399
382
  const ignoreList = [
400
383
  "**/*.{h,c,cpp,hpp,man,txt,md,htm,html,jar,ear,war,zip,tar,egg,keepme,gitignore,json,js,py,pyc}",
401
384
  ];
385
+ const addCandidate = (file) => {
386
+ let resolvedFile = file;
387
+ try {
388
+ resolvedFile = relative(basePath, realpathSync(join(basePath, file)));
389
+ recordSymlinkResolution(join(basePath, file), resolvedFile, {
390
+ basePath,
391
+ metadata: {
392
+ resolutionKind: "shared-library",
393
+ },
394
+ reason: `Resolved shared library candidate ${file} to ${resolvedFile}.`,
395
+ });
396
+ } catch (err) {
397
+ recordSymlinkResolution(join(basePath, file), undefined, {
398
+ basePath,
399
+ errorCode: err?.code || err?.name,
400
+ metadata: {
401
+ resolutionKind: "shared-library",
402
+ },
403
+ reason: `Failed to resolve shared library candidate ${file}.`,
404
+ status: "failed",
405
+ });
406
+ // Broken symlinks or permission errors can prevent realpath resolution.
407
+ }
408
+ if (
409
+ excludedPathSet.has(file.replace(/^\/+/, "").replace(/\\/g, "/")) ||
410
+ excludedPathSet.has(resolvedFile.replace(/^\/+/, "").replace(/\\/g, "/"))
411
+ ) {
412
+ return;
413
+ }
414
+ sharedLibs.push(file);
415
+ };
402
416
  const allLdConfDirs = ldConfDirPattern ? [ldConfDirPattern] : [];
403
417
  collectAllLdConfs(basePath, ldConf, allLdConfDirs, libPaths);
404
418
  if (allLdConfDirs.length) {
@@ -428,37 +442,25 @@ export function collectSharedLibs(
428
442
  ignore: ignoreList,
429
443
  });
430
444
  for (const file of files) {
431
- let resolvedFile = file;
432
- try {
433
- resolvedFile = relative(basePath, realpathSync(join(basePath, file)));
434
- recordSymlinkResolution(join(basePath, file), resolvedFile, {
435
- basePath,
436
- metadata: {
437
- resolutionKind: "shared-library",
438
- },
439
- reason: `Resolved shared library candidate ${file} to ${resolvedFile}.`,
440
- });
441
- } catch (err) {
442
- recordSymlinkResolution(join(basePath, file), undefined, {
443
- basePath,
444
- errorCode: err?.code || err?.name,
445
- metadata: {
446
- resolutionKind: "shared-library",
447
- },
448
- reason: `Failed to resolve shared library candidate ${file}.`,
449
- status: "failed",
450
- });
451
- // Broken symlinks or permission errors can prevent realpath resolution.
452
- }
453
- if (
454
- excludedPathSet.has(file.replace(/^\/+/, "").replace(/\\/g, "/")) ||
455
- excludedPathSet.has(
456
- resolvedFile.replace(/^\/+/, "").replace(/\\/g, "/"),
457
- )
458
- ) {
459
- continue;
460
- }
461
- sharedLibs.push(file);
445
+ addCandidate(file);
446
+ }
447
+ } catch (_err) {
448
+ // ignore
449
+ }
450
+ }
451
+ for (const pattern of extraLibGlobs) {
452
+ try {
453
+ const files = globSync(pattern, {
454
+ cwd: basePath,
455
+ absolute: false,
456
+ nocase: true,
457
+ nodir: true,
458
+ dot: true,
459
+ follow: true,
460
+ ignore: ignoreList,
461
+ });
462
+ for (const file of files) {
463
+ addCandidate(file);
462
464
  }
463
465
  } catch (_err) {
464
466
  // ignore