kubernetes-sigs/bom

GitHub: kubernetes-sigs/bom

这是一个由 Kubernetes 社区开发的命令行工具,用于生成、查看和转换符合 SPDX 标准的软件物料清单(SBOM),支持从源码、镜像等多种来源构建清单。

Stars: 451 | Forks: 65

# `bom`:SBOM 多功能工具 [![PkgGoDev](https://pkg.go.dev/badge/sigs.k8s.io/bom)](https://pkg.go.dev/sigs.k8s.io/bom) [![Go Report Card](https://goreportcard.com/badge/sigs.k8s.io/bom)](https://goreportcard.com/report/sigs.k8s.io/bom) [![Slack](https://img.shields.io/badge/Slack-%23release--management-blueviolet)](https://kubernetes.slack.com/archives/C2C40FMNF) ![bom The SBOM Multitool](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/3b3ec0fa27073441.png) ## 什么是 `bom`? `bom` 是一个实用工具,允许您创建、查看和转换软件物料清单(SBOM)。`bom` 是作为为 Kubernetes 项目创建 SBOM 的项目的一部分而创建的。它使软件作者能够以简单但强大的方式为其项目生成 SBOM。 bom 是 Linux Foundation [Automating Compliance Toling TAC](https://github.com/act-project/TAC) 中孵化的一个项目。 `bom` 是一个通用工具,可以从目录、容器镜像、单个文件和其他源生成 SPDX 软件包。该实用程序具有内置的许可证分类器,可识别 SPDX 目录中的 400 多种许可证。 其他功能包括 Golang 依赖项分析,以及在扫描 git 仓库时提供完整的 `.gitignore` 支持。 有关如何为您的项目创建 SBOM 的更深入说明,请参阅[“为您的项目生成物料清单”](https://kubernetes-sigs.github.io/bom/tutorials/creating_bill_of_materials/)。 该指南包含有关什么是软件物料清单、SPDX 标准的信息,以及将文件、镜像、目录和其他源添加到您的 SBOM 的说明。 - [安装](#installation) - [用法](#usage) - [`bom generate`](#bom-generate) - [`bom document`](#bom-document) - [示例](#examples) - [从当前目录生成 SBOM](#generate-a-sbom-from-the-current-directory) - [处理容器镜像](#process-a-container-image) - [生成 SBOM 以描述文件](#generate-a-sbom-to-describe-files) - [行为准则](#code-of-conduct) ## 安装 要安装 `bom`: ``` go install sigs.k8s.io/bom/cmd/bom@latest ``` ## 用法 - completion:为指定的 shell 生成自动补全脚本 - [document](#bom-document):处理 SPDX 文档 - [generate](#bom-generate):创建 SPDX 清单 - help:关于任何命令的帮助 ### bom 生成 `bom generate` 是用于生成 SPDX 清单的 `bom` 子命令。 目前支持从文件、镜像和 docker 归档文件(tar 包中的镜像)创建 SBOM。它支持从远程仓库拉取镜像进行分析。 bom 可以使用越来越多的分析器对镜像进行更深入的分析,这些分析器旨在为常见的基础镜像增加更多语义。 SBOM 数据也可以导出为 in-toto 来源证明(provenance attestation)。输出将生成一个来源证明语句,将所有 SPDX 数据列为 in-toto 主题,但除此之外,该语句已准备好由 CI/CD 流水线中的后续阶段完成。有关更多详细信息,请参阅 --provenance 标志。 ``` Usage: bom generate [flags] Flags: -a, --analyze-images go deeper into images using the available analyzers --archive strings list of archives to add as packages (supports tar, tar.gz) -c, --config string path to yaml SBOM configuration file -d, --dirs strings list of directories to include in the manifest as packages -f, --file strings list of files to include --format string format of the document (supports tag-value, json) (default "tag-value") -h, --help help for generate --ignore strings list of regexp patterns to ignore when scanning directories -i, --image strings list of images --image-archive strings list of docker archive tarballs to include in the manifest -l, --license string SPDX license identifier to declare in the SBOM --name string name for the document, in contrast to URLs, intended for humans -n, --namespace string an URI that serves as namespace for the SPDX doc --no-gitignore don't use exclusions from .gitignore files --no-gomod don't perform go.mod analysis, sbom will not include data about go packages --no-transient don't include transient go dependencies, only direct deps from go.mod -o, --output string path to the file where the document will be written (defaults to STDOUT) --provenance string path to export the SBOM as an in-toto provenance statement --scan-images scan container images to look for OS information (currently debian only) (default true) Global Flags: --log-level string the logging verbosity, either 'panic', 'fatal', 'error', 'warning', 'info', 'debug', 'trace' (default "info") ``` ### bom 文档 `bom document subcommand` 可以可视化 SBOM 并查询其中的信息。 ``` bom document → Work with SPDX documents Usage: bom document [command] Available Commands: outline bom document outline → Draw structure of a SPDX document query bom document query → Search for information in an SBOM ``` ### bom 文档大纲 使用 `bom document outline` 可以渲染 SBOM 内容,以查看其中所包含信息的结构。以下是渲染 amd64 的 `debian:bookworm-slim` 镜像的示例: ``` bom generate --output=debian.spdx --image \ debian@sha256:0aac521df91463e54189d82fe820b6d36b4a0992751c8339fbdd42e2bc1aa491 bom document outline debian.spdx _ ___ _ __ __| |_ __ / __| '_ \ / _` \ \/ / \__ \ |_) | (_| |> < |___/ .__/ \__,_/_/\_\ |_| 📂 SPDX Document SBOM-SPDX-71f1009c-dc17-4f4d-b4ec-72210c1a8d7f │ │ 📦 DESCRIBES 1 Packages │ ├ sha256:0aac521df91463e54189d82fe820b6d36b4a0992751c8339fbdd42e2bc1aa491 │ │ 🔗 1 Relationships │ └ CONTAINS PACKAGE sha256:b37cbf60a964400132f658413bf66b67e5e67da35b9c080be137ff3c37cc7f65 │ │ │ 🔗 86 Relationships │ │ ├ CONTAINS PACKAGE apt@2.5.4 │ │ ├ CONTAINS PACKAGE base-files@12.3 │ │ ├ CONTAINS PACKAGE base-passwd@3.6.1 │ │ ├ CONTAINS PACKAGE bash@5.2.15-2 │ │ ├ CONTAINS PACKAGE bsdutils@1:2.38.1-4 │ │ ├ CONTAINS PACKAGE coreutils@9.1-1 │ │ ├ CONTAINS PACKAGE dash@0.5.11+git20210903+057cd650a4ed-9 │ │ ├ CONTAINS PACKAGE debconf@1.5.81 │ │ ├ CONTAINS PACKAGE debian-archive-keyring@2021.1.1 │ │ ├ CONTAINS PACKAGE debianutils@5.7-0.4 │ │ ├ CONTAINS PACKAGE diffutils@1:3.8-3 │ │ ├ CONTAINS PACKAGE dpkg@1.21.13 │ │ ├ CONTAINS PACKAGE e2fsprogs@1.46.6~rc1-1+b1 │ │ ├ CONTAINS PACKAGE findutils@4.9.0-3 │ │ ├ CONTAINS PACKAGE gcc-12-base@12.2.0-13 │ │ ├ CONTAINS PACKAGE gpgv@2.2.40-1 │ │ ├ CONTAINS PACKAGE grep@3.8-3 │ │ ├ CONTAINS PACKAGE gzip@1.12-1 │ │ ├ CONTAINS PACKAGE hostname@3.23+nmu1 │ │ ├ CONTAINS PACKAGE init-system-helpers@1.65.2 [trimmed] ``` ## 示例 以下示例展示了 bom 如何处理不同的源以生成 SPDX 物料清单。可以组合多个源以获取描述不同软件包的文档。 ### 从当前目录生成 SBOM 要将目录作为 SBOM 的源进行处理,请使用 `-d` 标志,或者直接将路径(或当前目录)作为 `bom generate` 的第一个参数传递: ``` bom generate . ``` ### 处理容器镜像 此示例拉取 `kube-apiserver` 镜像,对其进行分析,并在 SBOM 中进行描述。其每一层随后都在生成的文档中表示为子软件包: ``` bom generate -n http://example.com/ --image registry.k8s.io/kube-apiserver:v1.21.0 ``` ### 生成 SBOM 以描述文件 您可以创建一个仅包含清单中文件的 SBOM。为此,请使用 `-f`: ``` bom generate -n http://example.com/ \ -f Makefile \ -f file1.exe \ -f document.md \ -f other/file.txt ``` ## 行为准则 参与 Kubernetes 社区受 [Kubernetes Code of Conduct](code-of-conduct.md) 的约束。 | | | | | --- | --- | -- | | ![ACT TAC](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/5de4d2ff0e073442.png) | ![SPDX](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/7d94459bff073443.png) | ![Kubernetes](https://static.pigsec.cn/wp-content/uploads/repos/2026/04/1ff8230f35073444.png) |
标签:ACT, AI应用开发, DevSecOps, EVTX分析, Git支持, Golang, Go语言, Linux基金会, SBOM, SPDX, WebSocket, 上游代理, 依赖分析, 大数据, 安全编程, 容器镜像, 开源合规, 日志审计, 目录扫描, 硬件无关, 程序破解, 许可证管理, 许可证识别, 请求拦截, 跌倒检测, 软件供应链安全, 软件物料清单, 远程方法调用