@cdxgen/cdxgen 13.6.0 → 13.7.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 (264) hide show
  1. package/README.md +15 -8
  2. package/bin/audit.js +7 -4
  3. package/bin/cdxgen.js +256 -37
  4. package/bin/convert.js +146 -22
  5. package/bin/evinse.js +25 -3
  6. package/bin/repl.js +47 -3
  7. package/bin/sign.js +211 -34
  8. package/bin/tracebom.js +18 -6
  9. package/bin/validate.js +18 -3
  10. package/bin/verify.js +113 -5
  11. package/data/behavior-taxonomy.schema.json +1491 -0
  12. package/data/cyclonedx-2.0-bundled.schema.json +18606 -5528
  13. package/data/cyclonedx-2.0-cryptography-defs.schema.json +857 -0
  14. package/data/pqc-migration.json +239 -0
  15. package/data/remediations.json +52 -0
  16. package/data/rules/cbom-security.yaml +4 -3
  17. package/data/rules/package-integrity.yaml +28 -0
  18. package/lib/audit/index.js +25 -3
  19. package/lib/cli/bomAssembly.js +80 -1
  20. package/lib/cli/cliOptions.js +121 -17
  21. package/lib/cli/index.js +609 -898
  22. package/lib/cli/jsBom.js +3 -0
  23. package/lib/cli/jvmBom.js +365 -40
  24. package/lib/cli/managedBom.js +19 -3
  25. package/lib/cli/nativeBom.js +10 -0
  26. package/lib/core/env.js +26 -0
  27. package/lib/core/fs.js +126 -3
  28. package/lib/core/globPatterns.js +218 -0
  29. package/lib/core/processTree.js +99 -12
  30. package/lib/core/projectConfig.js +332 -25
  31. package/lib/core/toolRegistry.js +15 -1
  32. package/lib/ecosystems/denoutils.js +2 -2
  33. package/lib/ecosystems/golem.js +3 -8
  34. package/lib/ecosystems/gradleutils.js +1082 -6
  35. package/lib/ecosystems/jsEvidence.js +90 -38
  36. package/lib/ecosystems/kosi.js +3 -5
  37. package/lib/ecosystems/npmVersionResolution.js +376 -0
  38. package/lib/ecosystems/parsers-python.js +89 -28
  39. package/lib/ecosystems/parsers-rust.js +117 -15
  40. package/lib/ecosystems/remote/huggingface.js +22 -0
  41. package/lib/ecosystems/rusi.js +2 -4
  42. package/lib/ecosystems/scalasem.js +2 -1
  43. package/lib/evinser/evinser.js +196 -34
  44. package/lib/evinser/scalasem.js +5 -1
  45. package/lib/helpers/agenticToolutils.js +112 -1
  46. package/lib/helpers/bomSigner.js +43 -9
  47. package/lib/helpers/jssSigner.js +1276 -0
  48. package/lib/inventory/agentBlueprint.js +193 -0
  49. package/lib/inventory/agentToolNames.js +145 -0
  50. package/lib/inventory/aiCollector.js +153 -7
  51. package/lib/inventory/aiInventory.js +44 -8
  52. package/lib/inventory/aiProviders.js +324 -0
  53. package/lib/inventory/bomUtils.js +8 -1
  54. package/lib/inventory/ciParsers/githubActionsLock.js +821 -0
  55. package/lib/inventory/citations.js +31 -2
  56. package/lib/inventory/communityAiConfigParser.js +978 -80
  57. package/lib/inventory/cyclonedx20.js +152 -0
  58. package/lib/inventory/cyclonedx20Common.js +286 -0
  59. package/lib/inventory/cyclonedx20Derived.js +159 -0
  60. package/lib/inventory/cyclonedx20Parties.js +552 -0
  61. package/lib/inventory/cyclonedx20Read.js +768 -0
  62. package/lib/inventory/cyclonedx20ReadCommon.js +374 -0
  63. package/lib/inventory/cyclonedx20ReadComponents.js +692 -0
  64. package/lib/inventory/cyclonedx20ReadContext.js +380 -0
  65. package/lib/inventory/cyclonedx20ReadEvidence.js +466 -0
  66. package/lib/inventory/cyclonedx20ReadSections.js +599 -0
  67. package/lib/inventory/cyclonedx20Render.js +766 -0
  68. package/lib/inventory/cyclonedx20RenderComponents.js +716 -0
  69. package/lib/inventory/cyclonedx20RenderDefinitions.js +405 -0
  70. package/lib/inventory/cyclonedx20RenderEvidence.js +726 -0
  71. package/lib/inventory/cyclonedx20RenderHardware.js +203 -0
  72. package/lib/inventory/cyclonedx20RenderPatents.js +174 -0
  73. package/lib/inventory/cyclonedx20RenderRefIds.js +314 -0
  74. package/lib/inventory/cyclonedx20RenderSections.js +499 -0
  75. package/lib/inventory/cyclonedx20Tables.js +594 -0
  76. package/lib/inventory/deps.js +106 -13
  77. package/lib/inventory/dosai.js +236 -1
  78. package/lib/inventory/dosaiParsers.js +3 -6
  79. package/lib/inventory/dotnetRuntime.js +164 -14
  80. package/lib/inventory/ecosystemFormulationParsers.js +979 -0
  81. package/lib/inventory/envcontext.js +132 -38
  82. package/lib/inventory/evidenceUtils.js +2 -1
  83. package/lib/inventory/formulationParsers.js +95 -13
  84. package/lib/inventory/hbom.js +45 -6
  85. package/lib/inventory/hbomLoader.js +166 -0
  86. package/lib/inventory/mcpConfigParser.js +5 -0
  87. package/lib/inventory/occurrenceKey.js +90 -0
  88. package/lib/inventory/pqcMigration.js +426 -0
  89. package/lib/inventory/rustFormulationParser.js +21 -10
  90. package/lib/inventory/source.js +65 -6
  91. package/lib/parsers/huggingfaceManifest.js +9 -1
  92. package/lib/parsers/huggingfaceUtils.js +18 -0
  93. package/lib/parsers/kiroPermissions.js +166 -0
  94. package/lib/server/server.js +36 -34
  95. package/lib/stages/postgen/postgen.js +41 -1
  96. package/lib/stages/postgen/specVersionCompat.js +76 -0
  97. package/lib/validator/bomValidator.js +8 -1
  98. package/lib/validator/complianceEngine.js +30 -3
  99. package/lib/validator/complianceRules.js +1416 -4
  100. package/lib/validator/generated/validate-2.0.mjs +57554 -13851
  101. package/lib/validator/index.js +48 -7
  102. package/lib/validator/reporters/json.js +6 -0
  103. package/package.json +9 -9
  104. package/types/bin/repl.d.ts.map +1 -1
  105. package/types/lib/audit/index.d.ts +6 -2
  106. package/types/lib/audit/index.d.ts.map +1 -1
  107. package/types/lib/cli/bomAssembly.d.ts +16 -0
  108. package/types/lib/cli/bomAssembly.d.ts.map +1 -1
  109. package/types/lib/cli/cliOptions.d.ts +6 -0
  110. package/types/lib/cli/cliOptions.d.ts.map +1 -1
  111. package/types/lib/cli/index.d.ts.map +1 -1
  112. package/types/lib/cli/jsBom.d.ts +2 -1
  113. package/types/lib/cli/jsBom.d.ts.map +1 -1
  114. package/types/lib/cli/jvmBom.d.ts +15 -0
  115. package/types/lib/cli/jvmBom.d.ts.map +1 -1
  116. package/types/lib/cli/managedBom.d.ts.map +1 -1
  117. package/types/lib/cli/nativeBom.d.ts.map +1 -1
  118. package/types/lib/core/boundedFile.d.ts +30 -0
  119. package/types/lib/core/boundedFile.d.ts.map +1 -1
  120. package/types/lib/core/env.d.ts +10 -0
  121. package/types/lib/core/env.d.ts.map +1 -1
  122. package/types/lib/core/fs.d.ts +4 -0
  123. package/types/lib/core/fs.d.ts.map +1 -1
  124. package/types/lib/core/globPatterns.d.ts +70 -0
  125. package/types/lib/core/globPatterns.d.ts.map +1 -0
  126. package/types/lib/core/paths.d.ts +9 -0
  127. package/types/lib/core/paths.d.ts.map +1 -1
  128. package/types/lib/core/processTree.d.ts +16 -5
  129. package/types/lib/core/processTree.d.ts.map +1 -1
  130. package/types/lib/core/projectConfig.d.ts +47 -8
  131. package/types/lib/core/projectConfig.d.ts.map +1 -1
  132. package/types/lib/core/toolRegistry.d.ts.map +1 -1
  133. package/types/lib/ecosystems/golem.d.ts.map +1 -1
  134. package/types/lib/ecosystems/gradleutils.d.ts +248 -8
  135. package/types/lib/ecosystems/gradleutils.d.ts.map +1 -1
  136. package/types/lib/ecosystems/jsEvidence.d.ts +14 -1
  137. package/types/lib/ecosystems/jsEvidence.d.ts.map +1 -1
  138. package/types/lib/ecosystems/kosi.d.ts.map +1 -1
  139. package/types/lib/ecosystems/npmVersionResolution.d.ts +119 -0
  140. package/types/lib/ecosystems/npmVersionResolution.d.ts.map +1 -0
  141. package/types/lib/ecosystems/parsers-python.d.ts.map +1 -1
  142. package/types/lib/ecosystems/parsers-rust.d.ts.map +1 -1
  143. package/types/lib/ecosystems/pythonutils.d.ts +1 -1
  144. package/types/lib/ecosystems/remote/huggingface.d.ts.map +1 -1
  145. package/types/lib/ecosystems/rusi.d.ts.map +1 -1
  146. package/types/lib/ecosystems/scalasem.d.ts +58 -16
  147. package/types/lib/ecosystems/scalasem.d.ts.map +1 -1
  148. package/types/lib/evinser/evinser.d.ts +61 -9
  149. package/types/lib/evinser/evinser.d.ts.map +1 -1
  150. package/types/lib/evinser/scalasem.d.ts.map +1 -1
  151. package/types/lib/helpers/agenticToolutils.d.ts +53 -19
  152. package/types/lib/helpers/agenticToolutils.d.ts.map +1 -1
  153. package/types/lib/helpers/bomSigner.d.ts +20 -3
  154. package/types/lib/helpers/bomSigner.d.ts.map +1 -1
  155. package/types/lib/helpers/jssSigner.d.ts +288 -0
  156. package/types/lib/helpers/jssSigner.d.ts.map +1 -0
  157. package/types/lib/helpers/vsixutils.d.ts +303 -19
  158. package/types/lib/helpers/vsixutils.d.ts.map +1 -1
  159. package/types/lib/inventory/agentBlueprint.d.ts +70 -0
  160. package/types/lib/inventory/agentBlueprint.d.ts.map +1 -0
  161. package/types/lib/inventory/agentToolNames.d.ts +51 -0
  162. package/types/lib/inventory/agentToolNames.d.ts.map +1 -0
  163. package/types/lib/inventory/aiCollector.d.ts.map +1 -1
  164. package/types/lib/inventory/aiInventory.d.ts.map +1 -1
  165. package/types/lib/inventory/aiProviders.d.ts +85 -0
  166. package/types/lib/inventory/aiProviders.d.ts.map +1 -0
  167. package/types/lib/inventory/bomUtils.d.ts.map +1 -1
  168. package/types/lib/inventory/ciParsers/githubActionsLock.d.ts +101 -0
  169. package/types/lib/inventory/ciParsers/githubActionsLock.d.ts.map +1 -0
  170. package/types/lib/inventory/citations.d.ts +5 -0
  171. package/types/lib/inventory/citations.d.ts.map +1 -1
  172. package/types/lib/inventory/communityAiConfigParser.d.ts.map +1 -1
  173. package/types/lib/inventory/cyclonedx20.d.ts +99 -0
  174. package/types/lib/inventory/cyclonedx20.d.ts.map +1 -0
  175. package/types/lib/inventory/cyclonedx20Common.d.ts +102 -0
  176. package/types/lib/inventory/cyclonedx20Common.d.ts.map +1 -0
  177. package/types/lib/inventory/cyclonedx20Derived.d.ts +74 -0
  178. package/types/lib/inventory/cyclonedx20Derived.d.ts.map +1 -0
  179. package/types/lib/inventory/cyclonedx20Parties.d.ts +91 -0
  180. package/types/lib/inventory/cyclonedx20Parties.d.ts.map +1 -0
  181. package/types/lib/inventory/cyclonedx20Read.d.ts +51 -0
  182. package/types/lib/inventory/cyclonedx20Read.d.ts.map +1 -0
  183. package/types/lib/inventory/cyclonedx20ReadCommon.d.ts +69 -0
  184. package/types/lib/inventory/cyclonedx20ReadCommon.d.ts.map +1 -0
  185. package/types/lib/inventory/cyclonedx20ReadComponents.d.ts +77 -0
  186. package/types/lib/inventory/cyclonedx20ReadComponents.d.ts.map +1 -0
  187. package/types/lib/inventory/cyclonedx20ReadContext.d.ts +118 -0
  188. package/types/lib/inventory/cyclonedx20ReadContext.d.ts.map +1 -0
  189. package/types/lib/inventory/cyclonedx20ReadEvidence.d.ts +40 -0
  190. package/types/lib/inventory/cyclonedx20ReadEvidence.d.ts.map +1 -0
  191. package/types/lib/inventory/cyclonedx20ReadSections.d.ts +45 -0
  192. package/types/lib/inventory/cyclonedx20ReadSections.d.ts.map +1 -0
  193. package/types/lib/inventory/cyclonedx20Render.d.ts +53 -0
  194. package/types/lib/inventory/cyclonedx20Render.d.ts.map +1 -0
  195. package/types/lib/inventory/cyclonedx20RenderComponents.d.ts +73 -0
  196. package/types/lib/inventory/cyclonedx20RenderComponents.d.ts.map +1 -0
  197. package/types/lib/inventory/cyclonedx20RenderDefinitions.d.ts +29 -0
  198. package/types/lib/inventory/cyclonedx20RenderDefinitions.d.ts.map +1 -0
  199. package/types/lib/inventory/cyclonedx20RenderEvidence.d.ts +110 -0
  200. package/types/lib/inventory/cyclonedx20RenderEvidence.d.ts.map +1 -0
  201. package/types/lib/inventory/cyclonedx20RenderHardware.d.ts +42 -0
  202. package/types/lib/inventory/cyclonedx20RenderHardware.d.ts.map +1 -0
  203. package/types/lib/inventory/cyclonedx20RenderPatents.d.ts +26 -0
  204. package/types/lib/inventory/cyclonedx20RenderPatents.d.ts.map +1 -0
  205. package/types/lib/inventory/cyclonedx20RenderRefIds.d.ts +55 -0
  206. package/types/lib/inventory/cyclonedx20RenderRefIds.d.ts.map +1 -0
  207. package/types/lib/inventory/cyclonedx20RenderSections.d.ts +45 -0
  208. package/types/lib/inventory/cyclonedx20RenderSections.d.ts.map +1 -0
  209. package/types/lib/inventory/cyclonedx20Tables.d.ts +134 -0
  210. package/types/lib/inventory/cyclonedx20Tables.d.ts.map +1 -0
  211. package/types/lib/inventory/deps.d.ts +35 -2
  212. package/types/lib/inventory/deps.d.ts.map +1 -1
  213. package/types/lib/inventory/dosai.d.ts +19 -0
  214. package/types/lib/inventory/dosai.d.ts.map +1 -1
  215. package/types/lib/inventory/dosaiParsers.d.ts.map +1 -1
  216. package/types/lib/inventory/dotnetRuntime.d.ts +51 -4
  217. package/types/lib/inventory/dotnetRuntime.d.ts.map +1 -1
  218. package/types/lib/inventory/ecosystemFormulationParsers.d.ts +73 -0
  219. package/types/lib/inventory/ecosystemFormulationParsers.d.ts.map +1 -0
  220. package/types/lib/inventory/envcontext.d.ts +22 -6
  221. package/types/lib/inventory/envcontext.d.ts.map +1 -1
  222. package/types/lib/inventory/evidenceUtils.d.ts.map +1 -1
  223. package/types/lib/inventory/formulationParsers.d.ts.map +1 -1
  224. package/types/lib/inventory/hbom.d.ts +11 -0
  225. package/types/lib/inventory/hbom.d.ts.map +1 -1
  226. package/types/lib/inventory/hbomLoader.d.ts +54 -0
  227. package/types/lib/inventory/hbomLoader.d.ts.map +1 -1
  228. package/types/lib/inventory/jvmLocalRepos.d.ts +5 -1
  229. package/types/lib/inventory/jvmLocalRepos.d.ts.map +1 -1
  230. package/types/lib/inventory/mcpConfigParser.d.ts.map +1 -1
  231. package/types/lib/inventory/occurrenceKey.d.ts +52 -0
  232. package/types/lib/inventory/occurrenceKey.d.ts.map +1 -0
  233. package/types/lib/inventory/pqcMigration.d.ts +84 -0
  234. package/types/lib/inventory/pqcMigration.d.ts.map +1 -0
  235. package/types/lib/inventory/rustFormulationParser.d.ts +7 -2
  236. package/types/lib/inventory/rustFormulationParser.d.ts.map +1 -1
  237. package/types/lib/inventory/scalaCoords.d.ts.map +1 -1
  238. package/types/lib/inventory/scalaDedupe.d.ts +43 -0
  239. package/types/lib/inventory/scalaDedupe.d.ts.map +1 -0
  240. package/types/lib/inventory/source.d.ts +15 -0
  241. package/types/lib/inventory/source.d.ts.map +1 -1
  242. package/types/lib/parsers/huggingfaceManifest.d.ts +10 -1
  243. package/types/lib/parsers/huggingfaceManifest.d.ts.map +1 -1
  244. package/types/lib/parsers/huggingfaceUtils.d.ts +12 -0
  245. package/types/lib/parsers/huggingfaceUtils.d.ts.map +1 -1
  246. package/types/lib/parsers/kiroPermissions.d.ts +62 -0
  247. package/types/lib/parsers/kiroPermissions.d.ts.map +1 -0
  248. package/types/lib/parsers/vscodeExtensionId.d.ts +48 -0
  249. package/types/lib/parsers/vscodeExtensionId.d.ts.map +1 -0
  250. package/types/lib/server/server.d.ts.map +1 -1
  251. package/types/lib/stages/postgen/postgen.d.ts +7 -0
  252. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  253. package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
  254. package/types/lib/stages/postgen/specVersionCompat.d.ts +25 -0
  255. package/types/lib/stages/postgen/specVersionCompat.d.ts.map +1 -1
  256. package/types/lib/validator/bomValidator.d.ts +5 -1
  257. package/types/lib/validator/bomValidator.d.ts.map +1 -1
  258. package/types/lib/validator/complianceEngine.d.ts +4 -4
  259. package/types/lib/validator/complianceEngine.d.ts.map +1 -1
  260. package/types/lib/validator/complianceRules.d.ts +14 -2
  261. package/types/lib/validator/complianceRules.d.ts.map +1 -1
  262. package/types/lib/validator/index.d.ts +10 -0
  263. package/types/lib/validator/index.d.ts.map +1 -1
  264. package/types/lib/validator/reporters/json.d.ts.map +1 -1
