Mengelola aturan penonaktifan

Dokumen ini menjelaskan cara membuat dan mengelola aturan nonaktif untuk secara otomatis menonaktifkan temuan di Security Command Center.

Peran yang diperlukan

Untuk mendapatkan izin yang Anda perlukan untuk mengelola aturan senyap, minta administrator untuk memberi Anda peran IAM berikut pada organisasi, folder, atau project:

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.

Membuat aturan penonaktifan

Organisasi Anda dapat membuat maksimal 1.000 aturan senyap.

Sebaiknya gunakan aturan penonaktifan dinamis secara eksklusif dalam konfigurasi aturan penonaktifan Anda, karena lebih fleksibel daripada aturan penonaktifan statis. Untuk perbandingan jenis aturan penonaktifan, lihat Jenis aturan penonaktifan.

Untuk membuat aturan senyap, klik tab untuk prosedur yang ingin Anda gunakan:

Konsol

Tentukan aturan penonaktifan

  1. Di konsol Google Cloud , buka halaman Temuan.

    Buka Temuan

  2. Pilih organisasi atau project.

  3. Klik Opsi senyapkan, lalu pilih Kelola aturan senyapkan.

  4. Klik Buat aturan senyap.

  5. Masukkan ID aturan Penonaktifan.

  6. Direkomendasikan: Masukkan Deskripsi yang memberikan konteks tentang alasan temuan dibisukan.

  7. Untuk mengonfirmasi cakupan aturan penonaktifan, periksa nilai Resource induk.

Opsional: Tambahkan tanggal habis masa berlaku

Anda dapat menambahkan tanggal habis masa berlaku ke aturan senyap dinamis.

  1. Pilih Bisukan temuan yang cocok untuk sementara.
  2. Untuk mengonfigurasi tanggal habis masa berlaku untuk aturan penonaktifan dinamis, pilih kalender, lalu pilih tanggal dan waktu minimal 24 jam ke depan.

    Setelah tanggal habis masa berlaku, aturan penonaktifan tidak akan berpengaruh.

Opsional: Batasi aturan penonaktifan dengan kueri

Jika Anda menambahkan kueri, aturan penonaktifan hanya berlaku untuk temuan yang cocok dengan kueri.

Untuk membatasi aturan penonaktifan dengan kueri, di bagian Kueri temuan, klik Tambahkan filter.

Menu Tambahkan filter memungkinkan Anda memilih atribut dan nilai temuan yang didukung.

  1. Di menu Pilih filter, pilih atribut temuan atau ketik namanya di kotak Telusuri atribut temuan. Daftar sub-atribut yang tersedia akan ditampilkan.
  2. Pilih sub-atribut. Kolom pilihan akan ditampilkan tempat Anda dapat membuat pernyataan kueri menggunakan sub-atribut yang Anda pilih, operator kueri, dan satu atau beberapa nilai untuk sub-atribut.
  3. Pilih operator dan satu atau beberapa nilai untuk sub-atribut dari panel. Untuk mengetahui informasi selengkapnya tentang operator kueri dan fungsi yang digunakannya, lihat Operator kueri di menu Tambahkan filter.

    Jika Anda ingin memulai ulang, klik Setel ulang.

  4. Klik Terapkan.

    Menu akan ditutup dan kueri Anda diperbarui.

  5. Ulangi hingga kueri temuan berisi semua atribut yang Anda inginkan.
Untuk memeriksa hasil kueri, klik Pratinjau temuan yang cocok. Tabel mencantumkan temuan yang cocok dengan kueri Anda.

Jika kueri tidak cocok dengan temuan yang benar, revisi kueri sesuai kebutuhan dan pratinjau temuan lagi. Ulangi langkah ini hingga Anda puas dengan hasilnya.

Simpan aturan penonaktifan

Klik Simpan. Konsol Google Cloud menampilkan daftar aturan senyap Anda.

