@cyclonedx/cdxgen 11.4.4 → 11.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/README.md +68 -64
  2. package/bin/cdxgen.js +31 -9
  3. package/lib/cli/index.js +336 -99
  4. package/lib/evinser/evinser.js +3 -0
  5. package/lib/evinser/{evinser.test.js → evinser.poku.js} +51 -33
  6. package/lib/evinser/{swiftsem.test.js → swiftsem.poku.js} +46 -45
  7. package/lib/helpers/cbomutils.poku.js +8 -0
  8. package/lib/helpers/{display.test.js → display.poku.js} +2 -2
  9. package/lib/helpers/dotnetutils.js +132 -0
  10. package/lib/helpers/dotnetutils.poku.js +429 -0
  11. package/lib/helpers/envcontext.js +20 -18
  12. package/lib/helpers/{envcontext.test.js → envcontext.poku.js} +24 -24
  13. package/lib/helpers/logger.js +0 -2
  14. package/lib/helpers/{protobom.test.js → protobom.poku.js} +12 -10
  15. package/lib/helpers/utils.js +853 -88
  16. package/lib/helpers/{utils.test.js → utils.poku.js} +1999 -1349
  17. package/lib/helpers/validator.js +10 -0
  18. package/lib/managers/binary.js +89 -11
  19. package/lib/managers/docker.js +47 -37
  20. package/lib/managers/{docker.test.js → docker.poku.js} +70 -59
  21. package/lib/parsers/iri.js +504 -0
  22. package/lib/parsers/iri.poku.js +406 -0
  23. package/lib/server/server.js +130 -7
  24. package/lib/server/server.poku.js +387 -0
  25. package/lib/stages/postgen/{annotator.test.js → annotator.poku.js} +11 -14
  26. package/lib/stages/postgen/{postgen.test.js → postgen.poku.js} +15 -15
  27. package/package.json +34 -16
  28. package/types/cli/index.d.ts +295 -0
  29. package/types/cli/index.d.ts.map +1 -0
  30. package/types/evinser/scalasem.d.ts +6 -0
  31. package/types/evinser/scalasem.d.ts.map +1 -0
  32. package/types/evinser/swiftsem.d.ts +103 -0
  33. package/types/evinser/swiftsem.d.ts.map +1 -0
  34. package/types/helpers/analyzer.d.ts +5 -0
  35. package/types/helpers/analyzer.d.ts.map +1 -0
  36. package/types/helpers/cbomutils.d.ts +15 -0
  37. package/types/helpers/cbomutils.d.ts.map +1 -0
  38. package/types/helpers/db.d.ts +19 -0
  39. package/types/helpers/db.d.ts.map +1 -0
  40. package/types/helpers/display.d.ts +12 -0
  41. package/types/helpers/display.d.ts.map +1 -0
  42. package/types/helpers/dotnetutils.d.ts +45 -0
  43. package/types/helpers/dotnetutils.d.ts.map +1 -0
  44. package/types/helpers/envcontext.d.ts +264 -0
  45. package/types/helpers/envcontext.d.ts.map +1 -0
  46. package/types/helpers/logger.d.ts +12 -0
  47. package/types/helpers/logger.d.ts.map +1 -0
  48. package/types/helpers/protobom.d.ts +3 -0
  49. package/types/helpers/protobom.d.ts.map +1 -0
  50. package/types/helpers/utils.d.ts +1556 -0
  51. package/types/helpers/utils.d.ts.map +1 -0
  52. package/types/helpers/validator.d.ts +11 -0
  53. package/types/helpers/validator.d.ts.map +1 -0
  54. package/types/lib/cli/index.d.ts +8 -1
  55. package/types/lib/cli/index.d.ts.map +1 -1
  56. package/types/lib/evinser/evinser.d.ts +2 -1
  57. package/types/lib/helpers/dotnetutils.d.ts +45 -0
  58. package/types/lib/helpers/dotnetutils.d.ts.map +1 -0
  59. package/types/lib/helpers/envcontext.d.ts +3 -8
  60. package/types/lib/helpers/envcontext.d.ts.map +1 -1
  61. package/types/lib/helpers/logger.d.ts +0 -1
  62. package/types/lib/helpers/logger.d.ts.map +1 -1
  63. package/types/lib/helpers/utils.d.ts +68 -66
  64. package/types/lib/helpers/utils.d.ts.map +1 -1
  65. package/types/lib/helpers/validator.d.ts.map +1 -1
  66. package/types/lib/managers/binary.d.ts.map +1 -1
  67. package/types/lib/managers/docker.d.ts.map +1 -1
  68. package/types/lib/server/server.d.ts +22 -2
  69. package/types/lib/server/server.d.ts.map +1 -1
  70. package/types/managers/binary.d.ts +37 -0
  71. package/types/managers/binary.d.ts.map +1 -0
  72. package/types/managers/docker.d.ts +56 -0
  73. package/types/managers/docker.d.ts.map +1 -0
  74. package/types/managers/oci.d.ts +2 -0
  75. package/types/managers/oci.d.ts.map +1 -0
  76. package/types/managers/piptree.d.ts +2 -0
  77. package/types/managers/piptree.d.ts.map +1 -0
  78. package/types/parsers/iri.d.ts +72 -0
  79. package/types/parsers/iri.d.ts.map +1 -0
  80. package/types/server/server.d.ts +34 -0
  81. package/types/server/server.d.ts.map +1 -0
  82. package/types/stages/postgen/annotator.d.ts +27 -0
  83. package/types/stages/postgen/annotator.d.ts.map +1 -0
  84. package/types/stages/postgen/postgen.d.ts +51 -0
  85. package/types/stages/postgen/postgen.d.ts.map +1 -0
  86. package/types/stages/pregen/pregen.d.ts +59 -0
  87. package/types/stages/pregen/pregen.d.ts.map +1 -0
  88. package/jest.config.js +0 -7
  89. package/lib/helpers/cbomutils.test.js +0 -8
  90. package/lib/server/server.test.js +0 -126