@@ -12,6 +12,14 @@
12
12
  * @returns {string} Human-readable duration
13
13
  */
14
14
  export declare function formatDuration(ms: number): string;
15
+ /**
16
+ * A UTC instant as a DMTF datetime, the form WQL compares CIM_DATETIME
17
+ * properties such as Win32_Process.CreationDate against.
18
+ *
19
+ * @param {number} ms Epoch milliseconds
20
+ * @returns {string} The instant as `yyyymmddHHMMSS.mmmmmm+000`
21
+ */
22
+ export declare function toDmtfUtc(ms: number): string;
15
23
  /**
16
24
  * Stop the descendants a timed-out run left behind on Windows.
17
25
  *
@@ -20,13 +28,16 @@ export declare function formatDuration(ms: number): string;
20
28
  * workers, or the build hosts a .NET analyzer starts keep running while still
21
29
  * pointing at the dead process's pid. `taskkill /T` on that pid finds nothing,
22
30
  * because the root is already gone. The live descendants are therefore found
23
- * by parent pid in a process snapshot and stopped, limited to processes
24
- * created after the run started. The root's own children must also predate
25
- * its end: once the root is gone its pid can be handed to an unrelated
26
- * process, whose children would otherwise look like the run's. Elsewhere this
31
+ * by parent pid in a PowerShell process snapshot, limited to processes
32
+ * created after the run started, and stopped from Node.js. The root's own
33
+ * children must also predate its end: once the root is gone its pid can be
34
+ * handed to an unrelated process, whose children would otherwise look like
35
+ * the run's. Elsewhere this
27
36
  * does nothing: an orphan is re-parented and can no longer be told apart.
28
37
  * It returns once the stopped processes have exited, or after ten seconds,
29
- * so the caller can remove files the run left half-written.
38
+ * so the caller can remove files the run left half-written. When the
39
+ * snapshot itself fails or runs past its time limit it warns and returns an
40
+ * empty list, since processes may then still be running.
30
41
  *
31
42
  * @param {number|undefined} rootPid pid of the process cdxgen spawned
32
43
  * @param {number} startedAt Epoch milliseconds at which the run started
@@ -1 +1 @@
1
- {"version":3,"file":"processTree.d.ts","sourceRoot":"","sources":["../../../lib/core/processTree.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAHtB,MAGsB,GAFpB,MAAM,CAQlB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAPE,MAAM,GAAC,SAOT,EACP,SAAS,EAPA,MAOA,EACT,OAAO,AAPN,CACA,EADQ,MAOW,EACpB,QAAQ,AAPP,CACA,EADQ,MAOY,GANV,MAAM,EAAE,CA0DpB"}
1
+ {"version":3,"file":"processTree.d.ts","sourceRoot":"","sources":["../../../lib/core/processTree.js"],"names":[],"mappings":"AAAA;;;;;GAKG;AAQH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAHtB,MAGsB,GAFpB,MAAM,CAQlB;AAqCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAHjB,MAGiB,GAFf,MAAM,CAMlB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAPE,MAAM,GAAC,SAOT,EACP,SAAS,EAPA,MAOA,EACT,OAAO,AAPN,CACA,EADQ,MAOW,EACpB,QAAQ,AAPP,CACA,EADQ,MAOY,GANV,MAAM,EAAE,CA4FpB"}
@@ -2,26 +2,65 @@
2
2
  * Config file names cdxgen reads from the directory it is invoked in.
3
3
  */
