step-security/sbom-action

GitHub: step-security/sbom-action

一个基于 Syft 的 GitHub Action,用于在 CI/CD 流程中自动生成和发布软件物料清单(SBOM),是 anchore/sbom-action 的安全替代方案。

Stars: 0 | Forks: 1

[![StepSecurity 维护的 Action](https://raw.githubusercontent.com/step-security/maintained-actions-assets/main/assets/maintained-action-banner.png)](https://docs.stepsecurity.io/actions/stepsecurity-maintained-actions) # 用于生成 SBOM 的 GitHub Action **一个使用 [Syft](https://github.com/anchore/syft) 创建软件物料清单 (SBOM) 的 GitHub Action。** [![GitHub release](https://img.shields.io/github/release/step-security/sbom-action.svg)](https://github.com/step-security/sbom-action/releases/latest) [![License: Apache-2.0](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/step-security/sbom-action/blob/main/LICENSE) ## 基本用法 ``` - uses: step-security/sbom-action@v0 ``` 默认情况下,此 Action 将在工作区目录中执行 Syft 扫描, 并以 SPDX 格式上传一个 workflow artifact SBOM。它还会检测 是否在 [GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) 期间运行, 并将 SBOM 作为 release asset 上传。 ## 用法示例 ### 扫描容器镜像 要扫描容器镜像,请使用 `image` 参数: ``` - uses: step-security/sbom-action@v0 with: image: ghcr.io/example/image_name:tag ``` 如果可用,将使用 Docker daemon 获取该镜像, 这将使用该 daemon 可用的任何身份验证。 如果 Docker daemon 不可用,此 Action 将直接从容器仓库获取该镜像。 也可以通过 `registry-username` 和 `registry-password` 参数直接连接到容器仓库。这将始终绕过 Docker daemon: ``` - uses: step-security/sbom-action@v0 with: image: my-registry.com/my/image registry-username: mr_awesome registry-password: ${{ secrets.REGISTRY_PASSWORD }} ``` ### 扫描特定目录 使用 `path` 参数,相对于仓库根目录: ``` - uses: step-security/sbom-action@v0 with: path: ./build/ ``` ### 扫描特定文件 使用 `file` 参数,相对于仓库根目录: ``` - uses: step-security/sbom-action@v0 with: file: ./build/file ``` ### 随 release 发布 SBOM `sbom-action` 会检测是否在 [GitHub release](https://docs.github.com/en/repositories/releasing-projects-on-github/about-releases) 期间运行, 并自动将所有 SBOM 作为 release asset 上传。但是, 您可能希望上传使用其他工具或在此 Action 之外使用 Syft 生成的 SBOM。 为此,请使用 `step-security/sbom-action/publish-sbom` 子 Action, 并使用 `sbom-artifact-match` 参数指定一个正则表达式: ``` - uses: step-security/sbom-action/publish-sbom@v0 with: sbom-artifact-match: ".*\\.spdx$" ``` ### 命名 SBOM 输出 默认情况下,此 Action 将上传一个名为 `-[-].` 的 artifact,例如: ``` build-sbom: steps: - uses: step-security/sbom-action@v0 - uses: step-security/sbom-action@v0 - uses: step-security/sbom-action@v0 id: myid ``` 将创建 3 个 artifact: ``` my-repo-build-sbom.spdx.json my-repo-build-sbom-2.spdx.json my-repo-build-sbom-myid.spdx.json ``` 您可能需要以不同的方式命名这些 artifact,只需 使用 `artifact-name` 参数: ``` - uses: step-security/sbom-action@v0 with: artifact-name: sbom.spdx ``` ## 权限 根据使用方式的不同,此 Action 需要以下权限: ``` contents: write # for sbom-action artifact uploads ``` 如果附加 release asset,还需要 `actions: read` 权限。 对于公共仓库,这可能是隐式的,但对于私有仓库很可能是必需的。 ``` actions: read # to find workflow artifacts when attaching release assets ``` ## 配置 ### step-security/sbom-action 主要的 [SBOM action](action.yml),负责生成 SBOM, 并将它们作为 workflow artifact 和 release asset 上传。 | 参数 | 描述 | 默认值 | | --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | | `path` | 要扫描的文件系统路径。与 `file` 和 `image` 互斥。 | \<当前目录> | | `file` | 要扫描的文件系统上的文件。与 `path` 和 `image` 互斥。 | | | `image` | 要扫描的容器镜像。与 `path` 和 `file` 互斥。有关更多信息,请参见[扫描容器镜像](#scan-a-container-image)。 | | | `registry-username` | 向外部 registry 进行身份验证时使用的 registry 用户名 | | | `registry-password` | 向外部 registry 进行身份验证时使用的 registry 密码 | | | `artifact-name` | 为生成的 SBOM artifact 指定的名称。请参见:[命名 SBOM 输出](#naming-the-sbom-output) | `sbom--.spdx.json` | | `output-file` | 输出生成的 SBOM 的位置 | | | `format` | 要导出的 SBOM 格式。取以下之一:`spdx`, `spdx-json`, `cyclonedx`, `cyclonedx-json` | `spdx-json` | | `dependency-snapshot` | 是否将 SBOM 上传到 GitHub Dependency submission API | `false` | | `upload-artifact` | 将 artifact 上传到 workflow | `true` | | `upload-artifact-retention` | 上传到 workflow 的 artifact 的保留策略(以天为单位)。 | | | `upload-release-assets` | 上传 release asset | `true` | | `syft-version` | 要使用的 Syft 版本 | | | `github-token` | 授权的 secret GitHub Personal Access Token。 | `github.token` | | `config ` | 要使用的 Syft 配置文件。 | | ### step-security/sbom-action/publish-sbom 用于将[多个 SBOM 上传](publish-sbom/action.yml)到 GitHub release 的子 Action。 | 参数 | 描述 | 默认值 | | --------------------- | ----------------------------- | ------------------- | | `sbom-artifact-match` | 用于查找 SBOM artifact 的模式。 | `.*\\.spdx\\.json$` | ### step-security/sbom-action/download-syft 用于[下载 Syft](download-syft/action.yml) 的子 Action。 | 参数 | 描述 | 默认值 | | -------------- | --------------------------- | ------ | | `syft-version` | 要下载的 Syft 版本 | | 输出参数: | 参数 | 描述 | | --------- | ---------------------------------------------------------- | | `cmd` | 对 [Syft](https://github.com/anchore/syft) 二进制文件的引用。 | `cmd` 可以像其他输出参数一样在工作流中引用: `${{ steps..outputs.cmd }}` ## Windows 此 Action 已在 Windows 上经过测试,并且应该无需 WSL 即可在 Windows 主机上原生运行。(请注意,它以前需要 WSL,但现在应该可以在 Windows 上原生运行。) ## 诊断 此 Action 广泛使用了 GitHub Action debug logging, 可以通过[在此处描述的方式](https://github.com/actions/toolkit/blob/master/docs/action-debugging.md) 在您的仓库中将 `ACTIONS_STEP_DEBUG` secret 设置为 `true` 来启用。
标签:AI应用开发, GitHub Action, LLM防护, SBOM生成, Syft, 安全合规, 网络代理, 自动化攻击, 请求拦截