@cyclonedx/cdxgen 10.5.2 → 10.6.2

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
@@ -5,17 +5,23 @@
5
5
  [![GitHub License][badge-github-license]][github-license]
6
6
  [![GitHub Contributors][badge-github-contributors]][github-contributors]
7
7
  [![SWH][badge-swh]][swh-cdxgen]
8
+ [![Libraries.io dependency status][badge-libraries]][librariesio]
9
+
8
10
 
9
11
  # CycloneDX Generator (cdxgen)
10
12
 
11
13
  ![cdxgen logo](./docs/_media/cdxgen.png)
12
14
 
13
- cdxgen is a CLI tool, library, [REPL](./ADVANCED.md), and server to create a valid and compliant [CycloneDX][cyclonedx-homepage] Bill of Materials (BOM) containing an aggregate of all project dependencies for C/C++, Node.js, PHP, Python, Ruby, Rust, Java, .Net, Dart, Haskell, Elixir, and Go projects 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.4 - 1.6.
15
+ cdxgen is a CLI tool, library, [REPL](./ADVANCED.md), and server to create a valid and compliant [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.4 - 1.6.
14
16
 
15
- When used with plugins:
17
+ Supported BOM formats:
16
18
 
17
- - cdxgen could generate an OBOM for Linux docker images and even VMs running Linux or Windows operating systems
18
- - cdxgen also includes an evinse tool to generate component evidence, CBOM, and SaaSBOM for some languages
19
+ - Software (SBOM) - For many languages and container images.
20
+ - Cryptography (CBOM) - For Java and Python projects.
21
+ - Operations (OBOM) - For Linux container images and VMs running Linux or Windows operating systems.
22
+ - Software-as-a-Service (SaaSBOM) - For Java, Python, JavaScript, TypeScript, and PHP projects.
23
+ - Attestations (CDXA) - Generate SBOM with templates for multiple standards. Sign the BOM document at a granular level to improve authenticity.
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.
19
25
 
20
26
  ## Why cdxgen?
21
27
 
@@ -23,11 +29,19 @@ Most SBOM tools are like simple barcode scanners. For easy applications, they ca
23
29
 
24
30
  <img src="./docs/_media/why-cdxgen.jpg" alt="why cdxgen" width="256">
25
31
 
32
+ Our philosophy:
33
+
34
+ - Explainability: Don't list, but explain with evidence.
35
+ - Precision: Try using multiple techniques to improve precision, even if it takes extra time.
36
+ - Personas: Cater to the needs of a range of personas such as security researchers, compliance auditors, developers, and SOC.
37
+ - Lifecycle: Support BOM generation for various product lifecycles.
38
+
26
39
  ## Documentation
27
40
 
28
- Please visit our [documentation site][docs-homepage] for detailed usage, tutorials and support documentation.
41
+ Please visit our [documentation site][docs-homepage] for detailed usage, tutorials, and support documentation.
29
42
 
30
43
  Sections include:
44
+
31
45
  - [Getting Started][docs-homepage]
32
46
  - [CLI Usage][docs-cli]
33
47
  - [Server Usage][docs-server]
@@ -37,7 +51,6 @@ Sections include:
37
51
  - [Permissions][docs-permissions]
38
52
  - [Support (Enterprise & Community)][docs-support]
39
53
 
40
-
41
54
  ### Automatic usage detection
42
55
 
43
56
  For node.js projects, lock files are parsed initially, so the SBOM would include all dependencies, including dev ones. An AST parser powered by babel-parser is then used to detect packages that are imported and used by non-test code. Such imported packages would automatically set their scope property to `required` in the resulting SBOM. You can turn off this analysis by passing the argument `--no-babel`. Scope property would then be set based on the `dev` attribute in the lock file.
@@ -472,8 +485,6 @@ Use the [CycloneDX CLI][cyclonedx-cli-github] tool for advanced use cases such a
472
485
 
473
486
  Permission to modify and redistribute is granted under the terms of the Apache 2.0 license. See the [LICENSE][github-license] file for the full license.
474
487
 
475
-
476
-
477
488
  ## Integration as library
478
489
 
479
490
  cdxgen is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) and could be imported and used with both deno and Node.js >= 20