gcloud

  1. Di konsol Google Cloud , aktifkan Cloud Shell.

    Aktifkan Cloud Shell

    Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

  2. Untuk membuat aturan senyap, jalankan perintah gcloud scc muteconfigs create:

    gcloud scc muteconfigs create CONFIG_ID \
      --PARENT=PARENT_ID \
      --location=LOCATION \
      --description="RULE_DESCRIPTION" \
      --filter="FILTER" \
      --type=MUTE_TYPE \
      --expiry-time=TIMESTAMP

    Ganti kode berikut:

    • CONFIG_ID: nama aturan senyap. ID harus menggunakan karakter alfanumerik dan tanda hubung, serta terdiri dari 1 hingga 63 karakter.
    • PARENT: cakupan dalam hierarki resource tempat aturan penonaktifan diterapkan, organization, folder, atau project.
    • PARENT_ID: ID numerik organisasi, folder, atau project induk, atau ID alfanumerik project induk.
    • LOCATION: Security Command Center location tempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global.
    • RULE_DESCRIPTION: deskripsi aturan senyap tidak lebih dari 1.024 karakter.
    • FILTER: ekspresi yang Anda tentukan untuk memfilter temuan. Misalnya, untuk membisukan temuan OPEN_FIREWALL, filter Anda dapat berupa FILTER="category=\"OPEN_FIREWALL\"".
    • MUTE_TYPE: jenis aturan penonaktifan yang ingin Anda buat. Jenis aturan penonaktifan yang valid adalah DYNAMIC dan STATIC. Jenis aturan penonaktifan ditetapkan ke STATIC secara default. Anda tidak dapat mengubah jenis aturan penonaktifan setelah membuatnya.
    • TIMESTAMP: hanya berlaku jika Anda membuat aturan penonaktifan dinamis. String tanggal dan waktu yang menunjukkan kapan aturan penonaktifan dinamis berakhir. Nilai harus ditetapkan ke setidaknya satu hari di masa mendatang atau permintaan akan ditolak. Untuk informasi tentang format waktu, lihat gcloud topic datetimes. Jika masa berlaku aturan bisu dinamis berakhir, aturan tersebut akan dihapus dari semua temuan yang cocok. Untuk membuat aturan penonaktifan dinamis berlaku tanpa batas waktu pada temuan yang cocok, hapus kolom ini.

    Respons mencakup ID aturan penonaktifan, yang dapat Anda gunakan untuk melihat, memperbarui, dan menghapus aturan penonaktifan, seperti yang dijelaskan dalam Mengelola aturan penonaktifan.

Terraform

Membuat aturan penonaktifan untuk organisasi:

resource "google_scc_v2_organization_mute_config" "default" {
  mute_config_id    = "my-config"
  organization = "123456789"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Organization mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

Membuat aturan penonaktifan untuk folder:

resource "google_folder" "folder" {
  parent       = "organizations/123456789"
  display_name = "folder-name"
}

resource "google_scc_v2_folder_mute_config" "default" {
  mute_config_id    = "my-config"
  folder = google_folder.folder.folder_id
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Folder mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

Membuat aturan penonaktifan untuk project:

resource "google_scc_v2_project_mute_config" "default" {
  mute_config_id    = "my-config"
  project = "my-project-name"
  location     = "global"
  description  = "My custom Cloud Security Command Center Finding Project mute Configuration"
  filter = "severity = \"HIGH\""
  type = "STATIC"
}

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
)

// createMuteRule: Creates a mute configuration under a given scope that will mute
// all new findings that match a given filter.
// Existing findings will not be muted.
func createMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// parent: Use any one of the following options:
	//             - organizations/{organization_id}
	//             - folders/{folder_id}
	//             - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	// muteConfigId: Set a random id; max of 63 chars.
	// muteConfigId := "random-mute-id-" + uuid.New().String()
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	muteConfig := &securitycenterpb.MuteConfig{
		Description: "Mute low-medium IAM grants excluding 'compute' ",
		// Set mute rule(s).
		// To construct mute rules and for supported properties, see:
		// https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
		Filter: "severity=\"LOW\" OR severity=\"MEDIUM\" AND " +
			"category=\"Persistence: IAM Anomalous Grant\" AND " +
			"-resource.type:\"compute\"",
		Type: securitycenterpb.MuteConfig_STATIC,
	}

	req := &securitycenterpb.CreateMuteConfigRequest{
		Parent:       parent,
		MuteConfigId: muteConfigId,
		MuteConfig:   muteConfig,
	}

	response, err := client.CreateMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("failed to create mute rule: %w", err)
	}
	fmt.Fprintf(w, "Mute rule created successfully: %s", response.Name)
	return nil
}

Java


import com.google.cloud.securitycenter.v2.LocationName;
import com.google.cloud.securitycenter.v2.MuteConfig;
import com.google.cloud.securitycenter.v2.MuteConfig.MuteConfigType;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;
import java.util.UUID;

public class CreateMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the following variables.
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config.
    String location = "global";

    // muteConfigId: Set a random id; max of 63 chars.
    String muteConfigId = "random-mute-id-" + UUID.randomUUID();

    createMuteRule(projectId, location, muteConfigId);
  }

  // Creates a mute configuration in a project under a given location.
  public static void createMuteRule(String projectId, String location, String muteConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      MuteConfig muteConfig =
          MuteConfig.newBuilder()
              .setDescription("Mute low-medium IAM grants excluding 'compute' ")
              // Set mute rule(s).
              // To construct mute rules and for supported properties, see:
              // https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
              .setFilter(
                  "severity=\"LOW\" OR severity=\"MEDIUM\" AND "
                      + "category=\"Persistence: IAM Anomalous Grant\" AND "
                      + "-resource.type:\"compute\"")
              .setType(MuteConfigType.STATIC)
              .build();

      // You can also create mute rules in an organization/ folder.
      // Construct the parameters according to the parent resource.
      //  * Organization -> client.createMuteConfig(OrganizationLocationName.of(...
      //  * Folder -> client.createMuteConfig(FolderLocationName.of(...
      MuteConfig response = client.createMuteConfig(
          LocationName.of(projectId, location), muteConfig, muteConfigId);
      System.out.println("Mute rule created successfully: " + response.getName());
    }
  }
}

Python

