Agrupar resultados com filtro

Demonstra como filtrar e agrupar descobertas por propriedades

Exemplo de código

Python

Para autenticar no Security Command Center, configure o Application Default Credentials. Para mais informações, consulte Configurar a autenticação para um ambiente de desenvolvimento local.

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"

group_result_iterator = client.group_findings(
    request={
        "parent": source_name,
        "group_by": "category",
        "filter": 'state="ACTIVE"',
    }
)
for i, group_result in enumerate(group_result_iterator):
    print((i + 1), group_result)

A seguir

Para pesquisar e filtrar amostras de código para outros produtos do Google Cloud, consulte o navegador de amostra do Google Cloud.