@@ -498,30 +509,33 @@ const dbody = await submitBom(args, bomNSData.bomJson);
498
509
 
499
510
  Please check out our [contribute to CycloneDX/cdxgen documentation][github-contribute] if you are interested in helping.
500
511
 
501
-
502
512
  Before raising a PR, please run the following commands.
503
513
 
504
514
  ```bash
515
+ corepack enable
516
+ corepack pnpm install
505
517
  # Generate types using jsdoc syntax
506
- npm run gen-types
518
+ corepack pnpm run gen-types
507
519
  # Run biomejs formatter and linter with auto fix
508
- npm run lint
520
+ corepack pnpm run lint
509
521
  # Run jest tests
510
- npm test
522
+ corepack pnpm test
511
523
  ```
512
524
 
513
-
514
525
  <!-- LINK LABELS -->
515
526
  <!-- Badges -->
527
+
516
528
  [badge-github-contributors]: https://img.shields.io/github/contributors/cyclonedx/cdxgen
517
529
  [badge-github-license]: https://img.shields.io/github/license/cyclonedx/cdxgen
518
530
  [badge-github-releases]: https://img.shields.io/github/v/release/cyclonedx/cdxgen
519
531
  [badge-jsr]: https://img.shields.io/jsr/v/%40cyclonedx/cdxgen
532
+ [badge-libraries]: https://img.shields.io/librariesio/github/cyclonedx/cdxgen
520
533
  [badge-npm]: https://img.shields.io/npm/v/%40cyclonedx%2Fcdxgen
521
534
  [badge-npm-downloads]: https://img.shields.io/npm/dy/%40cyclonedx%2Fcdxgen
522
535
  [badge-swh]: https://archive.softwareheritage.org/badge/origin/https://github.com/CycloneDX/cdxgen/
523
536
 
524
537
  <!-- cdxgen github project -->
538
+
525
539
  [github-contribute]: https://github.com/CycloneDX/cdxgen/contribute
526
540
  [github-contributors]: https://github.com/CycloneDX/cdxgen/graphs/contributors
527
541
  [github-issues]: https://github.com/CycloneDX/cdxgen/issues
@@ -529,6 +543,7 @@ npm test
529
543
  [github-releases]: https://github.com/CycloneDX/cdxgen/releases
530
544
 
531
545
  <!-- cdxgen documentation site -->
546
+
532
547
  [docs-homepage]: https://cyclonedx.github.io/cdxgen
533
548
  [docs-advanced-usage]: https://cyclonedx.github.io/cdxgen/#/ADVANCED
534
549
  [docs-cli]: https://cyclonedx.github.io/cdxgen/#/CLI
@@ -539,6 +554,7 @@ npm test
539
554
  [docs-support]: https://cyclonedx.github.io/cdxgen/#/PROJECT_TYPES
540
555
 
541
556
  <!-- web links-->
557
+
542
558
  [appthreat-homepage]: https://www.appthreat.com
543
559
  [cyclonedx-homepage]: https://cyclonedx.org
544
560
  [cyclonedx-cli-github]: https://github.com/CycloneDX/cyclonedx-cli
@@ -549,7 +565,8 @@ npm test
549
565
  [jsr-cdxgen]: https://jsr.io/@cyclonedx/cdxgen
550
566
  [jwt-homepage]: https://jwt.io
551
567
  [jwt-libraries]: https://jwt.io/libraries
568
+ [librariesio]: https://libraries.io/npm/@cyclonedx%2Fcdxgen
552
569
  [npmjs-cdxgen]: https://www.npmjs.com/package/@cyclonedx/cdxgen
553
570
  [podman-github-rootless]: https://github.com/containers/podman/blob/master/docs/tutorials/rootless_tutorial.md