def create_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    Creates a mute configuration under a given scope that will mute
    all new findings that match a given filter.
    Existing findings will NOT BE muted.
    Args:
        parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
        Dict: returns the mute rule details
    """

    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    mute_config = securitycenter_v2.MuteConfig()
    mute_config.description = "Mute low-medium IAM grants excluding 'compute' "
    # Set mute rule(s).
    # To construct mute rules and for supported properties, see:
    # https://cloud.google.com/security-command-center/docs/how-to-mute-findings#create_mute_rules
    mute_config.filter = (
        'severity="LOW" OR severity="MEDIUM" AND '
        'category="Persistence: IAM Anomalous Grant" AND '
        '-resource.type:"compute"'
    )
    mute_config.type = "STATIC"

    request = securitycenter_v2.CreateMuteConfigRequest()
    request.parent = parent_path + "/locations/" + location_id
    request.mute_config_id = mute_config_id
    request.mute_config = mute_config

    mute_config = client.create_mute_config(request=request)
    print(f"Mute rule created successfully: {mute_config.name}")
    return mute_config

REST

Di Security Command Center API, gunakan metode muteConfigs.create untuk membuat aturan penonaktifan. Isi permintaan adalah instance MuteConfig:

POST https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs?muteConfigId=MUTE_CONFIG_ID -d

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
    "type": "MUTE_TYPE",
    "expiryTime": "TIMESTAMP"
  }

Ganti kode berikut:

  • PARENT: resource induk untuk aturan penonaktifan Anda (organizations, folders, atau projects)
  • PARENT_ID: ID organisasi induk, folder, atau project
  • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global
  • MUTE_CONFIG_ID: nama aturan penonaktifan (antara 1 dan 63 karakter)
  • RULE_DESCRIPTION: deskripsi aturan senyap (maks: 1.024 karakter)
  • FILTER: ekspresi yang Anda tentukan untuk memfilter temuan

    Misalnya, untuk membisukan temuan OPEN_FIREWALL, filter Anda dapat berupa "category=\"OPEN_FIREWALL\"".

  • MUTE_TYPE: jenis aturan penonaktifan yang ingin Anda buat. Jenis aturan penonaktifan yang valid adalah DYNAMIC dan STATIC. Anda tidak dapat mengubah jenis aturan penonaktifan setelah Anda membuatnya.

  • TIMESTAMP: hanya berlaku jika Anda membuat aturan penonaktifan dinamis. String tanggal dan waktu yang menunjukkan kapan aturan penonaktifan dinamis berakhir. Nilai harus ditetapkan ke setidaknya satu hari di masa mendatang atau permintaan akan ditolak. Untuk informasi tentang format waktu, lihat gcloud topic datetimes. Jika masa berlaku aturan bisu dinamis berakhir, aturan tersebut akan dihapus dari semua temuan yang cocok. Jika Anda ingin aturan penonaktifan dinamis berlaku tanpa batas pada temuan yang cocok, jangan isi kolom ini.

Respons mencakup ID konfigurasi senyap, yang dapat Anda gunakan untuk melihat, memperbarui, dan menghapus aturan senyap, seperti yang dijelaskan dalam Mengelola aturan senyap.

Temuan baru yang cocok persis dengan filter disembunyikan, dan atribut mute untuk temuan ditetapkan ke MUTED.

Properti temuan yang tidak didukung untuk aturan penonaktifan

Aturan nonaktif tidak mendukung semua properti temuan dalam filter. Luaskan bagian berikut untuk melihat daftar properti yang tidak didukung dalam filter aturan penonaktifan.

Properti temuan yang tidak didukung

  • caiResource
  • canonicalName
  • createTime
  • description
  • eventTime
  • externalUri
  • gcpMetadata.folders1
  • libraryPaths
  • mute
  • muteAnnotation
  • muteInfo
  • muteInitiator
  • muteUpdateTime
  • name
  • nextSteps
  • originalProviderId
  • parent
  • processes.binaryPath
  • processes.libraryPaths
  • propertyDataTypes
  • resource.tags
  • resourceName
  • securityMarks
  • sourceProperties
  • state
  • workflowState
  • 1Properti gcpMetadata.folders berisi sub-kolom yang didukung dalam filter senyap.

Mencantumkan aturan penonaktifan

Anda dapat mencantumkan aturan nonaktif di organisasi, folder, atau project menggunakan Google Cloud konsol, gcloud CLI, atau Security Command Center API.

Kemampuan Anda untuk mencantumkan aturan senyap untuk cakupan tertentu bergantung pada izin yang diberikan ke peran IAM Anda.

Jika residensi data diaktifkan untuk Security Command Center, cakupan perintah list juga dibatasi ke lokasi Security Command Center yang dipilih.

Untuk kode contoh yang mencantumkan aturan penonaktifan, lihat Mencantumkan aturan penonaktifan.

Untuk mencantumkan aturan nonaktif untuk organisasi, folder, atau project, klik tab untuk prosedur yang ingin Anda gunakan:

Konsol

  1. Di konsol Google Cloud , buka tab Aturan nonaktif di halaman Setelan Security Command Center.

    Buka Aturan penonaktifan

  2. Jika perlu, pilih Google Cloud project atau organisasi Anda.

  3. Di bagian Aturan senyap, Anda akan melihat detail untuk aturan senyap yang aktif, termasuk:

    • Nama: ID aturan penonaktifan
    • Resource induk: resource tempat aturan penonaktifan berada
    • Description: deskripsi aturan penonaktifan, jika tersedia
    • Terakhir diperbarui oleh: kepala sekolah yang terakhir memperbarui aturan
    • Terakhir diperbarui: tanggal dan waktu aturan terakhir diperbarui

gcloud

  1. Di konsol Google Cloud , aktifkan Cloud Shell.

    Aktifkan Cloud Shell

    Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

  2. Untuk mencantumkan aturan senyap, jalankan perintah gcloud scc muteconfigs list:

    gcloud scc muteconfigs list --PARENT=PARENT_ID \
      --location=LOCATION

    Ganti kode berikut:

    • PARENT: organization, folder, atau project induk yang akan mencantumkan aturan senyapkan
    • PARENT_ID: ID organisasi induk, folder, atau project
    • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global

Go

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
	"google.golang.org/api/iterator"
)

// listMuteRules lists mute configs at the organization level will return all the configs
// at the org, folder, and project levels.
// Similarly, listing configs at folder level will list all the configs
// at the folder and project levels.
func listMuteRules(w io.Writer, parent string) error {
	// Use any one of the following resource paths to list mute configurations:
	//         - organizations/{organization_id}
	//         - folders/{folder_id}
	//         - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.ListMuteConfigsRequest{Parent: parent}

	// List all mute configs present in the resource.
	it := client.ListMuteConfigs(ctx, req)
	for {
		muteconfig, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			return fmt.Errorf("it.Next: %w", err)
		}
		fmt.Fprintf(w, "Muteconfig Name: %s, ", muteconfig.Name)
	}
	return nil
}

Java


import com.google.cloud.securitycenter.v2.ListMuteConfigsRequest;
import com.google.cloud.securitycenter.v2.MuteConfig;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;

public class ListMuteRules {

  public static void main(String[] args) throws IOException {
    // TODO: Replace variables enclosed within {}
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location to list mute configs.
    String location = "global";

    listMuteRules(projectId, location);
  }

  // Lists all mute rules present under the resource type in the given location.
  public static void listMuteRules(String projectId, String location) throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {

      // Parent can also be one of:
      //  * "organizations/{org_id}/locations/{location}"
      //  * "folders/{folder_id}/locations/{location}"
      ListMuteConfigsRequest listMuteConfigsRequest = ListMuteConfigsRequest.newBuilder()
          .setParent(String.format("projects/%s/locations/%s", projectId, location))
          .build();

      // List all mute configs present in the resource.
      for (MuteConfig muteConfig : client.listMuteConfigs(listMuteConfigsRequest).iterateAll()) {
        System.out.println(muteConfig.getName());
      }
    }
  }
}

Python

def list_mute_rules(parent: str, location_id: str) -> Dict:
    """
    Listing mute configs at organization level will return all the configs
    at the org, folder and project levels.
    Similarly, listing configs at folder level will list all the configs
    at the folder and project levels.
    Args:
        parent: Use any one of the following resource paths to list mute configurations:
                - organizations/{organization_id}
                - folders/{folder_id}
                - projects/{project_id}
        location_id: Gcp location id; example: 'global'
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.ListMuteConfigsRequest()
    request.parent = parent + "/locations/" + location_id
    response = client.list_mute_configs(request)
    # List all Mute Configs present in the resource.
    for mute_config in response:
        print(mute_config.name)
    return response

