Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@cyclonedx/yarn-plugin-cyclonedx

CycloneDX35.2kApache-2.03.0.2

Create CycloneDX Software Bill of Materials (SBOM) from yarn projects.

CycloneDX, SBOM, BOM, inventory, bill-of-materials, software-bill-of-materials, component, dependency, package-url, PURL, spdx, node, yarn

readme

CycloneDX SBOM for yarn

shield_yarnpkg-version shield_npm-version shield_gh-workflow-test shield_coverage shield_ossf-best-practices shield_license
shield_website shield_slack shield_groups shield_twitter-follow


Create CycloneDX Software Bill of Materials (SBOM) from yarn projects.
This is probably the most accurate, complete SBOM generator for yarn-based projects.

Requirements

  • node >= 20.18.0
  • yarn >= 4.0.0 (berry)

However, there are older version of this software which support

  • Node v18 and later
  • Yarn v3 and later

Installation

Install the plugin into your yarn project via one of the following methods:

  • zero-install: No install needed, just call on demand via dlx-wrapper as described in section "usage".
  • cli-wrapper: As a development dependency of the current project:
    yarn add --dev @cyclonedx/yarn-plugin-cyclonedx
  • plugin: Install the latest version from GitHub release asset as a plugin for the current project:
    yarn plugin import https://github.com/CycloneDX/cyclonedx-node-yarn/releases/latest/download/yarn-plugin-cyclonedx.cjs

Usage

Usage depends on the installation method:

  • With zero-install via dlx-wrapper:
    yarn dlx -q @cyclonedx/yarn-plugin-cyclonedx --help
  • After cli-wrapper installation:
    yarn exec cyclonedx-yarn --help
  • After plugin installation:
    yarn cyclonedx --help

The help page:

Generates CycloneDX SBOM for current workspace.

━━━ Usage ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

$ yarn cyclonedx

━━━ Options ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  --production,--prod        Exclude development dependencies.
                             (default: true if the NODE_ENV environment variable is set to "production", otherwise false)
  --gather-license-texts     Search for license files in components and include them as license evidence.
                             This feature is experimental.
  --short-PURLs              Omit all qualifiers from PackageURLs.
                             This causes information loss in trade-off shorter PURLs, which might improve ingesting these strings.
  --sv,--spec-version #0     Which version of CycloneDX to use.
                             (choices: 1.2, 1.3, 1.4, 1.5, 1.6, default: 1.6)
  --output-reproducible      Whether to go the extra mile and make the output reproducible.
                             This might result in loss of time- and random-based values.
  --of,--output-format #0    Which output format to use.
                             (choices: JSON, XML, default: JSON)
  -o,--output-file #0        Path to the output file.
                             Set to "-" to write to STDOUT.
                             (default: write to STDOUT)
  --mc-type #0               Type of the main component.
                             (choices: application, library, firmware, default: application)
  -v,--verbose               Increase the verbosity of messages.
                             Use multiple times to increase the verbosity even more.

━━━ Details ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Recursively scan workspace dependencies and emits them as 
Software-Bill-of-Materials(SBOM) in CycloneDX format.

Internals

This yarn plugin utilizes the CycloneDX library to generate the actual data structures.

This tool does not expose any additional public API or classes - all code is intended to be internal and might change without any notice during version upgrades. However, the CLI is stable - you may call it programmatically like:

const { execFileSync } = require('node:child_process')
const { constants: { MAX_LENGTH: BUFFER_MAX_LENGTH } } = require('node:buffer')
const sbom = JSON.parse(execFileSync(process.execPath, [
    '.../path/to/this/package/bin/cyclonedx-yarn-cli.js',
    '--output-format', 'JSON',
    '--output-file', '-'
    // additional CLI args
  ], {stdio: ['ignore', 'pipe', 'ignore'], encoding: 'buffer', maxBuffer: BUFFER_MAX_LENGTH }))

Development & Contributing

Feel free to open issues, bugreports or pull requests.
See the CONTRIBUTING file for details.

License

Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.
See the LICENSE file for the full license.

For details and license posture of the assembly, see the LICENSE file in the respective release assets.

changelog

Changelog

All notable changes to this project will be documented in this file.

unreleased

3.0.2 - 2025-04-10