package/README.md CHANGED
@@ -117,73 +117,76 @@ Commands:
117
117
  cdxgen completion Generate bash/zsh completion
118
118
 
119
119
  Options:
120
- -o, --output Output file. Default bom.json [default: "bom.json"]
121
- -t, --type Project type. Please refer to https://cyclonedx.github.io/cdxgen/#/PROJECT_TYPES for supp
122
- orted languages/platforms. [array]
123
- --exclude-type Project types to exclude. Please refer to https://cyclonedx.github.io/cdxgen/#/PROJECT_TY
124
- PES for supported languages/platforms.
125
- -r, --recurse Recurse mode suitable for mono-repos. Defaults to true. Pass --no-recurse to disable.
120
+ -o, --output Output file. Default bom.json [default: "bom.json"]
121
+ -t, --type Project type. Please refer to https://cyclonedx.github.io/cdxgen/#/PROJECT_TYPES for s
122
+ upported languages/platforms. [array]
123
+ --exclude-type Project types to exclude. Please refer to https://cyclonedx.github.io/cdxgen/#/PROJECT
124
+ _TYPES for supported languages/platforms.
125
+ -r, --recurse Recurse mode suitable for mono-repos. Defaults to true. Pass --no-recurse to disable.
126
126
  [boolean] [default: true]