REST

Di Security Command Center API, gunakan metode muteConfigs.list untuk mencantumkan aturan nonaktif:

GET https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs

Ganti kode berikut:

  • PARENT: resource induk untuk aturan penonaktifan Anda (organizations, folders, atau projects)
  • PARENT_ID: ID organisasi induk, folder, atau project
  • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global

Respons mencakup nama, deskripsi, dan ID konfigurasi penonaktifan untuk aturan penonaktifan Anda.

Melihat konfigurasi aturan penonaktifan

Anda dapat melihat konfigurasi aturan penonaktifan menggunakan konsol Google Cloud , gcloud CLI, atau Security Command Center API.

Untuk kode contoh yang mengambil konfigurasi aturan penonaktifan, lihat Melihat aturan penonaktifan.

Untuk melihat konfigurasi aturan penonaktifan, klik tab untuk prosedur yang ingin Anda gunakan:

Konsol

  1. Di konsol Google Cloud , buka tab Aturan nonaktif di halaman Setelan Security Command Center.

    Buka Aturan penonaktifan

  2. Jika perlu, pilih Google Cloud project atau organisasi Anda.

  3. Di bagian Aturan penonaktifan, Anda akan melihat daftar aturan penonaktifan.

  4. Klik nama aturan yang ingin Anda lihat.

    Halaman akan terbuka dengan konfigurasi aturan senyapkan.

