@cyclonedx/cdxgen 10.4.2 → 10.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  [![JSR](https://img.shields.io/jsr/v/%40cyclonedx/cdxgen)](https://jsr.io/@cyclonedx/cdxgen) [![NPM](https://img.shields.io/npm/v/%40cyclonedx%2Fcdxgen)](https://www.npmjs.com/package/@cyclonedx/cdxgen) [![GitHub Releases](https://img.shields.io/github/v/release/cyclonedx/cdxgen)](https://github.com/CycloneDX/cdxgen/releases) [![NPM Downloads](https://img.shields.io/npm/dy/%40cyclonedx%2Fcdxgen)](<(https://www.npmjs.com/package/@cyclonedx/cdxgen)>) [![GitHub License](https://img.shields.io/github/license/cyclonedx/cdxgen)](./LICENSE.md) [![GitHub Contributors](https://img.shields.io/github/contributors/cyclonedx/cdxgen)](https://github.com/CycloneDX/cdxgen/graphs/contributors)
2
2
 
3
+ [![SWH](https://archive.softwareheritage.org/badge/origin/https://github.com/CycloneDX/cdxgen/)](https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/CycloneDX/cdxgen)
4
+
3
5
  # CycloneDX Generator
4
6
 
5
7
  ![cdxgen logo](cdxgen.png)
@@ -9,7 +11,7 @@ cdxgen is a CLI tool, library, [REPL](./ADVANCED.md), and server to create a val
9
11
  When used with plugins:
10
12
 
11
13
  - cdxgen could generate an OBOM for Linux docker images and even VMs running Linux or Windows operating systems
12
- - cdxgen also includes an evinse tool to generate component evidence, CBOM and SaaSBOM for some languages
14
+ - cdxgen also includes an evinse tool to generate component evidence, CBOM, and SaaSBOM for some languages
13
15
 
14
16
  ## Why cdxgen?
15
17
 
@@ -80,7 +82,7 @@ For node.js projects, lock files are parsed initially, so the SBOM would include
80
82
 
81
83
  This attribute can be later used for various purposes. For example, [dep-scan](https://github.com/cyclonedx/dep-scan) uses this attribute to prioritize vulnerabilities. Unfortunately, tools such as dependency track, do not include this feature and might over-report the CVEs.
82
84
 
83
- By passing the argument `--required-only`, you can limit the SBOM only to include packages with the scope "required", commonly called production or non-dev dependencies. Combine with `--no-babel` to limit this list to only non-dev dependencies based on the `dev` attribute being false in the lock files.
85
+ With the argument `--required-only`, you can limit the SBOM only to include packages with the scope "required", commonly called production or non-dev dependencies. Combine with `--no-babel` to limit this list to only non-dev dependencies based on the `dev` attribute being false in the lock files.
84
86
 
85
87
  For go, `go mod why` command is used to identify required packages. For php, composer lock file is parsed to distinguish required (packages) from optional (packages-dev).
86
88
 
@@ -98,18 +100,18 @@ If you are a [Homebrew](https://brew.sh/) user, you can also install [cdxgen](ht
98
100
  $ brew install cdxgen
99
101
  ```
100
102
 
101
- Deno install is also supported.
103
+ Deno and bun runtime can be used with limited support.
102
104
 
103
105
  ```shell
104
106
  deno install --allow-read --allow-env --allow-run --allow-sys=uid,systemMemoryInfo,gid --allow-write --allow-net -n cdxgen "npm:@cyclonedx/cdxgen/cdxgen"
105
107
  ```
106
108
 
107
- You can also use the cdxgen container image
109
+ You can also use the cdxgen container image with node, deno, or bun runtime versions.
110
+
111
+ The default version uses Node.js 20
108
112
 
109
113
  ```bash
110
114
  docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen -r /app -o /app/bom.json
111
-
112
- docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen:v8.6.0 -r /app -o /app/bom.json
113
115
  ```
114
116
 
115
117
  To use the deno version, use `ghcr.io/cyclonedx/cdxgen-deno` as the image name.
@@ -118,7 +120,13 @@ To use the deno version, use `ghcr.io/cyclonedx/cdxgen-deno` as the image name.
118
120
  docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen-deno -r /app -o /app/bom.json
119
121
  ```
120
122
 
121
- In deno applications, cdxgen could be directly imported without any conversion. Please see the section on [integration as library](#integration-as-library)
123
+ For the bun version, use `ghcr.io/cyclonedx/cdxgen-bun` as the image name.
124
+
125
+ ```bash
126
+ docker run --rm -v /tmp:/tmp -v $(pwd):/app:rw -t ghcr.io/cyclonedx/cdxgen-bun -r /app -o /app/bom.json
127
+ ```
128
+
129
+ In deno applications, cdxgen could be directly imported without any conversion. Please see the section on [integration as a library](#integration-as-library)
122
130
 
123
131
  ```ts
124
132
  import { createBom, submitBom } from "npm:@cyclonedx/cdxgen@^9.0.1";
@@ -195,6 +203,13 @@ Options:
195
203
  [boolean] [default: false]
196
204
  --include-crypto Include crypto libraries found under formulation.
197
205
  [boolean] [default: false]
206
+ --standard The list of standards which may consist of regula
207
+ tions, industry or organizational-specific standa
208
+ rds, maturity models, best practices, or any othe
209
+ r requirements which can be evaluated against or
210
+ attested to.
211
+ [array] [choices: "asvs-4.0.3", "bsimm-v13", "masvs-2.0.0", "nist_ssdf-1.1", "
212
+ pcissc-secure-slc-1.1", "scvs-1.0.0", "ssaf-DRAFT-2023-11"]
198
213
  --auto-compositions Automatically set compositions when the BOM was f
199
214
  iltered. Defaults to true
200
215
  [boolean] [default: true]
package/analyzer.js CHANGED
@@ -26,7 +26,7 @@ const IGNORE_DIRS = process.env.ASTGEN_IGNORE_DIRS
26
26
  "codemods",
27
27
  "flow-typed",
28
28
  "i18n",
29
- "__tests__",
29
+ "coverage",
30
30
  ];
31
31
 
32
32
  const IGNORE_FILE_PATTERN = new RegExp(
@@ -54,6 +54,7 @@ const getAllFiles = (deep, dir, extn, files, result, regex) => {
54
54
  const dirName = basename(file);
55
55
  if (
56
56
  dirName.startsWith(".") ||
57
+ dirName.startsWith("__") ||
57
58
  IGNORE_DIRS.includes(dirName.toLowerCase())
58
59
  ) {
59
60
  continue;
package/bin/cdxgen.js CHANGED
@@ -244,11 +244,25 @@ const args = yargs(hideBin(process.argv))
244
244
  default: false,
245
245
  description: "Include crypto libraries found under formulation.",
246
246
  })
247
+ .option("standard", {
248
+ description:
249
+ "The list of standards which may consist of regulations, industry or organizational-specific standards, maturity models, best practices, or any other requirements which can be evaluated against or attested to.",
250
+ choices: [
251
+ "asvs-4.0.3",
252
+ "bsimm-v13",
253
+ "masvs-2.0.0",
254
+ "nist_ssdf-1.1",
255
+ "pcissc-secure-slc-1.1",
256
+ "scvs-1.0.0",
257
+ "ssaf-DRAFT-2023-11",
258
+ ],
259
+ })
247
260
  .completion("completion", "Generate bash/zsh completion")
248
261
  .array("filter")
249
262
  .array("only")
250
263
  .array("author")
251
264
  .array("exclude")
265
+ .array("standard")
252
266
  .option("auto-compositions", {
253
267
  type: "boolean",
254
268
  default: true,
@@ -318,7 +332,9 @@ if (process.argv[1].includes("cbom")) {
318
332
  options.specVersion = 1.6;
319
333
  options.deep = true;
320
334
  }
321
-
335
+ if (options.standard) {
336
+ options.specVersion = 1.6;
337
+ }
322
338
  /**
323
339
  * Method to apply advanced options such as profile and lifecycles
324
340
  *
@@ -371,10 +387,13 @@ const applyAdvancedOptions = (options) => {
371
387
  "aab",
372
388
  "go",
373
389
  "golang",
390
+ "rust",
391
+ "rust-lang",
392
+ "cargo",
374
393
  ].includes(options.projectType)
375
394
  ) {
376
395
  console.log(
377
- "PREVIEW: post-build lifecycle SBOM generation is supported only for android, dotnet, and go projects. Please specify the type using the -t argument.",
396
+ "PREVIEW: post-build lifecycle SBOM generation is supported only for android, dotnet, go, and Rust projects. Please specify the type using the -t argument.",
378
397
  );
379
398
  process.exit(1);
380
399
  }
@@ -439,7 +458,12 @@ const checkPermissions = (filePath) => {
439
458
  options.usagesSlicesFile = `${options.projectName}-usages.json`;
440
459
  }
441
460
  let bomNSData = (await createBom(filePath, options)) || {};
442
- if (options.requiredOnly || options["filter"] || options["only"]) {
461
+ if (
462
+ options.requiredOnly ||
463
+ options["filter"] ||
464
+ options["only"] ||
465
+ options.standard
466
+ ) {
443
467
  bomNSData = postProcess(bomNSData, options);
444
468
  }
445
469
  if (
@@ -663,5 +687,11 @@ const checkPermissions = (filePath) => {
663
687
  if (options.print && bomNSData.bomJson && bomNSData.bomJson.components) {
664
688
  printDependencyTree(bomNSData.bomJson);
665
689
  printTable(bomNSData.bomJson);
690
+ // CBOM related print
691
+ if (options.includeCrypto) {
692
+ console.log("*** Cryptography BOM ***");
693
+ printTable(bomNSData.bomJson, ["cryptographic-asset"]);
694
+ printDependencyTree(bomNSData.bomJson, "provides");
695
+ }
666
696
  }
667
697
  })();
package/bin/repl.js CHANGED
@@ -244,6 +244,32 @@ cdxgenRepl.defineCommand("print", {
244
244
  this.displayPrompt();
245
245
  },
246
246
  });
247
+ cdxgenRepl.defineCommand("cryptos", {
248
+ help: "print the components of type cryptographic-asset as a table",
249
+ action() {
250
+ if (sbom) {
251
+ printTable(sbom, ["cryptographic-asset"]);
252
+ } else {
253
+ console.log(
254
+ "⚠ No BOM is loaded. Use .import command to import an existing BOM",
255
+ );
256
+ }
257
+ this.displayPrompt();
258
+ },
259
+ });
260
+ cdxgenRepl.defineCommand("frameworks", {
261
+ help: "print the components of type framework as a table",
262
+ action() {
263
+ if (sbom) {
264
+ printTable(sbom, ["framework"]);
265
+ } else {
266
+ console.log(
267
+ "⚠ No BOM is loaded. Use .import command to import an existing BOM",
268
+ );
269
+ }
270
+ this.displayPrompt();
271
+ },
272
+ });
247
273
  cdxgenRepl.defineCommand("tree", {
248
274
  help: "display the dependency tree",
249
275
  action() {
@@ -257,6 +283,19 @@ cdxgenRepl.defineCommand("tree", {
257
283
  this.displayPrompt();
258
284
  },
259
285
  });
286
+ cdxgenRepl.defineCommand("provides", {
287
+ help: "display the provides tree",
288
+ action() {
289
+ if (sbom) {
290
+ printDependencyTree(sbom, "provides");
291
+ } else {
292
+ console.log(
293
+ "⚠ No BOM is loaded. Use .import command to import an existing BOM",
294
+ );
295
+ }
296
+ this.displayPrompt();
297
+ },
298
+ });
260
299
  cdxgenRepl.defineCommand("validate", {
261
300
  help: "validate the bom using jsonschema",
262
301
  action() {
package/binary.js CHANGED
@@ -71,7 +71,7 @@ let CDXGEN_PLUGINS_DIR = process.env.CDXGEN_PLUGINS_DIR;
71
71
  if (
72
72
  !CDXGEN_PLUGINS_DIR &&
73
73
  existsSync(join(dirName, "plugins")) &&
74
- existsSync(join(dirName, "plugins", "goversion"))
74
+ existsSync(join(dirName, "plugins", "trivy"))
75
75
  ) {
76
76
  CDXGEN_PLUGINS_DIR = join(dirName, "plugins");
77
77
  }
@@ -94,7 +94,7 @@ if (
94
94
  "@cyclonedx",
95
95
  `cdxgen-plugins-bin${pluginsBinSuffix}`,
96
96
  "plugins",
97
- "goversion",
97
+ "trivy",
98
98
  ),
99
99
  )
100
100
  ) {
@@ -245,6 +245,8 @@ const OS_DISTRO_ALIAS = {
245
245
  "ubuntu-20.10": "groovy",
246
246
  "ubuntu-22.04": "jammy",
247
247
  "ubuntu-23.04": "lunar",
248
+ "ubuntu-23.10": "mantic",
249
+ "ubuntu-24.04": "noble",
248
250
  "debian-14": "forky",
249
251
  "debian-14.5": "forky",
250
252
  "debian-13": "trixie",
@@ -1946,5 +1946,37 @@
1946
1946
  "sm2sign_with_": {
1947
1947
  "oid": "1.2.156.10197.1.501",
1948
1948
  "description": "Chinese Cryptography Standardization Technology Committee (CCSTC)"
1949
+ },
1950
+ "PBKDF2": {
1951
+ "oid": "1.2.840.113549.1.5.12",
1952
+ "description": "PBKDF2 key derivation algorithm"
1953
+ },
1954
+ "pbeWithMD2AndDES-CBC": {
1955
+ "oid": "1.2.840.113549.1.5.1",
1956
+ "description": "Password Based Encryption Algorithm"
1957
+ },
1958
+ "pbeWithMD5AndDES-CBC": {
1959
+ "oid": "1.2.840.113549.1.5.3",
1960
+ "description": "Password Based Encryption Algorithm"
1961
+ },
1962
+ "pbeWithMD2AndRC2-CBC": {
1963
+ "oid": "1.2.840.113549.1.5.4",
1964
+ "description": "Password Based Encryption Algorithm. Uses RC2 in Cipher Block Chaining Mode (RC2-CBC)"
1965
+ },
1966
+ "pbeWithMD5AndRC2-CBC": {
1967
+ "oid": "1.2.840.113549.1.5.6",
1968
+ "description": "Password Based Encryption Algorithm. Uses RC2 in Cipher Block Chaining Mode (RC2-CBC)"
1969
+ },
1970
+ "pbeWithMD5AndXOR": {
1971
+ "oid": "1.2.840.113549.1.5.9",
1972
+ "description": "Password Based Encryption Algorithm. Uses XOR. Uses MD5 to hash a password & salt to get Key and IV."
1973
+ },
1974
+ "pbeWithSHA1AndDES-CBC": {
1975
+ "oid": "1.2.840.113549.1.5.10",
1976
+ "description": "Password Based Encryption Algorithm. Uses Data Encryption Standard in Cipher Block Chaining Mode (DES-CBC)"
1977
+ },
1978
+ "pbeWithSHA1AndRC2-CBC": {
1979
+ "oid": "1.2.840.113549.1.5.11",
1980
+ "description": "Password Based Encryption Algorithm. Uses RC2 in Cipher Block Chaining Mode (RC2-CBC)."
1949
1981
  }
1950
1982
  }
@@ -174,7 +174,8 @@
174
174
  "GNU Lesser General Public License",
175
175
  "GNU Lesser General Public License Version 2.1",
176
176
  "GNU Lesser General Public License Version 2.1, February 1999",
177
- "GNU Library or Lesser General Public License (LGPL) V2.1"
177
+ "GNU Library or Lesser General Public License (LGPL) V2.1",
178
+ "GNU Library or Lesser General Public License (LGPL)"
178
179
  ]
179
180
  },
180
181
  {
@@ -192,6 +193,7 @@
192
193
  "LGPL v3.0",
193
194
  "LGPL-3.0",
194
195
  "LGPL3.0",
196
+ "LGPL 3",
195
197
  "GNU Lesser General Public License (LGPL), version 3",
196
198
  "GNU Lesser General Public License (LGPL), version 3.0",
197
199
  "GNU Lesser General Public License v3.0",
@@ -203,9 +205,15 @@
203
205
  "names": [
204
206
  "GNU Lesser General Public License (LGPL), version 3 or later",
205
207
  "GNU Lesser General Public License (LGPL), version 3.0 or later",
206
- "GNU Lesser General Public License v3.0 or later"
208
+ "GNU Lesser General Public License v3.0 or later",
209
+ "GNU Lesser General Public License v3 or later (LGPLv3+)",
210
+ "LGPLv3+"
207
211
  ]
208
212
  },
213
+ {
214
+ "exp": "GPL-1.0-only",
215
+ "names": ["GNU General Public License (GPL)"]
216
+ },
209
217
  {
210
218
  "exp": "GPL-2.0-only",
211
219
  "names": [
@@ -217,7 +225,8 @@
217
225
  "GNU General Public License v2.0",
218
226
  "GNU General Public License Version 2",
219
227
  "GNU General Public License, version 2",
220
- "GNU General Public License as published by the Free Software Foundation; version 2."
228
+ "GNU General Public License as published by the Free Software Foundation; version 2.",
229
+ "GNU General Public License v2 (GPLv2)"
221
230
  ]
222
231
  },
223
232
  {
@@ -251,7 +260,8 @@
251
260
  "GNU General Public License v3.0",
252
261
  "GNU General Public License as published by the Free Software Foundation, version 3.",
253
262
  "GPL-3",
254
- "GPL-3.0"
263
+ "GPL-3.0",
264
+ "GNU GPL 3"
255
265
  ]
256
266
  },
257
267
  {
@@ -0,0 +1,3 @@
1
+ Content copied from https://github.com/CycloneDX/official-3rd-party-standards available under CC0-1.0
2
+
3
+ Individual templates use a range of licenses. Refer to the `metadata.licenses` attribute.