127
- -p, --print Print the SBOM as a table with tree. [boolean]
128
- -c, --resolve-class Resolve class names for packages. jars only for now. [boolean]
129
- --deep Perform deep searches for components. Useful while scanning C/C++ apps, live OS and oci i
130
- mages. [boolean]
131
- --server-url Dependency track url. Eg: https://deptrack.cyclonedx.io
132
- --skip-dt-tls-check Skip TLS certificate check when calling Dependency-Track. [boolean] [default: false]
133
- --api-key Dependency track api key
134
- --project-group Dependency track project group
135
- --project-name Dependency track project name. Default use the directory name
136
- --project-version Dependency track project version [string] [default: ""]
137
- --project-id Dependency track project id. Either provide the id or the project name and version togeth
138
- er [string]
139
- --parent-project-id Dependency track parent project id [string]
140
- --required-only Include only the packages with required scope on the SBOM. Would set compositions.aggrega
141
- te to incomplete unless --no-auto-compositions is passed. [boolean]
142
- --fail-on-error Fail if any dependency extractor fails. [boolean]
143
- --no-babel Do not use babel to perform usage analysis for JavaScript/TypeScript projects. [boolean]
144
- --generate-key-and-sign Generate an RSA public/private key pair and then sign the generated SBOM using JSON Web S
145
- ignatures. [boolean]
146
- --server Run cdxgen as a server [boolean]
147
- --server-host Listen address [default: "127.0.0.1"]
148
- --server-port Listen port [default: "9090"]
149
- --install-deps Install dependencies automatically for some projects. Defaults to true but disabled for c
150
- ontainers and oci scans. Use --no-install-deps to disable this feature.
127
+ -p, --print Print the SBOM as a table with tree. [boolean]
128
+ -c, --resolve-class Resolve class names for packages. jars only for now. [boolean]
129
+ --deep Perform deep searches for components. Useful while scanning C/C++ apps, live OS and oc
130
+ i images. [boolean]
131
+ --server-url Dependency track url. Eg: https://deptrack.cyclonedx.io
132
+ --skip-dt-tls-check Skip TLS certificate check when calling Dependency-Track. [boolean] [default: false]
133
+ --api-key Dependency track api key
134
+ --project-group Dependency track project group
135
+ --project-name Dependency track project name. Default use the directory name
136
+ --project-version Dependency track project version [string] [default: ""]
137
+ --project-id Dependency track project id. Either provide the id or the project name and version tog
138
+ ether [string]
139
+ --parent-project-id Dependency track parent project id [string]
140
+ --required-only Include only the packages with required scope on the SBOM. Would set compositions.aggr
141
+ egate to incomplete unless --no-auto-compositions is passed. [boolean]
142
+ --fail-on-error Fail if any dependency extractor fails. [boolean]
143
+ --no-babel Do not use babel to perform usage analysis for JavaScript/TypeScript projects.
144
+ [boolean]
145
+ --generate-key-and-sign Generate an RSA public/private key pair and then sign the generated SBOM using JSON We
146
+ b Signatures. [boolean]
147
+ --server Run cdxgen as a server [boolean]
148
+ --server-host Listen address [default: "127.0.0.1"]
149
+ --server-port Listen port [default: "9090"]
150
+ --install-deps Install dependencies automatically for some projects. Defaults to true but disabled fo
151
+ r containers and oci scans. Use --no-install-deps to disable this feature.
151
152
  [boolean] [default: true]
152
- --validate Validate the generated SBOM using json schema. Defaults to true. Pass --no-validate to di
153
- sable. [boolean] [default: true]
154
- --evidence Generate SBOM with evidence for supported languages. [boolean] [default: false]
155
- --spec-version CycloneDX Specification version to use. Defaults to 1.6
156
- [number] [choices: 1.4, 1.5, 1.6] [default: 1.6]
157
- --filter Filter components containing this word in purl or component.properties.value. Multiple va
158
- lues allowed. [array]
159
- --only Include components only containing this word in purl. Useful to generate BOM with first p
160
- arty components alone. Multiple values allowed. [array]
161
- --author The person(s) who created the BOM. Set this value if you're intending the modify the BOM
162
- and claim authorship. [array] [default: "OWASP Foundation"]
163
- --profile BOM profile to use for generation. Default generic.
153
+ --validate Validate the generated SBOM using json schema. Defaults to true. Pass --no-validate to
154
+ disable. [boolean] [default: true]
155
+ --evidence Generate SBOM with evidence for supported languages. [boolean] [default: false]
156
+ --spec-version CycloneDX Specification version to use. Defaults to 1.6
157
+ [number] [choices: 1.4, 1.5, 1.6, 1.7] [default: 1.6]
158
+ --filter Filter components containing this word in purl or component.properties.value. Multiple
159
+ values allowed. [array]
160
+ --only Include components only containing this word in purl. Useful to generate BOM with firs
161
+ t party components alone. Multiple values allowed. [array]
162
+ --author The person(s) who created the BOM. Set this value if you're intending the modify the B
163
+ OM and claim authorship. [array] [default: "OWASP Foundation"]
164
+ --profile BOM profile to use for generation. Default generic.
164
165
  [choices: "appsec", "research", "operational", "threat-modeling", "license-compliance", "generic", "machine-learning",
165
166
  "ml", "deep-learning", "ml-deep", "ml-tiny"] [default: "generic"]