gcloud

  1. Di konsol Google Cloud , aktifkan Cloud Shell.

    Aktifkan Cloud Shell

    Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

  2. Untuk melihat konfigurasi aturan penonaktifan, jalankan perintah gcloud scc muteconfigs get:

    gcloud scc muteconfigs get MUTE_CONFIG_ID \
      --PARENT=PARENT_ID --location=LOCATION

    Ganti kode berikut:

    • MUTE_CONFIG_ID: ID untuk aturan penonaktifan
    • PARENT: resource induk untuk aturan penonaktifan Anda (organization, folder, atau project)
    • PARENT_ID: ID organisasi, folder, atau project
    • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global

Go

import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
)

// getMuteRule retrieves a mute configuration given its resource name.
func getMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// Use any one of the following resource paths to get mute configuration:
	//         - organizations/{organization_id}
	//         - folders/{folder_id}
	//         - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	//
	// Name of the mute config to retrieve.
	// muteConfigId := "mute-config-id"
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.GetMuteConfigRequest{
		Name: fmt.Sprintf("%s/muteConfigs/%s", parent, muteConfigId),
	}

	muteconfig, err := client.GetMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("Failed to retrieve Muteconfig: %w", err)
	}
	fmt.Fprintf(w, "Muteconfig Name: %s ", muteconfig.Name)
	return nil
}

Java


import com.google.cloud.securitycenter.v2.MuteConfig;
import com.google.cloud.securitycenter.v2.MuteConfigName;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;

public class GetMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO(Developer): Replace the following variables
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

    // muteConfigId: Name of the mute config to retrieve.
    String muteConfigId = "mute-config-id";

    getMuteRule(projectId, location, muteConfigId);
  }

  // Retrieves a mute configuration given its resource name.
  public static MuteConfig getMuteRule(String projectId, String location, String muteConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Use appropriate `MuteConfigName` methods depending on the parent type.
      //  * organization -> MuteConfigName.ofOrganizationLocationMuteConfigName()
      //  * folder -> MuteConfigName.ofFolderLocationMuteConfigName()

      MuteConfigName muteConfigName = MuteConfigName.ofProjectLocationMuteConfigName(projectId,
          location, muteConfigId);
      return client.getMuteConfig(muteConfigName);
    }
  }
}

Python

def get_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    Retrieves a mute configuration given its resource name.
    Args:
        parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.GetMuteConfigRequest()
    request.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )

    mute_config = client.get_mute_config(request)
    print(f"Retrieved the mute rule: {mute_config.name}")
    return mute_config

REST

Di Security Command Center API, gunakan metode muteConfigs.get untuk menampilkan konfigurasi aturan penonaktifan:

GET https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

Ganti kode berikut:

  • PARENT: resource induk untuk aturan penonaktifan Anda (organizations, folders, atau projects)
  • PARENT_ID: ID untuk organisasi, folder, atau project
  • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global
  • CONFIG_ID: ID numerik aturan penonaktifan

Memperbarui aturan penonaktifan

Anda dapat memperbarui deskripsi atau filter temuan aturan penonaktifan menggunakan konsol Google Cloud , gcloud CLI, atau Security Command Center API.

Anda tidak dapat mengubah ID; organisasi, folder, atau project induk; atau lokasi aturan penonaktifan. Untuk mengubah salah satu nilai ini, Anda harus membuat aturan penonaktifan baru.

Jika sebelumnya Anda mengaktifkan temuan, temuan tersebut akan dinonaktifkan kembali jika cocok melalui aturan penonaktifan yang diperbarui di konsol Google Cloud . Untuk mengetahui informasi selengkapnya, lihat Membatalkan bisu temuan individual.

Untuk kode contoh yang memperbarui aturan penonaktifan, lihat Memperbarui aturan penonaktifan.

Untuk memperbarui aturan penonaktifan, klik tab untuk prosedur yang ingin Anda gunakan:

Konsol

  1. Di konsol Google Cloud , buka tab Aturan nonaktif di halaman Setelan Security Command Center.

    Buka Aturan penonaktifan

  2. Pilih Google Cloud project atau organisasi yang merupakan resource induk untuk aturan penonaktifan yang ingin Anda ubah.

  3. Klik nama aturan penonaktifan yang ingin Anda ubah.

    Jika Anda tidak memilih project atau organisasi yang sesuai, Anda mungkin melihat catatan yang memberi tahu Anda bahwa Anda tidak memiliki izin untuk mengubah aturan senyapkan.

  4. Buat perubahan pada aturan penonaktifan.

  5. Opsional: Setelah memperbarui filter, klik Pratinjau Temuan yang Cocok untuk melihat temuan yang cocok dengan filter yang diperbarui. Tabel dimuat dengan temuan yang cocok dengan kueri baru.

  6. Klik Simpan.

