Mengonfigurasi kebijakan organisasi kustom

Halaman ini menunjukkan cara menggunakan batasan kustom Layanan Kebijakan Organisasi untuk membatasi operasi tertentu pada resource Google Cloud berikut:

  • securitycenter.googleapis.com/BigQueryExport
  • securitycenter.googleapis.com/MuteConfig
  • securitycenter.googleapis.com/NotificationConfig
  • securitycenter.googleapis.com/ResourceValueConfig
  • securitycenter.googleapis.com/ContainerThreatDetectionSettings
  • securitycenter.googleapis.com/EventThreatDetectionSettings
  • securitycenter.googleapis.com/SecurityHealthAnalyticsSettings
  • securitycenter.googleapis.com/VirtualMachineThreatDetectionSettings
  • securitycenter.googleapis.com/WebSecurityScannerSettings
  • securitycentermanagement.googleapis.com/SecurityCenterService
  • securitycentermanagement.googleapis.com/SecurityHealthAnalyticsCustomModule
  • securitycentermanagement.googleapis.com/EventThreatDetectionCustomModule

Untuk mempelajari Kebijakan Organisasi lebih lanjut, lihat Kebijakan organisasi kustom.

Tentang batasan dan kebijakan organisasi

Google Cloud Layanan Kebijakan Organisasi memberi Anda kontrol terpusat dan terprogram atas resource organisasi. Sebagai administrator kebijakan organisasi, Anda dapat menentukan kebijakan organisasi, yang merupakan serangkaian batasan yang disebut batasan yang berlaku untuk resourceGoogle Cloud dan turunan dari resource tersebut dalam hierarki resourceGoogle Cloud . Anda dapat menerapkan kebijakan organisasi di tingkat organisasi, folder, atau project.

Kebijakan Organisasi memberikan batasan yang telah ditetapkan untuk berbagai layanan Google Cloud . Namun, jika ingin kontrol yang lebih terperinci dan dapat disesuaikan atas kolom tertentu yang dibatasi dalam kebijakan organisasi, Anda juga dapat membuat batasan khusus dan menggunakan batasan khusus tersebut dalam kebijakan organisasi.

Pewarisan kebijakan

Secara default, kebijakan organisasi diwarisi oleh turunan resource tempat Anda menerapkan kebijakan tersebut. Misalnya, jika Anda menerapkan kebijakan pada folder, Google Cloud akan menerapkan kebijakan tersebut pada semua project dalam folder tersebut. Untuk mempelajari lebih lanjut perilaku ini dan cara mengubahnya, lihat Aturan evaluasi hierarki.

Sebelum memulai

  1. 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.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  3. Make sure that billing is enabled for your Google Cloud project.

  4. Install the Google Cloud CLI.
  5. To initialize the gcloud CLI, run the following command:

    gcloud init
  6. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Go to project selector

  7. Make sure that billing is enabled for your Google Cloud project.

  8. Install the Google Cloud CLI.
  9. To initialize the gcloud CLI, run the following command:

    gcloud init
  10. Pastikan Anda mengetahui ID organisasi Anda.

Peran yang diperlukan

Untuk mendapatkan izin yang diperlukan guna mengelola kebijakan organisasi kustom, minta administrator untuk memberi Anda peran IAM Administrator Kebijakan Organisasi (roles/orgpolicy.policyAdmin) di resource organisasi. Untuk mengetahui informasi selengkapnya tentang cara memberikan peran, lihat Mengelola akses ke project, folder, dan organisasi.

Anda mungkin juga bisa mendapatkan izin yang diperlukan melalui peran khusus atau peran bawaan lainnya.

Membuat batasan khusus

Batasan kustom ditentukan dalam file YAML oleh resource, metode, kondisi, dan tindakan yang didukung oleh layanan tempat Anda menerapkan kebijakan organisasi. Kondisi untuk batasan kustom Anda ditentukan menggunakan Common Expression Language (CEL). Untuk mengetahui informasi selengkapnya tentang cara membangun kondisi dalam batasan khusus menggunakan CEL, lihat bagian CEL tentang Membuat dan mengelola batasan kustom.

Untuk membuat batasan khusus, buat file YAML menggunakan format berikut:

name: organizations/ORGANIZATION_ID/customConstraints/CONSTRAINT_NAME
resourceTypes:
- RESOURCE_NAME
methodTypes:
- CREATE
- UPDATE
condition: "CONDITION"
actionType: ACTION
displayName: DISPLAY_NAME
description: DESCRIPTION

Ganti kode berikut:

  • ORGANIZATION_ID: ID organisasi Anda, seperti 123456789.

  • CONSTRAINT_NAME: nama yang Anda inginkan untuk batasan kustom baru. Batasan kustom harus diawali dengan custom., dan hanya dapat menyertakan huruf besar, huruf kecil, atau angka. Contohnya, custom.SccNotificationConfig. Panjang maksimum kolom ini adalah 70 karakter.

  • RESOURCE_NAME: nama lengkap resourceGoogle Cloud yang berisi objek dan kolom yang ingin Anda batasi. Misalnya, securitycenter.googleapis.com/NotificationConfig.

  • CONDITION: kondisi CEL yang ditulis berdasarkan representasi resource layanan yang didukung. Kolom ini memiliki panjang maksimal 1.000 karakter. Lihat Resource yang didukung untuk mengetahui informasi selengkapnya tentang resource yang tersedia untuk menulis kondisi. Contoh, "resource.pubsubTopic != 'projects/PROJECT_ID/topics/TOPIC_ID'"

  • ACTION: tindakan yang akan diambil jika condition terpenuhi. Kemungkinan nilainya adalah ALLOW dan DENY.

  • DISPLAY_NAME: nama yang mudah dibaca manusia untuk batasan. Kolom ini memiliki panjang maksimal 200 karakter.

  • DESCRIPTION: deskripsi batasan yang mudah dipahami untuk ditampilkan sebagai pesan error saat kebijakan dilanggar. Kolom ini memiliki panjang maksimal 2.000 karakter.

Untuk mengetahui informasi selengkapnya tentang cara membuat batasan kustom, lihat Menentukan batasan kustom.

Menyiapkan batasan kustom

Setelah membuat file YAML untuk batasan khusus baru, Anda harus menyiapkannya agar tersedia untuk kebijakan organisasi di organisasi Anda. Untuk menyiapkan batasan kustom, gunakan perintah gcloud org-policies set-custom-constraint:
gcloud org-policies set-custom-constraint CONSTRAINT_PATH
Ganti CONSTRAINT_PATH dengan jalur lengkap ke file batasan kustom Anda. Contohnya, /home/user/customconstraint.yaml Setelah selesai, batasan kustom Anda akan tersedia sebagai kebijakan organisasi dalam daftar Google Cloud kebijakan organisasi Anda. Untuk memverifikasi bahwa ada batasan kustom, gunakan perintah gcloud org-policies list-custom-constraints:
gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
Ganti ORGANIZATION_ID dengan ID fasilitas organisasi Anda. Untuk mengetahui informasi selengkapnya, lihat Melihat kebijakan organisasi.

Menerapkan kebijakan organisasi kustom

Anda dapat menerapkan batasan boolean dengan membuat kebijakan organisasi yang mereferensikannya, lalu menerapkan kebijakan organisasi tersebut ke resource Google Cloud .

Konsol

  1. Di konsol Google Cloud, buka halaman Organization policies.

    Buka Organization policies

  2. Dari pemilih project, pilih project yang ingin Anda tetapkan kebijakan organisasinya.
  3. Dari daftar di halaman Organization policies, pilih batasan untuk melihat halaman Policy details untuk batasan tersebut.
  4. Untuk mengonfigurasi kebijakan organisasi untuk resource ini, klik Manage policy.
  5. Di halaman Edit policy, pilih Override parent's policy.
  6. Klik Add a rule.
  7. Di bagian Enforcement, pilih apakah penerapan kebijakan organisasi ini diaktifkan atau dinonaktifkan.
  8. Opsional: Untuk membuat kebijakan organisasi bersyarat pada tag, klik Add condition. Perhatikan bahwa jika menambahkan aturan kondisional ke kebijakan organisasi, Anda harus menambahkan setidaknya satu aturan tanpa syarat atau kebijakan tidak dapat disimpan. Untuk mengetahui informasi selengkapnya, lihat Menetapkan kebijakan organisasi dengan tag.
  9. Jika ini adalah batasan kustom, Anda dapat mengklik Uji perubahan untuk menyimulasikan efek kebijakan organisasi ini. Untuk mengetahui informasi selengkapnya, lihat Menguji perubahan kebijakan organisasi dengan Policy Simulator.
  10. Untuk menyelesaikan dan menerapkan kebijakan organisasi, klik Set policy. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

