本頁面說明如何將軟體物料清單 (SBOM) 檔案上傳至 Cloud Storage,以便追蹤及驗證您儲存在 Artifact Registry 中的容器映像檔元件。
如要進一步瞭解 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.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Container Analysis APIs.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
-
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
-
Make sure that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry, Container Analysis APIs.
-
Install the Google Cloud CLI.
-
If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.
-
To initialize the gcloud CLI, run the following command:
gcloud init
- 在 Artifact Registry 中建立 Docker 存放區,並納入 SBOM 所描述的容器映像檔。如果您不熟悉 Artifact Registry,請參閱 Docker 快速入門。
- 準備好採用支援的格式之一上傳 SBOM 檔案。
-
如果您使用的是預設 Cloud Storage 值區,請按照下列步驟管理儲存空間值區:
Storage Admin(
roles/storage.admin
) -
如果您要指定 Cloud Storage 值區,請按照下列步驟管理儲存空間值區:
儲存空間物件管理員(
roles/storage.objectAdmin
) -
如果 SBOM 參考資料的附註已存在:
容器分析註記附加者 (
roles/containeranalysis.notes.attacher
) -
如要為目前專案中的 SBOM 參照例項建立新註記,請按照下列步驟操作:
容器分析註記編輯器(
(roles/containeranalysis.notes.editor
) -
如要建立 SBOM 參照例項,請按照下列步驟操作:
容器分析發生頻率編輯器(
roles/containeranalysis.occurrences.editor
) - Software Package Data Exchange (SPDX) 2.2 或 2.3 版
- CycloneDX 1.4 或 1.5 版
- SOURCE:要上傳的 SBOM 檔案路徑。
- URI:SBOM 檔案所描述 Docker 映像檔的 URI。圖片格式可為標記格式或摘要格式。以標記格式提供的圖片會解析為摘要格式。
--destination
:指定要使用的 Cloud Storage 值區,取代預設值區。--kms-key-version
:提供金鑰版本,用於簽署 SBOM 參照事件酬載。您可以使用這個金鑰驗證 SBOM 的來源。
必要的角色
如要取得建立及管理 Cloud Storage 值區和 SBOM 檔案所需的權限,請要求管理員為您授予專案的下列 IAM 角色:
如要進一步瞭解如何授予角色,請參閱「管理專案、資料夾和機構的存取權」。
支援的格式
SBOM 檔案必須是 JSON 檔案,且採用下列任一格式:
上傳 SBOM
使用下列指令上傳 SBOM:
gcloud artifacts sbom load /
--source SOURCE /
--uri URI
其中:
選用標記
舉例來說,下列指令會上傳從標記圖片 us-east1-docker.pkg.dev/my-image-repo/my-image
產生的 JSON 檔案 my-sbom.bom.json
,並使用結尾為 my-key/cryptoKeyVersions/1
的 KMS 金鑰版本簽署 SBOM 參照事件。
gcloud artifacts sbom load /
--source=my-sbom.bom.json
--uri=us-east1-docker.pkg.dev/my-image-repo/my-image
--kms-key-version=projects/my-project/locations/us/keyRings/my-key-ring/cryptoKeys/my-key/cryptoKeyVersions/1
以下指令會上傳與圖片摘要 my-local-image@sha256:abcxyz
相關聯的 JSON 檔案 my-sbom.spdx.json
,並將檔案儲存在 Cloud Storage 值區 gs://my-sbom-bucket
中。
gcloud artifacts sbom load /
--source=my-sbom.spdx.json /
--uri=my-local-image@sha256:abcxyz /
--destination=gs://my-sbom-bucket
Artifact Analysis 會將 SBOM 上傳至 Cloud Storage,並建立 SBOM 參照事件。
您可以使用 Google Cloud 控制台或 gcloud CLI 查看 SBOM。如果您想找出包含 SBOM 的 Cloud Storage 值區,請務必使用 gcloud CLI 搜尋 SBOM。