@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
@@ -0,0 +1,294 @@
1
+ /**
2
+ * Which package provides a C/C++ header, from the file the include resolved
3
+ * to. atom 4 and later name that file in each include's usages slice
4
+ * (`resolvedPath`); with it, a header is attributed exactly instead of by its
5
+ * name: to the project itself, to a dependency whose sources CMake fetched or
6
+ * a submodule checked out, to code the project vendors, to a port vcpkg
7
+ * installed, to a package in the Conan cache, or to the operating-system
8
+ * package that owns the file.
9
+ *
10
+ * Layer 3: reads the vcpkg installed tree and the Conan cache, and asks the
11
+ * OS package manager about a file (`dpkg-query -S`, `rpm -qf`, `apk info -W`,
12
+ * or the Homebrew Cellar path).
13
+ */
14
+
15
+ import { readdirSync, readFileSync, realpathSync } from "node:fs";
16
+ import { homedir } from "node:os";
17
+ import { isAbsolute, join, resolve, sep } from "node:path";
18
+ import process from "node:process";
19
+
20
+ import { readEnvironmentVariable } from "../core/activity.js";
21
+ import { safeExistsSync } from "../core/fs.js";
22
+ import { isInsideDir } from "../inventory/cmakeBuildDirs.js";
23
+ import { resolvePackageForFile } from "../inventory/osPackageResolver.js";
24
+
25
+ /**
26
+ * The include slices of an atom C/C++ usages report: for each header as
27
+ * written, the files it resolved to, whether it was written as a system
28
+ * include, and the functions the including files call that it declares.
29
+ * Slices from atom releases that do not name the resolved file contribute no
30
+ * paths and no symbols.
31
+ *
32
+ * @param {Object} sliceData Parsed atom usages report
33
+ * @returns {Map<string, {paths: Set<string>, system: boolean, symbols: Set<string>}>}
34
+ */
35
+ export function parseCIncludeSlices(sliceData) {
36
+ const includes = new Map();
37
+ for (const slice of sliceData?.objectSlices || []) {
38
+ if (!slice || !`${slice.code || ""}`.startsWith("#include")) {
39
+ continue;
40
+ }
41
+ const header = slice.fullName;
42
+ if (!header) {
43
+ continue;
44
+ }
45
+ const entry = includes.get(header) || {
46
+ paths: new Set(),
47
+ system: false,
48
+ symbols: new Set(),
49
+ };
50
+ if (typeof slice.resolvedPath === "string" && slice.resolvedPath.length) {
51
+ entry.paths.add(slice.resolvedPath);
52
+ }
53
+ entry.system = entry.system || slice.isSystem === true;
54
+ for (const symbol of Array.isArray(slice.importedSymbols)
55
+ ? slice.importedSymbols
56
+ : []) {
57
+ if (typeof symbol === "string" && symbol.length) {
58
+ entry.symbols.add(symbol);
59
+ }
60
+ }
61
+ includes.set(header, entry);
62
+ }
63
+ return includes;
64
+ }
65
+
66
+ /**
67
+ * Index the ports vcpkg installed into the given `vcpkg_installed`
68
+ * directories: every file a port installed, by absolute path. vcpkg lists a
69
+ * port's files in `vcpkg/info/<port>_<version>_<triplet>.list`, one path per
70
+ * line relative to the installed directory.
71
+ *
72
+ * @param {string[]} installedDirs `vcpkg_installed` directories
73
+ * @returns {Map<string, {port: string, version: string, triplet: string}>}
74
+ */
75
+ export function readVcpkgInstalledIndex(installedDirs) {
76
+ const index = new Map();
77
+ for (const dir of installedDirs) {
78
+ const infoDir = join(dir, "vcpkg", "info");
79
+ let lists = [];
80
+ try {
81
+ lists = readdirSync(infoDir).filter((f) => f.endsWith(".list"));
82
+ } catch (_err) {
83
+ continue;
84
+ }
85
+ for (const list of lists) {
86
+ const stem = list.slice(0, -".list".length);
87
+ const first = stem.indexOf("_");
88
+ const last = stem.lastIndexOf("_");
89
+ if (first <= 0 || last <= first) {
90
+ continue;
91
+ }
92
+ const port = stem.slice(0, first);
93
+ const version = stem.slice(first + 1, last);
94
+ const triplet = stem.slice(last + 1);
95
+ let text = "";
96
+ try {
97
+ text = readFileSync(join(infoDir, list), "utf-8");
98
+ } catch (_err) {
99
+ continue;
100
+ }
101
+ for (const line of text.split(/\r?\n/)) {
102
+ const rel = line.trim();
103
+ if (!rel || rel.endsWith("/")) {
104
+ continue;
105
+ }
106
+ index.set(resolve(dir, rel), { port, version, triplet });
107
+ }
108
+ }
109
+ }
110
+ return index;
111
+ }
112
+
113
+ /**
114
+ * The package folders of a Conan 2 cache, from its database
115
+ * (`<home>/p/cache.sqlite3`, table `packages`).
116
+ *
117
+ * @param {string} conanHome Conan 2 home (`CONAN_HOME`, or `~/.conan2`)
118
+ * @returns {Array<{dir: string, name: string, version: string}>}
119
+ */
120
+ export function conan2Packages(conanHome) {
121
+ const packages = [];
122
+ const db = join(conanHome, "p", "cache.sqlite3");
123
+ if (!safeExistsSync(db)) {
124
+ return packages;
125
+ }
126
+ const sqlite = process.getBuiltinModule?.("node:sqlite");
127
+ if (!sqlite?.DatabaseSync) {
128
+ return packages;
129
+ }
130
+ let handle;
131
+ try {
132
+ handle = new sqlite.DatabaseSync(db, { readOnly: true });
133
+ for (const row of handle
134
+ .prepare("SELECT reference, path FROM packages")
135
+ .all()) {
136
+ if (typeof row.reference === "string" && typeof row.path === "string") {
137
+ const [name, version] = row.reference.split("@")[0].split("/");
138
+ if (name && version) {
139
+ packages.push({
140
+ dir: resolve(conanHome, "p", row.path),
141
+ name,
142
+ version,
143
+ });
144
+ }
145
+ }
146
+ }
147
+ } catch (_err) {
148
+ // a database of another layout tells nothing
149
+ } finally {
150
+ try {
151
+ handle?.close();
152
+ } catch (_err) {
153
+ // already closed
154
+ }
155
+ }
156
+ return packages;
157
+ }
158
+
159
+ /**
160
+ * The Conan package a file belongs to: in a Conan 1 cache
161
+ * (`<home>/.conan/data/<name>/<version>/<user>/<channel>/package/<id>/...`)
162
+ * from its path, in a Conan 2 cache from the cache's database.
163
+ *
164
+ * @param {string} file Absolute path
165
+ * @param {Object[]} conan2 Conan 2 package folders (see `conan2Packages`)
166
+ * @returns {{name: string, version: string}|undefined}
167
+ */
168
+ export function conanPackageOf(file, conan2) {
169
+ const segments = file.split(sep);
170
+ const data = segments.findIndex(
171
+ (s, i) => s === "data" && segments[i - 1] === ".conan",
172
+ );
173
+ if (
174
+ data >= 0 &&
175
+ segments.length > data + 6 &&
176
+ segments[data + 5] === "package"
177
+ ) {
178
+ return { name: segments[data + 1], version: segments[data + 2] };
179
+ }
180
+ const hit = conan2.find((p) => isInsideDir(file, p.dir));
181
+ return hit ? { name: hit.name, version: hit.version } : undefined;
182
+ }
183
+
184
+ function propertyValue(component, name) {
185
+ return (component?.properties || []).find((p) => p.name === name)?.value;
186
+ }
187
+
188
+ /**
189
+ * Build the function that attributes a header from the files it resolved
190
+ * to.
191
+ *
192
+ * @param {Object} context
193
+ * @param {string} context.src Project scan root
194
+ * @param {Object[]} [context.components] Components already known: CMake
195
+ * dependencies (`cdx:cmake:sourceDir`) and vendored code
196
+ * (`cdx:vendored:path`) claim the headers under their directories
197
+ * @param {string[]} [context.buildDirs] Build directories, searched for
198
+ * `vcpkg_installed`
199
+ * @param {function(string): boolean} [context.isFirstPartyHeader] Whether a
200
+ * file is the project's own
201
+ * @returns {function(Iterable<string>): Object|undefined} Given the resolved
202
+ * files, `{kind: "first-party"}`, `{kind: "component", component}`,
203
+ * `{kind: "vcpkg", port, version, triplet}`, `{kind: "conan", name,
204
+ * version}`, `{kind: "os", pkgInfo}`, or `undefined` when no file says.
205
+ * Its `vcpkgPorts()` lists the ports vcpkg installed.
206
+ */
207
+ export function createIncludeAttributor(context) {
208
+ const root = resolve(context.src);
209
+ const owners = [];
210
+ for (const component of context.components || []) {
211
+ for (const name of ["cdx:cmake:sourceDir", "cdx:vendored:path"]) {
212
+ const dir = propertyValue(component, name);
213
+ if (dir) {
214
+ owners.push({ dir: resolve(root, dir), component });
215
+ }
216
+ }
217
+ }
218
+ // the deepest directory owns a file inside nested ones
219
+ owners.sort((a, b) => b.dir.length - a.dir.length);
220
+ const installedDirs = [root, ...(context.buildDirs || [])]
221
+ .map((d) => join(d, "vcpkg_installed"))
222
+ .filter((d) => safeExistsSync(d));
223
+ let vcpkgIndex;
224
+ const vcpkg = () => {
225
+ vcpkgIndex = vcpkgIndex || readVcpkgInstalledIndex(installedDirs);
226
+ return vcpkgIndex;
227
+ };
228
+ const conanHome =
229
+ readEnvironmentVariable("CONAN_HOME") || join(homedir(), ".conan2");
230
+ let conan2;
231
+ const conan2Folders = () => {
232
+ conan2 = conan2 || conan2Packages(conanHome);
233
+ return conan2;
234
+ };
235
+ const real = (p) => {
236
+ try {
237
+ return realpathSync(p);
238
+ } catch (_err) {
239
+ return resolve(p);
240
+ }
241
+ };
242
+ const attributeOne = (file) => {
243
+ if (!file || !isAbsolute(file)) {
244
+ return undefined;
245
+ }
246
+ const abs = resolve(file);
247
+ const owner = owners.find((o) => isInsideDir(abs, o.dir));
248
+ if (owner) {
249
+ return { kind: "component", component: owner.component };
250
+ }
251
+ if (context.isFirstPartyHeader?.(abs)) {
252
+ return { kind: "first-party" };
253
+ }
254
+ const port =
255
+ installedDirs.length && (vcpkg().get(abs) || vcpkg().get(real(abs)));
256
+ if (port) {
257
+ return { kind: "vcpkg", ...port };
258
+ }
259
+ const conan = conanPackageOf(real(abs), conan2Folders());
260
+ if (conan) {
261
+ return { kind: "conan", ...conan };
262
+ }
263
+ if (isInsideDir(abs, root)) {
264
+ return undefined;
265
+ }
266
+ const pkgInfo = resolvePackageForFile(real(abs));
267
+ if (pkgInfo?.name) {
268
+ return { kind: "os", pkgInfo };
269
+ }
270
+ return undefined;
271
+ };
272
+ const attribute = (files) => {
273
+ for (const file of files || []) {
274
+ const target = attributeOne(file);
275
+ if (target) {
276
+ return target;
277
+ }
278
+ }
279
+ return undefined;
280
+ };
281
+ /** The ports vcpkg installed for the project: port to version and triplet. */
282
+ attribute.vcpkgPorts = () => {
283
+ const ports = new Map();
284
+ if (installedDirs.length) {
285
+ for (const { port, version, triplet } of vcpkg().values()) {
286
+ if (!ports.has(port)) {
287
+ ports.set(port, { version, triplet });
288
+ }
289
+ }
290
+ }
291
+ return ports;
292
+ };
293
+ return attribute;
294
+ }
@@ -6,14 +6,12 @@ import { build } from "@cdxgen/cdx-purl";
6
6
 
