En esta guía, se explica cómo usar la API de Security Command Center para crear una fuente para generar resultados. Cuando agregas una fuente, Security Command Center crea las fuentes adecuadas y les asigna los permisos correspondientes.
Los roles de IAM para Security Command Center se pueden otorgar a nivel de la organización, a nivel de carpeta o proyecto. Tu capacidad para ver, editar, crear o actualizar resultados, recursos, y las fuentes de seguridad dependen del nivel al que se te otorgue acceso. Para obtener más información Para los roles de Security Command Center, consulta Control de acceso.
Antes de comenzar
Antes de configurar una fuente, debes hacer lo siguiente: autenticar con la API de Security Command Center.
Crea una fuente
En este ejemplo, se muestra cómo crear una fuente con un nombre visible específico y que se usa en Security Command Center.
El servidor asigna de forma automática un ID al origen.
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.create
. El cuerpo de la solicitud contiene una instancia de Fuente.
POST https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources -d { "name": "SOURCE_NAME", "description": "SOURCE_DESCRIPTION", "displayName": "DISPLAY_NAME" }
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
- SOURCE_NAME: Es el nombre de la fuente.
- SOURCE_DESCRIPTION: Es una descripción de la fuente (máx. 1,024 caracteres).
- DISPLAY_NAME: Es el nombre visible de la fuente (entre uno y 64 caracteres).
La fuente no se puede ver en la consola de Security Command Center hasta que se genera de los resultados de búsqueda. Puedes verificar que se creó. Para ello, sigue las instrucciones en Obtén una fuente específica.
Actualiza una fuente
Puedes actualizar el nombre visible y la descripción de una fuente después de crearla. También puedes usar una máscara de campo para actualizar solo un campo. En el siguiente ejemplo, se usa una máscara de campo para actualizar solo el nombre visible, sin modificar la descripción.
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.patch
. El cuerpo de la solicitud contiene una instancia de Fuente.
PATCH https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources/SOURCE_ID?updateMask=displayName -d { "description": "SOURCE_DESCRIPTION", "displayName": "DISPLAY_NAME", }
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
- SOURCE_ID: Es el ID de origen. Para obtener instrucciones sobre cómo recuperar una fuente ID, consulta Obtener el ID de la fuente
- SOURCE_DESCRIPTION: Es una descripción de la fuente (máx.: 1,024 caracteres).
- DISPLAY_NAME: Es el nombre visible de la fuente (entre uno y 64 caracteres).
Configura políticas de IAM en una fuente
Después de crear una fuente, actualiza las políticas de Identity and Access Management (IAM) para permitir el acceso.
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.setIamPolicy
. El cuerpo de la solicitud incluye una instancia de Política.
POST https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources/SOURCE_ID:setIamPolicy -d { "version": POLICY_FORMAT, "bindings": [ { "role": IAM_ROLE, "members": [ IAM_EMAIL ] } ], "auditConfigs": [ { "service": "SERVICE", "auditLogConfigs": [ { "logType": "LOG_PERMISSION", "exemptedMembers": [ "user:EXEMPT_EMAIL" ] } ] } ], "etag": ETAG }
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
- SOURCE_ID: Es el ID de origen. Consulta Obtén una fuente específica para obtener instrucciones sobre cómo recuperar un ID de fuente.
- POLICY_FORMAT: 0, 1 o 3 para especificar el formato de la política.
- IAM_ROLE: Es el rol de IAM que se otorga.
- IAM_USER_EMAIL: Es la dirección de correo electrónico del usuario al que le otorgas el rol.
- SERVICE: Es el servicio de Google Cloud para el que habilitas el registro de auditoría.
- LOG_PERMISSION: Los permisos de registro que se otorgan:
ADMIN_READ
,DATA_READ
oDATA_WRITE
. - EXEMPT_EMAIL: Son las identidades que no generan registros para el tipo de permiso.
- ETAG: Es una string que se muestra en la respuesta a
getIamPolicy
que debe incluirse para ayudar a evitar que las actualizaciones simultáneas de una política se reemplacen entre sí.
Obtén una fuente específica
Verifica que se cree o actualice una fuente de forma adecuada mediante la consulta de Security Command Center con el nombre absoluto del recurso de la fuente:
gcloud
# Note: For GCloud you can use either full resource name or just ID Flags. # In this example, we are using ID Flags. # ORGANIZATION_ID=12344321 # SOURCE_ID=43211234 gcloud scc sources describe $ORGANIZATION_ID --source=$SOURCE_ID
Para obtener más ejemplos, ejecuta lo siguiente:
gcloud scc sources describe --help
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.get
. El cuerpo de la solicitud está vacío.
GET https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources/SOURCE_ID
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
- SOURCE_ID: Es el ID de origen.
Enumera fuentes
Security Command Center te permite enumerar una fuente específica y enumerar todas las fuentes disponibles actualmente en una organización:
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.list
. El cuerpo de la solicitud está vacío.
GET https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
Obtener políticas de IAM
Para verificar si se aplicaron las políticas de IAM adecuadas a una fuente, obtén los datos de la política de IAM actual del Security Command Center:
Python
Java
Go
Node.js
API
En la API, realiza una solicitud al método organizations.sources.getIamPolicy
. El cuerpo de la solicitud contiene un mensaje de solicitud GetIamPolicyRequest
. El objeto options
es opcional y se usa para solicitar un formato de política.
GET https://securitycenter.googleapis.com/API_VERSION/organizations/ORGANIZATION_ID/sources/SOURCE_ID:getIamPolicy -d { "resource": "organizations/ORGANIZATION_ID/sources/SOURCE_ID", "options": { "requestedPolicyVersion": POLICY_VERSION } }
Reemplaza lo siguiente:
- API_VERSION: Es la versión de la API a la que se orienta.
- ORGANIZATION_ID: El ID de tu organización.
- SOURCE_ID: Es el ID de origen. Consulta Obtén una fuente específica para obtener instrucciones sobre cómo recuperar un ID de fuente.
- POLICY_VERSION: Es el formato de política que se mostrará, 0, 1 o 3.
¿Qué sigue?
Obtén más información para acceder a Security Command Center mediante un SDK.