gcloud

  1. Di konsol Google Cloud , aktifkan Cloud Shell.

    Aktifkan Cloud Shell

    Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

  2. Untuk memperbarui aturan senyap, jalankan perintah gcloud scc muteconfigs update:

    gcloud scc muteconfigs update MUTE_CONFIG_ID \
        --PARENT=PARENT_ID \
        --location=LOCATION \
        --description=RULE_DESCRIPTION \
        --filter=FILTER \
        --type=MUTE_TYPE \
        --expiry-time=TIMESTAMP
    

    Ganti kode berikut:

    • MUTE_CONFIG_ID: ID untuk aturan penonaktifan.
    • PARENT: resource induk untuk aturan penonaktifan Anda (organization, folder, atau project).
    • PARENT_ID: ID untuk organisasi, folder, atau project.
    • LOCATION: Security Command Center location tempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global.
    • RULE_DESCRIPTION: deskripsi aturan senyapkan (maks: 1.024 karakter).
    • FILTER: ekspresi yang Anda tentukan untuk memfilter temuan.

      Misalnya, untuk membisukan temuan OPEN_FIREWALL, filter Anda dapat berupa FILTER="category=\"OPEN_FIREWALL\"".

    • MUTE_TYPE: jenis aturan penonaktifan yang Anda perbarui. Jenis aturan penonaktifan yang valid adalah DYNAMIC dan STATIC. Anda tidak dapat mengubah jenis aturan penonaktifan setelah dibuat.

    • TIMESTAMP: hanya berlaku jika Anda memperbarui aturan penonaktifan dinamis. String tanggal dan waktu yang menunjukkan kapan aturan penonaktifan dinamis berakhir. Nilai harus ditetapkan ke setidaknya satu hari di masa mendatang atau permintaan akan ditolak. Untuk mengetahui informasi tentang format waktu, lihat gcloud topic datetimes. Jika masa berlaku aturan bisu dinamis berakhir, aturan tersebut akan dihapus dari semua temuan yang cocok. Jika Anda ingin aturan penonaktifan dinamis berlaku tanpa batas pada temuan yang cocok, jangan isi kolom ini.

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
	"google.golang.org/protobuf/types/known/fieldmaskpb"
)

// updateMuteRule Updates an existing mute configuration.
// The following can be updated in a mute config: description and filter.
func updateMuteRule(w io.Writer, muteConfigName string) error {
	// Specify the name of the mute config to delete.
	// muteConfigName: Use any one of the following formats:
	//                 - organizations/{organization}/muteConfigs/{config_id}
	//                 - folders/{folder}/muteConfigs/{config_id}
	//                 - projects/{project}/muteConfigs/{config_id}
	// muteConfigName := fmt.Sprintf("projects/%s/muteConfigs/%s", "project-id", "mute-config")
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	updateMuteConfig := &securitycenterpb.MuteConfig{
		Name:        muteConfigName,
		Description: "Updated mute config description",
	}

	req := &securitycenterpb.UpdateMuteConfigRequest{
		MuteConfig: updateMuteConfig,
		// Set the update mask to specify which properties of the mute config should be
		// updated.
		// If empty, all mutable fields will be updated.
		// Make sure that the mask fields match the properties changed in 'updateMuteConfig'.
		// For more info on constructing update mask path, see the proto or:
		// https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters
		UpdateMask: &fieldmaskpb.FieldMask{
			Paths: []string{
				"description",
			},
		},
	}

	response, err := client.UpdateMuteConfig(ctx, req)
	if err != nil {
		return fmt.Errorf("mute rule update failed! %w", err)
	}
	fmt.Fprintf(w, "Mute rule updated %s", response.Name)
	return nil
}

Java


import com.google.cloud.securitycenter.v2.MuteConfig;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import com.google.cloud.securitycenter.v2.UpdateMuteConfigRequest;
import com.google.protobuf.FieldMask;
import java.io.IOException;

public class UpdateMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO: Replace the variables within {}
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config to update. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

    // muteConfigId: Name of the mute config to update.
    String muteConfigId = "mute-config-id";

    updateMuteRule(projectId, location, muteConfigId);
  }

  // Updates an existing mute configuration.
  // The following can be updated in a mute config: description and filter.
  public static void updateMuteRule(String projectId, String location, String muteConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (SecurityCenterClient securityCenterClient = SecurityCenterClient.create()) {

      MuteConfig updateMuteConfig =
          MuteConfig.newBuilder()
              // Construct the name according to the parent type of the mute rule.
              // Parent can also be one of:
              //  * "organizations/{org_id}/locations/{location}/muteConfigs/{muteConfig_id}"
              //  * "folders/{folder_id}/locations/{location}/muteConfigs/{muteConfig_id}"
              .setName(String.format("projects/%s/locations/%s/muteConfigs/%s", projectId, location,
                  muteConfigId))
              .setDescription("Updated mute config description")
              .build();

      UpdateMuteConfigRequest updateMuteConfigRequest =
          UpdateMuteConfigRequest.newBuilder()
              .setMuteConfig(updateMuteConfig)
              // Make sure that the mask fields match the properties changed in
              // 'updateMuteConfig' object.
              // For more info on constructing update mask path, see the proto or:
              // https://cloud.google.com/security-command-center/docs/reference/rest/v2/folders.muteConfigs/patch?hl=en#query-parameters
              .setUpdateMask(FieldMask.newBuilder().addPaths("description").build())
              .build();

      MuteConfig response = securityCenterClient.updateMuteConfig(updateMuteConfigRequest);
      System.out.println(response);
    }
  }
}

