Mengonfigurasi notifikasi Pub/Sub

Dokumen ini menjelaskan cara menyiapkan notifikasi untuk pembaruan pada catatan dan kejadian.

Artifact Analysis memberikan notifikasi melalui Pub/Sub untuk kerentanan yang ditemukan oleh pemindaian otomatis dan untuk metadata lainnya. Saat catatan atau kejadian dibuat atau diperbarui, pesan akan dipublikasikan ke topik yang sesuai untuk setiap versi API. Gunakan topik untuk versi API yang Anda gunakan.

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. Enable the Container Analysis API.

    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 API

  4. Instal Google Cloud CLI.

  5. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

  6. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

    gcloud init
  7. 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

  8. Enable the Container Analysis API.

    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 API

  9. Instal Google Cloud CLI.

  10. Jika Anda menggunakan penyedia identitas (IdP) eksternal, Anda harus login ke gcloud CLI dengan identitas gabungan Anda terlebih dahulu.

  11. Untuk melakukan inisialisasi gcloud CLI, jalankan perintah berikut:

    gcloud init
  12. Pelajari cara menyiapkan kontrol akses untuk metadata di project Anda. Lewati langkah ini jika Anda hanya menggunakan metadata dari kejadian yang dibuat oleh pemindaian container Artifact Analysis.

Membuat topik Pub/Sub

Setelah Anda mengaktifkan Artifact Analysis API, Artifact Analysis akan otomatis membuat topik Pub/Sub dengan ID topik berikut:

  • container-analysis-notes-v1
  • container-analysis-occurrences-v1

Jika topik tidak sengaja dihapus atau tidak ada, Anda dapat menambahkannya sendiri. Misalnya, topik mungkin tidak ada jika organisasi Anda memiliki batasan kebijakan organisasi yang mewajibkan enkripsi dengan kunci enkripsi yang dikelola pelanggan (CMEK). Google CloudJika Pub/Sub API berada dalam daftar penolakan batasan ini, layanan tidak dapat otomatis membuat topik dengan Google-owned and Google-managed encryption keys.

Untuk membuat topik dengan Google-owned and Google-managed encryption keys:

Konsol

  1. Buka halaman topik Pub/Sub di konsol Google Cloud .

    Buka halaman topik Pub/Sub

  2. Klik Buat Topik.

  3. Masukkan ID Topik:

    container-analysis-notes-v1
    

    sehingga nama cocok dengan URI:

    projects/PROJECT_ID/topics/container-analysis-notes-v1
    

    dengan PROJECT_ID adalah Google Cloud project ID Anda.

  4. Klik Create.

  5. Masukkan ID Topik:

    container-analysis-occurrences-v1
    

    sehingga nama cocok dengan URI:

    projects/PROJECT_ID/topics/container-analysis-occurrences-v1
    

gcloud

Jalankan perintah berikut di jendela shell atau terminal Anda:

gcloud pubsub topics create projects/PROJECT_ID/topics/container-analysis-notes-v1
gcloud pubsub topics create projects/PROJECT_ID/topics/container-analysis-occurrences-v1

Untuk mempelajari perintah gcloud pubsub topics lebih lanjut, lihat