cyclonedx/cyclonedx-php-composer

从 PHP Composer 项目创建 CycloneDX 软件物料清单 (SBOM)

资助包维护!
其他

安装数: 884,265

依赖项: 10

建议者: 0

安全: 0

星标: 48

关注者: 5

分支: 7

公开问题: 15

类型:composer-plugin


README

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

这是一个用于 PHP 的 Composer 插件,用于生成 CycloneDX 格式的软件物料清单 (SBOM)。

基于 OWASP 软件组件验证标准 的标准,此工具能够生成几乎通过 Level-2 的 SBOM 文档(仅需要在外部完成签名)。

生成的 SBOM 文档遵循 官方规范和标准,并且可能具有遵循 cdx:composer 命名空间分类法 的属性。

要求

  • PHP ^8.1
  • Composer ^2.3

然而,此插件有更早的版本可用,支持 PHP ^5.5||^7.0||^8.0 与 Composer ^1.0||^2.0

安装

作为全局 Composer 插件

composer global require cyclonedx/cyclonedx-php-composer

作为当前项目的开发依赖

composer require --dev cyclonedx/cyclonedx-php-composer

用法

安装成功后,将提供 Composer 命令 CycloneDX:make-sbom

$ composer CycloneDX:make-sbom --help

Description:
  Generate a CycloneDX Bill of Materials from a PHP Composer project.

Usage:
  CycloneDX:make-sbom [options] [--] [<composer-file>]

Arguments:
  composer-file                                       Path to Composer config file.
                                                      [default: "composer.json" file in current working directory]

Options:
      --output-format=OUTPUT-FORMAT                   Which output format to use.
                                                      {choices: "JSON", "XML"}
                                                      [default: "XML"]
      --output-file=OUTPUT-FILE                       Path to the output file.
                                                      Set to "-" to write to STDOUT
                                                      [default: "-"]
      --omit=OMIT                                     Omit dependency types.
                                                      {choices: "dev", "plugin"}
                                                      (multiple values allowed)
      --spec-version=SPEC-VERSION                     Which version of CycloneDX spec to use.
                                                      {choices: "1.1", "1.2", "1.3", "1.4", "1.5", "1.6"}
                                                      [default: "1.5"]
      --output-reproducible|--no-output-reproducible  Whether to go the extra mile and make the output reproducible.
                                                      This might result in loss of time- and random-based-values.
      --validate|--no-validate                        Formal validate the resulting BOM.
      --mc-version=MC-VERSION                         Version of the main component.
                                                      This will override auto-detection.
  -h, --help                                          Display help for the given command.
  -q, --quiet                                         Do not output any message
  -v|vv|vvv, --verbose                                Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

演示

有关 cyclonedx-php-composer 的演示,请参阅 演示项目

工作原理

此工具利用 composer 自身来收集已安装 composer 包的证据。
在证据收集方面,实际安装配置优先于纯 lock 文件分析。
所需证据

  • composer config/manifest 文件(例如 composer.json 文件)
  • 以下之一
    • 实际的 composer 配置(在你的项目上运行 composer install [...] 后的结果)
    • 一个有效的 composer lock 文件(例如 composer.lock 文件)

内部

此工具利用 CycloneDX PHP 库 来生成实际的数据结构,标准化/序列化它们并验证 SBOM 结果。

此工具不公开任何额外的 公共 API 或类 - 所有代码均标记为 @internal,并在版本升级期间可能会无通知更改。

贡献

请随时提交问题、错误报告或拉取请求。
有关详细信息,请参阅 CONTRIBUTING 文件。

许可

在 Apache 2.0 许可证的条款下,授予修改和重新分发许可。
有关完整许可,请参阅 LICENSE 文件。