Security Command Center 发现结果模型可为组织资源的潜在安全风险建模。发现结果始终与 Security Command Center 中的特定资源相关。
本指南介绍了如何使用 Security Command Center 客户端库访问组织的发现结果。每个结果都属于一个来源。大多数检测器或发现结果提供程序在同一来源内生成发现结果。
准备工作
在设置来源之前,您需要完成以下操作:
页面大小
所有 Security Command Center list API 都是分页的。每个响应都会返回一个结果页面和一个返回下一页的令牌。页面大小可配置。默认的 pageSize 为 10,可设置为最小值 1 和最大值 1000。
发现结果保留
发现结果包含一系列 event_time
快照,用于捕获扫描过程中每次遇到关联漏洞或威胁时发现结果的状态和属性。
Security Command Center 从其 event_time
或事件发生的时间存储 13 个月的快照。13 个月后,发现结果快照及其数据会从 Security Command Center 数据库中删除,并且无法恢复。这会导致发现结果中的快照更少,导致无法查看发现结果及其随时间变化的方式。
只要发现结果至少有一个快照包含最近 13 个月的 event_time
,就会持续保存在 Security Command Center 中。如需将发现结果及其所有数据保留更长时间,请将其导出到其他存储位置。如需相关说明,请参阅导出 Security Command Center 数据。
列出组织中的所有发现结果
gcloud
# ORGANIZATION_ID=organization-id gcloud scc findings list $ORGANIZATION_ID
如需查看更多示例,请运行以下命令:
gcloud scc findings list --help
Python
Java
Go
Node.js
每个发现结果的输出如下所示:
finding:
category: 'Persistence: IAM Anomalous Grant'
createTime: '2020-09-13T12:30:10.248Z'
eventTime: '2020-09-13T12:30:09.528Z'
name: organizations/organization-id/sources/source-id/findings/finding-id
parent: organizations/organization-id/sources/source-id
resourceName: //cloudresourcemanager.googleapis.com/projects/project-number
securityMarks:
name: organizations/organization-id/sources/source-id/findings/finding-id/securityMarks
sourceProperties:
affectedResources:
- gcpResourceName: //cloudresourcemanager.googleapis.com/projects/project-number
detectionCategory:
indicator: audit_log
ruleName: iam_anomalous_grant
subRuleName: service_account_granted_sensitive_role_to_member
technique: persistence
detectionPriority: HIGH
evidence:
- sourceLogId:
insertId: insert-id
projectId: project-id
timestamp:
nanos: 183000000
seconds: '1600000206'
findingId: finding-id
properties:
sensitiveRoleGrant:
bindingDeltas:
- action: ADD
member: user:user-email@gmail.com
role: roles/editor
members:
- user:user-email@gmail.com
principalEmail: principal-email.iam.gserviceaccount.com
sourceId:
customerOrganizationNumber: 'organization-id'
projectNumber: 'project-number'
state: ACTIVE
resource:
name: //cloudresourcemanager.googleapis.com/projects/project-number
parentDisplayName: organization-name
parentName: //cloudresourcemanager.googleapis.com/folders/folder-id
projectDisplayName: project-id
projectName: //cloudresourcemanager.googleapis.com/projects/project-number
过滤发现结果
一个组织可能会有许多发现结果。上面的示例未使用过滤条件,因此会返回所有发现结果记录。借助 Security Command Center,您可以使用发现结果过滤条件来获取所需发现结果的相关信息,并将父级限制为特定来源。
发现结果的过滤条件与 SQL 语句中的“where”子句类似,但列除外,它们会应用于 API 返回的对象。
以下示例仅列出类别为“MEDIUM_RISK_ONE
”的发现结果。具体类别可能发生变化,您应查阅发现结果服务提供商的文档以确定其使用的类别。
gcloud
# ORGANIZATION_ID=organization-id # SOURCE_ID="source-id" FILTER="category=\"MEDIUM_RISK_ONE\"" gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID --filter="$FILTER"
如需查看更多示例,请运行以下命令:
gcloud scc findings list --help
Python
Java
Go
Node.js
Security Command Center 还支持完整的 JSON 数组和对象作为潜在属性类型。您可以按以下条件进行过滤:
- 数组元素
- 对象中部分字符串匹配的完整 JSON 对象
- JSON 对象子字段
子字段必须是数字、字符串或布尔值,并且必须使用以下运算符:
- 字符串
- 完全相等运算符
=
- 部分字符串与
:
匹配
- 完全相等运算符
- 数字
- 不等式
<
、>
、<=
、>=
- 相等
=
- 不等式
- 布尔值
- 相等
=
- 相等
本页面后面的示例假定以下 JSON 对象是发现结果的源属性:
{
"outer_object": {
"middle_object": {
"deeply_nested_object": {
"x": 123,
},
"y": "some-string-value",
},
"z": "some-other-string-value",
"u": ["list-element-1", "list-element-2", "list-element-3", ],
},
}
过滤发现结果示例
在此示例中,上一个 JSON 对象是名为 my_property
的发现结果的来源属性。以下示例展示了如何将对象作为属性的发现结果进行查询。您还可以在查询中使用 AND
和 OR
将这些过滤条件与其他过滤条件一起使用。
# ORGANIZATION_ID=organization-id
# SOURCE_ID="source-id"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.middle_object.deeply_nested_object.x = 123"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.middle_object.y = \"some-string-value\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.middle_object.y : \"string-value\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.z = \"some-other-string-value\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.z : \"other-string-value\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.u : \"list-element-1\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.u : \"list-element-2\""
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--filter="source_properties.my_property.outer_object.u : \"list-element-3\""
对发现结果进行排序的示例
您可以按原始类型(字符串,数字和布尔值)的严格子字段对结果进行排序。在此示例中,上一个 JSON 对象是名为 my_property
的发现结果的来源属性。以下示例包含用于对发现结果字段进行排序的查询:
# ORGANIZATION_ID=organization-id
# SOURCE_ID="source-id"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.middle_object.deeply_nested_object.x DESC"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.middle_object.deeply_nested_object.x"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.middle_object.y DESC"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.middle_object.y"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.z DESC"
gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID \
--order-by="source_properties.my_property.outer_object.z"
时间点查询
Security Command Center 可让您列出 13 个月内特定快照时间的发现结果。如需了解详情,请参阅发现结果保留。
gcloud
# ORGANIZATION_ID=organization-id # SOURCE_ID="source-id" # READ_TIME follows the format YYYY-MM-DDThh:mm:ss.ffffffZ READ_TIME=2019-02-28T07:00:06.861Z gcloud scc findings list $ORGANIZATION_ID --source=$SOURCE_ID --read-time=$READ_TIME
如需查看更多示例,请运行以下命令:
gcloud scc findings list --help
Python
Java
Go
Node.js
FilterExamples
以下是一些其他有用的发现结果过滤器。
在某个时间点之后出现的发现结果
以下示例过滤条件将匹配最近 2019 年 6 月 5 日星期三下午 10:12:05 (格林尼治标准时间)之后的最新发现结果。借助 event_time
过滤器,您可以使用以下格式和类型表示时间:
以整数字面量表示的 Unix 时间(以毫秒为单位)
"event_time > 1559772725000"
作为字符串字面量的 RFC 3339
"event_time > \"2019-06-05T22:34:40+00:00\""