Mengonfigurasi kebijakan organisasi kustom

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

  • 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
  • websecurityscanner.googleapis.com/ScanConfig

Untuk mempelajari lebih lanjut Kebijakan Organisasi, 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 Google Cloud resource dan turunan dari resource tersebut dalam Google Cloud hierarki resource. Anda dapat menerapkan kebijakan organisasi di tingkat organisasi, folder, atau project.

Kebijakan Organisasi menyediakan batasan terkelola bawaan untuk berbagai layanan Google Cloud . Namun, jika menginginkan 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 di 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. If you're using an external identity provider (IdP), you must first sign in to the gcloud CLI with your federated identity.

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

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

    Go to project selector

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

  9. Install the Google Cloud CLI.

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

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

    gcloud init
  12. Pastikan Anda mengetahui ID organisasi Anda.
  13. Peran yang diperlukan

    Untuk mendapatkan izin yang diperlukan untuk 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 boleh menyertakan huruf besar, huruf kecil, atau angka. Contohnya, custom.SccNotificationConfig. Panjang maksimum kolom ini adalah 70 karakter.

    • RESOURCE_NAME: nama lengkap Google Cloud resource 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. Nilai yang mungkin 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 khusus Anda tersedia sebagai kebijakan organisasi dalam daftar kebijakan organisasi. Google Cloud 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 resource organisasi Anda. Untuk mengetahui informasi selengkapnya, lihat Melihat kebijakan organisasi.

    Menerapkan kebijakan organisasi kustom

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

    Konsol

    1. Di konsol Google Cloud , buka halaman Kebijakan organisasi.

      Buka Organization policies

    2. Dari pemilih project, pilih project yang ingin Anda tetapkan kebijakan organisasinya.
    3. Dari daftar di halaman Kebijakan organisasi, pilih batasan Anda untuk melihat halaman Detail kebijakan untuk batasan tersebut.
    4. Untuk mengonfigurasi kebijakan organisasi untuk resource ini, klik Manage policy.
    5. Di halaman Edit kebijakan, pilih Ganti kebijakan induk.
    6. Klik Add a rule.
    7. Di bagian Penerapan, pilih apakah penerapan kebijakan organisasi ini diaktifkan atau dinonaktifkan.
    8. Opsional: Untuk membuat kebijakan organisasi bersyarat pada tag, klik Tambahkan kondisi. 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. Klik Uji perubahan untuk menyimulasikan efek kebijakan organisasi. Simulasi kebijakan tidak tersedia untuk batasan terkelola lama. 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 dengan aturan boolean, buat file YAML kebijakan yang merujuk batasan:

          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 khusus:

       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 org:

      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 khusus untuk kasus penggunaan umum:

    Deskripsi Sintaksis batasan
    Hanya mengizinkan 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 Deteksi Ancaman Kontainer. Kasus penggunaan ini juga berlaku untuk sumber daya 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."
          
    Mencegah pengguna membuat atau mengubah konfigurasi pemindaian Web Security Scanner dengan batas QPS maksimum lebih dari 10.
          name: organizations/ORGANIZATION_ID/customConstraints/custom.WssScanConfig
          resourceTypes:
          - websecurityscanner.googleapis.com/ScanConfig
          methodTypes:
          - CREATE
          - UPDATE
          condition: "resource.maxQps > 10"
          actionType: DENY
          displayName: Only let users create or modify scan configs with a maximum
            QPS limit of 10 or less.
          description: "Can't create or modify scan configs that have a maximum QPS
            limit greater than 10."
          

    Resource yang didukung Security Command Center

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

    Resource Kolom
    securitycenter.googleapis.com/BigQueryExport resource.dataset
    resource.description
    resource.name
    securitycenter.googleapis.com/ContainerThreatDetectionSettings resource.modules[*].moduleEnablementState
    resource.name
    resource.serviceEnablementState
    securitycenter.googleapis.com/EventThreatDetectionSettings resource.modules[*].moduleEnablementState
    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[*].moduleEnablementState
    resource.name
    resource.serviceEnablementState
    securitycenter.googleapis.com/VirtualMachineThreatDetectionSettings resource.modules[*].moduleEnablementState
    resource.name
    resource.serviceEnablementState
    securitycenter.googleapis.com/WebSecurityScannerSettings resource.modules[*].moduleEnablementState
    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[*].intendedEnablementState
    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
    websecurityscanner.googleapis.com/ScanConfig resource.authentication.customAccount.loginUrl
    resource.authentication.customAccount.password
    resource.authentication.customAccount.username
    resource.authentication.googleAccount.password
    resource.authentication.googleAccount.username
    resource.authentication.iapCredential.iapTestServiceAccountInfo.targetAudienceClientId
    resource.blacklistPatterns
    resource.displayName
    resource.exportToSecurityCommandCenter
    resource.ignoreHttpStatusErrors
    resource.managedScan
    resource.maxQps
    resource.name
    resource.riskLevel
    resource.schedule.intervalDurationDays
    resource.schedule.scheduleTime
    resource.startingUrls
    resource.staticIpScan
    resource.targetPlatforms
    resource.userAgent

    Langkah berikutnya