166
- --exclude Additional glob pattern(s) to ignore [array]
167
- --export-proto Serialize and export BOM as protobuf binary. [boolean] [default: false]
168
- --proto-bin-file Path for the serialized protobuf binary. [default: "bom.cdx"]
169
- --include-formulation Generate formulation section with git metadata and build tools. Defaults to false.
167
+ --include-regex glob pattern to include. This overrides the default pattern used during auto-detection
168
+ . [string]
169
+ --exclude, --exclude-regex Additional glob pattern(s) to ignore [array]
170
+ --export-proto Serialize and export BOM as protobuf binary. [boolean] [default: false]
171
+ --proto-bin-file Path for the serialized protobuf binary. [default: "bom.cdx"]
172
+ --include-formulation Generate formulation section with git metadata and build tools. Defaults to false.
170
173
  [boolean] [default: false]
171
- --include-crypto Include crypto libraries as components. [boolean] [default: false]
172
- --standard The list of standards which may consist of regulations, industry or organizational-specif
173
- ic standards, maturity models, best practices, or any other requirements which can be eva
174
- luated against or attested to.
174
+ --include-crypto Include crypto libraries as components. [boolean] [default: false]
175
+ --standard The list of standards which may consist of regulations, industry or organizational-spe
176
+ cific standards, maturity models, best practices, or any other requirements which can
177
+ be evaluated against or attested to.
175
178
  [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
176
179
  s-1.0.0", "ssaf-DRAFT-2023-11"]
177
- --json-pretty Pretty-print the generated BOM json. [boolean] [default: false]
178
- --min-confidence Minimum confidence needed for the identity of a component from 0 - 1, where 1 is 100% con
179
- fidence. [number] [default: 0]
180
- --technique Analysis technique to use
180
+ --json-pretty Pretty-print the generated BOM json. [boolean] [default: false]
181
+ --min-confidence Minimum confidence needed for the identity of a component from 0 - 1, where 1 is 100%
182
+ confidence. [number] [default: 0]
183
+ --technique Analysis technique to use
181
184
  [array] [choices: "auto", "source-code-analysis", "binary-analysis", "manifest-analysis", "hash-comparison", "instrume
182
185
  ntation", "filename"]
183
- --auto-compositions Automatically set compositions when the BOM was filtered. Defaults to true
186
+ --auto-compositions Automatically set compositions when the BOM was filtered. Defaults to true
184
187
  [boolean] [default: true]
185
- -h, --help Show help [boolean]
186
- -v, --version Show version number [boolean]
188
+ -h, --help Show help [boolean]
189
+ -v, --version Show version number [boolean]
187
190
  ```
188
191
 
189
192
  All boolean arguments accept `--no` prefix to toggle the behavior.
@@ -214,14 +217,11 @@ To recursively generate a single BOM for all languages pass `-r` argument.
214
217
  cdxgen -r -o bom.json
215
218
  ```
216
219
 
217
- The default specification used by cdxgen is 1.5. To generate BOM for a different specification version, such as 1.6 or 1.4, pass the version number using the `--spec-version` argument.
220
+ The default specification used by cdxgen is 1.6. To generate BOM for a different specification version, such as 1.5 or 1.4, pass the version number using the `--spec-version` argument.
218
221
 
219
222
  ```shell
220
- # 1.6 is unsupported by most tools
221
- cdxgen -r -o bom.json --spec-version 1.6
222
-
223
- # 1.4 is supported by most tools
224
- cdxgen -r -o bom.json --spec-version 1.4
223
+ # 1.5 is supported by most tools
224
+ cdxgen -r -o bom.json --spec-version 1.5
225
225
  ```
226
226
 
227
227
  To generate SBOM for C or Python, ensure Java >= 21 is installed.
@@ -543,7 +543,11 @@ cdxgen --help
543
543
 
544
544
  ## Sponsors
545
545
 
546
- <img src="./docs/_media/LevoLogo-LightBg.jpg" width="200" height="auto">
546
+ <div style="display: flex; align-items: center; gap: 20px;">
547
+ <img src="./docs/_media/LevoLogo-LightBg.jpg" width="200" height="auto">
548
+ <img src="./docs/_media/GithubLogo-LightBg.png" width="170" height="auto">
549
+ <img src="./docs/_media/MicrosoftLogo.png" width="180" height="auto">
550
+ </div>
547
551
 
548
552
  <!-- LINK LABELS -->
549
553
  <!-- Badges -->
package/bin/cdxgen.js CHANGED
@@ -29,6 +29,7 @@ import {
29
29
  commandsExecuted,
30
30
  DEBUG_MODE,
31
31
  dirNameStr,
32
+ getRuntimeInformation,
32
33
  getTmpDir,
33
34
  isMac,
34
35
  isSecureMode,
@@ -66,7 +67,9 @@ for (const configPattern of configPaths) {
66
67
  }
67
68
  }
68
69
 
69
- const args = yargs(hideBin(process.argv))
70
+ const _yargs = yargs(hideBin(process.argv));
71
+
72
+ const args = _yargs
70
73
  .env("CDXGEN")
71
74
  .parserConfiguration({
72
75
  "greedy-arrays": false,
@@ -261,8 +264,15 @@ const args = yargs(hideBin(process.argv))
261
264
  hidden: true,
262
265
  choices: ["pre-build", "build", "post-build"],
263
266
  })
267
+ .option("include-regex", {
268
+ description:
269
+ "glob pattern to include. This overrides the default pattern used during auto-detection.",
270
+ type: "string",
271
+ })
264
272
  .option("exclude", {
273
+ alias: "exclude-regex",
265
274
  description: "Additional glob pattern(s) to ignore",
275
+ type: "array",
266
276
  })
267
277
  .option("export-proto", {
268
278
  type: "boolean",
@@ -346,7 +356,6 @@ const args = yargs(hideBin(process.argv))
346
356
  .array("filter")
347
357
  .array("only")
348
358
  .array("author")
349
- .array("exclude")
350
359
  .array("standard")
351
360
  .array("feature-flags")
352
361
  .array("technique")
@@ -375,25 +384,36 @@ const args = yargs(hideBin(process.argv))
375
384
  .epilogue("for documentation, visit https://cyclonedx.github.io/cdxgen")
376
385
  .config(config)
377
386
  .scriptName("cdxgen")
378
- .version()
387
+ .version(version())
379
388
  .alias("v", "version")
380
- .help("h")
381
- .alias("h", "help")
389
+ .help(false)
390
+ .option("help", {
391
+ alias: "h",
392
+ type: "boolean",
393
+ description: "Show help",
394
+ })
382
395
  .wrap(Math.min(120, yargs().terminalWidth())).argv;
383
396
 
384
397
  if (process.env?.CDXGEN_NODE_OPTIONS) {
385
398
  process.env.NODE_OPTIONS = `${process.env.NODE_OPTIONS || ""} ${process.env.CDXGEN_NODE_OPTIONS}`;
386
399
  }
387
400
 
388
- if (args.version) {
401
+ if (args.help) {
402
+ console.log(`${version()}\n`);
403
+ _yargs.showHelp();
404
+ process.exit(0);
405
+ }
406
+
407
+ function version() {
389
408
  const packageJsonAsString = fs.readFileSync(
390
- join(dirName, "..", "package.json"),
409
+ join(dirName, "package.json"),
391
410
  "utf-8",
392
411
  );
393
412
  const packageJson = JSON.parse(packageJsonAsString);
394
413
 
395
- console.log(packageJson.version);
396
- process.exit(0);
414
+ const runtimeInfo = getRuntimeInformation();
415
+
416
+ return `\x1b[1mCycloneDX Generator ${packageJson.version}\x1b[0m\nRuntime: ${runtimeInfo.runtime}, Version: ${runtimeInfo.version}`;
397
417
  }
398
418
 
399
419
  if (process.env.GLOBAL_AGENT_HTTP_PROXY || process.env.HTTP_PROXY) {
@@ -447,6 +467,8 @@ const options = Object.assign({}, args, {
447
467
  isSecureMode && args.output === "bom.json"
448
468
  ? resolve(join(filePath, args.output))
449
469
  : args.output,
470
+ exclude: args.exclude || args.excludeRegex,
471
+ include: args.include || args.includeRegex,
450
472
  });
451
473
  // Should we create the output directory?
452
474
  const outputDirectory = dirname(options.output);