Artifact Analysis の脆弱性スキャンでは、スキャンされたイメージに保存されているサービス アカウント キーや API キーなどのシークレットを特定できます。これらのシークレットに関する情報は、脆弱性スキャンの発生レポートで確認できます。また、機密情報が公開されないように対策を講じることもできます。
概要
脆弱性スキャンでシークレットが検出されると、Artifact Analysis はシークレットの詳細を含むシークレット タイプのオカレンスを作成します。Artifact Analysis では、次のシークレットを検出できます。
シークレット
- Anthropic 管理者キー
- Anthropic API キー
- Azure アクセス トークン
- Azure ID トークン
- Docker Hub の個人用アクセス トークン
- GitHub アプリの更新トークン
- GitHub アプリのサーバー間トークン
- GitHub アプリのユーザー間トークン
- GitHub の従来の個人アクセス トークン
- GitHub のきめ細かい個人アクセス トークン
- GitHub OAuth トークン
- Google Cloud OAuth2(クライアント ID とシークレット)のペア
- Google Cloud OAuth2 アクセス トークン
- Google Cloud サービス アカウント キー
- Google Cloud API キー
- Huggingface API キー
- OpenAI API キー
- Perplexity API キー
- Stripe の制限付きキー
- Stripe の秘密鍵
- Stripe Webhook シークレット
発生レポートのさまざまな種類のシークレットの詳細については、Artifact Analysis API ドキュメントの SecretKind をご覧ください。
Artifact Analysis で検出できるのは、テキスト ファイルとして保存されたシークレットのみです。次のファイル拡張子がサポートされています。
.cer.cfg.crt.der.env.html.key.ipynb.json.log.md.pem.py.pypirc.textproto.toml.txt.xml.yaml
始める前に
- Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
-
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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
このガイドで既存のプロジェクトを使用する場合は、このガイドを完了するために必要な権限があることを確認します。新しいプロジェクトを作成した場合は、必要な権限がすでに付与されています。
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry and 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.enablepermission. Learn how to grant roles. -
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.
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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
このガイドで既存のプロジェクトを使用する場合は、このガイドを完了するために必要な権限があることを確認します。新しいプロジェクトを作成した場合は、必要な権限がすでに付与されています。
-
Verify that billing is enabled for your Google Cloud project.
-
Enable the Artifact Registry and 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.enablepermission. Learn how to grant roles. -
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
この API を有効にすると、Artifact Registry で言語パッケージ スキャンも有効になります。サポートされているパッケージ タイプをご覧ください。
必要なロール
脆弱性スキャン中にシークレットのイメージをスキャンするために必要な権限を取得するには、プロジェクトに対する次の IAM ロールを付与するよう管理者に依頼してください。
-
Artifact Registry 書き込み(
roles/artifactregistry.writer) -
Container Analysis のオカレンスの閲覧者 (
roles/containeranalysis.occurrences.viewer)
ロールの付与については、プロジェクト、フォルダ、組織へのアクセス権の管理をご覧ください。
必要な権限は、カスタムロールや他の事前定義ロールから取得することもできます。
Secret を表示する
脆弱性スキャン後にシークレットを表示する手順は次のとおりです。
脆弱性スキャンが完了するまで待ちます。
次のコマンドを実行して、スキャンされたイメージのシークレットの検出結果を一覧表示します。
$ curl -G -H "Content-Type: application/json" -H "Authorization: Bearer $(gcloud auth print-access-token)" --data-urlencode "filter=(kind=\"SECRET\" AND resourceUrl=\"RESOURCE_URL\")" https://containeranalysis.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/occurrencesここで
- PROJECT_ID は Google Cloud コンソールのプロジェクト ID です。
- LOCATION は、リポジトリのリージョンまたはマルチリージョンのロケーションです。
- RESOURCE_URL は、スキャンされた画像の URL です(
https://LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE_ID形式)。
次のレスポンス例は、考えられる結果を示しています。この場合、
my_api_key.yamlという名前のGoogle Cloud API キーがイメージのdocumentsディレクトリで特定されました。secret属性には、検出されたシークレットに関する情報が表示されます。{ "occurrences": [ { "name": "projects/my-project/locations/us-east1/occurrences/45619d23-66b1-4f5b-9b12-9060d7f97ff3", "resourceUri": "https://us-east1-docker.pkg.dev/my-project/my-images/test-image-0106@sha256:73cf5b9a788dc391c40e9cf1599144d03875b5d2dc935988ebfef8260bd2678e", "noteName": "projects/my-project/locations/us-east1/notes/secret_kind_gcp_api_key", "kind": "SECRET", "createTime": "2026-01-06T21:16:14.905851Z", "updateTime": "2026-01-06T21:16:14.905851Z", "secret": { "kind": "SECRET_KIND_GCP_API_KEY", "locations": [ { "fileLocation": { "filePath": "documents/my_api_key.yaml", "layerDetails": { "index": 2, "diffId": "7b76df10d6d90391830392eac96b0ef2d2d43822c6ff4754aa6daea0fe14a8c5", "command": "COPY . . # buildkit", "chainId": "sha256:75df0c59982f47cc38e730e1a122b67fceaaf7797d91e1fa17ffffc5cfe7ff59" } } } ] } } ] }
制限事項
- シークレット スキャンが公開プレビュー版の期間中は、シークレット タイプのオカレンスは Container Analysis API でのみ表示できます。
- Artifact Analysis のシークレット スキャンでは、イメージごとにシークレットごとに最大 1 つのオカレンスがレポートされます。1 回の発生につき最大 1,000 個のファイル ロケーションが返されます。
- 特定されたシークレットで誤検出が発生する可能性があります。イメージに対してアクションを実行する前に、特定された各シークレットを必ず確認してください。