@cdxgen/cdxgen 13.4.0 → 13.6.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 (305) hide show
  1. package/README.md +9 -9
  2. package/bin/cdxgen-secure.js +15 -0
  3. package/bin/cdxgen.js +29 -5
  4. package/bin/evinse.js +8 -0
  5. package/bin/hbom.js +15 -7
  6. package/bin/repl.js +29 -0
  7. package/bin/validate.js +6 -0
  8. package/data/cbomosdb-queries.json +13 -1
  9. package/data/component-tags.json +8 -0
  10. package/data/license-aliases.json +24 -2
  11. package/data/queries-darwin.json +25 -1
  12. package/data/queries-win.json +19 -1
  13. package/data/queries.json +41 -0
  14. package/data/remediations.json +407 -1
  15. package/data/rules/ai-bom.yaml +1 -1
  16. package/data/rules/brotli-decoder.yaml +107 -0
  17. package/data/rules/cbom-security.yaml +235 -4
  18. package/data/rules/go-binaries.yaml +46 -0
  19. package/data/rules/golem-go.yaml +80 -0
  20. package/data/rules/hbom-compliance.yaml +40 -22
  21. package/data/rules/hbom-performance.yaml +7 -1
  22. package/data/rules/host-topology.yaml +1 -1
  23. package/data/rules/obom-runtime.yaml +31 -2
  24. package/data/rules/php-runtime.yaml +143 -0
  25. package/data/rules/vscode-extensions.yaml +75 -0
  26. package/data/spdx-license-list.json +121 -7
  27. package/data/spdx-licenses.json +69 -0
  28. package/data/spdx.schema.json +845 -2
  29. package/lib/audit/index.js +14 -0
  30. package/lib/cli/bomAssembly.js +120 -6
  31. package/lib/cli/cliOptions.js +110 -3
  32. package/lib/cli/index.js +182 -6
  33. package/lib/cli/jsBom.js +153 -64
  34. package/lib/cli/jvmBom.js +363 -66
  35. package/lib/cli/managedBom.js +853 -87
  36. package/lib/cli/nativeBom.js +267 -33
  37. package/lib/core/boundedFile.js +344 -0
  38. package/lib/core/brotliProbe.js +182 -0
  39. package/lib/core/env.js +38 -8
  40. package/lib/core/fs.js +40 -19
  41. package/lib/core/httpClient.js +172 -46
  42. package/lib/core/lockPaths.js +38 -0
  43. package/lib/core/paths.js +24 -1
  44. package/lib/core/processTree.js +5 -0
  45. package/lib/core/projectConfig.js +1 -0
  46. package/lib/core/projectTooling.js +97 -0
  47. package/lib/core/propertySanitizer.js +72 -0
  48. package/lib/core/toolRegistry.js +170 -0
  49. package/lib/ecosystems/cppEvidence.js +263 -106
  50. package/lib/ecosystems/cppIncludeResolver.js +16 -5
  51. package/lib/ecosystems/ecosystems.js +25 -10
  52. package/lib/ecosystems/gemHostProbe.js +301 -0
  53. package/lib/ecosystems/golem.js +550 -6
  54. package/lib/ecosystems/gradleutils.js +858 -244
  55. package/lib/ecosystems/parsers-bazel.js +107 -6
  56. package/lib/ecosystems/parsers-dotnet.js +117 -18
  57. package/lib/ecosystems/parsers-go.js +1090 -367
  58. package/lib/ecosystems/parsers-js.js +505 -22
  59. package/lib/ecosystems/parsers-jvm.js +259 -17
  60. package/lib/ecosystems/parsers-misc.js +438 -64
  61. package/lib/ecosystems/parsers-python.js +100 -12
  62. package/lib/ecosystems/pythonutils.js +128 -2
  63. package/lib/ecosystems/rubyutils.js +544 -34
  64. package/lib/ecosystems/rusi.js +10 -0
  65. package/lib/ecosystems/scalacliutils.js +4 -1
  66. package/lib/ecosystems/scalasem.js +798 -151
  67. package/lib/ecosystems/vendoredCode.js +237 -3
  68. package/lib/ecosystems/venvProbe.js +360 -0
  69. package/lib/evinser/evinser.js +472 -61
  70. package/lib/evinser/swiftsem.js +68 -5
  71. package/lib/helpers/agenticToolutils.js +413 -93
  72. package/lib/helpers/vsixutils.js +1574 -315
  73. package/lib/inventory/agentSkillSpec.js +17 -0
  74. package/lib/inventory/apkInstalledDb.js +243 -0
  75. package/lib/inventory/atomUtils.js +110 -0
  76. package/lib/inventory/auditCategories.js +3 -3
  77. package/lib/inventory/brotliDecoder.js +142 -0
  78. package/lib/inventory/buildToolRateLimit.js +1 -1
  79. package/lib/inventory/cacheDir.js +52 -9
  80. package/lib/inventory/cbomutils.js +56 -7
  81. package/lib/inventory/certificates.js +2371 -0
  82. package/lib/inventory/communityAiConfigParser.js +4 -9
  83. package/lib/inventory/deps.js +41 -4
  84. package/lib/inventory/display.js +200 -3
  85. package/lib/inventory/dosai.js +639 -63
  86. package/lib/inventory/dotnetRuntime.js +217 -0
  87. package/lib/inventory/dynamic.js +45 -3
  88. package/lib/inventory/envcontext.js +475 -18
  89. package/lib/inventory/evidenceUtils.js +447 -23
  90. package/lib/inventory/fetchBatch.js +1 -1
  91. package/lib/inventory/formulationParsers.js +32 -3
  92. package/lib/inventory/goBuildInfo.js +140 -0
  93. package/lib/inventory/gtfobins.js +13 -0
  94. package/lib/inventory/hbom.js +67 -7
  95. package/lib/inventory/hbomAnalysis.js +16 -0
  96. package/lib/inventory/hostRuntimeProbe.js +686 -0
  97. package/lib/inventory/hostTopology.js +21 -0
  98. package/lib/inventory/jvmLocalRepos.js +9 -2
  99. package/lib/inventory/jvmToolEnv.js +29 -0
  100. package/lib/inventory/licenseEnhancer.js +12 -0
  101. package/lib/inventory/mavenCentralMirror.js +534 -0
  102. package/lib/inventory/nodeBuildInfo.js +218 -0
  103. package/lib/inventory/nodeHostProbe.js +202 -0
  104. package/lib/inventory/osPackagePurl.js +244 -0
  105. package/lib/inventory/osPackageResolver.js +271 -87
  106. package/lib/inventory/osinfo.js +79 -31
  107. package/lib/inventory/osqueryTransform.js +114 -5
  108. package/lib/inventory/phpBuildInfo.js +438 -0
  109. package/lib/inventory/phpHostProbe.js +185 -0
  110. package/lib/inventory/rootfsCerts.js +426 -0
  111. package/lib/inventory/rubyBuildInfo.js +972 -0
  112. package/lib/inventory/rubyHostProbe.js +218 -0
  113. package/lib/inventory/scalaCoords.js +4 -3
  114. package/lib/inventory/scalaDedupe.js +440 -0
  115. package/lib/inventory/source.js +256 -5
  116. package/lib/inventory/spdx.js +144 -0
  117. package/lib/inventory/traceRunner.js +5 -1
  118. package/lib/inventory/tracedCrypto.js +129 -0
  119. package/lib/managers/binary.js +866 -186
  120. package/lib/managers/docker.js +245 -12
  121. package/lib/parsers/email.js +277 -0
  122. package/lib/parsers/largeJson.js +62 -13
  123. package/lib/parsers/vscodeExtensionId.js +183 -0
  124. package/lib/server/server.js +198 -2
  125. package/lib/stages/postgen/annotator.js +17 -1
  126. package/lib/stages/postgen/introspection/reflect.js +4 -1
  127. package/lib/stages/postgen/postgen.js +5 -5
  128. package/lib/stages/postgen/ruleEngine.js +71 -6
  129. package/lib/stages/postgen/specVersionCompat.js +30 -0
  130. package/lib/stages/pregen/envAudit.js +1 -0
  131. package/lib/stages/pregen/pregen.js +231 -62
  132. package/lib/validator/bomValidator.js +32 -6
  133. package/lib/validator/generated/runtime.mjs +13 -0
  134. package/lib/validator/generated/validate-1.6.mjs +27 -8
  135. package/lib/validator/generated/validate-1.7.mjs +32 -13
  136. package/lib/validator/generated/validate-2.0.mjs +31 -12
  137. package/lib/validator/index.js +1 -1
  138. package/package.json +19 -18
  139. package/types/bin/cdxgen-secure.d.ts +3 -0
  140. package/types/bin/cdxgen-secure.d.ts.map +1 -0
  141. package/types/bin/repl.d.ts.map +1 -1
  142. package/types/lib/audit/index.d.ts.map +1 -1
  143. package/types/lib/cli/bomAssembly.d.ts +22 -3
  144. package/types/lib/cli/bomAssembly.d.ts.map +1 -1
  145. package/types/lib/cli/cliOptions.d.ts +43 -0
  146. package/types/lib/cli/cliOptions.d.ts.map +1 -1
  147. package/types/lib/cli/index.d.ts.map +1 -1
  148. package/types/lib/cli/jsBom.d.ts +1 -17
  149. package/types/lib/cli/jsBom.d.ts.map +1 -1
  150. package/types/lib/cli/jvmBom.d.ts +20 -0
  151. package/types/lib/cli/jvmBom.d.ts.map +1 -1
  152. package/types/lib/cli/managedBom.d.ts.map +1 -1
  153. package/types/lib/cli/nativeBom.d.ts.map +1 -1
  154. package/types/lib/core/boundedFile.d.ts +70 -0
  155. package/types/lib/core/boundedFile.d.ts.map +1 -0
  156. package/types/lib/core/brotliProbe.d.ts +37 -0
  157. package/types/lib/core/brotliProbe.d.ts.map +1 -0
  158. package/types/lib/core/env.d.ts +22 -2
  159. package/types/lib/core/env.d.ts.map +1 -1
  160. package/types/lib/core/fs.d.ts.map +1 -1
  161. package/types/lib/core/httpClient.d.ts +24 -0
  162. package/types/lib/core/httpClient.d.ts.map +1 -1
  163. package/types/lib/core/lockPaths.d.ts +19 -0
  164. package/types/lib/core/lockPaths.d.ts.map +1 -0
  165. package/types/lib/core/processTree.d.ts +2 -0
  166. package/types/lib/core/processTree.d.ts.map +1 -1
  167. package/types/lib/core/projectConfig.d.ts.map +1 -1
  168. package/types/lib/core/projectTooling.d.ts +41 -0
  169. package/types/lib/core/projectTooling.d.ts.map +1 -0
  170. package/types/lib/core/propertySanitizer.d.ts +26 -0
  171. package/types/lib/core/propertySanitizer.d.ts.map +1 -1
  172. package/types/lib/core/toolRegistry.d.ts +36 -0
  173. package/types/lib/core/toolRegistry.d.ts.map +1 -0
  174. package/types/lib/ecosystems/cppEvidence.d.ts +40 -13
  175. package/types/lib/ecosystems/cppEvidence.d.ts.map +1 -1
  176. package/types/lib/ecosystems/cppIncludeResolver.d.ts +2 -1
  177. package/types/lib/ecosystems/cppIncludeResolver.d.ts.map +1 -1
  178. package/types/lib/ecosystems/ecosystems.d.ts.map +1 -1
  179. package/types/lib/ecosystems/gemHostProbe.d.ts +28 -0
  180. package/types/lib/ecosystems/gemHostProbe.d.ts.map +1 -0
  181. package/types/lib/ecosystems/golem.d.ts +81 -1
  182. package/types/lib/ecosystems/golem.d.ts.map +1 -1
  183. package/types/lib/ecosystems/gradleutils.d.ts +57 -21
  184. package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
  185. package/types/lib/ecosystems/parsers-bazel.d.ts.map +1 -1
  186. package/types/lib/ecosystems/parsers-dotnet.d.ts +40 -4
  187. package/types/lib/ecosystems/parsers-dotnet.d.ts.map +1 -1
  188. package/types/lib/ecosystems/parsers-go.d.ts +85 -13
  189. package/types/lib/ecosystems/parsers-go.d.ts.map +1 -1
  190. package/types/lib/ecosystems/parsers-js.d.ts +17 -20
  191. package/types/lib/ecosystems/parsers-js.d.ts.map +1 -1
  192. package/types/lib/ecosystems/parsers-jvm.d.ts +28 -2
  193. package/types/lib/ecosystems/parsers-jvm.d.ts.map +1 -1
  194. package/types/lib/ecosystems/parsers-misc.d.ts +37 -58
  195. package/types/lib/ecosystems/parsers-misc.d.ts.map +1 -1
  196. package/types/lib/ecosystems/parsers-python.d.ts +14 -3
  197. package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
  198. package/types/lib/ecosystems/pythonutils.d.ts +19 -1
  199. package/types/lib/ecosystems/pythonutils.d.ts.map +1 -1
  200. package/types/lib/ecosystems/rubyutils.d.ts +144 -12
  201. package/types/lib/ecosystems/rubyutils.d.ts.map +1 -1
  202. package/types/lib/ecosystems/rusi.d.ts.map +1 -1
  203. package/types/lib/ecosystems/scalacliutils.d.ts.map +1 -1
  204. package/types/lib/ecosystems/scalasem.d.ts.map +1 -1
  205. package/types/lib/ecosystems/vendoredCode.d.ts +26 -0
  206. package/types/lib/ecosystems/vendoredCode.d.ts.map +1 -1
  207. package/types/lib/ecosystems/venvProbe.d.ts +40 -0
  208. package/types/lib/ecosystems/venvProbe.d.ts.map +1 -0
  209. package/types/lib/evinser/evinser.d.ts +88 -8
  210. package/types/lib/evinser/evinser.d.ts.map +1 -1
  211. package/types/lib/evinser/swiftsem.d.ts +10 -0
  212. package/types/lib/evinser/swiftsem.d.ts.map +1 -1
  213. package/types/lib/inventory/agentSkillSpec.d.ts +13 -0
  214. package/types/lib/inventory/agentSkillSpec.d.ts.map +1 -0
  215. package/types/lib/inventory/apkInstalledDb.d.ts +42 -0
  216. package/types/lib/inventory/apkInstalledDb.d.ts.map +1 -0
  217. package/types/lib/inventory/atomUtils.d.ts +33 -0
  218. package/types/lib/inventory/atomUtils.d.ts.map +1 -1
  219. package/types/lib/inventory/brotliDecoder.d.ts +58 -0
  220. package/types/lib/inventory/brotliDecoder.d.ts.map +1 -0
  221. package/types/lib/inventory/cacheDir.d.ts +12 -4
  222. package/types/lib/inventory/cacheDir.d.ts.map +1 -1
  223. package/types/lib/inventory/cbomutils.d.ts +17 -0
  224. package/types/lib/inventory/cbomutils.d.ts.map +1 -1
  225. package/types/lib/inventory/certificates.d.ts +205 -0
  226. package/types/lib/inventory/certificates.d.ts.map +1 -0
  227. package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
  228. package/types/lib/inventory/deps.d.ts +2 -1
  229. package/types/lib/inventory/deps.d.ts.map +1 -1
  230. package/types/lib/inventory/display.d.ts +18 -0
  231. package/types/lib/inventory/display.d.ts.map +1 -1
  232. package/types/lib/inventory/dosai.d.ts +162 -7
  233. package/types/lib/inventory/dosai.d.ts.map +1 -1
  234. package/types/lib/inventory/dotnetRuntime.d.ts +44 -0
  235. package/types/lib/inventory/dotnetRuntime.d.ts.map +1 -0
  236. package/types/lib/inventory/dynamic.d.ts +6 -1
  237. package/types/lib/inventory/dynamic.d.ts.map +1 -1
  238. package/types/lib/inventory/envcontext.d.ts +92 -8
  239. package/types/lib/inventory/envcontext.d.ts.map +1 -1
  240. package/types/lib/inventory/evidenceUtils.d.ts +29 -10
  241. package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
  242. package/types/lib/inventory/formulationParsers.d.ts.map +1 -1
  243. package/types/lib/inventory/goBuildInfo.d.ts +10 -0
  244. package/types/lib/inventory/goBuildInfo.d.ts.map +1 -0
  245. package/types/lib/inventory/gtfobins.d.ts.map +1 -1
  246. package/types/lib/inventory/hbom.d.ts.map +1 -1
  247. package/types/lib/inventory/hbomAnalysis.d.ts +10 -0
  248. package/types/lib/inventory/hbomAnalysis.d.ts.map +1 -1
  249. package/types/lib/inventory/hostRuntimeProbe.d.ts +44 -0
  250. package/types/lib/inventory/hostRuntimeProbe.d.ts.map +1 -0
  251. package/types/lib/inventory/hostTopology.d.ts.map +1 -1
  252. package/types/lib/inventory/jvmToolEnv.d.ts +12 -0
  253. package/types/lib/inventory/jvmToolEnv.d.ts.map +1 -1
  254. package/types/lib/inventory/licenseEnhancer.d.ts.map +1 -1
  255. package/types/lib/inventory/mavenCentralMirror.d.ts +170 -0
  256. package/types/lib/inventory/mavenCentralMirror.d.ts.map +1 -0
  257. package/types/lib/inventory/nodeBuildInfo.d.ts +95 -0
  258. package/types/lib/inventory/nodeBuildInfo.d.ts.map +1 -0
  259. package/types/lib/inventory/nodeHostProbe.d.ts +15 -0
  260. package/types/lib/inventory/nodeHostProbe.d.ts.map +1 -0
  261. package/types/lib/inventory/osPackagePurl.d.ts +99 -0
  262. package/types/lib/inventory/osPackagePurl.d.ts.map +1 -0
  263. package/types/lib/inventory/osPackageResolver.d.ts +44 -2
  264. package/types/lib/inventory/osPackageResolver.d.ts.map +1 -1
  265. package/types/lib/inventory/osinfo.d.ts +31 -6
  266. package/types/lib/inventory/osinfo.d.ts.map +1 -1
  267. package/types/lib/inventory/osqueryTransform.d.ts +51 -0
  268. package/types/lib/inventory/osqueryTransform.d.ts.map +1 -1
  269. package/types/lib/inventory/phpBuildInfo.d.ts +142 -0
  270. package/types/lib/inventory/phpBuildInfo.d.ts.map +1 -0
  271. package/types/lib/inventory/phpHostProbe.d.ts +35 -0
  272. package/types/lib/inventory/phpHostProbe.d.ts.map +1 -0
  273. package/types/lib/inventory/rootfsCerts.d.ts +27 -0
  274. package/types/lib/inventory/rootfsCerts.d.ts.map +1 -0
  275. package/types/lib/inventory/rubyBuildInfo.d.ts +271 -0
  276. package/types/lib/inventory/rubyBuildInfo.d.ts.map +1 -0
  277. package/types/lib/inventory/rubyHostProbe.d.ts +47 -0
  278. package/types/lib/inventory/rubyHostProbe.d.ts.map +1 -0
  279. package/types/lib/inventory/source.d.ts +38 -0
  280. package/types/lib/inventory/source.d.ts.map +1 -1
  281. package/types/lib/inventory/spdx.d.ts +15 -0
  282. package/types/lib/inventory/spdx.d.ts.map +1 -1
  283. package/types/lib/inventory/traceRunner.d.ts +4 -1
  284. package/types/lib/inventory/traceRunner.d.ts.map +1 -1
  285. package/types/lib/inventory/tracedCrypto.d.ts +22 -0
  286. package/types/lib/inventory/tracedCrypto.d.ts.map +1 -1
  287. package/types/lib/managers/binary.d.ts +10 -0
  288. package/types/lib/managers/binary.d.ts.map +1 -1
  289. package/types/lib/managers/docker.d.ts +24 -0
  290. package/types/lib/managers/docker.d.ts.map +1 -1
  291. package/types/lib/parsers/email.d.ts +19 -0
  292. package/types/lib/parsers/email.d.ts.map +1 -0
  293. package/types/lib/parsers/largeJson.d.ts +17 -3
  294. package/types/lib/parsers/largeJson.d.ts.map +1 -1
  295. package/types/lib/server/server.d.ts +8 -0
  296. package/types/lib/server/server.d.ts.map +1 -1
  297. package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
  298. package/types/lib/stages/postgen/introspection/reflect.d.ts.map +1 -1
  299. package/types/lib/stages/postgen/ruleEngine.d.ts +7 -4
  300. package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
  301. package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
  302. package/types/lib/stages/pregen/envAudit.d.ts.map +1 -1
  303. package/types/lib/stages/pregen/pregen.d.ts +26 -9
  304. package/types/lib/stages/pregen/pregen.d.ts.map +1 -1
  305. package/types/lib/validator/bomValidator.d.ts.map +1 -1