4
4
  export declare const PROJECT_CONFIG_FILENAMES: string[];
5
+ /**
6
+ * Options a config file may set, by their kebab-case name. A config file may
7
+ * also use the camelCase spelling of each, or one of the aliases in
8
+ * PROJECT_CONFIG_OPTION_ALIASES. Every other key is ignored: options that
9
+ * only library callers pass (such as `dosaiCommand` or `traceCmd`), yargs'
10
+ * own `extends`, and anything cdxgen does not know.
11
+ *
12
+ * Every option bin/cdxgen.js declares is either here or in
13
+ * OPERATOR_ONLY_OPTIONS, which projectConfig.poku.js checks.
14
+ */
15
+ export declare const PROJECT_CONFIG_OPTIONS: Set<string>;
16
+ /**
17
+ * Options only the operator may set, on the command line or through a
18
+ * CDXGEN_* environment variable. They choose an executable, start a listener,
19
+ * turn off certificate checks on the operator's own upload, opt into
20
+ * experimental tool installation, or end the run without a BOM. A config file
21
+ * that sets one is told so and ignored.
22
+ */
23
+ export declare const OPERATOR_ONLY_OPTIONS: Set<string>;
24
+ /**
25
+ * Alternate option names a config file may use, with the option each one
26
+ * stands for. yargs applies its aliases to config keys too, so each is
27
+ * checked as the option it names.
28
+ */
29
+ export declare const PROJECT_CONFIG_OPTION_ALIASES: Map<string, string>;
5
30
  /**
6
31
  * Apply the trust boundary between cdxgen and the directory it is scanning.
7
32
  *
8
33
  * A config file lives in the tree under analysis, so it is attacker-controlled
9
- * whenever that tree is. Path options are therefore confined to the config's
10
- * own directory - a scanned project may choose where in itself the BOM lands,
11
- * but not write outside it - and options that redirect data off the host or
12
- * widen what cdxgen executes are announced on the console. A project may
13
- * describe itself with custom metadata properties, but not in the namespaces
14
- * cdxgen reserves for the facts it establishes, so a scanned tree cannot pass
15
- * its own claims off as cdxgen's.
34
+ * whenever that tree is. It may therefore only set the options listed in
35
+ * PROJECT_CONFIG_OPTIONS: options that choose an executable, start a listener
36
+ * or weaken the operator's own checks, and every key cdxgen does not declare
37
+ * as an option, are dropped. Path options are confined to the config's own
38
+ * directory - a scanned project may choose where in itself the BOM lands, but
39
+ * not write outside it - and project types that inventory the host rather
40
+ * than the scan path are dropped. Exclude and include patterns are kept
41
+ * within the bounds of boundUntrustedGlobPatterns, so a project cannot make
42
+ * every file match against thousands of brace-expanded patterns. Options that
43
+ * redirect data off the host or widen what cdxgen does are announced on the
44
+ * console. A project may describe itself with custom metadata properties, but
45
+ * not in the namespaces cdxgen reserves for the facts it establishes, so a
46
+ * scanned tree cannot pass its own claims off as cdxgen's.
16
47
  *
17
48
  * @param {Object} config parsed config file contents
18
49
  * @param {string} configDir directory the config file was read from
19
- * @returns {{config: Object, rejected: string[], announced: string[], reservedProperties: string[]}} sanitized config and what it did
50
+ * @returns {{config: Object, rejected: string[], announced: string[], reservedProperties: string[], ignored: string[], operatorOnly: string[], hostScopeTypes: string[], refusedPatterns: {key: string, pattern: string, reason: string}[]}} sanitized config and what it did
20
51
  */
