CycloneDX/cyclonedx-node-yarn
GitHub: CycloneDX/cyclonedx-node-yarn
专为Yarn项目设计的CycloneDX SBOM生成器,通过原生插件方式递归扫描工作区依赖并输出标准化的软件物料清单。
Stars: 24 | Forks: 8
# 适用于 yarn 的 CycloneDX SBOM
[![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]
从 _[yarn]_ 项目创建 [CycloneDX] 软件物料清单 (SBOM)。
这可能是基于 yarn 的项目中最准确、最完整的 SBOM 生成器。
## 环境要求
* `node >= 20.18.0`
* `yarn >= 4.0.0` (berry)
不过,此软件的旧版本支持
* Node v18 及更高版本
* Yarn v3 及更高版本
## 安装
通过以下方法之一将插件安装到您的 yarn 项目中:
* **zero-install**:无需安装,只需按“使用说明”章节所述通过 dlx-wrapper 按需调用。
* **cli-wrapper**:作为当前项目的开发依赖项:
yarn add --dev @cyclonedx/yarn-plugin-cyclonedx
* **plugin**:从 [GitHub release](https://github.com/CycloneDX/cyclonedx-node-yarn/releases/latest) 资产安装最新版本作为当前项目的插件:
yarn plugin import https://github.com/CycloneDX/cyclonedx-node-yarn/releases/latest/download/yarn-plugin-cyclonedx.cjs
## 使用说明
使用方式取决于安装方法:
* 通过 dlx-wrapper 使用 **zero-install**:
yarn dlx -q @cyclonedx/yarn-plugin-cyclonedx --help
* **cli-wrapper** 安装后:
yarn exec cyclonedx-yarn --help
* **plugin** 安装后:
yarn cyclonedx --help
帮助页面:
```
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, 1.7, 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.
```
## 内部实现
此 _yarn_ 插件利用 [CycloneDX library][CycloneDX-library] 生成实际的数据结构。
此工具**不**暴露任何额外的_公共_ API 或类 —— 所有代码均为内部代码,可能会在版本升级时未经通知而更改。
不过,CLI 是稳定的 —— 您可以像这样通过编程方式调用它:
```
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 }))
```
## 开发与贡献
欢迎提交 issue、bug 报告或 pull request。
详情请参阅 [`CONTRIBUTING`][contributing_file] 文件。
## 许可证
在 Apache 2.0 许可证条款下,允许修改和重新分发。
完整许可证请参阅 [`LICENSE`][license_file] 文件。
有关组装的详细信息和许可证状况,请参阅相应 release 资产中的文件:`LICENSE`、`NOTICE`、`bom.json`。
标签:BOM 生成器, CMS安全, CycloneDX, DevSecOps, GNU通用公共许可证, JavaScript, MITM代理, Node.js, SBOM, TypeScript, Yarn, Yarn Berry, Yarn 插件, Zero-Install, 上游代理, 二进制发布, 依赖管理, 包管理器, 占用监测, 安全合规, 安全插件, 开源工具, 数据可视化, 硬件无关, 统一API, 网络代理, 自定义脚本, 自定义脚本, 资产管理, 跌倒检测, 软件物料清单