7
7
  // utils.js does not import denoutils.js, so importing from it here is safe and
8
8
  // does not introduce a cyclic dependency.
9
- import {
10
- cdxgenAgent,
11
- DEBUG_MODE,
12
- readEnvironmentVariable,
13
- } from "../core/activity.js";
14
- import { shouldFetchLicense, shouldFetchVCS } from "../core/env.js";
9
+ import { DEBUG_MODE, readEnvironmentVariable } from "../core/activity.js";
10
+ import { shouldFetchPackageMetadata } from "../core/env.js";
15
11
  import { safeExistsSync } from "../core/fs.js";
12
+ import { registerRunReset } from "../core/runState.js";
16
13
  import {
14
+ gatedGet,
17
15
  prefetchEnabled,
18
16
  prefetchedResponse,
19
17
  prefetchJson,
@@ -23,6 +21,7 @@ import {
23
21
  buildNpmRegistryTarballUrl,
24
22
  loadNpmrcConfig,
25
23
  normalizeNpmRegistryUrl,
24
+ resolveNpmLicense,
26
25
  } from "./npmutils.js";
27
26
 
28
27
  const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org/";
@@ -37,6 +36,7 @@ const JSR_API_URL =
37
36
  // Small in-module response cache so repeated packages (or multiple lockfiles)
38
37
  // don't re-fetch the same jsr metadata.
39
38
  const jsrMetadataCache = new Map();
39
+ registerRunReset("jsr:documents", () => jsrMetadataCache.clear());
40
40
 
41
41
  /**
42
42
  * purl decision for `jsr:` dependencies.
@@ -314,8 +314,11 @@ function applyPackageJsonMetadata(component, pj) {
314
314
  if (!component.description && pj.description) {
315
315
  component.description = pj.description;
316
316
  }
317
- if (!component.license && (pj.license || pj.licenses)) {
318
- component.license = pj.license || pj.licenses;
317
+ if (!component.license) {
318
+ const license = resolveNpmLicense(pj);
319
+ if (license) {
320
+ component.license = license;
321
+ }
319
322
  }
320
323
  if (pj.repository) {
321
324
  const url =
@@ -468,78 +471,104 @@ function jsrUrlsFor(component) {
468
471
  };
469
472
  }
470
473
 
474
+ /**
475
+ * Whether a component already names its source repository, so the jsr
476
+ * package document, which supplies the GitHub link, has nothing left to add.
477
+ *
478
+ * @param {Object} component CycloneDX component with cdxgen properties.
479
+ * @returns {boolean}
480
+ */
481
+ function hasVcsReference(component) {
482
+ return Boolean(
483
+ component.repository?.url ||
484
+ (component.externalReferences || []).some(
485
+ (ref) => ref.type === "vcs" && ref.url,
486
+ ),
487
+ );
488
+ }
489
+
471
490
  /**
472
491
  * Fetch JSR registry metadata for deno/jsr package components.
473
492
  *
474
- * For each component carrying a `cdx:deno:jsrKey` property, fetches the version
475
- * and package endpoints from the JSR API (batched in a single prefetch round
476
- * when enabled) and fills in license, description, and the GitHub source link.
493
+ * For each component carrying a `cdx:deno:jsrKey` property, fetches the
494
+ * version and package endpoints from the JSR API and fills in license,
495
+ * description, and the GitHub source link. A document is requested only for
496
+ * a component that still misses a field that document supplies: the version
497
+ * document carries the license, the package document the description and the
498
+ * repository link, so whatever the lockfile and the installed-manifest
499
+ * mining filled is never asked for again. Neither document carries
500
+ * provenance, so a provenance fetch, as under --bom-audit, asks for nothing
501
+ * more.
477
502
  *
478
503
  * @param {Array<object>} pkgList Package components potentially enriched with `cdx:deno:jsrKey`.
479
504
  * @returns {Promise<Array<object>>} The enriched package list (same reference as pkgList).
480
505
  */
481
506
  export async function getJsrMetadata(pkgList) {
482
- // Both URLs per component, for every component, in one batched round.
507
+ // The documents each component still needs, decided before the batched
508
+ // round so a fetch the loop would never make is not issued either.
509
+ const documentsByComponent = new Map();
510
+ for (const component of pkgList) {
511
+ const urls = jsrUrlsFor(component);
512
+ if (!urls) {
513
+ continue;
514
+ }
515
+ const documents = [];
516
+ if (!component.license) {
517
+ documents.push(urls.versionUrl);
518
+ }
519
+ if (!component.description || !hasVcsReference(component)) {
520
+ documents.push(urls.packageUrl);
521
+ }
522
+ documentsByComponent.set(component, documents);
523
+ }
483
524
  const prefetched = await prefetchJson(
484
525
  prefetchEnabled()
485
- ? pkgList.flatMap((component) => {
486
- const urls = jsrUrlsFor(component);
487
- return urls
488
- ? [{ url: urls.versionUrl }, { url: urls.packageUrl }]
489
- : [];
490
- })
526
+ ? [...new Set([...documentsByComponent.values()].flat())]
527
+ .filter((url) => !jsrMetadataCache.has(url))
528
+ .map((url) => ({ url }))
491
529
  : [],
492
530
  );
493
531
  for (const component of pkgList) {
494
532
  try {
495
- const jsrKey = (component.properties || []).find(
496
- (p) => p.name === "cdx:deno:jsrKey",
497
- )?.value;
498
- if (!jsrKey) {
499
- continue;
500
- }
501
- // jsrKey looks like `@scope/name@version`.
502
- const atIndex = jsrKey.lastIndexOf("@");
503
- const idPart = atIndex > 0 ? jsrKey.substring(0, atIndex) : jsrKey;
504
- const version =
505
- atIndex > 0 ? jsrKey.substring(atIndex + 1) : component.version;
506
- const match = idPart.match(/^@([^/]+)\/(.+)$/);
507
- if (!match) {
533
+ const urls = jsrUrlsFor(component);
534
+ if (!urls) {
508
535
  continue;
509
536
  }
510
- const [, scope, pkgName] = match;
511
- const versionUrl = `${JSR_API_URL}scopes/${scope}/packages/${pkgName}/versions/${version}`;
512
- const packageUrl = `${JSR_API_URL}scopes/${scope}/packages/${pkgName}`;
537
+ const documents = documentsByComponent.get(component) || [];
513
538
 
514
- let versionBody = jsrMetadataCache.get(versionUrl);
515
- if (!versionBody) {
516
- const res =
517
- prefetchedResponse(prefetched, versionUrl) ||
518
- (await cdxgenAgent.get(versionUrl, { responseType: "json" }));
519
- versionBody = res.body;
520
- jsrMetadataCache.set(versionUrl, versionBody);
521
- }
522
- if (versionBody?.license && !component.license) {
523
- component.license = versionBody.license;
539
+ if (documents.includes(urls.versionUrl)) {
540
+ let versionBody = jsrMetadataCache.get(urls.versionUrl);
541
+ if (!versionBody) {
542
+ const res =
543
+ prefetchedResponse(prefetched, urls.versionUrl) ||
544
+ (await gatedGet(urls.versionUrl, { responseType: "json" }));
545
+ versionBody = res.body;
546
+ jsrMetadataCache.set(urls.versionUrl, versionBody);
547
+ }
548
+ if (versionBody?.license && !component.license) {
549
+ component.license = versionBody.license;
550
+ }
524
551
  }
525
552
 
526
- let packageBody = jsrMetadataCache.get(packageUrl);
527
- if (!packageBody) {
528
- const res =
529
- prefetchedResponse(prefetched, packageUrl) ||
530
- (await cdxgenAgent.get(packageUrl, { responseType: "json" }));
531
- packageBody = res.body;
532
- jsrMetadataCache.set(packageUrl, packageBody);
533
- }
534
- if (packageBody?.description && !component.description) {
535
- component.description = packageBody.description;
536
- }
537
- const ghRepo = packageBody?.githubRepository;
538
- if (ghRepo?.owner && ghRepo?.name) {
539
- addVcsReference(
540
- component,
541
- `https://github.com/${ghRepo.owner}/${ghRepo.name}`,
542
- );
553
+ if (documents.includes(urls.packageUrl)) {
554
+ let packageBody = jsrMetadataCache.get(urls.packageUrl);
555
+ if (!packageBody) {
556
+ const res =
557
+ prefetchedResponse(prefetched, urls.packageUrl) ||
558
+ (await gatedGet(urls.packageUrl, { responseType: "json" }));
559
+ packageBody = res.body;
560
+ jsrMetadataCache.set(urls.packageUrl, packageBody);
561
+ }
562
+ if (packageBody?.description && !component.description) {
563
+ component.description = packageBody.description;
564
+ }
565
+ const ghRepo = packageBody?.githubRepository;
566
+ if (ghRepo?.owner && ghRepo?.name) {
567
+ addVcsReference(
568
+ component,
569
+ `https://github.com/${ghRepo.owner}/${ghRepo.name}`,
570
+ );
571
+ }
543
572
  }
544
573
  } catch (_err) {
545
574
  if (DEBUG_MODE) {
@@ -1034,11 +1063,9 @@ export async function parseDenoLock(lockFile, options = {}) {
1034
1063
  JSR_NPM_REGISTRY_HOST,
1035
1064
  );
1036
1065
 
1037
- if (
1038
- shouldFetchLicense() ||
1039
- shouldFetchVCS() ||
1040
- readEnvironmentVariable("FETCH_LICENSE") === "true"
1041
- ) {
1066
+ // The shared metadata gate: FETCH_LICENSE and the provenance fetch that
1067
+ // --bom-audit turns on both reach the registries from here.
1068
+ if (shouldFetchPackageMetadata()) {
1042
1069
  if (DEBUG_MODE) {
1043
1070
  console.log(
1044
1071
  `About to fetch registry metadata for ${pkgList.length} packages in parseDenoLock`,