SBOM をアップロードする

このページでは、ソフトウェア部品構成表(SBOM)ファイルを Cloud Storage にアップロードして、Artifact Registry に保存するコンテナ イメージのコンポーネントを追跡し、証明する方法について説明します。

Cloud Storage の料金については、料金をご覧ください。

始める前に

  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Enable the Artifact Registry, Container Analysis APIs.

    Enable the APIs

  5. Install the Google Cloud CLI.

  6. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  7. To initialize the gcloud CLI, run the following command:

    gcloud init
  8. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  9. Make sure that billing is enabled for your Google Cloud project.

  10. Enable the Artifact Registry, Container Analysis APIs.

    Enable the APIs

  11. Install the Google Cloud CLI.

  12. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

  13. To initialize the gcloud CLI, run the following command:

    gcloud init
  14. SBOM で記述されているコンテナ イメージを含む Artifact Registry の Docker リポジトリがある。Artifact Registry に習熟されていない場合は、Docker のクイックスタートをご覧ください。
  15. サポートされている形式のいずれかでアップロードする SBOM ファイルを用意します。
  16. 必要なロール

    Cloud Storage バケットと SBOM ファイルの作成と管理に必要な権限を取得するには、プロジェクトに対する次の IAM ロールの付与を管理者に依頼してください。

    • デフォルトの Cloud Storage バケットを使用している場合、ストレージ バケットを管理するには: ストレージ管理者(roles/storage.admin
    • Cloud Storage バケットを指定する場合は、ストレージ バケットを管理する: ストレージ オブジェクト管理者(roles/storage.objectAdmin
    • SBOM 参照のメモがすでに存在する場合: Container Analysis メモの添付者 roles/containeranalysis.notes.attacher
    • 現在のプロジェクトで SBOM 参照オカレンスの新しいメモを作成するには: Container Analysis メモの編集者((roles/containeranalysis.notes.editor
    • SBOM 参照オカレンスを作成するには: Container Analysis 実行回数の編集者(roles/containeranalysis.occurrences.editor

    ロールの付与については、プロジェクト、フォルダ、組織に対するアクセス権の管理をご覧ください。

    必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。

    サポートされているファイル形式

    SBOM ファイルは、次のいずれかの形式の JSON ファイルである必要があります。

    SBOM をアップロードする

    次のコマンドを使用して SBOM をアップロードします。

    gcloud artifacts sbom load /
        --source SOURCE /
        --uri URI
    

    ここで

    • SOURCE: アップロードする SBOM ファイルのパス。
    • URI: SBOM ファイルが記述する Docker イメージの URI。画像はタグ形式またはダイジェスト形式で指定できます。タグ形式で指定されたイメージは、ダイジェスト形式に解決されます。

    オプション フラグ

    • --destination: デフォルトのバケットの代わりに、使用する Cloud Storage バケットを指定します。
    • --kms-key-version: SBOM 参照オカレンスのペイロードに署名する鍵バージョンを提供します。この鍵を使用して、SBOM のオリジンを検証できます。

    たとえば、次のコマンドは、タグ付きイメージ 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 参照オカレンスを作成します。

    SBOM は、 Google Cloud コンソールまたは gcloud CLI を使用して表示できます。SBOM を含む Cloud Storage バケットを見つけるには、gcloud CLI を使用して SBOM を検索する必要があります。

    次のステップ