554
571
  [podman-github-remote]: https://github.com/containers/podman/blob/master/docs/tutorials/mac_win_client.md
555
- [swh-cdxgen]: https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/CycloneDX/cdxgen
572
+ [swh-cdxgen]: https://archive.softwareheritage.org/browse/origin/?origin_url=https://github.com/CycloneDX/cdxgen
package/analyzer.js CHANGED
@@ -292,7 +292,7 @@ export const findJSImportsExports = async (src, deep) => {
292
292
  const errFiles = [];
293
293
  try {
294
294
  const promiseMap = await getAllSrcJSAndTSFiles(src, deep);
295
- const srcFiles = promiseMap.flatMap((d) => d);
295
+ const srcFiles = promiseMap.flat();
296
296
  for (const file of srcFiles) {
297
297
  try {
298
298
  parseFileASTTree(src, file, allImports, allExports);
package/bin/cdxgen.js CHANGED
@@ -16,6 +16,7 @@ import {
16
16
  printOccurrences,
17
17
  printReachables,
18
18
  printServices,
19
+ printSponsorBanner,
19
20
  printTable,
20
21
  } from "../display.js";
21
22
  import { createBom, submitBom } from "../index.js";
@@ -258,6 +259,12 @@ const args = yargs(hideBin(process.argv))
258
259
  "ssaf-DRAFT-2023-11",
259
260
  ],
260
261
  })
262
+ .option("no-banner", {
263
+ type: "boolean",
264
+ default: false,
265
+ description:
266
+ "Do not show the donation banner. Set this attribute if you are an active sponsor for OWASP CycloneDX.",
267
+ })
261
268
  .completion("completion", "Generate bash/zsh completion")
262
269
  .array("filter")
263
270
  .array("only")
@@ -446,6 +453,8 @@ const checkPermissions = (filePath) => {
446
453
  * Method to start the bom creation process
447
454
  */
448
455
  (async () => {
456
+ // Display the sponsor banner
457
+ printSponsorBanner(options);
449
458
  // Start SBOM server
450
459
  if (options.server) {
451
460
  const serverModule = await import("../server.js");
@@ -675,8 +684,7 @@ const checkPermissions = (filePath) => {
675
684
  // biome-ignore lint/suspicious/noDoubleEquals: yargs passes true for empty values
676
685
  if (options.serverUrl && options.serverUrl != true && options.apiKey) {
677
686
  try {
678
- const dbody = await submitBom(options, bomNSData.bomJson);
679
- console.log("Response from server", dbody);
687
+ await submitBom(options, bomNSData.bomJson);
680
688
  } catch (err) {
681
689
  console.log(err);
682
690
  }
package/display.js CHANGED
@@ -368,3 +368,25 @@ export function printVulnerabilities(vulnerabilities) {
368
368
  }
369
369
  console.log(`${vulnerabilities.length} vulnerabilities found.`);
370
370
  }
371
+
372
+ export function printSponsorBanner(options) {
373
+ if (
374
+ process?.env?.CI &&
375
+ !options.noBanner &&
376
+ !process.env?.GITHUB_REPOSITORY?.toLowerCase().startsWith("cyclonedx")
377
+ ) {
378
+ const config = {
379
+ header: {
380
+ alignment: "center",
381
+ content: "\u00A4 Donate to the OWASP Foundation",
382
+ },
383
+ };
384
+ let message =
385
+ "OWASP foundation relies on donations to fund our projects.\nDonation link: https://owasp.org/donate/?reponame=www-project-cyclonedx&title=OWASP+CycloneDX";
386
+ if (options.serverUrl && options.apiKey) {
387
+ message = `${message}\nDependency Track: https://owasp.org/donate/?reponame=www-project-dependency-track&title=OWASP+Dependency-Track`;
388
+ }
389
+ const data = [[message]];
390
+ console.log(table(data, config));
391
+ }
392
+ }