Python

def update_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> Dict:
    """
    Updates an existing mute configuration.
    The following can be updated in a mute config: description, and filter/ mute rule.
    Args:
        parent: Use any one of the following resource paths to list mute configurations:
                - organizations/{organization_id}
                - folders/{folder_id}
                - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         Dict: returns the mute rule details
    """
    from google.cloud import securitycenter_v2
    from google.protobuf import field_mask_pb2

    client = securitycenter_v2.SecurityCenterClient()

    update_mute_config = securitycenter_v2.MuteConfig()
    update_mute_config.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )
    update_mute_config.description = "Updated mute config description"

    field_mask = field_mask_pb2.FieldMask(paths=["description"])

    request = securitycenter_v2.UpdateMuteConfigRequest()
    request.mute_config = update_mute_config
    # Set the update mask to specify which properties of the Mute Config should be updated.
    # If empty, all mutable fields will be updated.
    # Make sure that the mask fields match the properties changed in 'update_mute_config'.
    # For more info on constructing update mask path, see the proto or:
    # https://cloud.google.com/security-command-center/docs/reference/rest/v1/folders.muteConfigs/patch?hl=en#query-parameters
    request.update_mask = field_mask

    mute_config = client.update_mute_config(request)
    print(f"Updated mute rule : {mute_config}")
    return mute_config

REST

Di Security Command Center API, gunakan metode muteConfigs.patch untuk memperbarui aturan penonaktifan. Isi permintaan adalah instance MuteConfig:

PATCH https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

  {
    "description": "RULE_DESCRIPTION",
    "filter": "FILTER",
    "type": "MUTE_TYPE",
    "expiryTime": "TIMESTAMP"
  }

Ganti kode berikut:

  • PARENT: resource induk untuk aturan penonaktifan Anda (organizations, folders, atau projects)
  • PARENT_ID: ID untuk organisasi, folder, atau project
  • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global
  • CONFIG_ID: ID numerik aturan penonaktifan
  • RULE_DESCRIPTION: deskripsi aturan senyap (maks: 1.024 karakter)
  • FILTER: ekspresi yang Anda tentukan untuk memfilter temuan
  • MUTE_TYPE: jenis aturan penonaktifan yang Anda perbarui. Jenis aturan penonaktifan yang valid adalah DYNAMIC dan STATIC. Anda tidak dapat mengubah jenis aturan penonaktifan setelah dibuat.
  • TIMESTAMP: hanya berlaku jika Anda memperbarui aturan penonaktifan dinamis. String tanggal dan waktu yang menunjukkan kapan aturan penonaktifan dinamis berakhir. Nilai harus ditetapkan ke setidaknya satu hari di masa mendatang atau permintaan akan ditolak. Untuk mengetahui informasi tentang format waktu, lihat gcloud topic datetimes. Jika masa berlaku aturan bisu dinamis berakhir, aturan tersebut akan dihapus dari semua temuan yang cocok. Jika Anda ingin aturan penonaktifan dinamis berlaku tanpa batas pada temuan yang cocok, jangan isi kolom ini.

Menghapus aturan penonaktifan

Anda dapat menghapus aturan penonaktifan menggunakan konsol Google Cloud , gcloud CLI, atau Security Command Center API.

Sebelum menghapus aturan senyap, pahami hal berikut:

  • Anda tidak dapat memulihkan aturan senyap yang dihapus.
  • Menghapus aturan penonaktifan statis tidak akan otomatis mengaktifkan kembali temuan yang dinonaktifkan. Anda harus membatalkan bisu temuan secara manual atau terprogram.
  • Menghapus aturan senyap dinamis akan otomatis menghapus aturan dari semua temuan yang sebelumnya cocok dan mengaktifkan suaranya jika tidak cocok dengan aturan tambahan apa pun.
  • Temuan mendatang yang cocok dengan filter dalam aturan senyap yang dihapus tidak akan disenyapkan.

Untuk kode contoh yang menghapus aturan penonaktifan, lihat Menghapus aturan penonaktifan.

Untuk menghapus aturan senyap, klik tab untuk prosedur yang ingin Anda gunakan:

Konsol

  1. Di konsol Google Cloud , buka tab Aturan nonaktif di halaman Setelan Security Command Center.

    Buka Aturan penonaktifan

  2. Jika perlu, pilih Google Cloud project atau organisasi Anda.

  3. Klik nama aturan penonaktifan yang ingin Anda hapus.

  4. Klik Delete.

  5. Baca dialognya dan, jika sudah yakin, klik Hapus.

gcloud

  1. Di konsol Google Cloud , aktifkan Cloud Shell.

    Aktifkan Cloud Shell

    Di bagian bawah konsol Google Cloud , sesi Cloud Shell akan dimulai dan menampilkan perintah command line. Cloud Shell adalah lingkungan shell dengan Google Cloud CLI yang sudah terinstal, dan dengan nilai yang sudah ditetapkan untuk project Anda saat ini. Diperlukan waktu beberapa detik untuk melakukan inisialisasi pada sesi.

  2. Untuk menghapus aturan senyap, jalankan perintah gcloud scc muteconfigs delete:

    gcloud scc muteconfigs delete MUTE_CONFIG_ID \
      --PARENT=PARENT_ID --location=LOCATION

    Ganti kode berikut:

    • MUTE_CONFIG_ID: ID untuk konfigurasi senyap
    • PARENT: resource induk untuk aturan penonaktifan Anda (organization, folder, atau project)
    • PARENT_ID: ID untuk organisasi, folder, atau project
    • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global
  3. Konfirmasi permintaan Anda untuk menghapus aturan penonaktifan.

