@cyclonedx/cdxgen 12.2.0 → 12.3.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 (181) hide show
  1. package/README.md +242 -90
  2. package/bin/audit.js +191 -0
  3. package/bin/cdxgen.js +532 -168
  4. package/bin/convert.js +99 -0
  5. package/bin/evinse.js +23 -0
  6. package/bin/repl.js +339 -8
  7. package/bin/sign.js +8 -0
  8. package/bin/validate.js +8 -0
  9. package/bin/verify.js +8 -0
  10. package/data/container-knowledge-index.json +125 -0
  11. package/data/gtfobins-index.json +6296 -0
  12. package/data/lolbas-index.json +150 -0
  13. package/data/queries-darwin.json +63 -3
  14. package/data/queries-win.json +45 -3
  15. package/data/queries.json +74 -2
  16. package/data/rules/chrome-extensions.yaml +240 -0
  17. package/data/rules/ci-permissions.yaml +478 -18
  18. package/data/rules/container-risk.yaml +270 -0
  19. package/data/rules/obom-runtime.yaml +891 -0
  20. package/data/rules/package-integrity.yaml +49 -0
  21. package/data/spdx-export.schema.json +6794 -0
  22. package/data/spdx-model-v3.0.1.jsonld +15999 -0
  23. package/lib/audit/index.js +1924 -0
  24. package/lib/audit/index.poku.js +1488 -0
  25. package/lib/audit/progress.js +137 -0
  26. package/lib/audit/progress.poku.js +188 -0
  27. package/lib/audit/reporters.js +618 -0
  28. package/lib/audit/scoring.js +310 -0
  29. package/lib/audit/scoring.poku.js +341 -0
  30. package/lib/audit/targets.js +260 -0
  31. package/lib/audit/targets.poku.js +331 -0
  32. package/lib/cli/index.js +276 -68
  33. package/lib/cli/index.poku.js +368 -0
  34. package/lib/helpers/analyzer.js +1052 -5
  35. package/lib/helpers/analyzer.poku.js +301 -0
  36. package/lib/helpers/annotationFormatter.js +49 -0
  37. package/lib/helpers/annotationFormatter.poku.js +44 -0
  38. package/lib/helpers/bomUtils.js +36 -0
  39. package/lib/helpers/bomUtils.poku.js +51 -0
  40. package/lib/helpers/caxa.js +2 -2
  41. package/lib/helpers/chromextutils.js +1153 -0
  42. package/lib/helpers/chromextutils.poku.js +493 -0
  43. package/lib/helpers/ciParsers/githubActions.js +1632 -45
  44. package/lib/helpers/ciParsers/githubActions.poku.js +853 -1
  45. package/lib/helpers/containerRisk.js +186 -0
  46. package/lib/helpers/containerRisk.poku.js +52 -0
  47. package/lib/helpers/depsUtils.js +16 -0
  48. package/lib/helpers/depsUtils.poku.js +58 -1
  49. package/lib/helpers/display.js +245 -61
  50. package/lib/helpers/display.poku.js +162 -2
  51. package/lib/helpers/exportUtils.js +123 -0
  52. package/lib/helpers/exportUtils.poku.js +60 -0
  53. package/lib/helpers/formulationParsers.js +69 -0
  54. package/lib/helpers/formulationParsers.poku.js +44 -0
  55. package/lib/helpers/gtfobins.js +189 -0
  56. package/lib/helpers/gtfobins.poku.js +49 -0
  57. package/lib/helpers/lolbas.js +267 -0
  58. package/lib/helpers/lolbas.poku.js +39 -0
  59. package/lib/helpers/osqueryTransform.js +84 -0
  60. package/lib/helpers/osqueryTransform.poku.js +49 -0
  61. package/lib/helpers/provenanceUtils.js +193 -0
  62. package/lib/helpers/provenanceUtils.poku.js +145 -0
  63. package/lib/helpers/pylockutils.js +281 -0
  64. package/lib/helpers/pylockutils.poku.js +48 -0
  65. package/lib/helpers/registryProvenance.js +793 -0
  66. package/lib/helpers/registryProvenance.poku.js +452 -0
  67. package/lib/helpers/remote/dependency-track.js +84 -0
  68. package/lib/helpers/remote/dependency-track.poku.js +119 -0
  69. package/lib/helpers/source.js +1267 -0
  70. package/lib/helpers/source.poku.js +771 -0
  71. package/lib/helpers/spdxUtils.js +97 -0
  72. package/lib/helpers/spdxUtils.poku.js +70 -0
  73. package/lib/helpers/table.js +384 -0
  74. package/lib/helpers/table.poku.js +186 -0
  75. package/lib/helpers/unicodeScan.js +147 -0
  76. package/lib/helpers/unicodeScan.poku.js +45 -0
  77. package/lib/helpers/utils.js +882 -136
  78. package/lib/helpers/utils.poku.js +995 -91
  79. package/lib/managers/binary.js +29 -5
  80. package/lib/managers/docker.js +179 -52
  81. package/lib/managers/docker.poku.js +327 -28
  82. package/lib/managers/oci.js +107 -23
  83. package/lib/managers/oci.poku.js +132 -0
  84. package/lib/server/openapi.yaml +50 -0
  85. package/lib/server/server.js +228 -331
  86. package/lib/server/server.poku.js +220 -5
  87. package/lib/stages/postgen/annotator.js +7 -0
  88. package/lib/stages/postgen/annotator.poku.js +40 -0
  89. package/lib/stages/postgen/auditBom.js +20 -5
  90. package/lib/stages/postgen/auditBom.poku.js +1729 -67
  91. package/lib/stages/postgen/postgen.js +40 -0
  92. package/lib/stages/postgen/postgen.poku.js +47 -0
  93. package/lib/stages/postgen/ruleEngine.js +80 -2
  94. package/lib/stages/postgen/spdxConverter.js +796 -0
  95. package/lib/stages/postgen/spdxConverter.poku.js +341 -0
  96. package/lib/validator/bomValidator.js +232 -0
  97. package/lib/validator/bomValidator.poku.js +70 -0
  98. package/lib/validator/complianceRules.js +70 -7
  99. package/lib/validator/complianceRules.poku.js +30 -0
  100. package/lib/validator/reporters/annotations.js +2 -2
  101. package/lib/validator/reporters/console.js +13 -2
  102. package/lib/validator/reporters.poku.js +13 -0
  103. package/package.json +10 -8
  104. package/types/bin/audit.d.ts +3 -0
  105. package/types/bin/audit.d.ts.map +1 -0
  106. package/types/bin/convert.d.ts +3 -0
  107. package/types/bin/convert.d.ts.map +1 -0
  108. package/types/bin/repl.d.ts.map +1 -1
  109. package/types/lib/audit/index.d.ts +115 -0
  110. package/types/lib/audit/index.d.ts.map +1 -0
  111. package/types/lib/audit/progress.d.ts +27 -0
  112. package/types/lib/audit/progress.d.ts.map +1 -0
  113. package/types/lib/audit/reporters.d.ts +35 -0
  114. package/types/lib/audit/reporters.d.ts.map +1 -0
  115. package/types/lib/audit/scoring.d.ts +35 -0
  116. package/types/lib/audit/scoring.d.ts.map +1 -0
  117. package/types/lib/audit/targets.d.ts +63 -0
  118. package/types/lib/audit/targets.d.ts.map +1 -0
  119. package/types/lib/cli/index.d.ts +8 -0
  120. package/types/lib/cli/index.d.ts.map +1 -1
  121. package/types/lib/helpers/analyzer.d.ts +13 -0
  122. package/types/lib/helpers/analyzer.d.ts.map +1 -1
  123. package/types/lib/helpers/annotationFormatter.d.ts +23 -0
  124. package/types/lib/helpers/annotationFormatter.d.ts.map +1 -0
  125. package/types/lib/helpers/bomUtils.d.ts +5 -0
  126. package/types/lib/helpers/bomUtils.d.ts.map +1 -0
  127. package/types/lib/helpers/chromextutils.d.ts +97 -0
  128. package/types/lib/helpers/chromextutils.d.ts.map +1 -0
  129. package/types/lib/helpers/ciParsers/githubActions.d.ts +3 -8
  130. package/types/lib/helpers/ciParsers/githubActions.d.ts.map +1 -1
  131. package/types/lib/helpers/containerRisk.d.ts +17 -0
  132. package/types/lib/helpers/containerRisk.d.ts.map +1 -0
  133. package/types/lib/helpers/depsUtils.d.ts.map +1 -1
  134. package/types/lib/helpers/display.d.ts +4 -1
  135. package/types/lib/helpers/display.d.ts.map +1 -1
  136. package/types/lib/helpers/exportUtils.d.ts +40 -0
  137. package/types/lib/helpers/exportUtils.d.ts.map +1 -0
  138. package/types/lib/helpers/formulationParsers.d.ts.map +1 -1
  139. package/types/lib/helpers/gtfobins.d.ts +17 -0
  140. package/types/lib/helpers/gtfobins.d.ts.map +1 -0
  141. package/types/lib/helpers/lolbas.d.ts +16 -0
  142. package/types/lib/helpers/lolbas.d.ts.map +1 -0
  143. package/types/lib/helpers/osqueryTransform.d.ts +7 -0
  144. package/types/lib/helpers/osqueryTransform.d.ts.map +1 -0
  145. package/types/lib/helpers/provenanceUtils.d.ts +90 -0
  146. package/types/lib/helpers/provenanceUtils.d.ts.map +1 -0
  147. package/types/lib/helpers/pylockutils.d.ts +51 -0
  148. package/types/lib/helpers/pylockutils.d.ts.map +1 -0
  149. package/types/lib/helpers/registryProvenance.d.ts +17 -0
  150. package/types/lib/helpers/registryProvenance.d.ts.map +1 -0
  151. package/types/lib/helpers/remote/dependency-track.d.ts +16 -0
  152. package/types/lib/helpers/remote/dependency-track.d.ts.map +1 -0
  153. package/types/lib/helpers/source.d.ts +141 -0
  154. package/types/lib/helpers/source.d.ts.map +1 -0
  155. package/types/lib/helpers/spdxUtils.d.ts +2 -0
  156. package/types/lib/helpers/spdxUtils.d.ts.map +1 -0
  157. package/types/lib/helpers/table.d.ts +6 -0
  158. package/types/lib/helpers/table.d.ts.map +1 -0
  159. package/types/lib/helpers/unicodeScan.d.ts +46 -0
  160. package/types/lib/helpers/unicodeScan.d.ts.map +1 -0
  161. package/types/lib/helpers/utils.d.ts +30 -11
  162. package/types/lib/helpers/utils.d.ts.map +1 -1
  163. package/types/lib/managers/binary.d.ts.map +1 -1
  164. package/types/lib/managers/docker.d.ts.map +1 -1
  165. package/types/lib/managers/oci.d.ts.map +1 -1
  166. package/types/lib/server/server.d.ts +0 -35
  167. package/types/lib/server/server.d.ts.map +1 -1
  168. package/types/lib/stages/postgen/annotator.d.ts.map +1 -1
  169. package/types/lib/stages/postgen/auditBom.d.ts.map +1 -1
  170. package/types/lib/stages/postgen/postgen.d.ts.map +1 -1
  171. package/types/lib/stages/postgen/ruleEngine.d.ts.map +1 -1
  172. package/types/lib/stages/postgen/spdxConverter.d.ts +11 -0
  173. package/types/lib/stages/postgen/spdxConverter.d.ts.map +1 -0
  174. package/types/lib/validator/bomValidator.d.ts +1 -0
  175. package/types/lib/validator/bomValidator.d.ts.map +1 -1
  176. package/types/lib/validator/complianceRules.d.ts.map +1 -1
  177. package/types/lib/validator/reporters/console.d.ts.map +1 -1
  178. package/types/bin/dependencies.d.ts +0 -3
  179. package/types/bin/dependencies.d.ts.map +0 -1
  180. package/types/bin/licenses.d.ts +0 -3
  181. package/types/bin/licenses.d.ts.map +0 -1