21
52
  export declare function sanitizeProjectConfig(config: Object, configDir: string): {
22
53
  config: Object;
23
54
  rejected: string[];
24
55
  announced: string[];
25
56
  reservedProperties: string[];
57
+ ignored: string[];
58
+ operatorOnly: string[];
59
+ hostScopeTypes: string[];
60
+ refusedPatterns: {
61
+ key: string;
62
+ pattern: string;
63
+ reason: string;
64
+ }[];
26
65
  };
27
66
  //# sourceMappingURL=projectConfig.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"projectConfig.d.ts","sourceRoot":"","sources":["../../../lib/core/projectConfig.js"],"names":[],"mappings":"AASA;;GAEG;AACH,eAAO,MAAM,wBAAwB,UAKpC,CAAC;AAuEF;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAJjC,MAIiC,EAAE,SAAS,EAH5C,MAG4C,GAF1C;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAA;CAAC,CA+CnG"}
1
+ {"version":3,"file":"projectConfig.d.ts","sourceRoot":"","sources":["../../../lib/core/projectConfig.js"],"names":[],"mappings":"AAYA;;GAEG;AACH,eAAO,MAAM,wBAAwB,UAKpC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,aA2GjC,CAAC;AAEH;;;;;;GAMG;AACH,eAAO,MAAM,qBAAqB,aAQhC,CAAC;AAEH;;;;GAIG;AACH,eAAO,MAAM,6BAA6B,qBASxC,CAAC;AA6IH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAJjC,MAIiC,EAAE,SAAS,EAH5C,MAG4C,GAF1C;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,MAAM,EAAE,CAAC;IAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,cAAc,EAAE,MAAM,EAAE,CAAC;IAAC,eAAe,EAAE;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAC,EAAE,CAAA;CAAC,CA2H3O"}
@@ -1 +1 @@
1
- {"version":3,"file":"toolRegistry.d.ts","sourceRoot":"","sources":["../../../lib/core/toolRegistry.js"],"names":[],"mappings":"AAsFA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAH5B,MAG4B,EAAE,OAAO,EAFrC,MAAM,GAAC,SAE8B,QAoB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAH3B,MAG2B,EAAE,OAAO,EAFpC,MAEoC,QAW9C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAFnB,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,GAAC,SAAS,CAAC,CAAA;CAAC,CAAC,CAe9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAFrB,IAAI,CAKhB"}
1
+ {"version":3,"file":"toolRegistry.d.ts","sourceRoot":"","sources":["../../../lib/core/toolRegistry.js"],"names":[],"mappings":"AAgGA;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAH5B,MAG4B,EAAE,OAAO,EAFrC,MAAM,GAAC,SAE8B,QAwB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAH3B,MAG2B,EAAE,OAAO,EAFpC,MAEoC,QAW9C;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAFnB,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,MAAM,GAAC,SAAS,CAAC,CAAA;CAAC,CAAC,CAe9D;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAFrB,IAAI,CAKhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"golem.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/golem.js"],"names":[],"mappings":"AA4mDA;;;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AAS,EAJtC,MAIsC,EAAE,SAAS,AAHzD,CACA,EADQ,MAGiD,GAF/C,MAAM,CAkDlB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,SAAS,EAJrC,MAIqC,GAHnC;IAAC,MAAM,EAAE,CAAC,MAAM,GAAC,SAAS,CAAC,CAAC;IAAC,IAAI,EAAE,CAAC,MAAM,GAAC,SAAS,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAC,GAAC,SAAS,CAyB1F;AAgDD;;;;;;;;;;;GAWG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAHnC,MAGmC,GAFjC,MAAM,GAAC,SAAS,CA2C5B;AA+BD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,AAJ7C,CACA,EADQ,MAAM,GAAC,IAImC,EAAE,WAAW,AAH/D,CACA,EADQ,MAG4D,GAF1D,MAAM,CAuElB"}
@@ -12,6 +12,15 @@ export { isProjectToolingAllowed };
12
12
  * @param {Object} [options] CLI options (`installDeps` gates wrapper use)
13
13
  */
14
14
  export declare function getGradleCommand(srcPath: string, rootPath: string | null, options?: Object): string;
15
+ /**
16
+ * Read a whitespace-separated list of Gradle arguments from an environment
17
+ * variable such as `GRADLE_ARGS`. Repeated, leading or trailing whitespace
18
+ * adds no empty argument, which Gradle would read as a task path.
19
+ *
20
+ * @param {string} name Name of the environment variable
21
+ * @returns {string[]} The arguments, empty when the variable is unset
22
+ */
23
+ export declare function gradleArgsFromEnv(name: string): string[];
15
24
  /**
16
25
  * Method to combine the general gradle arguments, the sub-commands and the sub-commands' arguments in the correct way
17
26
  *
@@ -23,6 +32,23 @@ export declare function getGradleCommand(srcPath: string, rootPath: string | nul
23
32
  * @returns {string[]} Array of arrays of arguments to be added to the gradle command
24
33
  */
25
34
  export declare function buildGradleCommandArguments(gradleArguments: string[], gradleSubCommands: string[], gradleSubCommandArguments: string[], gradleCommandLength: int): string[];
35
+ /**
36
+ * List the dependency tasks to run for the root project and every module read
37
+ * from `gradle properties`.
38
+ *
39
+ * The root project is recognised by identity, never by purl. A module named
40
+ * after the root project that inherits its group and version has the root's
41
+ * purl (issue 4695), and it still needs its own `:module:dependencies` task.
42
+ * `root` in `modulesToSkip` drops the root task; any other entry is a module
43
+ * path.
44
+ *
45
+ * @param {Map<string, Object>} gradleModules Modules keyed by project path, and the root project by its name
46
+ * @param {Object} rootComponent The component built for the root project
47
+ * @param {string} gradleDepTask Name of the dependency task, usually `dependencies`
48
+ * @param {string[]} modulesToSkip Module paths, or `root`, to leave out
49
+ * @returns {string[]} Task paths in the order Gradle should run them
50
+ */
51
+ export declare function gradleDependencyTasks(gradleModules: Map<string, Object>, rootComponent: Object, gradleDepTask: string, modulesToSkip?: string[]): string[];
26
52
  /**
27
53
  * Method to split the output produced by Gradle using parallel processing by project
28
54
  *
@@ -55,17 +81,19 @@ export declare function parseGradleProjects(rawOutput: string): {
55
81
  /**
56
82
  * Parse gradle properties output
57
83
  *
84
+ * `gradlePlugin` is true when the project has the `gradlePlugin` extension,
85
+ * which `java-gradle-plugin`, `kotlin-dsl` and `groovy-gradle-plugin` add: the
86
+ * project builds Gradle plugins, as a `build-logic` build does.
87
+ *
58
88
  * @param {string} rawOutput Raw string output
59
89
  * @param {string} gradleModuleName The name (or 'path') of the module as seen from the root of the project
90
+ * @returns {{rootProject: string, projects: string[], metadata: Object, gradlePlugin: boolean}} The parsed properties
60
91
  */
61
92
  export declare function parseGradleProperties(rawOutput: string, gradleModuleName?: string): {
62
93
  rootProject: string;
63
- projects: any[];
64
- metadata: {
65
- group: string;
66
- version: string;
67
- properties: never[];
68
- };
94
+ projects: string[];
95
+ metadata: Object;
96
+ gradlePlugin: boolean;
69
97
  };
70
98
  /**
71
99
  * Execute gradle properties command using multi-threading and return parsed output
@@ -123,6 +151,17 @@ export declare function recordGradleInvocationFailure(result: Object, context?:
123
151
  * @returns {Promise<string[]>} Paths of the projects added
124
152
  */
125
153
  export declare function loadGradleModulesForReports(reports: Iterable<string>, gradleModules: Map<any, any>, gradleRootPath: string, options?: Object): Promise<string[]>;
154
+ /**
155
+ * Give the components of a build-tooling report, such as that of an included
156
+ * build that builds Gradle plugins, the `excluded` scope that build-tool
157
+ * configurations get. `reconcileGradleComponents` later keeps a stronger
158
+ * scope that another project's report gives the same component.
159
+ *
160
+ * @param {Object[]} pkgList Components from one project's report, updated in place
161
+ * @param {Map<string, Object>} gradleModules Modules, which keep their own scope
162
+ * @returns {Object[]} The same list
163
+ */
164
+ export declare function excludeGradleBuildTooling(pkgList: Object[], gradleModules: Map<string, Object>): Object[];
126
165
  /**
127
166
  * Reconcile the copies of a component that several Gradle projects report.
128
167
  * Every copy gets the strongest scope any project gave it, so a library one
@@ -146,19 +185,26 @@ export declare function reconcileGradleComponents(pkgList: Object[]): Object[];
146
185
  * `cdx:gradle:resolutionFailed`, keeps the version it was requested at when
147
186
  * that is a concrete version, and otherwise records the request in
148
187
  * `cdx:gradle:requestedVersion`. A dependency seen in several configurations
149
- * keeps the strongest scope among them.
188
+ * keeps the strongest scope among them. Platforms and BOMs get a `pom` type
189
+ * and the `excluded` scope.
150
190
  *
151
191
  * The parser runs no Gradle task. A project the tree names but `gradleModules`
152
192
  * lacks gets a component built from the root project's group and version; use
153
193
  * `loadGradleModulesForReports` first to read such projects' properties.
154
194
  *
195
+ * The lines Gradle prints under another project, such as `project ':lib'` in
196
+ * the report of `:app`, show that project's dependencies as `:app` resolved
197
+ * them, after conflict resolution. When `reportedProjects` names that project,
198
+ * its own report supplies its edges, so these lines add no edge from it.
199
+ *
155
200
  * @param {string} rawOutput Text output from gradle dependencies task
156
201
  * @param {string} rootProjectName Key in `gradleModules` of the project the report belongs to
157
202
  * @param {map} gradleModules Gradle modules keyed by project path, and the root project by its name
158
203
  * @param {string} gradleRootPath Directory Gradle ran in, recorded as `cdx:gradle:GradleRootPath`
204
+ * @param {Set<string>} [reportedProjects] Keys in `gradleModules` of the projects whose own reports are parsed
159
205
  * @returns {{pkgList: Object[], dependenciesList: Object[]}|{}} The components and dependency graph
160
206
  */
161
- export declare function parseGradleDep(rawOutput: string, rootProjectName?: string, gradleModules?: map, gradleRootPath?: string): {
207
+ export declare function parseGradleDep(rawOutput: string, rootProjectName?: string, gradleModules?: map, gradleRootPath?: string, reportedProjects?: Set<string>): {
162
208
  pkgList: Object[];
163
209
  dependenciesList: Object[];
164
210
  } | {};
@@ -291,4 +337,198 @@ export declare function getMavenCommand(srcPath: string, rootPath: string, optio
291
337
  * @returns {Object[]} Package records for resolvable library entries
292
338
  */
293
339
  export declare function parseGradleVersionCatalog(catalogFile: string): Object[];
340
+ /**
341
+ * Parse one Gradle dependency lockfile.
342
+ *
343
+ * Both layouts are read. A Gradle 6+ `gradle.lockfile` has one
344
+ * `group:name:version=configuration,configuration` line per module and an
345
+ * `empty=` line naming the configurations that resolved nothing. A legacy
346
+ * `gradle/dependency-locks/<configuration>.lockfile` has one
347
+ * `group:name:version` line per module, and the file name is the
348
+ * configuration.
349
+ *
350
+ * The scope of a module is the strongest that `gradleConfigurationScope`
351
+ * gives any of its configurations, so a module locked for both
352
+ * `testRuntimeClasspath` and `runtimeClasspath` is `required`. Everything in
353
+ * a buildscript or settings lockfile is build tooling and `excluded`.
354
+ *
355
+ * A lockfile records resolved versions, so components carry a purl identity
356
+ * with confidence 1 and the lockfile path as the evidence value. The purl and
357
+ * bom-ref match what `parseGradleDep` builds for the same coordinate, so a
358
+ * component reads the same whether Gradle ran or not. A lockfile is flat: it
359
+ * says nothing about which module depends on which, so no dependency graph is
360
+ * returned.
361
+ *
362
+ * The file is untrusted input. It is read only when it is a regular file no
363
+ * larger than 8 MiB, at most 100000 lines are read, and a malformed line
364
+ * costs only itself. Line content never reaches a property.
365
+ *
366
+ * @param {string} lockFile Path to the lockfile
367
+ * @param {Object} [options] Parse options
368
+ * @param {string} [options.rootDir] Directory the lockfile must resolve inside
369
+ * @returns {Object[]} Components, one per locked module
370
+ */
371
+ export declare function parseGradleLockfile(lockFile: string, options?: {
372
+ rootDir?: string;
373
+ }): Object[];
374
+ /**
375
+ * Parse several Gradle lockfiles of one build and merge the result.
376
+ *
377
+ * Every project of a multi-project build has its own lockfile, so the same
378
+ * module often appears in several of them with different configurations. The
379
+ * copies collapse into one component with the strongest scope any lockfile
380
+ * gave it (see `reconcileGradleComponents`), and its evidence lists every
381
+ * lockfile that locked it. The first lockfile that locked a module stays its
382
+ * `internal:SrcFile`.
383
+ *
384
+ * @param {string[]} lockFiles Paths to the lockfiles
385
+ * @param {Object} [options] Parse options, as for `parseGradleLockfile`
386
+ * @returns {Object[]} Components, one per locked module
387
+ */
388
+ export declare function parseGradleLockfiles(lockFiles: string[], options?: Object): Object[];
389
+ /**
390
+ * Find the Gradle dependency lockfiles of one build.
391
+ *
392
+ * Both layouts are searched below `rootPath`, recursively even when
393
+ * `options.multiProject` is off: every subproject of a Gradle build locks its
394
+ * own configurations, and the subprojects belong to the same build. The
395
+ * Gradle 6+ names are `gradle.lockfile`, `buildscript-gradle.lockfile` and
396
+ * `settings-gradle.lockfile`; the Gradle 4.8 to 5.x layout is
397
+ * `gradle/dependency-locks/<configuration>.lockfile`.
398
+ *
399
+ * A lockfile is accepted only when the project directory that owns it holds a
400
+ * Gradle build file, and never when it sits under `build/`, `.gradle/`,
401
+ * `node_modules/` or a vendored directory. `getAllFiles` already leaves
402
+ * `.git`, `.hg`, `.chen` and `node_modules` out; `build/` and `.gradle/` are
403
+ * Gradle's own output and cache directories, which a lockfile in them cannot
404
+ * belong to the project's source of truth.
405
+ *
406
+ * Custom `dependencyLocking.lockFile` paths, the Nebula `dependencies.lock`
407
+ * and Palantir `versions.lock` formats are not looked for.
408
+ *
409
+ * @param {string} rootPath Directory to search
410
+ * @param {Object} [options] CLI options
411
+ * @returns {string[]} Lockfile paths, in a stable order
412
+ */
413
+ export declare function findGradleLockfiles(rootPath: string, options?: Object): string[];
414
+ /**
415
+ * Read the root project name a Gradle settings script assigns with
416
+ * `rootProject.name = '<name>'` or `rootProject.name = "<name>"`, without
417
+ * running Gradle.
418
+ *
419
+ * `settings.gradle` is read before `settings.gradle.kts`, and the last
420
+ * assignment in the file wins, as it does in Gradle. Only a plain string
421
+ * literal is accepted: a value built from a variable, a template
422
+ * (`"${x}"`) or a method call is not something a static read can resolve.
423
+ *
424
+ * @param {string} gradleRootPath Root directory of the Gradle build
425
+ * @returns {string|undefined} The root project name, or undefined when no
426
+ * settings script assigns one as a plain literal
427
+ */
428
+ export declare function readGradleRootProjectName(gradleRootPath: string): string | undefined;
429
+ /**
430
+ * Parse a `gradle/verification-metadata.xml` file.
431
+ *
432
+ * The file is untrusted input. It records what Gradle verified when
433
+ * `gradle --write-verification-metadata` last ran, which does not prove that
434
+ * the artifacts in this BOM match: the file travels with the source, and
435
+ * nothing here re-checks the digests. Trust rules (`trusted-artifacts`,
436
+ * `trusted-keys`, `ignored-keys`) may be regular expressions, so they are
437
+ * only counted, never evaluated, and no free text of the file (an `origin`, a
438
+ * `reason`, a key-server URI) reaches the result. Only checksum digests,
439
+ * PGP key ids and the configuration flags survive.
440
+ *
441
+ * The read is bounded: the file must be a regular file no larger than
442
+ * 32 MiB inside `options.rootDir`, at most 200000 components and 64
443
+ * artifacts per component are read, and a malformed file yields undefined
444
+ * rather than an error.
445
+ *
446
+ * @param {string} metadataFile Path to verification-metadata.xml
447
+ * @param {Object} [options] Parse options
448
+ * @param {string} [options.rootDir] Directory the file must resolve inside
449
+ * @returns {{configuration: {verifyMetadata: (boolean|undefined), verifySignatures: (boolean|undefined), trustedKeyCount: number, trustedArtifactRuleCount: number, ignoredKeyCount: number, keyServerCount: number}, components: Map<string, {group: string, name: string, version: string, artifacts: {fileName: string, classifier: string, extension: string, hashes: {alg: string, content: string}[], pgpKeyIds: string[]}[]}>}|undefined}
450
+ * The parsed metadata, or undefined when the file could not be read
451
+ */
452
+ export declare function parseGradleVerificationMetadata(metadataFile: string, options?: {
453
+ rootDir?: string;
454
+ }): {
455
+ configuration: {
456
+ verifyMetadata: (boolean | undefined);
457
+ verifySignatures: (boolean | undefined);
458
+ trustedKeyCount: number;
459
+ trustedArtifactRuleCount: number;
460
+ ignoredKeyCount: number;
461
+ keyServerCount: number;
462
+ };
463
+ components: Map<string, {
464
+ group: string;
465
+ name: string;
466
+ version: string;
467
+ artifacts: {
468
+ fileName: string;
469
+ classifier: string;
470
+ extension: string;
471
+ hashes: {
472
+ alg: string;
473
+ content: string;
474
+ }[];
475
+ pgpKeyIds: string[];
476
+ }[];
477
+ }>;
478
+ } | undefined;
479
+ /**
480
+ * Find the gradle/verification-metadata.xml of one Gradle build.
481
+ *
482
+ * Gradle reads one verification file per build, from the root build's
483
+ * `gradle` directory; included builds' copies are ignored, so nothing is
484
+ * searched below the root. The file is accepted only when the directory is a
485
+ * Gradle project of its own, so a file copied into a nested folder is not
486
+ * read as an inventory source.
487
+ *
488
+ * @param {string} gradleRootPath Root directory of the Gradle build
489
+ * @returns {string|undefined} The metadata file path, or undefined
490
+ */
491
+ export declare function findGradleVerificationMetadata(gradleRootPath: string): string | undefined;
492
+ /**
493
+ * The artifact of a coordinate whose hashes describe the component itself:
494
+ * the `.pom` artifact for a platform or BOM component, else the main jar,
495
+ * else the main aar. Sources, javadoc and other classifiers, and the
496
+ * `.module` and `.pom` hashes of a jar component, are never used.
497
+ *
498
+ * @param {object} component Parsed verification metadata component
499
+ * @param {boolean} wantsPom True for a component with purl qualifier type=pom
500
+ * @returns {object|undefined} The artifact, or undefined
501
+ */
502
+ export declare function gradleVerificationMainArtifact(component: object, wantsPom: boolean): object | undefined;
503
+ /**
504
+ * Merge the checksums and PGP key ids a verification-metadata.xml records
505
+ * into the components of a package list.
506
+ *
507
+ * A digest of the artifact itself, computed from the jar in the local cache
508
+ * or found by another collector, is the stronger claim, so the recorded
509
+ * digests only fill the algorithms a component still lacks. Where the file
510
+ * records a different digest for an algorithm the component already has,
511
+ * the recorded digest never wins: the component keeps its own, and the
512
+ * component gains the cdx:gradle:verificationMismatch=true property so the
513
+ * disagreement is visible. A released Maven version does not change after
514
+ * publishing, so a stale file cannot explain a mismatch: a stale file names
515
+ * old versions, which match nothing. The likely causes are an artifact
516
+ * republished on a mirror or internal repository, or a corrupted or
517
+ * tampered cache. SNAPSHOT versions and digests that are not hex are not
518
+ * compared.
519
+ *
520
+ * Every matched component also gains two properties naming the verification
521
+ * methods and the PGP key ids of its artifact. The evidence of the
522
+ * component is left alone: a component found by a Gradle run or a lockfile
523
+ * keeps the identity evidence of that source, and only the components the
524
+ * verification-metadata fallback built carry the file as their evidence.
525
+ *
526
+ * @param {Object[]} pkgList Components to enrich in place
527
+ * @param {Object} metadata Parsed metadata, as parseGradleVerificationMetadata
528
+ * returns
529
+ * @param {string} metadataFile Path to the verification-metadata.xml, named
530
+ * in the debug reasoning
531
+ * @returns {number} The number of components this call changed
532
+ */
533
+ export declare function applyGradleVerificationMetadata(pkgList: Object[], metadata: Object, metadataFile: string): number;
294
534
  //# sourceMappingURL=gradleutils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gradleutils.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/gradleutils.js"],"names":[],"mappings":"AAyBA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAyBpE,OAAO,EAAE,uBAAuB,EAAE,CAAC;AAEnC;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAJ7B,MAI6B,EAAE,QAAQ,EAHvC,MAAM,GAAC,IAGgC,EAAE,OAAO,AAFxD,CACF,EADU,MAEqD,UAiG/D;AA6DD;;;;;;;;;GASG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EARN,MAAM,EAQA,EACf,iBAAiB,EARR,MAAM,EAQE,EACjB,yBAAyB,EARhB,MAAM,EAQU,EACzB,mBAAmB,EARV,GAQU,GANR,MAAM,EAAE,CA6CpB;AAqCD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,2BAA2B,CAAC,SAAS,EAJ1C,MAI0C,EAAE,a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E;QAAC,cAAc,EAAE,CAAC,OAAO,GAAC,SAAS,CAAC,CAAC;QAAC,gBAAgB,EAAE,CAAC,OAAO,GAAC,SAAS,CAAC,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,wBAAwB,EAAE,MAAM,CAAC;QAAC,eAAe,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAA;KAAC,CAAC;IAAC,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE;YAAC,QAAQ,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAC;YAAC,SAAS,EAAE,MAAM,CAAC;YAAC,MAAM,EAAE;gBAAC,GAAG,EAAE,MAAM,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAC,EAAE,CAAC;YAAC,SAAS,EAAE,MAAM,EAAE,CAAA;SAAC,EAAE,CAAA;KAAC,CAAC,CAAA;CAAC,GAAC,SAAS,CA4N/a;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,8BAA8B,CAAC,cAAc,EAHlD,MAGkD,GAFhD,MAAM,GAAC,SAAS,CAmB5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAAC,SAAS,EAJ7C,MAI6C,EAAE,QAAQ,EAHvD,OAGuD,GAFrD,MAAM,GAAC,SAAS,CAa5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EARE,MAAM,EAQR,EACP,QAAQ,EARC,MAQD,EACR,YAAY,EAPH,MAOG,GALD,MAAM,CA2GlB"}
@@ -9,12 +9,25 @@
9
9
  * from configuration, bundler entrypoints, stylesheets, or plugins, so a
10
10
  * missing import is not evidence that a package is optional.
11
11
  *
12
+ * When the lock file holds several versions of a package, an import is
13
+ * evidence only for the version the importing file resolves to (see
14
+ * `createNpmVersionChooser`), so a copy nested under another package is not
15
+ * credited with, or promoted to required by, the project's own imports.
16
+ *
12
17
  * @param {Array<object>} pkgList Package components to enrich.
13
18
  * @param {object} allImports Map of import specifier to usage evidence objects.
14
19
  * @param {object} allExports Map of export specifier to export evidence objects.
15
20
  * @param {boolean} deep When true, fill in missing description/author/license
16
21
  * metadata from the local node_modules copy of each package.
22
+ * @param {object} [context] Project facts that pick the version a file uses.
23
+ * @param {string} [context.srcDir] Directory the evidence file names are relative to.
24
+ * @param {Array<object>} [context.dependencies] Dependency tree of the packages.
25
+ * @param {object} [context.parentComponent] Project component, with any workspace members as its components.
17
26
  * @returns {Promise<Array<object>>} The enriched package list (same reference as pkgList).
18
27
  */
19
- export declare function addEvidenceForImports(pkgList: Array<object>, allImports: object, allExports: object, deep: boolean): Promise<Array<object>>;
28
+ export declare function addEvidenceForImports(pkgList: Array<object>, allImports: object, allExports: object, deep: boolean, context?: {
29
+ srcDir?: string;
30
+ dependencies?: Array<object>;
31
+ parentComponent?: object;
32
+ }): Promise<Array<object>>;
20
33
  //# sourceMappingURL=jsEvidence.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsEvidence.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/jsEvidence.js"],"names":[],"mappings":"AAyLA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EARE,KAAK,CAAC,MAAM,CAQd,EACP,UAAU,EARD,MAQC,EACV,UAAU,EARD,MAQC,EACV,IAAI,EARK,OAQL,GANO,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CA+KlC"}
1
+ {"version":3,"file":"jsEvidence.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/jsEvidence.js"],"names":[],"mappings":"AAsMA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAZE,KAAK,CAAC,MAAM,CAYd,EACP,UAAU,EAZD,MAYC,EACV,UAAU,EAZD,MAYC,EACV,IAAI,EAZK,OAYL,EACJ,OAAO,AAXN,CAIA,EAHA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;IAAgC,YAAY,AAA5C,CACA,EADQ,KAAK,CAAC,MAAM,CAAC,CACrB;IAAyB,eAAe,AAAxC,CACA,EADQ,MAAM,CACd;CAOW,GAPD,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CA6MlC"}
@@ -1 +1 @@
1
- {"version":3,"file":"kosi.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/kosi.js"],"names":[],"mappings":"AAqCA;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAH3C,MAAM,GAAC,SAGoC,GAFzC,MAAM,GAAC,SAAS,CAwB5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,WAE5C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,QAQ3B;AA6DD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAJ3B,MAI2B,EAAE,OAAO,GAHpC,MAGyC,GAFvC,MAAM,GAAC,SAAS,CAkE5B;AA0BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,KAAA,EAAE,SAAS,KAAA,OA4B/C;AAusBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,KAAK,EAAE,WAAW,KAAK,MAsEpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,GAJvC,MAI4C,EAAE,WAAW,GAHzD,MAG8D,GAF5D,MAAM,CAoFlB;AAiCD,wBAAgB,mBAAmB,CAAC,UAAU,KAAK,EAAE,UAAU,QAAK;;;;;;;EA2DnE"}
1
+ {"version":3,"file":"kosi.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/kosi.js"],"names":[],"mappings":"AAsCA;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,eAAe,EAH3C,MAAM,GAAC,SAGoC,GAFzC,MAAM,GAAC,SAAS,CAwB5B;AAED,wBAAgB,oBAAoB,CAAC,QAAQ,KAAA,WAE5C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,QAQ3B;AA6DD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAJ3B,MAI2B,EAAE,OAAO,GAHpC,MAGyC,GAFvC,MAAM,GAAC,SAAS,CAkE5B;AA0BD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,KAAA,EAAE,SAAS,KAAA,OA4B/C;AAosBD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,KAAK,EAAE,WAAW,KAAK,MAsEpE;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,GAJvC,MAI4C,EAAE,WAAW,GAHzD,MAG8D,GAF5D,MAAM,CAoFlB;AAiCD,wBAAgB,mBAAmB,CAAC,UAAU,KAAK,EAAE,UAAU,QAAK;;;;;;;EA2DnE"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * Full npm package name (`@scope/name` or `name`) of a component or manifest.
3
+ *
4
+ * @param {{group?: string, name?: string}} pkg Component or parsed manifest
5
+ * @returns {string} The package name npm installs it under
6
+ */
7
+ export declare function npmPackageName({ group, name }: {
8
+ group?: string;
9
+ name?: string;
10
+ }): string;
11
+ /**
12
+ * Full npm package name of an npm purl.
13
+ *
14
+ * @param {string} purl Package URL
15
+ * @returns {string|undefined} `@scope/name` or `name`; undefined for a purl that is not npm or does not parse
16
+ */
17
+ export declare function npmPackageNameOfPurl(purl: string): string | undefined;
18
+ /**
19
+ * Directory a package-lock component is installed in.
20
+ *
21
+ * `internal:LocalNodeModulesPath` holds the arborist location, relative to the
22
+ * root of the tree: `node_modules/a/node_modules/b` for a nested copy and
23
+ * `packages/web/node_modules/b` for a copy under a workspace member. The
24
+ * component's `internal:SrcFile` names a `package-lock.json` in the directory
25
+ * that holds the location's first `node_modules` segment, so the install
26
+ * directory is that location's `node_modules/...` part resolved against the
27
+ * SrcFile's directory. A location without a `node_modules` segment (a
28
+ * workspace member itself) and an absolute location (pnpm metadata found by
29
+ * searching node_modules) name no install a file resolves to.
30
+ *
31
+ * @param {Object} pkg Package component
32
+ * @returns {string|undefined} Absolute install directory
33
+ */
34
+ export declare function npmInstallDirectory(pkg: Object): string | undefined;
35
+ /**
36
+ * References the given root components depend on directly.
37
+ *
38
+ * @param {Array<{ref: string, dependsOn?: string[]}>} dependencies Dependency tree
39
+ * @param {Iterable<string>} rootRefs bom-refs of the project and its workspace members
40
+ * @returns {Set<string>} bom-refs of their direct dependencies
41
+ */
42
+ export declare function directDependencyRefs(dependencies: Array<{
43
+ ref: string;
44
+ dependsOn?: string[];
45
+ }>, rootRefs: Iterable<string>): Set<string>;
46
+ /**
47
+ * The direct dependencies that apply to a project file, nearest first.
48
+ *
49
+ * A file inside an npm workspace member (a component with
50
+ * `cdx:npm:isWorkspace=true` and its directory in `cdx:npm:resolvedPath`,
51
+ * relative to the project) depends first on what that member declares, then
52
+ * on what the project root declares, since Node.js finds the root's hoisted
53
+ * copies from inside a member too. Any other file depends on the root's.
54
+ *
55
+ * @param {Object[]} components Components or package list
56
+ * @param {Object[]} dependencies Dependency tree
57
+ * @param {string[]} rootRefs bom-refs of the project and the sub-components it lists
58
+ * @returns {function(string): Set<string>[]} Lookup from a file name, relative to the project, to sets of bom-refs
59
+ */
60
+ export declare function createDirectDependencyLookup(components: Object[], dependencies: Object[], rootRefs: string[]): Function;
61
+ /**
62
+ * bom-refs of a parent component and the sub-components it lists, which are
63
+ * the roots whose direct dependencies a project's own files use.
64
+ *
65
+ * @param {Object} parentComponent Parent (metadata) component
66
+ * @returns {string[]} bom-refs
67
+ */
68
+ export declare function projectRootRefs(parentComponent: Object): string[];
69
+ /**
70
+ * Decide which installed versions of an npm package a project file uses.
71
+ *
72
+ * Only package names with more than one version in `pkgList` are decided; a
73
+ * file uses the single version of any other package. For the rest, the file
74
+ * uses:
75
+ *
76
+ * 1. the copy Node.js resolves from the file's directory, when the lock file
77
+ * records install locations (package-lock.json): the first
78
+ * `<dir>/node_modules/<name>` holding one of the versions, walking up from
79
+ * the file;
80
+ * 2. otherwise the versions the file's workspace member, or else the project,
81
+ * depends on directly (see `createDirectDependencyLookup`);
82
+ * 3. otherwise every version, since nothing tells them apart.
83
+ *
84
+ * @param {Object[]} pkgList Package components, duplicates per install location included
85
+ * @param {Object} [context] Project facts
86
+ * @param {string} [context.srcDir] Directory the file names are relative to
87
+ * @param {Object[]} [context.dependencies] Dependency tree
88
+ * @param {string[]} [context.rootRefs] bom-refs of the project and the sub-components it lists
89
+ * @returns {{isAmbiguous: function(Object): boolean, allows: function(Object, string): boolean}} Chooser
90
+ */
91
+ export declare function createNpmVersionChooser(pkgList: Object[], context?: {
92
+ srcDir?: string;
93
+ dependencies?: Object[];
94
+ rootRefs?: string[];
95
+ }): {
96
+ isAmbiguous: Function;
97
+ (Object: any): boolean;
98
+ allows: Function;
99
+ (Object: any, string: any): boolean;
100
+ };
101
+ /**
102
+ * Keep each npm occurrence only on the versions the project file uses.
103
+ *
104
+ * evinse credits a slice record to every component of the record's package,
105
+ * one per installed version. For a package with several versions in the BOM,
106
+ * an occurrence in file F stays on a version when the input BOM's own import
107
+ * evidence (seeded before any slice is read) puts that version in F; when the
108
+ * BOM credits none of the versions in F, or several, the versions F's
109
+ * workspace member or else the project depends on directly are kept (see
110
+ * `createDirectDependencyLookup`); failing both, all stay.
111
+ *
112
+ * @param {Object} purlLocationMap purl -> Set of occurrence keys, changed in place
113
+ * @param {Object} purlSymbolMap purl -> occurrence key -> symbol, changed in place
114
+ * @param {Object} seededLocationMap purl -> Set of occurrence keys the input BOM carried
115
+ * @param {Object} bomJson Input BOM, for its components, dependencies and metadata component
116
+ * @returns {Set<string>} purls left with no occurrence, whose input occurrences belong to another version
117
+ */
118
+ export declare function keepResolvedNpmVersions(purlLocationMap: Object, purlSymbolMap: Object, seededLocationMap: Object, bomJson: Object): Set<string>;
119
+ //# sourceMappingURL=npmVersionResolution.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"npmVersionResolution.d.ts","sourceRoot":"","sources":["../../../lib/ecosystems/npmVersionResolution.js"],"names":[],"mappings":"AAeA;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAHnC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAGK,GAFjC,MAAM,CAKlB;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAH9B,MAG8B,GAF5B,MAAM,GAAC,SAAS,CAc5B;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAH5B,MAG4B,GAF1B,MAAM,GAAC,SAAS,CAuB5B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,YAAY,EAJtC,KAAK,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CAAC,CAIH,EAAE,QAAQ,EAHhD,QAAQ,CAAC,MAAM,CAGiC,GAF9C,GAAG,CAAC,MAAM,CAAC,CAavB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,4BAA4B,CAC1C,UAAU,EAND,MAAM,EAML,EACV,YAAY,EANH,MAAM,EAMH,EACZ,QAAQ,EANC,MAAM,EAMP,YAqCT;AAqBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,eAAe,EAHpC,MAGoC,GAFlC,MAAM,EAAE,CAMpB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAPpC,MAAM,EAO8B,EAAE,OAAO,AANrD,CAIA,EAHA;IAAyB,MAAM,AAA/B,CACA,EADQ,MAAM,CACd;I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