Go


import (
	"context"
	"fmt"
	"io"

	securitycenter "cloud.google.com/go/securitycenter/apiv2"
	"cloud.google.com/go/securitycenter/apiv2/securitycenterpb"
)

// deleteMuteRule deletes a mute configuration given its resource name.
// Note: Previously muted findings are not affected when a mute config is deleted.
func deleteMuteRule(w io.Writer, parent string, muteConfigId string) error {
	// parent: Use any one of the following options:
	//             - organizations/{organization_id}
	//             - folders/{folder_id}
	//             - projects/{project_id}
	// parent := fmt.Sprintf("projects/%s", "your-google-cloud-project-id")
	//
	// muteConfigId: Specify the name of the mute config to delete.
	// muteConfigId := "mute-config-id"
	ctx := context.Background()
	client, err := securitycenter.NewClient(ctx)
	if err != nil {
		return fmt.Errorf("securitycenter.NewClient: %w", err)
	}
	defer client.Close()

	req := &securitycenterpb.DeleteMuteConfigRequest{
		Name: fmt.Sprintf("%s/muteConfigs/%s", parent, muteConfigId),
	}

	if err := client.DeleteMuteConfig(ctx, req); err != nil {
		return fmt.Errorf("failed to delete Muteconfig: %w", err)
	}
	fmt.Fprintf(w, "Mute rule deleted successfully: %s", muteConfigId)
	return nil
}

Java


import com.google.cloud.securitycenter.v2.MuteConfigName;
import com.google.cloud.securitycenter.v2.SecurityCenterClient;
import java.io.IOException;

public class DeleteMuteRule {

  public static void main(String[] args) throws IOException {
    // TODO(Developer): Replace the following variables
    // projectId: Google Cloud Project id.
    String projectId = "google-cloud-project-id";

    // Specify the location of the mute config. If the mute config was
    // created with v1 API, it can be accessed with "global".
    String location = "global";

    // muteConfigId: Specify the name of the mute config to delete.
    String muteConfigId = "mute-config-id";

    deleteMuteRule(projectId, location, muteConfigId);
  }

  // Deletes a mute configuration given its resource name.
  // Note: Previously muted findings are not affected when a mute config is deleted.
  public static void deleteMuteRule(String projectId, String location, String muteConfigId)
      throws IOException {
    // Initialize client that will be used to send requests. This client only needs to be created
    // once, and can be reused for multiple requests.
    try (SecurityCenterClient client = SecurityCenterClient.create()) {
      // Use appropriate `MuteConfigName` methods depending on the parent type.
      // folder -> MuteConfigName.ofFolderLocationMuteConfigName()
      // organization -> MuteConfigName.ofOrganizationLocationMuteConfigName()
      client.deleteMuteConfig(
          MuteConfigName.ofProjectLocationMuteConfigName(projectId, location, muteConfigId));

      System.out.println("Mute rule deleted successfully: " + muteConfigId);
    }
  }
}

Python

def delete_mute_rule(parent_path: str, location_id: str, mute_config_id: str) -> None:
    """
    Deletes a mute configuration given its resource name.
    Note: Previously muted findings are not affected when a mute config is deleted.
    Args:
         parent_path: use any one of the following options:
                     - organizations/{organization_id}
                     - folders/{folder_id}
                     - projects/{project_id}
        location_id: Gcp location id; example: 'global'
        mute_config_id: Set a unique id; max of 63 chars.
    Returns:
         None: returns none mute rule is deleted
    """
    from google.cloud import securitycenter_v2

    client = securitycenter_v2.SecurityCenterClient()

    request = securitycenter_v2.DeleteMuteConfigRequest()
    request.name = (
        parent_path + "/locations/" + location_id + "/muteConfigs/" + mute_config_id
    )

    client.delete_mute_config(request)
    print(f"Mute rule deleted successfully: {mute_config_id}")

REST

Di Security Command Center API, gunakan metode muteConfigs.delete untuk menghapus aturan penonaktifan:

DELETE https://securitycenter.googleapis.com/v2/PARENT/PARENT_ID/locations/LOCATION/muteConfigs/CONFIG_ID

Ganti kode berikut:

  • PARENT: resource induk untuk aturan penonaktifan Anda (organizations, folders, atau projects)
  • PARENT_ID: ID untuk organisasi, folder, atau project
  • LOCATION: lokasi Security Command Centertempat mengelola aturan nonaktif; jika residensi data diaktifkan, gunakan eu, sa, atau us; jika tidak, gunakan nilai global
  • CONFIG_ID: ID numerik aturan penonaktifan