package/README.md CHANGED
@@ -12,7 +12,7 @@
12
12
 
13
13
  <img src="./docs/_media/cdxgen.png" width="200" height="auto" />
14
14
 
15
- cdxgen is a CLI tool, library, [REPL](./ADVANCED.md), and server to create, validate, sign, and verify [CycloneDX][cyclonedx-homepage] Bill of Materials (BOM) containing an aggregate of all project dependencies in JSON format. CycloneDX is a full-stack BOM specification that is easily created, human and machine-readable, and simple to parse. The tool supports CycloneDX specification versions from 1.5 - 1.7.
15
+ cdxgen is a CLI tool, library, [REPL](./ADVANCED.md), and server to create, validate, sign, and verify software BOMs. It generates CycloneDX JSON BOMs and supports SPDX 3.0.1 JSON-LD export. CycloneDX is a full-stack BOM specification that is easily created, human and machine-readable, and simple to parse. The tool supports CycloneDX specification versions from 1.5 - 1.7.
16
16
 
17
17
  Supported BOM formats:
18
18
 
@@ -23,6 +23,42 @@ Supported BOM formats:
23
23
  - Attestations (CDXA) - Generate SBOM with templates for multiple standards. Sign the BOM document at a granular level to improve authenticity.
24
24
  - Vulnerability Disclosure Report (VDR) - Use cdxgen with [OWASP depscan](https://github.com/owasp-dep-scan/dep-scan) to automate the generation of VDR at scale.
25
25
 
26
+ Supported output document formats:
27
+
28
+ - CycloneDX JSON (primary native format)
29
+ - SPDX 3.0.1 JSON-LD (`cdxgen --format spdx` or `cdx-convert`)
30
+
31
+ ## Choose your path
32
+
33
+ | Persona | What cdxgen helps you do | First command | Read next |
34
+ | -------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
35
+ | **Developers** | Generate a CycloneDX BOM from a local repo, git URL, purl, or container image | `cdxgen -o bom.json .` | [CLI Usage][docs-cli], [Supported Project Types][docs-project-types] |
36
+ | **AppSec** | Enrich BOMs with evidence, run BOM audit rules, and feed downstream security workflows | `cdxgen -o bom.json --profile appsec --evidence --bom-audit .` | [BOM Audit](docs/BOM_AUDIT.md), [Threat Model](docs/THREAT_MODEL.md) |
37
+ | **SOC analysts** | Build OBOM inventories for live hosts and triage runtime posture issues | `obom -o obom.json --deep --bom-audit --bom-audit-categories obom-runtime` | [OBOM lessons](docs/OBOM_LESSONS.md), [Server Usage][docs-server] |
38
+ | **Compliance teams** | Validate BOM quality, check SCVS/CRA posture, and export SPDX deliverables | `cdx-validate -i bom.json --benchmark scvs-l2,cra` | [cdx-validate](docs/CDX_VALIDATE.md), [cdx-convert](docs/CDX_CONVERT.md), [Permissions][docs-permissions] |
39
+
40
+ ### Role-based quick starts
41
+
42
+ #### For developers
43
+
44
+ - Start with a local path, git URL, or purl and generate a BOM in one command.
45
+ - Use [Supported Project Types][docs-project-types] to confirm ecosystem coverage before wiring cdxgen into CI.
46
+
47
+ #### For AppSec
48
+
49
+ - Use `--profile appsec`, `--evidence`, and `--bom-audit` when you want richer security context.
50
+ - Combine generation with [BOM Audit](docs/BOM_AUDIT.md), [cdx-validate](docs/CDX_VALIDATE.md), signing, and verification for a fuller secure-SBOM workflow.
51
+
52
+ #### For SOC analysts
53
+
54
+ - Use `obom` for live-system and runtime inventory on Linux and Windows hosts.
55
+ - Focus on [OBOM lessons](docs/OBOM_LESSONS.md) when you need host triage, persistence review, LOLBAS-backed Windows startup analysis, or incident-response evidence.
56
+
57
+ #### For compliance and platform governance
58
+
59
+ - Use `cdx-validate` to assess structural and compliance posture, then `cdx-convert` when SPDX output is required.
60
+ - Review [Permissions][docs-permissions] and hardened-environment guidance before adopting cdxgen in controlled pipelines.
61
+
26
62
  ## Why cdxgen?
27
63
 
28
64
  Most SBOM tools are like simple barcode scanners. For easy applications, they can parse a few package manifests and create a list of components only based on these files without any deep inspection. Further, a typical application might have several repos, components, and libraries with complex build requirements. Traditional techniques to generate an SBOM per language or package manifest either do not work in enterprise environments or don't provide the confidence required for both compliance and automated analysis. So we built cdxgen - the universal polyglot SBOM generator that is user-friendly, precise, and comprehensive!
@@ -44,6 +80,8 @@ Sections include:
44
80
  - [Getting Started][docs-homepage]
45
81
  - [CLI Usage][docs-cli]
46
82
  - [Server Usage][docs-server]
83
+ - [Hands-on Lessons](docs/LESSON8.md)
84
+ - [Container Escape & Privilege Lesson](docs/LESSON9.md)
47
85
  - [Supported Project Types][docs-project-types]
48
86
  - [Environment Variables][docs-env-vars]
49
87
  - [Advanced Usage][docs-advanced-usage]
@@ -56,16 +94,52 @@ Sections include:
56
94
 
57
95
  ## Installing
58
96
 
97
+ Install the npm package when you want the full multi-command CLI surface.
98
+
59
99
  ```shell
60
100
  npm install -g @cyclonedx/cdxgen
61
101
  ```
62
102
 
103
+ Installing `@cyclonedx/cdxgen` exposes these commands:
104
+
105
+ | Command | Purpose | Standalone GitHub release binary |
106
+ | --------------- | ---------------------------------------------------------------------------------------------------- | -------------------------------- |
107
+ | `cdxgen` | Generate CycloneDX / SPDX BOMs from source, images, binaries, git URLs, or purls | yes |
108
+ | `cdx-audit` | Prioritize existing BOM dependencies for upstream supply-chain review using explainable risk signals | yes |
109
+ | `cdx-convert` | Convert CycloneDX JSON to SPDX 3.0.1 JSON-LD | yes |
110
+ | `cdx-sign` | Sign BOMs with JSF signatures | yes |
111
+ | `cdx-validate` | Validate BOMs and benchmark posture | yes |
112
+ | `cdx-verify` | Verify BOM signatures | yes |
113
+ | `cdxi` | Open the interactive REPL | no |
114
+ | `evinse` | Add evidence, reachability, and service context | no |
115
+ | `cbom` | Alias for CBOM-oriented `cdxgen` defaults | use `cdxgen` |
116
+ | `obom` | Alias for `cdxgen -t os` | use `cdxgen` |
117
+ | `saasbom` | Alias for SaaSBOM-oriented `cdxgen` defaults | use `cdxgen` |
118
+ | `spdxgen` | Alias for `cdxgen --format spdx` | use `cdxgen` |
119
+ | `cdxgen-secure` | Alias for hardened `cdxgen` defaults | use `cdxgen` |
120
+
121
+ Standalone GitHub release binaries are published for `cdxgen`, `cdxgen-slim`, `cdx-audit`, `cdx-convert`, `cdx-sign`, `cdx-validate`, and `cdx-verify`.
122
+
123
+ `cdx-audit` is designed to accelerate upstream dependency review with explainable, evidence-backed risk prioritization. It complements provenance, reproducibility, and manual investigation rather than replacing them.
124
+
63
125
  To run cdxgen without installing (hotloading), use the [pnpm dlx](https://pnpm.io/cli/dlx) command.
64
126
 
65
127
  ```shell
66
128
  corepack pnpm dlx @cyclonedx/cdxgen --help
67
129
  ```
68
130
 
131
+ You can call any packaged command the same way:
132
+
133
+ ```shell
134
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdx-audit --help
135
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdx-convert --help
136
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdx-validate --help
137
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdx-sign --help
138
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdx-verify --help
139
+ corepack pnpm dlx --package=@cyclonedx/cdxgen evinse --help
140
+ corepack pnpm dlx --package=@cyclonedx/cdxgen cdxi --help
141
+ ```
142
+
69
143
  If you are a [Homebrew][homebrew-homepage] user, you can also install [cdxgen][homebrew-cdxgen] via:
70
144
 
71
145
  ```shell
@@ -78,6 +152,86 @@ If you are a [Winget][winget-homepage] user on windows, you can also install cdx
78
152
  winget install cdxgen
79
153
  ```
80
154
 
155
+ ### Standalone GitHub release binaries
156
+
157
+ If you want a single-file executable instead of an npm installation, download a published release asset and verify its hash before executing it.
158
+
159
+ Common asset names:
160
+
161
+ - `cdxgen-linux-amd64`
162
+ - `cdxgen-linux-amd64-musl`
163
+ - `cdxgen-darwin-arm64`
164
+ - `cdxgen-windows-amd64.exe`
165
+ - `cdx-audit-linux-amd64`
166
+ - `cdx-audit-darwin-arm64`
167
+ - `cdx-audit-windows-amd64.exe`
168
+ - `cdx-convert-*`, `cdx-sign-*`, `cdx-validate-*`, `cdx-verify-*`
169
+
170
+ #### Linux
171
+
172
+ ```bash
173
+ VERSION="v12.3.0"
174
+ ASSET="cdx-audit-linux-amd64"
175
+ BASE_URL="https://github.com/cdxgen/cdxgen/releases/download/${VERSION}"
176
+
177
+ curl -fsSLO "${BASE_URL}/${ASSET}"
178
+ curl -fsSLO "${BASE_URL}/${ASSET}.sha256"
179
+ sha256sum -c "${ASSET}.sha256"
180
+ chmod +x "${ASSET}"
181
+ ./"${ASSET}" --help
182
+ ```
183
+
184
+ #### macOS
185
+
186
+ ```bash
187
+ VERSION="v12.3.0"
188
+ ASSET="cdx-audit-darwin-arm64"
189
+ BASE_URL="https://github.com/cdxgen/cdxgen/releases/download/${VERSION}"
190
+
191
+ curl -fsSLO "${BASE_URL}/${ASSET}"
192
+ curl -fsSLO "${BASE_URL}/${ASSET}.sha256"
193
+ shasum -a 256 -c "${ASSET}.sha256"
194
+ chmod +x "${ASSET}"
195
+ ./"${ASSET}" --help
196
+ ```
197
+
198
+ #### Windows (PowerShell)
199
+
200
+ ```powershell
201
+ $Version = "v12.3.0"
202
+ $Asset = "cdx-audit-windows-amd64.exe"
203
+ $BaseUrl = "https://github.com/cdxgen/cdxgen/releases/download/$Version"
204
+
205
+ Invoke-WebRequest -Uri "$BaseUrl/$Asset" -OutFile $Asset
206
+ Invoke-WebRequest -Uri "$BaseUrl/$Asset.sha256" -OutFile "$Asset.sha256"
207
+ $Expected = (Get-Content "$Asset.sha256" | Select-Object -First 1).Trim().Split()[0]
208
+ $Actual = (Get-FileHash $Asset -Algorithm SHA256).Hash.ToLowerInvariant()
209
+ if ($Actual -ne $Expected.ToLowerInvariant()) {
210
+ throw "SHA256 mismatch for $Asset"
211
+ }
212
+ .\$Asset --help
213
+ ```
214
+
215
+ #### GitHub Actions with the GitHub CLI
216
+
217
+ ```yaml
218
+ permissions:
219
+ contents: read
220
+
221
+ steps:
222
+ - name: Download cdx-audit release binary
223
+ env:
224
+ GH_TOKEN: ${{ github.token }}
225
+ run: |
226
+ gh release download v12.3.0 \
227
+ --repo cdxgen/cdxgen \
228
+ --pattern 'cdx-audit-linux-amd64' \
229
+ --pattern 'cdx-audit-linux-amd64.sha256'
230
+ sha256sum -c cdx-audit-linux-amd64.sha256
231
+ chmod +x cdx-audit-linux-amd64
232
+ ./cdx-audit-linux-amd64 --help
233
+ ```
234
+
81
235
  Deno and bun runtime can be used with limited support.
82
236
 
83
237
  ```shell
@@ -104,95 +258,42 @@ For the bun version, use `ghcr.io/cyclonedx/cdxgen-bun` as the image name.
104
258
  docker run --rm -e CDXGEN_DEBUG_MODE=debug -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen-bun:master -r /app -o /app/bom.json
105
259
  ```
106
260
 
107
- In deno applications, cdxgen could be directly imported without any conversion. Please see the section on [integration as a library](#integration-as-library)
261
+ In deno applications, cdxgen could be directly imported without any conversion.
108
262
 
109
263
  ```ts
110
- import { createBom, submitBom } from "npm:@cyclonedx/cdxgen@^12.2.0";
111
- ```
112
-
113
- ## Getting Help
114
-
115
- ```text
116
- cdxgen [command]
117
-
118
- Commands:
119
- cdxgen completion Generate bash/zsh completion
120
-
121
- Options:
122
- -o, --output Output file. Default bom.json [default: "bom.json"]
123
- -t, --type Project type. Please refer to https://cdxgen.github.io/cdxgen/#/PROJECT_TYPES for supp
124
- orted languages/platforms. [array]
125
- --exclude-type Project types to exclude. Please refer to https://cdxgen.github.io/cdxgen/#/PROJECT_TY
126
- PES for supported languages/platforms.
127
- -r, --recurse Recurse mode suitable for mono-repos. Defaults to true. Pass --no-recurse to disable.
128
- [boolean] [default: true]
129
- -p, --print Print the SBOM as a table with tree. [boolean]
130
- -c, --resolve-class Resolve class names for packages. jars only for now. [boolean]
131
- --deep Perform deep searches for components. Useful while scanning C/C++ apps, live OS and oc
132
- i images. [boolean]
133
- --server-url Dependency track url. Eg: https://deptrack.cyclonedx.io
134
- --skip-dt-tls-check Skip TLS certificate check when calling Dependency-Track. [boolean] [default: false]
135
- --api-key Dependency track api key
136
- --project-group Dependency track project group
137
- --project-name Dependency track project name. Default use the directory name
138
- --project-version Dependency track project version [string] [default: ""]
139
- --project-tag Dependency track project tag. Multiple values allowed. [array]
140
- --project-id Dependency track project id. Either provide the id or the project name and version tog
141
- ether [string]
142
- --parent-project-id Dependency track parent project id [string]
143
- --required-only Include only the packages with required scope on the SBOM. Would set compositions.aggr
144
- egate to incomplete unless --no-auto-compositions is passed. [boolean]
145
- --fail-on-error Fail if any dependency extractor fails. [boolean]
146
- --no-babel Do not use babel to perform usage analysis for JavaScript/TypeScript projects.
147
- [boolean]
148
- --generate-key-and-sign Generate an RSA public/private key pair and then sign the generated SBOM using JSON We
149
- b Signatures. [boolean]
150
- --server Run cdxgen as a server [boolean]
151
- --server-host Listen address [default: "127.0.0.1"]
152
- --server-port Listen port [default: "9090"]
153
- --install-deps Install dependencies automatically for some projects. Defaults to true but disabled fo
154
- r containers and oci scans. Use --no-install-deps to disable this feature.
155
- [boolean] [default: true]
156
- --validate Validate the generated SBOM using json schema. Defaults to true. Pass --no-validate to
157
- disable. [boolean] [default: true]
158
- --evidence Generate SBOM with evidence for supported languages. [boolean] [default: false]
159
- --spec-version CycloneDX Specification version to use. Defaults to 1.7
160
- [number] [choices: 1.4, 1.5, 1.6, 1.7] [default: 1.7]
161
- --filter Filter components containing this word in purl or component.properties.value. Multiple
162
- values allowed. [array]
163
- --only Include components only containing this word in purl. Useful to generate BOM with firs
164
- t party components alone. Multiple values allowed. [array]
165
- --author The person(s) who created the BOM. Set this value if you're intending the modify the B
166
- OM and claim authorship. [array] [default: "OWASP Foundation"]
167
- --profile BOM profile to use for generation. Default generic.
168
- [choices: "appsec", "research", "operational", "threat-modeling", "license-compliance", "generic", "machine-learning",
169
- "ml", "deep-learning", "ml-deep", "ml-tiny"] [default: "generic"]
170
- --include-regex glob pattern to include. This overrides the default pattern used during auto-detection
171
- . [string]
172
- --exclude, --exclude-regex Additional glob pattern(s) to ignore [array]
173
- --export-proto Serialize and export BOM as protobuf binary. [boolean] [default: false]
174
- --proto-bin-file Path for the serialized protobuf binary. [default: "bom.cdx"]
175
- --include-formulation Generate formulation section with git metadata and build tools. Defaults to false.
176
- [boolean] [default: false]
177
- --include-crypto Include crypto libraries as components. [boolean] [default: false]
178
- --standard The list of standards which may consist of regulations, industry or organizational-spe
179
- cific standards, maturity models, best practices, or any other requirements which can
180
- be evaluated against or attested to.
181
- [array] [choices: "asvs-5.0", "asvs-4.0.3", "bsimm-v13", "masvs-2.0.0", "nist_ssdf-1.1", "pcissc-secure-slc-1.1", "scv
182
- s-1.0.0", "ssaf-DRAFT-2023-11"]
183
- --json-pretty Pretty-print the generated BOM json. [boolean] [default: false]
184
- --min-confidence Minimum confidence needed for the identity of a component from 0 - 1, where 1 is 100%
185
- confidence. [number] [default: 0]
186
- --technique Analysis technique to use
187
- [array] [choices: "auto", "source-code-analysis", "binary-analysis", "manifest-analysis", "hash-comparison", "instrume
188
- ntation", "filename"]
189
- --auto-compositions Automatically set compositions when the BOM was filtered. Defaults to true
190
- [boolean] [default: true]
191
- -h, --help Show help [boolean]
192
- -v, --version Show version number [boolean]
193
- ```
194
-
195
- All boolean arguments accept `--no` prefix to toggle the behavior.
264
+ import { createBom, submitBom } from "npm:@cyclonedx/cdxgen@^12.2.1";
265
+ ```
266
+
267
+ ## Common workflows
268
+
269
+ | Goal | First command | Read next |
270
+ | ---------------------------------------------------------- | -------------------------------------------------------------------------- | ------------------------------------ |
271
+ | Generate a BOM from the current repository | `cdxgen -o bom.json .` | [CLI Usage][docs-cli] |
272
+ | Generate a BOM from a git URL | `cdxgen -o bom.json https://github.com/example/project.git` | [CLI Usage][docs-cli] |
273
+ | Generate a BOM from a package URL | `cdxgen -o bom.json "pkg:npm/lodash@4.17.21"` | [CLI Usage][docs-cli] |
274
+ | Scan a container image | `cdxgen ghcr.io/owasp-dep-scan/depscan:nightly -o bom.json -t docker` | [Server Usage][docs-server] |
275
+ | Audit a generated BOM for built-in supply-chain findings | `cdxgen -o bom.json --bom-audit .` | [BOM Audit](docs/BOM_AUDIT.md) |
276
+ | Prioritize an existing BOM for upstream risk-driven review | `cdx-audit --bom bom.json` | [cdx-audit](docs/CDX_AUDIT.md) |
277
+ | Validate a BOM against structural and compliance checks | `cdx-validate -i bom.json` | [cdx-validate](docs/CDX_VALIDATE.md) |
278
+ | Convert CycloneDX JSON to SPDX JSON-LD | `cdx-convert -i bom.json -o bom.spdx.json` | [cdx-convert](docs/CDX_CONVERT.md) |
279
+ | Generate an OBOM for live-system triage | `obom -o obom.json --deep --bom-audit --bom-audit-categories obom-runtime` | [OBOM lessons](docs/OBOM_LESSONS.md) |
280
+
281
+ For the full option reference, use `cdxgen --help` or visit [CLI Usage][docs-cli].
282
+
283
+ Companion commands also expose built-in help:
284
+
285
+ - `cbom --help`
286
+ - `cdx-audit --help`
287
+ - `cdx-validate --help`
288
+ - `cdx-convert --help`
289
+ - `cdx-sign --help`
290
+ - `cdx-verify --help`
291
+ - `cdxgen-secure --help`
292
+ - `cdxi --help`
293
+ - `evinse --help`
294
+ - `obom --help`
295
+ - `saasbom --help`
296
+ - `spdxgen --help`
196
297
 
197
298
  ## Example
198
299
 
@@ -202,6 +303,25 @@ Minimal example.
202
303
  cdxgen -o bom.json
203
304
  ```
204
305
 
306
+ The primary positional input can be:
307
+
308
+ - a local filesystem path (default: current directory)
309
+ - a git URL that cdxgen clones before scanning
310
+ - a package URL (purl) that cdxgen resolves to source and then scans
311
+
312
+ Common source input examples:
313
+
314
+ ```shell
315
+ # Local path
316
+ cdxgen -o bom.json .
317
+
318
+ # Git URL
319
+ cdxgen -t java -o bom.json --git-branch main https://github.com/HooliCorp/java-sec-code.git
320
+
321
+ # Package URL (purl)
322
+ cdxgen -t js -o bom.json "pkg:npm/lodash@4.17.21"
323
+ ```
324
+
205
325
  For a java project. cdxgen would automatically detect maven, gradle, or sbt and build bom accordingly
206
326
 
207
327
  ```shell
@@ -220,6 +340,24 @@ To recursively generate a single BOM for all languages pass `-r` argument.
220
340
  cdxgen -r -o bom.json
221
341
  ```
222
342
 
343
+ To generate an SBOM directly from a git URL:
344
+
345
+ ```shell
346
+ cdxgen -t java -o bom.json --git-branch main https://github.com/HooliCorp/java-sec-code.git
347
+ ```
348
+
349
+ This works anywhere cdxgen expects its primary source input, so a git URL can be used in place of `.` or any other local path.
350
+
351
+ To generate an SBOM from a package URL (purl), cdxgen resolves registry metadata to a repository URL, clones it, and scans it:
352
+
353
+ ```shell
354
+ cdxgen -t js -o bom.json "pkg:npm/lodash@4.17.21"
355
+ ```
356
+
357
+ Supported purl source types: `npm`, `pypi`, `gem`, `cargo`, `pub`, `github`, `bitbucket`, `maven` (version required), `composer`, and `generic` (with `vcs_url` or `download_url` qualifier).
358
+
359
+ > **Warning:** Repository URLs resolved from registries may be inaccurate or malicious. Review resolved sources before trusting generated output.
360
+
223
361
  The default specification used by cdxgen is 1.7. To generate BOM for a different specification version, such as 1.5 or 1.6, pass the version number using the `--spec-version` argument.
224
362
 
225
363
  ```shell
@@ -408,6 +546,8 @@ obom
408
546
 
409
547
  This feature is powered by osquery, which is [installed](https://github.com/cdxgen/cdxgen-plugins-bin/blob/main/build.sh#L8) along with the binary plugins. cdxgen would opportunistically try to detect as many components, apps, and extensions as possible using the [default queries](data/queries.json). The process would take several minutes and result in an SBOM file with thousands of components of various types, such as operating-system, device-drivers, files, and data.
410
548
 
549
+ For practical SOC/IR and compliance workflows, see the dedicated [OBOM lessons](./docs/OBOM_LESSONS.md).
550
+
411
551
  ## Generate Cryptography Bill of Materials (CBOM)
412
552
 
413
553
  Use the `cbom` alias to generate a CBOM. This is currently supported only for Java projects.
@@ -496,7 +636,19 @@ cdxgen can automatically detect names of services from YAML manifests such as do
496
636
 
497
637
  ## Conversion to SPDX format
498
638
 
499
- Use the [CycloneDX CLI][cyclonedx-cli-github] tool for advanced use cases such as conversion, diff and merging.
639
+ For direct conversion of an existing CycloneDX JSON BOM to SPDX JSON-LD, use
640
+ the bundled `cdx-convert` command:
641
+
642
+ ```shell
643
+ cdx-convert -i bom.json -o bom.spdx.json
644
+ ```
645
+
646
+ `cdx-convert` currently supports CycloneDX 1.6 and 1.7 inputs and exports
647
+ SPDX 3.0.1 JSON-LD.
648
+
649
+ Use `cdxgen --format spdx` (or `--format cyclonedx,spdx`) when generating BOMs.
650
+ Use the [CycloneDX CLI][cyclonedx-cli-github] tool for advanced use cases such
651
+ as diff and merging.
500
652
 
501
653
  ## Including .NET Global Assembly Cache dependencies in the results
502
654
 
@@ -642,7 +794,7 @@ Copy the below block to your markdown files to show your ❤️ for cdxgen.
642
794
  [docs-permissions]: https://cdxgen.github.io/cdxgen/#/PERMISSIONS
643
795
  [docs-project-types]: https://cdxgen.github.io/cdxgen/#/PROJECT_TYPES
644
796
  [docs-server]: https://cdxgen.github.io/cdxgen/#/SERVER
645
- [docs-support]: https://cdxgen.github.io/cdxgen/#/PROJECT_TYPES
797
+ [docs-support]: https://cdxgen.github.io/cdxgen/#/SUPPORT
646
798
 
647
799
  <!-- web links-->
648
800
 
package/bin/audit.js ADDED
@@ -0,0 +1,191 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { writeFileSync } from "node:fs";
4
+ import { dirname } from "node:path";
5
+ import process from "node:process";
6
+
7
+ import yargs from "yargs";
8
+ import { hideBin } from "yargs/helpers";
9
+
10
+ import {
11
+ DEFAULT_AUDIT_CATEGORIES,
12
+ finalizeAuditReport,
13
+ runAudit,
14
+ } from "../lib/audit/index.js";
15
+ import { createProgressTracker } from "../lib/audit/progress.js";
16
+ import {
17
+ retrieveCdxgenVersion,
18
+ safeExistsSync,
19
+ safeMkdirSync,
20
+ } from "../lib/helpers/utils.js";
21
+
22
+ const args = yargs(hideBin(process.argv))
23
+ .option("bom", {
24
+ description: "Path to a CycloneDX JSON BOM file.",
25
+ type: "string",
26
+ })
27
+ .option("bom-dir", {
28
+ description: "Directory containing one or more CycloneDX JSON BOM files.",
29
+ type: "string",
30
+ })
31
+ .option("workspace-dir", {
32
+ description:
33
+ "Optional directory to reuse git clones for purl-to-source enrichment.",
34
+ type: "string",
35
+ })
36
+ .option("reports-dir", {
37
+ description:
38
+ "Optional directory to store generated per-purl SBOMs and findings.",
39
+ type: "string",
40
+ })
41
+ .option("report", {
42
+ choices: ["console", "json", "sarif"],
43
+ default: "console",
44
+ description: "Output format.",
45
+ })
46
+ .option("report-file", {
47
+ alias: "o",
48
+ description: "Write the report to this file. Defaults to stdout.",
49
+ type: "string",
50
+ })
51
+ .option("categories", {
52
+ default: DEFAULT_AUDIT_CATEGORIES.join(","),
53
+ description:
54
+ "Comma-separated rule categories to evaluate for each generated child SBOM.",
55
+ type: "string",
56
+ })
57
+ .option("min-severity", {
58
+ choices: ["low", "medium", "high", "critical"],
59
+ default: "low",
60
+ description:
61
+ "Minimum final target severity to include in console or SARIF output.",
62
+ type: "string",
63
+ })
64
+ .option("fail-severity", {
65
+ choices: ["low", "medium", "high", "critical"],
66
+ default: "high",
67
+ description:
68
+ "Exit with code 3 when any target reaches this final severity or above.",
69
+ type: "string",
70
+ })
71
+ .option("max-targets", {
72
+ description:
73
+ "Optional safety limit for the number of unique npm/PyPI purls to analyze.",
74
+ type: "number",
75
+ })
76
+ .option("scope", {
77
+ choices: ["all", "required"],
78
+ default: "all",
79
+ description:
80
+ "Target selection scope. Use 'required' to scan only components with CycloneDX scope=required (missing scope is treated as required).",
81
+ type: "string",
82
+ })
83
+ .option("include-trusted", {
84
+ default: false,
85
+ description:
86
+ "Include packages already marked with trusted publishing metadata in predictive audit target selection.",
87
+ type: "boolean",
88
+ })
89
+ .option("only-trusted", {
90
+ default: false,
91
+ description:
92
+ "Restrict predictive audit target selection to packages marked with trusted publishing metadata.",
93
+ type: "boolean",
94
+ })
95
+ .check((argv) => {
96
+ if (!argv.bom && !argv.bomDir) {
97
+ throw new Error("Specify --bom or --bom-dir.");
98
+ }
99
+ if (argv.bom && argv.bomDir) {
100
+ throw new Error("Use either --bom or --bom-dir, not both.");
101
+ }
102
+ if (argv.output && argv.reportFile) {
103
+ throw new Error("Use either --report-file or --output, not both.");
104
+ }
105
+ if (argv.includeTrusted && argv.onlyTrusted) {
106
+ throw new Error(
107
+ "Use either --include-trusted or --only-trusted, not both.",
108
+ );
109
+ }
110
+ return true;
111
+ })
112
+ .completion("completion", "Generate bash/zsh completion")
113
+ .epilogue("for documentation, visit https://cdxgen.github.io/cdxgen")
114
+ .scriptName("cdx-audit")
115
+ .version(retrieveCdxgenVersion())
116
+ .help()
117
+ .wrap(Math.min(120, yargs().terminalWidth())).argv;
118
+
119
+ /**
120
+ * Split a CSV option into a normalized string array.
121
+ *
122
+ * @param {string | undefined} value CSV string
123
+ * @returns {string[] | undefined} parsed values
124
+ */
125
+ function splitCsv(value) {
126
+ if (!value) {
127
+ return undefined;
128
+ }
129
+ return value
130
+ .split(",")
131
+ .map((entry) => entry.trim())
132
+ .filter(Boolean);
133
+ }
134
+
135
+ /**
136
+ * Print or write rendered report output.
137
+ *
138
+ * @param {string} output rendered output
139
+ * @param {string | undefined} outputPath optional file path
140
+ * @returns {void}
141
+ */
142
+ function writeOrPrint(output, outputPath) {
143
+ if (!outputPath) {
144
+ process.stdout.write(output);
145
+ return;
146
+ }
147
+ const parentDir = dirname(outputPath);
148
+ if (!safeExistsSync(parentDir)) {
149
+ safeMkdirSync(parentDir, { recursive: true });
150
+ }
151
+ writeFileSync(outputPath, output);
152
+ }
153
+
154
+ (async () => {
155
+ const progressTracker = createProgressTracker();
156
+ try {
157
+ const reportFile = args.reportFile || args.output;
158
+ const report = await runAudit({
159
+ bom: args.bom,
160
+ bomDir: args.bomDir,
161
+ categories: splitCsv(args.categories),
162
+ failSeverity: args.failSeverity,
163
+ maxTargets: args.maxTargets,
164
+ minSeverity: args.minSeverity,
165
+ onProgress: progressTracker.onProgress,
166
+ report: args.report,
167
+ reportsDir: args.reportsDir,
168
+ scope: args.scope === "required" ? "required" : undefined,
169
+ trusted: args.onlyTrusted
170
+ ? "only"
171
+ : args.includeTrusted
172
+ ? "include"
173
+ : undefined,
174
+ trustedSelectionHelp:
175
+ "Use --include-trusted to include them or --only-trusted to audit just those packages.",
176
+ workspaceDir: args.workspaceDir,
177
+ });
178
+ const finalized = finalizeAuditReport(report, {
179
+ failSeverity: args.failSeverity,
180
+ minSeverity: args.minSeverity,
181
+ report: args.report,
182
+ });
183
+ writeOrPrint(finalized.output, reportFile);
184
+ process.exit(finalized.exitCode);
185
+ } catch (error) {
186
+ console.error(error.message);
187
+ process.exit(1);
188
+ } finally {
189
+ progressTracker.stop();
190
+ }
191
+ })();