psastras/sbom-rs

GitHub: psastras/sbom-rs

这是一个专为 Rust 生态系统设计的工具集,用于生成、解析和交互 SPDX 及 CycloneDX 格式的软件物料清单(SBOM)。

Stars: 42 | Forks: 7

[![Workflow Status](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/dc0b61ae85214321.svg)](https://github.com/psastras/sbom-rs/actions?query=workflow%3A%22main%22) [![codecov](https://codecov.io/gh/psastras/sbom-rs/branch/main/graph/badge.svg?token=KSXYAZGS5U)](https://codecov.io/gh/psastras/sbom-rs) # sbom-rs 一组用于交互和生成软件物料清单 (SBOMs) 的 Rust 项目。 ## 示例 ### cargo-sbom #### 为 Cargo 项目创建 SPDX SBOM 在 shell 中: ``` $ cargo sbom { "SPDXID": "SPDXRef-DOCUMENT", "creationInfo": { "created": "2023-07-04T12:38:15.211Z", "creators": [ "Tool: cargo-sbom-v0.10.0" ] }, "dataLicense": "CC0-1.0", "documentNamespace": "https://docs.rs/cargo_sbom/spdxdocs/cargo-sbom-0.10.0-9cae390a-4b46-457c-95b9-e59a5e62b57d", "files": [ { ``` #### 在 Github Actions 中创建 CycloneDx SBOM 在 Github Actions workflow 中: ``` jobs: sbom: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: psastras/sbom-rs/actions/install-cargo-sbom@cargo-sbom-latest - name: Run cargo-sbom run: cargo-sbom --output-format=cyclone_dx_json_1_4 ``` #### 在 Github Actions 中创建 CycloneDx 1.5 SBOM ``` jobs: sbom: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: psastras/sbom-rs/actions/install-cargo-sbom@cargo-sbom-latest - name: Run cargo-sbom run: cargo-sbom --output-format=cyclone_dx_json_1_5 ``` #### 在 Github Actions 中创建 CycloneDx 1.6 SBOM ``` jobs: sbom: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - uses: psastras/sbom-rs/actions/install-cargo-sbom@cargo-sbom-latest - name: Run cargo-sbom run: cargo-sbom --output-format=cyclone_dx_json_1_6 ``` #### 根据开源漏洞数据库 (OSV) 检查依赖 假设已安装 `osv-scanner`(参见 [https://osv.dev/](https://osv.dev/)) ``` $ cargo-sbom > sbom.spdx.json $ osv-scanner --sbom=sbom.spdx.json Scanned sbom.json as SPDX SBOM and found 91 packages ╭─────────────────────────────────────┬──────┬───────────┬─────────┬─────────┬───────────╮ │ OSV URL │ CVSS │ ECOSYSTEM │ PACKAGE │ VERSION │ SOURCE │ ├─────────────────────────────────────┼──────┼───────────┼─────────┼─────────┼───────────┤ │ https://osv.dev/GHSA-wcg3-cvx6-7396 │ 6.2, │ crates.io │ time │ 0.1.45 │ sbom.json │ │ https://osv.dev/RUSTSEC-2020-0071 │ 6.2 │ │ │ │ │ ╰─────────────────────────────────────┴──────┴───────────┴─────────┴─────────┴───────────╯ ``` ## 安装 ### cargo-sbom 可以通过 `cargo`、[cargo-binstall](https://github.com/cargo-bins/cargo-binstall) 安装 `cargo-sbom`,或直接从对应的 Github release 下载。 #### Cargo ``` cargo install cargo-sbom ``` #### Cargo-binstall ``` cargo binstall cargo-sbom ``` #### Github Releases 最新版本会[持续发布并打标签](https://github.com/psastras/sbom-rs/releases)。 使用 `curl`: ``` # 确保调整 target 和 version(您可能还需要固定到特定版本) curl -sSL https://github.com/psastras/sbom-rs/releases/download/cargo-sbom-latest/cargo-sbom-x86_64-unknown-linux-gnu -o cargo-sbom ``` ## 文档 查看每个子项目以获取更详细的信息: - `cargo-sbom`:用于从 Cargo workspace 生成 SBOM 的 CLI 工具。请参阅 [Rust 文档](https://docs.rs/cargo_sbom/)。 - `serde-cyclonedx`:用于使用 [serde](https://serde.rs/) 序列化和反序列化 CycloneDX 信息的类型安全 CycloneDX 结构。请参阅 [Rust 文档](https://docs.rs/serde_cyclonedx/)。 - `serde-spdx`:用于使用 [serde](https://serde.rs/) 序列化和反序列化 SPDX 信息的类型安全 SPDX 结构。请参阅 [Rust 文档](https://docs.rs/serde_spdx/)。 - `actions`:用于在 CI workflows 中使用 `cargo-sbom` 和相关工具的 Github actions。请参阅 [README.md](https://github.com/psastras/sbom-rs/tree/main/actions/README.md) 获取文档。 [另请查看示例。](https://github.com/psastras/sbom-rs/tree/main/examples) ## 开发 在开始之前,请确保您的机器上已安装以下程序: - [`cargo`](https://rustup.rs/) 假设您的机器上已安装 `cargo`,则可以运行标准的 `cargo` 命令来构建和测试 workspace 中的所有项目: ``` cargo build cargo test ``` 有关特定配置的更多信息,请参阅 [`cargo` 文档](https://doc.rust-lang.org/cargo)。 ### 发布 要发布新版本(发布到 crates.io),请将 head commit 的前缀设为 `release:` 并更新相关的 rust crate 版本。一旦合并到 main 分支,pipeline 应会检测到更改并发布新版本。 License: MIT
标签:Cargo, CycloneDX, DevSecOps, GitHub Actions, OSV, Rust, SBOM, SPDX, Vercel, 上游代理, 依赖管理, 可视化界面, 安全合规, 开源漏洞数据库, 硬件无关, 网络代理, 网络流量审计, 网络调试, 自动化, 自动笔记, 跌倒检测, 软件物料清单, 通知系统