package/lib/cli/jsBom.js CHANGED
@@ -70,9 +70,13 @@ import {
70
70
  } from "../helpers/agenticToolutils.js";
71
71
  import {
72
72
  cleanupTempDir,
73
- collectInstalledExtensions,
73
+ collectIdeInventory,
74
74
  discoverIdeExtensionDirs,
75
75
  extractVsixToTempDir,
76
+ identifyIdeFromExtensionsDir,
77
+ isInstalledExtensionDir,
78
+ isInstalledExtensionsDir,
79
+ mergeExtensionComponents,
76
80
  parseVsixFile,
77
81
  VSCODE_EXTENSION_PURL_TYPE,
78
82
  } from "../helpers/vsixutils.js";
@@ -96,6 +100,7 @@ import {
96
100
  } from "../inventory/depsUtils.js";
97
101
  import { GIT_COMMAND } from "../inventory/envcontext.js";
98
102
  import { tryBuildPurl } from "../inventory/purl.js";
103
+ import { isInsideInstalledGem } from "../inventory/rubyBuildInfo.js";
99
104
  import { DEFAULT_NPMRC_BLOCKLIST, parseNpmrc } from "../parsers/npmrc.js";
100
105
  import {
101
106
  buildBomNSData,
@@ -127,6 +132,13 @@ const isWin = _platform() === "win32";
127
132
  * @param {object} options CLI options
128
133
  * @returns {string|undefined} The detected AI inventory type (`"ai"`) or undefined
129
134
  */
135
+ // The manifests and lockfiles inside an installed gem, such as the VS Code
136
+ // extension typeprof ships, are part of the gem's sources and install nothing.
137
+ // An image scan reads each gem home as a directory of its own, so the check is
138
+ // on the absolute path rather than a glob relative to the scanned directory.
139
+ const outsideInstalledGems = (files, scanRoot) =>
140
+ files.filter((file) => !isInsideInstalledGem(file, safeExistsSync, scanRoot));
141
+
130
142
  export function getDirectAiInventoryType(path, options) {
131
143
  const exactAiInventoryType = getExactAiInventoryType(options);
132
144
  if (exactAiInventoryType) {
@@ -166,6 +178,9 @@ export async function createNodejsBom(path, options) {
166
178
  let dependencies = [];
167
179
  let parentComponent = {};
168
180
  const parentSubComponents = [];
181
+ // Formulation components reported by the pnpm lockfiles, such as the
182
+ // pnpm version resolved for the project.
183
+ const pnpmFormulationList = [];
169
184
  let ppurl = "";
170
185
  const exactAiInventoryType = getDirectAiInventoryType(path, options);
171
186
  const requestedAiInventoryTypes = getRequestedAiInventoryTypes(options);
@@ -225,7 +240,10 @@ export async function createNodejsBom(path, options) {
225
240
  }
226
241
  // Docker mode requires special handling
227
242
  if (hasAnyProjectType(["docker", "oci", "container", "os"], options, false)) {
228
- const pkgJsonFiles = getAllFiles(path, "**/package.json", options);
243
+ const pkgJsonFiles = outsideInstalledGems(
244
+ getAllFiles(path, "**/package.json", options),
245
+ path,
246
+ );
229
247
  // Are there any package.json files in the container?
230
248
  if (pkgJsonFiles.length) {
231
249
  // Every manifest is read locally first, and the registry is asked about
@@ -314,33 +332,48 @@ export async function createNodejsBom(path, options) {
314
332
  // otherwise the dependencies of those nested projects are silently dropped
315
333
  // from the BOM (see #4224). node_modules and .git stay ignored by getAllFiles.
316
334
  const lockSearchOptions = { ...options, includeDot: true };
317
- let yarnLockFiles = getAllFiles(
335
+ let yarnLockFiles = outsideInstalledGems(
336
+ getAllFiles(
337
+ path,
338
+ `${options.multiProject ? "**/" : ""}yarn.lock`,
339
+ lockSearchOptions,
340
+ ),
318
341
  path,
319
- `${options.multiProject ? "**/" : ""}yarn.lock`,
320
- lockSearchOptions,
321
342
  );
322
- const shrinkwrapFiles = getAllFiles(
343
+ const shrinkwrapFiles = outsideInstalledGems(
344
+ getAllFiles(
345
+ path,
346
+ `${options.multiProject ? "**/" : ""}npm-shrinkwrap.json`,
347
+ lockSearchOptions,
348
+ ),
323
349
  path,
324
- `${options.multiProject ? "**/" : ""}npm-shrinkwrap.json`,
325
- lockSearchOptions,
326
350
  );
327
- let pkgLockFiles = getAllFiles(
351
+ let pkgLockFiles = outsideInstalledGems(
352
+ getAllFiles(
353
+ path,
354
+ `${options.multiProject ? "**/" : ""}package-lock.json`,
355
+ lockSearchOptions,
356
+ ),
328
357
  path,
329
- `${options.multiProject ? "**/" : ""}package-lock.json`,
330
- lockSearchOptions,
331
358
  );
332
359
  if (shrinkwrapFiles.length) {
333
360
  pkgLockFiles = pkgLockFiles.concat(shrinkwrapFiles);
334
361
  }
335
- let pnpmLockFiles = getAllFiles(
362
+ let pnpmLockFiles = outsideInstalledGems(
363
+ getAllFiles(
364
+ path,
365
+ `${options.multiProject ? "**/" : ""}pnpm-lock.yaml`,
366
+ lockSearchOptions,
367
+ ),
336
368
  path,
337
- `${options.multiProject ? "**/" : ""}pnpm-lock.yaml`,
338
- lockSearchOptions,
339
369
  );
340
- const bunLockFiles = getAllFiles(
370
+ const bunLockFiles = outsideInstalledGems(
371
+ getAllFiles(
372
+ path,
373
+ `${options.multiProject ? "**/" : ""}bun.lock`,
374
+ lockSearchOptions,
375
+ ),
341
376
  path,
342
- `${options.multiProject ? "**/" : ""}bun.lock`,
343
- lockSearchOptions,
344
377
  );
345
378
  // Warn about the binary bun lockfile which cdxgen cannot parse. Users should
346
379
  // regenerate a text lockfile with `bun install --save-text-lockfile`.
@@ -476,15 +509,21 @@ export async function createNodejsBom(path, options) {
476
509
  }
477
510
  }
478
511
  }
479
- const pkgJsonLockFiles = getAllFiles(
512
+ const pkgJsonLockFiles = outsideInstalledGems(
513
+ getAllFiles(
514
+ path,
515
+ `${options.multiProject ? "**/" : ""}package-lock.json`,
516
+ lockSearchOptions,
517
+ ),
480
518
  path,
481
- `${options.multiProject ? "**/" : ""}package-lock.json`,
482
- lockSearchOptions,
483
519
  );
484
- const pkgJsonFiles = getAllFiles(
520
+ const pkgJsonFiles = outsideInstalledGems(
521
+ getAllFiles(
522
+ path,
523
+ `${options.multiProject ? "**/" : ""}package.json`,
524
+ lockSearchOptions,
525
+ ),
485
526
  path,
486
- `${options.multiProject ? "**/" : ""}package.json`,
487
- lockSearchOptions,
488
527
  );
489
528
  const npmInstallCount =
490
529
  Number.parseInt(readEnvironmentVariable("NPM_INSTALL_COUNT"), 10) || 2;
@@ -708,20 +747,29 @@ export async function createNodejsBom(path, options) {
708
747
  anyInstallSuccess = true;
709
748
  }
710
749
  }
711
- pkgLockFiles = getAllFiles(
750
+ pkgLockFiles = outsideInstalledGems(
751
+ getAllFiles(
752
+ path,
753
+ `${options.multiProject ? "**/" : ""}package-lock.json`,
754
+ options,
755
+ ),
712
756
  path,
713
- `${options.multiProject ? "**/" : ""}package-lock.json`,
714
- options,
715
757
  );
716
- pnpmLockFiles = getAllFiles(
758
+ pnpmLockFiles = outsideInstalledGems(
759
+ getAllFiles(
760
+ path,
761
+ `${options.multiProject ? "**/" : ""}pnpm-lock.yaml`,
762
+ options,
763
+ ),
717
764
  path,
718
- `${options.multiProject ? "**/" : ""}pnpm-lock.yaml`,
719
- options,
720
765
  );
721
- yarnLockFiles = getAllFiles(
766
+ yarnLockFiles = outsideInstalledGems(
767
+ getAllFiles(
768
+ path,
769
+ `${options.multiProject ? "**/" : ""}yarn.lock`,
770
+ options,
771
+ ),
722
772
  path,
723
- `${options.multiProject ? "**/" : ""}yarn.lock`,
724
- options,
725
773
  );
726
774
  if (
727
775
  anyInstallSuccess &&
@@ -743,7 +791,6 @@ export async function createNodejsBom(path, options) {
743
791
  const workspaceSrcFiles = {};
744
792
  const workspaceDirectDeps = {};
745
793
  const depsWorkspaceRefs = {};
746
- let workspaceCatalogs = {};
747
794
  const seenPkgJsonFiles = {};
748
795
  // Is this a pnpm workspace?
749
796
  for (const f of pnpmWorkspaceFiles) {
@@ -832,10 +879,6 @@ export async function createNodejsBom(path, options) {
832
879
  }
833
880
  }
834
881
  }
835
- workspaceCatalogs = {
836
- ...workspaceCatalogs,
837
- ...(workspaceObj.catalogs || {}),
838
- };
839
882
  }
840
883
  if (DEBUG_MODE && Object.keys(seenPkgJsonFiles).length) {
841
884
  console.log(
@@ -898,11 +941,13 @@ export async function createNodejsBom(path, options) {
898
941
  parentComponent,
899
942
  workspacePackages,
900
943
  workspaceSrcFiles,
901
- workspaceCatalogs,
902
944
  workspaceDirectDeps,
903
945
  depsWorkspaceRefs,
904
946
  path,
905
947
  );
948
+ if (parsedList?.formulationList?.length) {
949
+ pnpmFormulationList.push(...parsedList.formulationList);
950
+ }
906
951
  const dlist = parsedList.pkgList;
907
952
  if (dlist?.length) {
908
953
  pkgList = pkgList.concat(dlist);
@@ -1043,7 +1088,6 @@ export async function createNodejsBom(path, options) {
1043
1088
  {},
1044
1089
  {},
1045
1090
  {},
1046
- {},
1047
1091
  path,
1048
1092
  );
1049
1093
  let pkgList = addWasmComponentsFromImports(
@@ -1554,6 +1598,7 @@ export async function createNodejsBom(path, options) {
1554
1598
  dependencies,
1555
1599
  parentComponent,
1556
1600
  services: inventoryServices,
1601
+ formulationList: pnpmFormulationList,
1557
1602
  });
1558
1603
  }
1559
1604
 
@@ -1724,12 +1769,13 @@ export async function createVscodeExtensionBom(path, options) {
1724
1769
  // Mode 1: Scan for .vsix files in the given directory, or treat the input
1725
1770
  // path as a single .vsix file.
1726
1771
  let vsixFiles = [];
1727
- if (path.endsWith(".vsix")) {
1772
+ const isVsixPath = path.toLowerCase().endsWith(".vsix");
1773
+ if (isVsixPath) {
1728
1774
  vsixFiles = [resolve(path)];
1729
1775
  } else {
1730
1776
  vsixFiles = getAllFiles(
1731
1777
  path,
1732
- `${options.multiProject ? "**/" : ""}*.vsix`,
1778
+ `${options.multiProject ? "**/" : ""}*.{vsix,VSIX,Vsix}`,
1733
1779
  options,
1734
1780
  );
1735
1781
  }
@@ -1764,32 +1810,68 @@ export async function createVscodeExtensionBom(path, options) {
1764
1810
  }
1765
1811
  }
1766
1812
 
1767
- // Mode 2: Auto-discover extensions from known IDE locations
1768
- if (shouldDiscoverInstalledIdeExtensions) {
1769
- const ideDirs = discoverIdeExtensionDirs();
1770
- if (ideDirs.length) {
1813
+ // Mode 2: The path is an editor's extensions folder, such as
1814
+ // ~/.cursor/extensions copied off a workstation, or one extension in such a
1815
+ // folder. A source repository that contains an extension is neither. The
1816
+ // editor's own version is looked up beside the folder, never among this
1817
+ // machine's installed applications.
1818
+ const resolvedPath = resolve(path);
1819
+ const pathIdeDirs = [];
1820
+ const pathFolder = (dir, only) => {
1821
+ const ide = identifyIdeFromExtensionsDir(dir);
1822
+ return {
1823
+ ...(ide || { name: undefined }),
1824
+ dir,
1825
+ only,
1826
+ probeApps: false,
1827
+ };
1828
+ };
1829
+ if (!isVsixPath && safeExistsSync(resolvedPath)) {
1830
+ if (isInstalledExtensionsDir(resolvedPath)) {
1831
+ pathIdeDirs.push(pathFolder(resolvedPath));
1832
+ } else if (
1833
+ isInstalledExtensionsDir(dirname(resolvedPath)) &&
1834
+ isInstalledExtensionDir(resolvedPath)
1835
+ ) {
1836
+ pathIdeDirs.push(
1837
+ pathFolder(dirname(resolvedPath), basename(resolvedPath)),
1838
+ );
1839
+ }
1840
+ }
1841
+
1842
+ // Mode 3: Auto-discover extensions from known IDE locations when the path
1843
+ // held nothing to scan, so `cdxgen -t ide` in any folder reads this host
1844
+ // while `cdxgen -t ide <folder of .vsix files>` reads only that folder.
1845
+ const hostIdeDirs =
1846
+ shouldDiscoverInstalledIdeExtensions &&
1847
+ !pathIdeDirs.length &&
1848
+ !vsixFiles.length
1849
+ ? discoverIdeExtensionDirs()
1850
+ : [];
1851
+ if (hostIdeDirs.length && DEBUG_MODE) {
1852
+ console.log(
1853
+ `Discovered IDE extension directories: ${hostIdeDirs.map((d) => `${d.name}: ${d.dir}`).join(", ")}`,
1854
+ );
1855
+ }
1856
+ const ideDirs = [...pathIdeDirs, ...hostIdeDirs];
1857
+ if (ideDirs.length) {
1858
+ const inventory = collectIdeInventory(ideDirs);
1859
+ if (inventory.components.length) {
1771
1860
  if (DEBUG_MODE) {
1772
1861
  console.log(
1773
- `Discovered IDE extension directories: ${ideDirs.map((d) => `${d.name}: ${d.dir}`).join(", ")}`,
1862
+ `Found ${inventory.components.length} IDE and extension component(s) in ${ideDirs.length} folder(s)`,
1774
1863
  );
1775
1864
  }
1776
- const ideExtensions = collectInstalledExtensions(ideDirs);
1777
- if (ideExtensions.length) {
1778
- if (DEBUG_MODE) {
1779
- console.log(
1780
- `Found ${ideExtensions.length} IDE extension(s) from ${ideDirs.length} IDE location(s)`,
1781
- );
1782
- }
1783
- pkgList = pkgList.concat(ideExtensions);
1784
- // Deep analysis for IDE extension directories
1785
- for (const ideDir of ideDirs) {
1786
- await analyzeInstalledExtensionDirs(
1787
- ideDir.dir,
1788
- options,
1789
- pkgList,
1790
- dependencies,
1791
- );
1792
- }
1865
+ pkgList = pkgList.concat(inventory.components);
1866
+ dependencies = mergeDependencies(dependencies, inventory.dependencies);
1867
+ for (const ideDir of ideDirs) {
1868
+ await analyzeInstalledExtensionDirs(
1869
+ ideDir.dir,
1870
+ options,
1871
+ pkgList,
1872
+ dependencies,
1873
+ ideDir.only,
1874
+ );
1793
1875
  }
1794
1876
  }
1795
1877
  }
@@ -1798,7 +1880,9 @@ export async function createVscodeExtensionBom(path, options) {
1798
1880
  for (const td of tempDirs) {
1799
1881
  cleanupTempDir(td);
1800
1882
  }
1801
- pkgList = trimComponents(pkgList);
1883
+ // A .vsix and the folder it was installed into describe one build; merge
1884
+ // them before trimComponents keeps only the first.
1885
+ pkgList = trimComponents(mergeExtensionComponents(pkgList));
1802
1886
  return buildBomNSData(options, pkgList, VSCODE_EXTENSION_PURL_TYPE, {
1803
1887
  src: path,
1804
1888
  filename: vsixFiles.join(", "),
@@ -2189,12 +2273,14 @@ export async function analyzeExtensionDir(extDir, options) {
2189
2273
  * @param {Object} options CLI options
2190
2274
  * @param {Object[]} pkgList Mutable array to push discovered components into
2191
2275
  * @param {Object[]} dependencies Mutable array to merge dependencies into
2276
+ * @param {string} [onlyEntry] Analyze only this extension folder
2192
2277
  */
2193
2278
  export async function analyzeInstalledExtensionDirs(
2194
2279
  extensionsDir,
2195
2280
  options,
2196
2281
  pkgList,
2197
2282
  dependencies,
2283
+ onlyEntry,
2198
2284
  ) {
2199
2285
  let entries;
2200
2286
  try {
@@ -2206,6 +2292,9 @@ export async function analyzeInstalledExtensionDirs(
2206
2292
  if (!entry.isDirectory() || entry.name.startsWith(".")) {
2207
2293
  continue;
2208
2294
  }
2295
+ if (onlyEntry && entry.name !== onlyEntry) {
2296
+ continue;
2297
+ }
2209
2298
  const extDir = join(extensionsDir, entry.name);
2210
2299
  const deepResult = await analyzeExtensionDir(extDir, options);
2211
2300
  if (deepResult.pkgList.length) {