Maintenance release with provenance.

  • Build
    • Enable release provenance (#290 via #292)

3.0.1 - 2025-04-08

  • Added
    • CLI switch -o as shorthand for --output-file (#280 via #281)
    • CLI switch --of as shorthand for --outout-format (#280 via #281)
    • CLI switch --sv as shorthand for --spec-version (#280 via #281)
  • Fixed
    • License gathering correctly ignores symlinks and directories (#287 via #288)
  • Build
    • Use TypeScript v5.8.3 now, was v5.8.2 (via #282)

3.0.0 - 2025-03-26

  • BREAKING Changes
    • Dropped support for node<20.18.0 (#260 via #265)
    • Dropped support for yarn<4.0.0 (#272 via #271)
  • Dependencies
  • Build
    • Use TypeScript v5.8.2 now, was v5.7.3 (via #261)
    • Use @yarnpkg/builder v4.2.1 now, was v4.2.0 (via #262)

2.0.0 - 2025-01-27

  • BREAKING Changes
    • CLI option --spec-version defaults to 1.6, was 1.5 (#222 via #251)
    • Emit $.metadata.tools as components (#221 via #254)
      This affects only CycloneDX spec-version 1.5 and later.
    • Emitted .purl values might be partially url-encoded (via #254)
      This is caused by changes on underlying 3rd-party dependency packageurl-js.
    • Create dir for output file if not exists (#253 via #255)
      This is only a breaking change if you relied on non-existent result paths to cause errors.
  • Dependencies
    • Upgraded runtime-dependency @cyclonedx/cyclonedx-library@7.1.0, was `@6.13.1` (via #254)

1.1.0 - 2025-01-14

  • Added
    • Capability to gather license text evidences (#33 via #193)
      This feature can be controlled via CLI switch --gather-license-texts.
      This feature is experimental. This feature is disabled per default.
  • Dependencies
    • Upgraded runtime-dependency @cyclonedx/cyclonedx-library@6.13.1, was `@6.11.0` (via #206, #237)
      This was done to incorporate non-breaking upstream changes and fixes.
    • Upgraded runtime-dependency `normalize-package-data@6.0.2, was@6.0.1` (via #141)
      This was done to incorporate non-breaking upstream changes and fixes.
    • Removed unused runtime dependency packageurl-js (via #220)
  • Build

[#]:

1.0.2 - 2024-07-15

  • Dependencies
    • Upgraded runtime-dependency @cyclonedx/cyclonedx-library@6.11.0, was `@6.10.0` (via #151, #157)
      This was done to incorporate non-breaking upstream changes and fixes.
  • Build
    • Use TypeScript v5.5.3 now, was v5.5.2 (via #149)

1.0.1 - 2024-06-27

  • Fixed
    • Writing output-files on Windows systems (#145 via #146)

1.0.0 - 2024-06-26

First release (#8 via #6)

  • Responsibilities
    • Provide a yarn (berry) plugin that generates CycloneDX SBOM for current workspace
    • Provide a CLI wrapper for said plugin
  • Capabilities
    • Support yarn (berry) v3 and v4
    • Can output in XML and JSON format according to CycloneDX v1.2 - v1.6 spec
    • Can omit dev-dependencies
    • Can generate reproducible results

1.0.0-rc.8 - 2024-06-25

  • Docs
    • Enhanced the installation docs
    • Fixed some typos here and there

1.0.0-rc.7 - 2024-06-01

  • Misc
    • Refactored node imports (via #127)
    • Revisited release pipeline

1.0.0-rc.5 - 2024-05-30

1.0.0-rc.2 - 2024-05-28

  • Added
  • Style
    • Some refactoring here and there
  • Docs
    • Some typo fixes and modernization here and there

1.0.0-rc.0 - 2024-05-27

Minimum Viable Product - RC-0

1.0.0-beta.1 - 2024-05-27

Minimum Viable Product - Beta-1

First release.

  • Responsibilities
    • Provide a yarn plugin that generates CycloneDX SBOM for current workspace
    • Provide a CLI wrapper got said plugin
  • Capabilities
    • Supports yarn4
    • Can output in XML and JSON format, CycloneDX v1.2 - v1.6 spec
    • Can omit dev dependencies