本文档介绍了如何创建和存储软件物料清单 (SBOM),其中列出了容器映像中的依赖项。
将容器映像存储在 Artifact Registry 中并使用 Artifact Analysis 扫描这些映像以查找漏洞后,您可以使用 Google Cloud CLI 生成 SBOM。
Artifact Analysis 会将 SBOM 存储在 Cloud Storage 中。如需详细了解 Cloud Storage 费用,请参阅价格。
准备工作
-
Sign in to your Google Account.
If you don't already have one, sign up for a new account.
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Container Analysis, Container Scanning APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Container Analysis, Container Scanning APIs.
Roles required to enable APIs
To enable APIs, you need the Service Usage Admin IAM role (
roles/serviceusage.serviceUsageAdmin
), which contains theserviceusage.services.enable
permission. Learn how to grant roles. -
Install the Google Cloud CLI.
-
如果您使用的是外部身份提供方 (IdP),则必须先使用联合身份登录 gcloud CLI。
-
如需初始化 gcloud CLI,请运行以下命令:
gcloud init
- 在 Artifact Registry 中创建 Docker 代码库,并将容器映像推送到该代码库。如果您不熟悉 Artifact Registry,请参阅 Docker 快速入门。
- URI 是 SBOM 文件描述的 Artifact Registry 映像 URI,类似于
us-east1-docker.pkg.dev/my-image-repo/my-image
。映像可以采用标记格式或摘要格式。 以标记格式提供的映像将解析为摘要格式。
所需的角色
如需获得管理 Cloud Storage 存储分区和上传 SBOM 文件所需的权限,请让您的管理员为您授予项目的 Storage Admin (roles/storage.admin
) IAM 角色。
如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限。
生成 SBOM 文件
如需生成 SBOM 文件,请使用以下命令:
gcloud artifacts sbom export --uri=URI
地点
Artifact Analysis 会将您的 SBOM 存储在 Cloud Storage 中。
您可以使用 Google Cloud 控制台或 gcloud CLI 查看 SBOM。如果您想找到包含 SBOM 的 Cloud Storage 存储桶,则必须使用 gcloud CLI 搜索 SBOM。
生成不含漏洞扫描的 SBOM
如果您想生成 SBOM,但不想为项目进行持续的漏洞扫描,那么在将映像推送到 Artifact Registry 之前启用 Container Scanning API,您仍然可以导出 SBOM。将映像推送到 Artifact Registry 并导出 SBOM 后,您必须停用 Container Scanning API,以免因进一步的漏洞扫描而产生费用。