Pemindaian kerentanan Artifact Analysis dapat mengidentifikasi rahasia, seperti kunci akun layanan dan kunci API, yang disimpan dalam image yang dipindai. Anda dapat melihat informasi tentang rahasia ini dalam laporan kemunculan pemindaian kerentanan dan mengambil tindakan untuk mencegah pengungkapan informasi sensitif.
Ringkasan
Saat pemindaian kerentanan mendeteksi secret, Artifact Analysis akan membuat kemunculan jenis secret dengan detail tentang secret tersebut. Analisis Artefak dapat mendeteksi rahasia berikut:
Rahasia
- Kunci admin Anthropic
- Kunci Anthropic API
- Token akses Azure
- Token ID Azure
- Token akses pribadi Docker Hub
- Token refresh aplikasi GitHub
- Token server-ke-server aplikasi GitHub
- Token user-ke-server aplikasi GitHub
- Token akses pribadi klasik GitHub
- Token akses pribadi terperinci GitHub
- Token OAuth GitHub
- Google Cloud Pasangan OAuth2 (ID & rahasia klien)
- Google Cloud Token akses OAuth2
- Google Cloud kunci akun layanan
- Google Cloud Kunci API
- Kunci API Hugging Face
- Kunci API OpenAI
- Kunci Perplexity API
- Kunci terbatas Stripe
- Kunci rahasia Stripe
- Stripe webhook secrets
Untuk mengetahui informasi mendetail tentang berbagai jenis rahasia dalam laporan kemunculan, lihat
SecretKind
dalam dokumentasi Artifact Analysis API.
Analisis Artefak hanya dapat mendeteksi secret yang disimpan sebagai file teks. Ekstensi file berikut didukung:
.cer.cfg.crt.der.env.html.key.ipynb.json.log.md.pem.py.pypirc.textproto.toml.txt.xml.yaml
Sebelum memulai
- 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.
-
Jika Anda menggunakan project yang sudah ada untuk panduan ini, pastikan Anda memiliki izin yang diperlukan untuk menyelesaikan panduan ini. Jika berhasil membuat project baru, berarti Anda sudah memiliki izin yang diperlukan.
-
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.
-
Jika Anda menggunakan project yang sudah ada untuk panduan ini, pastikan Anda memiliki izin yang diperlukan untuk menyelesaikan panduan ini. Jika berhasil membuat project baru, berarti Anda sudah memiliki izin yang diperlukan.
-
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
Mengaktifkan API ini juga akan mengaktifkan pemindaian paket bahasa di Artifact Registry. Lihat jenis paket yang didukung.
Peran yang diperlukan
Untuk mendapatkan izin yang Anda perlukan untuk memindai rahasia dalam gambar selama pemindaian kerentanan, minta administrator untuk memberi Anda peran IAM berikut di project Anda:
-
Artifact Registry Writer (
roles/artifactregistry.writer) -
Container Analysis Occurrences Viewer (
roles/containeranalysis.occurrences.viewer)
Untuk mengetahui informasi selengkapnya tentang pemberian peran, lihat Mengelola akses ke project, folder, dan organisasi.
Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.
Melihat secret
Untuk melihat secret setelah pemindaian kerentanan, lakukan hal berikut:
Tunggu hingga pemindaian kerentanan selesai.
Jalankan perintah berikut untuk mencantumkan kemunculan secret untuk gambar yang dipindai:
$ 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/occurrencesDengan:
- PROJECT_ID adalah project ID konsol Google Cloud Anda.
- LOCATION adalah lokasi regional atau multi-regional repositori Anda.
- RESOURCE_URL adalah URL gambar yang dipindai, dalam format
https://LOCATION-docker.pkg.dev/PROJECT_ID/REPOSITORY/IMAGE_ID.
Contoh respons berikut menunjukkan kemungkinan hasil. Dalam hal ini, kunci API Google Cloud bernama
my_api_key.yamldiidentifikasi sebagaidocumentsdirektori gambar. Atributsecretmenampilkan informasi tentang secret yang ditemukan.{ "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" } } } ] } } ] }
Batasan
- Selama pemindaian rahasia dalam pratinjau publik, kejadian jenis rahasia hanya dapat dilihat di Container Analysis API.
- Pemindaian rahasia Artifact Analysis melaporkan paling banyak satu kemunculan per rahasia per gambar. Maksimal 1.000 lokasi file per kemunculan yang ditampilkan.
- Positif palsu dapat terjadi dengan secret yang teridentifikasi. Selalu verifikasi setiap secret yang teridentifikasi sebelum mengambil tindakan apa pun pada image Anda.