@cyclonedx/yarn-plugin-cyclonedx
Version:
Create CycloneDX Software Bill of Materials (SBOM) from yarn projects.
154 lines (119 loc) • 7.62 kB
Markdown
[![shield_yarnpkg-version]][link_yarnpkg]
[![shield_npm-version]][link_npm]
[![shield_gh-workflow-test]][link_gh-workflow-test]
[![shield_coverage]][link_codacy]
[![shield_ossf-best-practices]][link_ossf-best-practices]
[![shield_license]][license_file]
[![shield_website]][link_website]
[![shield_slack]][link_slack]
[![shield_groups]][link_discussion]
[![shield_twitter-follow]][link_twitter]
----
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
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:
```shell
yarn add --dev @cyclonedx/yarn-plugin-cyclonedx
```
* **plugin**: Install the [latest version from GitHub release](https://github.com/CycloneDX/cyclonedx-node-yarn/releases/latest) asset as a plugin for the current project:
```shell
yarn plugin import https://github.com/CycloneDX/cyclonedx-node-yarn/releases/latest/download/yarn-plugin-cyclonedx.cjs
```
Usage depends on the installation method:
* With **zero-install** via dlx-wrapper:
```shell
yarn dlx -q @cyclonedx/yarn-plugin-cyclonedx --help
```
* After **cli-wrapper** installation:
```shell
yarn exec cyclonedx-yarn --help
```
* After **plugin** installation:
```shell
yarn cyclonedx --help
```
The help page:
```text
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
(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
(choices: JSON, XML, default: JSON)
-o,--output-file
Set to "-" to write to STDOUT.
(default: write to STDOUT)
--mc-type
(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.
```
This _yarn_ plugin utilizes the [CycloneDX library][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:
```javascript
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 }))
```
Feel free to open issues, bugreports or pull requests.
See the [`CONTRIBUTING`][contributing_file] file for details.
Permission to modify and redistribute is granted under the terms of the Apache 2.0 license.
See the [`LICENSE`][license_file] file for the full license.
For details and license posture of the assembly, see the `LICENSE` file in the respective release assets.
[]: https://github.com/CycloneDX/cyclonedx-node-yarn/blob/main/LICENSE
[]: https://github.com/CycloneDX/cyclonedx-node-yarn/blob/main/CONTRIBUTING.md
[]: https://cyclonedx.org/
[]: https://yarnpkg.com/
[]: https://www.npmjs.com/package/@cyclonedx/cyclonedx-library
[]: https://img.shields.io/github/actions/workflow/status/CycloneDX/cyclonedx-node-yarn/nodejs.yml?branch=main&logo=GitHub&logoColor=white "tests"
[]: https://img.shields.io/codacy/coverage/b0af77db5c7b4ab7a36eab255c7f9ede?logo=Codacy&logoColor=white "test coverage"
[]: https://img.shields.io/cii/percentage/8960?label=OpenSSF%20best%20practices "OpenSSF best practices"
[]: https://img.shields.io/npm/v/%40cyclonedx%2Fyarn-plugin-cyclonedx/latest?registry_uri=https%3A%2F%2Fregistry.yarnpkg.com&logo=yarn&logoColor=white&label=yarnpkg "yarnpkg"
[]: https://img.shields.io/npm/v/%40cyclonedx%2Fyarn-plugin-cyclonedx/latest?logo=npm&logoColor=white&label=npm "npm"
[]: https://img.shields.io/github/license/CycloneDX/cyclonedx-node-yarn?logo=open%20source%20initiative&logoColor=white "license"
[]: https://img.shields.io/badge/https://-cyclonedx.org-blue.svg "homepage"
[]: https://img.shields.io/badge/slack-join-blue?logo=Slack&logoColor=white "slack join"
[]: https://img.shields.io/badge/discussion-groups.io-blue.svg "groups discussion"
[]: https://img.shields.io/badge/Twitter-follow-blue?logo=Twitter&logoColor=white "twitter follow"
[]: https://cyclonedx.org/
[]: https://github.com/CycloneDX/cyclonedx-node-yarn/actions/workflows/nodejs.yml?query=branch%3Amain
[]: https://yarnpkg.com/package?name=%40cyclonedx%2Fyarn-plugin-cyclonedx
[]: https://www.npmjs.com/package/@cyclonedx/yarn-plugin-cyclonedx
[]: https://app.codacy.com/gh/CycloneDX/cyclonedx-node-yarn/dashboard
[]: https://www.bestpractices.dev/projects/8960
[]: https://cyclonedx.org/slack/invite
[]: https://groups.io/g/CycloneDX
[]: https://twitter.com/CycloneDX_Spec