gcloud

Untuk membuat kebijakan organisasi yang menerapkan batasan boolean, buat file YAML kebijakan yang merujuk batasan tersebut:

      name: projects/PROJECT_ID/policies/CONSTRAINT_NAME
      spec:
        rules:
        - enforce: true
    

Ganti kode berikut:

  • PROJECT_ID: project tempat Anda ingin menerapkan batasan.
  • CONSTRAINT_NAME: nama yang Anda tentukan untuk batasan kustom. Contoh, custom.SccNotificationConfig

Untuk menerapkan kebijakan organisasi yang berisi batasan, jalankan perintah berikut:

    gcloud org-policies set-policy POLICY_PATH
    

Ganti POLICY_PATH dengan jalur lengkap ke file YAML kebijakan organisasi Anda. Kebijakan ini memerlukan waktu hingga 15 menit untuk diterapkan.

Menguji kebijakan organisasi kustom

Contoh berikut membuat batasan kustom untuk resource securitycenter.googleapis.com/NotificationConfig. Batasan ini hanya memungkinkan pengguna membuat atau mengubah konfigurasi notifikasi yang berlangganan ke topik Pub/Sub tertentu.

Sebelum memulai, Anda harus mengetahui hal-hal berikut:

  • ID organisasi Anda
  • Project ID
  • ID topik Pub/Sub

Membuat batasan

  1. Buat file YAML bernama notificationConfig_constraint.yaml yang menentukan batasan kustom:

     name: organizations/ORGANIZATION_ID/customConstraints/custom.SccNotificationConfig
     resourceTypes:
     - securitycenter.googleapis.com/NotificationConfig
     methodTypes:
     - CREATE
     - UPDATE
     condition: "resource.pubsubTopic != 'projects/PROJECT_ID/topics/TOPIC_ID'"
     actionType: DENY
     displayName: Only let users create or modify notification configs that
       are subscribed to a specific Pub/Sub topic.
     description: "Can't create or modify notification configs that are subscribed
       to the specified Pub/Sub topic."
    
  2. Terapkan batasan:

    gcloud org-policies set-custom-constraint ~/notificationConfig_constraint.yaml
    
  3. Pastikan batasan ada:

    gcloud org-policies list-custom-constraints --organization=ORGANIZATION_ID
    --filter="RESOURCE_TYPES='securitycenter.googleapis.com/NotificationConfig'"
    

Membuat kebijakan

  1. Buat file YAML bernama notificationConfig_policy.yaml yang menentukan kebijakan organisasi:

     name: projects/PROJECT_ID/policies/custom.SccNotificationConfig
     spec:
       rules:
       - enforce: true
    
  2. Terapkan kebijakan:

    gcloud org-policies set-policy ~/notificationConfig_policy.yaml
    
  3. Pastikan kebijakan ada:

    gcloud org-policies list --organization=ORGANIZATION_ID
    --filter="constraint:custom.SccNotificationConfig"
    

Menguji kebijakan

Coba buat konfigurasi notifikasi yang melanggar kebijakan organisasi:

  gcloud scc notifications create NOTIFICATION_CONFIG_ID \
  --pubsub-topic=projects/PROJECT_ID/topics/example_topic \
  --project=PROJECT_ID  \
  --filter="state=\"ACTIVE\""

