Mengelompokkan temuan menurut status

Menunjukkan cara mengelompokkan temuan menurut perubahan status

Contoh kode

Python

Untuk melakukan autentikasi ke Security Command Center, siapkan Kredensial Default Aplikasi. Untuk mengetahui informasi selengkapnya, baca Menyiapkan autentikasi untuk lingkungan pengembangan lokal.

from datetime import timedelta

from google.cloud import securitycenter

# Create a client.
client = securitycenter.SecurityCenterClient()

# 'source_name' is the resource path for a source that has been
# created previously (you can use list_sources to find a specific one).
# Its format is:
# source_name = "{parent}/sources/{source_id}"
# 'parent' must be in one of the following formats:
#   "organizations/{organization_id}"
#   "projects/{project_id}"
#   "folders/{folder_id}"
# source_name = "organizations/111122222444/sources/1234"

# List assets and their state change the last 30 days
compare_delta = timedelta(days=30)

group_result_iterator = client.group_findings(
    request={
        "parent": source_name,
        "group_by": "state_change",
        "compare_duration": compare_delta,
    }
)
for i, group_result in enumerate(group_result_iterator):
    print((i + 1), group_result)

Langkah berikutnya

Untuk menelusuri dan memfilter contoh kode untuk produk Google Cloud lainnya, lihat Google Cloud browser contoh.