Memindai rahasia

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 kejadian 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. Artifact Analysis dapat mendeteksi secret berikut:

Rahasia

  • Kunci admin Anthropic
  • Kunci API Anthropic
  • Token akses Azure
  • Token ID Azure
  • Token akses pribadi Docker Hub
  • Token refresh aplikasi GitHub
  • Token server ke server aplikasi GitHub
  • Token pengguna ke server aplikasi GitHub
  • Token akses pribadi klasik GitHub
  • Token akses pribadi GitHub yang sangat terperinci
  • Token OAuth GitHub
  • Google Cloud Pasangan OAuth2 (client ID & rahasia)
  • Google Cloud Token akses OAuth2
  • Google Cloud kunci akun layanan
  • Google Cloud Kunci API
  • Kunci API Hugging Face
  • Kunci API OpenAI
  • Kunci API Perplexity
  • Kunci terbatas Stripe
  • Kunci rahasia Stripe
  • Secret webhook Stripe

Untuk mengetahui informasi mendetail tentang berbagai jenis rahasia dalam laporan kemunculan, lihat SecretKind dalam dokumentasi Artifact Analysis API.

Artifact Analysis 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

  1. Login ke akun Google Cloud Anda. Jika Anda baru menggunakan Google Cloud, buat akun untuk mengevaluasi performa produk kami dalam skenario dunia nyata. Pelanggan baru juga mendapatkan kredit gratis senilai $300 untuk menjalankan, menguji, dan men-deploy workload.
  2. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. 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.

  4. Verify that billing is enabled for your Google Cloud project.

  5. Enable the Artifact Registry and Container Scanning APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  6. Install the Google Cloud CLI.

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

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

    gcloud init
  9. 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 the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  10. 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.

  11. Verify that billing is enabled for your Google Cloud project.

  12. Enable the Artifact Registry and Container Scanning APIs, if any are not already enabled.

    Roles required to enable APIs

    To enable APIs, you need the serviceusage.services.enable permission. If you created the project, then you likely already have this permission through the Owner role (roles/owner). Otherwise, you can get this permission through the Service Usage Admin role (roles/serviceusage.serviceUsageAdmin). Learn how to grant roles.

    Enable the APIs

  13. Install the Google Cloud CLI.

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

  15. 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 guna memindai rahasia dalam gambar selama pemindaian kerentanan, minta administrator untuk memberi Anda peran IAM berikut di project Anda:

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:

  1. Mengirim image Docker ke Artifact Registry.

  2. Tunggu hingga pemindaian kerentanan selesai.

  3. Jalankan perintah berikut untuk mencantumkan kemunculan secret untuk image 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/occurrences
    

    Dengan:

    • 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 APIGoogle Cloud bernama my_api_key.yaml diidentifikasi di direktori documents dari sebuah image. Atribut secret menampilkan informasi tentang rahasia 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, kemunculan jenis rahasia hanya dapat dilihat di Container Analysis API.
  • Pemindaian secret Artifact Analysis melaporkan, maksimal, satu kemunculan per secret per image. Maksimal 1.000 lokasi file per kemunculan akan ditampilkan.
  • Positif palsu dapat terjadi dengan secret yang teridentifikasi. Selalu verifikasi setiap secret yang teridentifikasi sebelum mengambil tindakan apa pun pada image Anda.