Outputnya adalah sebagai berikut:

  Operation denied by custom org policies:
  ["customConstraints/SccNotificationConfig": "Can't create or modify
  notification configs that are subscribed to the specified Pub/Sub
  topic."]

Contoh kebijakan organisasi kustom untuk kasus penggunaan umum

Tabel berikut memberikan sintaksis beberapa batasan kustom untuk kasus penggunaan umum:

Deskripsi Sintaksis batasan
Hanya izinkan pengguna membuat atau mengubah konfigurasi notifikasi yang berlangganan ke topik Pub/Sub tertentu.
      name: organizations/ORGANIZATION_ID/customConstraints/custom.SccNotificationConfig
      resourceTypes:
      - securitycenter.googleapis.com/NotificationConfig
      methodTypes:
      - CREATE
      - UPDATE
      condition: "resource.pubsubTopic != 'projects/PROJECT_ID/topics/TOPIC_ID'"
      actionType: DENY
      displayName: Only let users create or modify notification configs
        that are subscribed to a specific Pub/Sub topic.
      description: "Can't create or modify notification configs that are subscribed
      to the specified Pub/Sub topic."
      
Hanya mengizinkan pengguna mengekspor set data BigQuery tertentu.
      name: organizations/ORGANIZATION_ID/customConstraints/custom.SccBigQueryExport
      resourceTypes:
      - securitycenter.googleapis.com/BigQueryExport
      methodTypes:
      - CREATE
      - UPDATE
      condition: "resource.dataset != 'projects/PROJECT_ID/datasets/DATASET_ID'"
      actionType: DENY
      displayName: Only let users export a specific BigQuery dataset.
      description: "Can't export the specified BigQuery dataset."
      
Mencegah pengguna mengubah status pengaktifan layanan resource setelan Pendeteksian Ancaman Penampung. Kasus penggunaan ini juga berlaku untuk resource setelan Event Threat Detection, Security Health Analytics, Virtual Machine Threat Detection, dan Web Security Scanner.
      name: organizations/ORGANIZATION_ID/customConstraints/custom.SccKtdSettings
      resourceTypes:
      - securitycenter.googleapis.com/securitycenter.googleapis.com/ContainerThreatDetectionSettings
      methodTypes:
      - CREATE
      - UPDATE
      condition: "resource.serviceEnablementState != ENABLED"
      actionType: DENY
      displayName: Prevent users from changing the Container Threat Detection service
        enablement state.
      description: "Can't change the Container Threat Detection service enablement
        state."
      
Mencegah pengguna mengubah status pengaktifan resource modul kustom Security Health Analytics. Kasus penggunaan ini juga berlaku untuk resource modul kustom Event Threat Detection.
      name: organizations/ORGANIZATION_ID/customConstraints/custom.SccShaCustomModule
      resourceTypes:
      - securitycentermanagement.googleapis.com/SecurityHealthAnalyticsCustomModule
      methodTypes:
      - CREATE
      - UPDATE
      condition: "resource.serviceEnablementState != ENABLED"
      actionType: DENY
      displayName: Prevent users from changing the Security Health Analytics custom
        module enablement state.
      description: "Can't change the Security Health Analytics custom module enablement
        state."
      

Resource yang didukung Security Command Center

Tabel berikut mencantumkan resource Security Command Center yang dapat Anda referensikan dalam batasan kustom.

Resource Kolom
securitycenter.googleapis.com/BigQueryExport resource.dataset
resource.description
resource.name
securitycenter.googleapis.com/ContainerThreatDetectionSettings resource.modules
resource.name
resource.serviceEnablementState
securitycenter.googleapis.com/EventThreatDetectionSettings resource.modules
resource.name
resource.serviceEnablementState
securitycenter.googleapis.com/MuteConfig resource.description
resource.expiryTime
resource.name
resource.type
securitycenter.googleapis.com/NotificationConfig resource.description
resource.name
resource.pubsubTopic
securitycenter.googleapis.com/ResourceValueConfig resource.cloudProvider
resource.description
resource.name
resource.resourceLabelsSelector
resource.resourceType
resource.resourceValue
resource.scope
resource.tagValues
securitycenter.googleapis.com/SecurityHealthAnalyticsSettings resource.modules
resource.name
resource.serviceEnablementState
securitycenter.googleapis.com/VirtualMachineThreatDetectionSettings resource.modules
resource.name
resource.serviceEnablementState
securitycenter.googleapis.com/WebSecurityScannerSettings resource.modules
resource.name
resource.serviceEnablementState
securitycentermanagement.googleapis.com/EventThreatDetectionCustomModule resource.description
resource.displayName
resource.enablementState
resource.name
resource.type
securitycentermanagement.googleapis.com/SecurityCenterService resource.intendedEnablementState
resource.modules
resource.name
securitycentermanagement.googleapis.com/SecurityHealthAnalyticsCustomModule resource.customConfig.customOutput.properties.name
resource.customConfig.description
resource.customConfig.recommendation
resource.customConfig.resourceSelector.resourceTypes
resource.customConfig.severity
resource.displayName
resource.enablementState
resource.name

Langkah berikutnya