概要
脆弱性スキャンでシークレットが検出されると、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
始める前に
- Google Cloud アカウントにログインします。 Google Cloudを初めて使用する場合は、 アカウントを作成して、実際のシナリオでの Google プロダクトのパフォーマンスを評価してください。新規のお客様には、ワークロードの実行、テスト、デプロイができる無料クレジット $300 分を差し上げます。
-
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.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
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.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して 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 role
(
roles/resourcemanager.projectCreator), which contains theresourcemanager.projects.createpermission. Learn how to grant roles.
-
If you're using an existing project for this guide, verify that you have the permissions required to complete this guide. If you created a new project, then you already have the required permissions.
-
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.-
Google Cloud CLI をインストールします。
-
外部 ID プロバイダ(IdP)を使用している場合は、まず連携 ID を使用して gcloud CLI にログインする必要があります。
-
gcloud CLI を初期化するには、次のコマンドを実行します。
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 個のファイル ロケーションが返されます。
- 特定されたシークレットで誤検出が発生する可能性があります。イメージに対してアクションを実行する前に、特定されたシークレットを必ず確認してください。