将 Cloud Asset Inventory 与 Google SecOps 集成
本文档介绍了如何将 Cloud Asset Inventory 与 Google Security Operations 集成。
使用场景
Cloud Asset Inventory 集成使用 Google SecOps 功能来支持以下使用情形:
丰富 Google Cloud 资源:使用完整资源名称自动提取云资源的详细元数据,以便为安全提醒提供上下文。
检索资源快照:获取资源配置和状态的时间点视图,以帮助进行取证调查和变更分析。
审核服务账号:列出与服务账号关联的角色和唯一权限,以识别权限过高的身份并遵循最小权限原则。
清点多云资产:访问Google Cloud 和关联的外部环境中的资源详细信息,以便在调查中集中查看资产。
准备工作
在 Google SecOps 中配置 Cloud Asset Inventory 集成之前,请完成以下前提步骤:
选择并配置以下身份验证方法之一:
方法 1:Workload Identity(推荐):此方法使用短期有效的临时访问令牌,通过服务账号模拟来消除存储任何 Secret 的需求。
方法 2:服务账号 JSON 密钥:此方法依赖于静态的长期有效的密钥文件。仅当您的环境中没有 Workload Identity 时,才使用此方法。
创建服务账号
如需创建服务账号,请完成以下步骤:
在 Google Cloud 控制台中,前往凭证页面。
从创建凭据菜单中选择服务账号。
在服务账号名称字段中输入一个名称,然后点击创建并继续。
点击继续 > 完成,跳过可选的角色分配和正文访问权限界面。
复制服务账号电子邮件地址,以便在配置步骤中使用。
创建自定义 IAM 角色
如需为集成提供所需的搜索功能,请创建自定义角色:
在 Google Cloud 控制台中,前往 IAM 和管理 > 角色。
点击创建角色,然后提供标题(例如“SecOps 资产搜索者”)和唯一 ID。
将角色发布阶段设置为正式版。
点击添加权限,然后添加
cloudasset.assets.searchAllResources。点击创建。
向服务账号授予角色
如需允许集成访问您的资源,请向您的服务账号授予以下角色:
在 Google Cloud 控制台中,依次前往 IAM 和管理 > IAM。
找到您的服务账号,然后点击修改修改主账号。
点击添加其他角色,然后选择以下内容:
在上一步中创建的自定义 IAM 角色。
Cloud Asset Viewer。
Service Usage Consumer(仅在您使用
Quota Project ID时需要)。
点击保存。
配置 Workload Identity 凭据
选择此方法或 JSON 密钥方法来验证集成。 Workload Identity 是推荐的更安全的方法,因为它使用短期临时访问令牌(通过服务账号模拟),无需存储或轮换长期有效的密钥。
确定唯一实例身份
如需使用 Workload Identity 进行身份验证,您必须向 Google SecOps 实例授予模拟服务账号的权限。这样,实例就可以安全地访问 Google Cloud 资源。
在 Google SecOps 中,前往内容中心 > 响应集成。
选择 Web Risk 集成,然后在
Workload Identity Email中输入您的服务账号电子邮件地址。依次点击保存 > 测试。测试预计会失败。
点击测试旁边的close_small按钮,然后搜索以
gke-init-python@...或soar-python@...开头的身份电子邮件地址的错误消息。复制此唯一电子邮件地址,并在集成配置期间将其粘贴到
Workload Identity Email中。
在 Google Cloud中授权实例身份
检索到 Google SecOps 实例的唯一身份后,您必须授权该身份访问您的Google Cloud 资源。此步骤可启用服务账号模拟,让平台能够生成短期有效令牌并代表您执行操作,而无需静态密钥。
在 Google Cloud 控制台中,依次前往 IAM 和管理 > 服务账号。
选择目标服务账号,然后依次前往权限 > 授予访问权限。
将唯一电子邮件地址粘贴到新的主账号字段中。
分配 Service Account Token Creator 角色 (
roles/iam.serviceAccountTokenCreator)。
授予配额项目访问权限
使用 Workload Identity 进行身份验证时,您必须在集成设置中指定 Quota Project ID,以便跟踪 API 使用情况和结算信息。
如需授权此操作,您必须向指定配额项目中的服务账号授予以下角色:
在 Google Cloud 控制台中,前往 IAM 和管理 > IAM,然后选择您的项目。
在主账号列表中找到您的服务账号,然后点击相应账号的修改(修改主账号)。
点击添加其他角色,然后选择 Service Usage Consumer 角色 (
roles/serviceusage.serviceUsageConsumer)。点击保存。
配置 JSON 密钥
选择此方法或 Workload Identity 方法来验证集成。仅当您的环境中没有 Workload Identity 时,才使用 JSON 密钥方法。建议使用 Workload Identity,这种方法更安全。此方法依赖于静态的长期有效的密钥文件,需要手动管理和轮替。
请按照以下步骤生成用于对集成进行身份验证的 JSON 密钥文件:
在 Google Cloud 控制台中,依次前往 IAM 和管理 > 服务账号,然后选择您创建的服务账号。
前往密钥标签页。
点击添加密钥 > 创建新密钥。
选择
JSON作为密钥类型,然后点击创建。JSON 文件会下载到您的计算机。复制此文件的全部内容,并在集成配置期间将其粘贴到
User's Service Account中。
集成参数
Cloud Asset Inventory 集成需要以下参数:
| 参数 | 说明 |
|---|---|
API Root |
必需
Cloud Asset Inventory 实例的 API 根。 默认值为 |
Organization ID |
可选
要在 Cloud Asset Inventory 集成中使用的组织 ID。 |
Project ID |
可选 用于 Cloud Asset Inventory 集成的项目 ID。如果未提供任何值,集成会从 |
User's Service Account |
必需
服务账号 JSON 密钥文件的完整内容。 |
Quota Project ID |
可选 您用于 Google Cloud API 和结算的 Google Cloud 项目 ID。此形参要求您向服务账号授予 如果未提供值,集成会从您的 Google Cloud 服务账号中检索项目 ID。 |
Workload Identity Email |
可选。
用于工作负载身份模拟的服务账号的客户端电子邮件地址。 |
Verify SSL |
必需
如果选择此选项,集成会在连接到 Cloud Asset Inventory 服务器时验证 SSL 证书。 默认处于启用状态。 |
如需了解如何在 Google SecOps 中配置集成,请参阅配置集成。
如有需要,您可以在稍后阶段进行更改。配置集成实例后,您可以在 playbook 中使用该实例。如需详细了解如何配置和支持多个实例,请参阅支持多个实例。
操作
如需详细了解操作,请参阅 在工作台页面中处理待处理的操作和执行人工处置措施。
丰富资源
使用 Enrich Resource 操作,通过 Cloud Asset Inventory 丰富有关 Google Cloud资源的信息。
此操作不适用于 Google SecOps 实体。
操作输入
如需配置 丰富资源操作,请使用以下参数:
| 参数 | 说明 |
|---|---|
Resource Names |
必需
一个逗号分隔列表,其中包含要获取详细信息的资源的资源名称。 如需配置此参数,请输入完整的元数据资源名称,格式如下: |
Fields To Return |
可选
要返回的字段的逗号分隔列表。 默认值为 值示例:
该操作始终返回 您还可以选择配置高级过滤条件。例如,如需从 |
操作输出
丰富资源操作提供以下输出:
| 操作输出类型 | 可用性 |
|---|---|
| 案例墙附件 | 不可用 |
| 案例墙链接 | 不可用 |
| “支持请求墙”表格 | 不可用 |
| 丰富化表 | 不可用 |
| JSON 结果 | 可用 |
| 输出消息 | 可用 |
| 脚本结果 | 可用 |
JSON 结果
以下示例展示了使用丰富资源操作时收到的 JSON 结果输出:
[
{
"Entity": "//iam.googleapis.com/projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT/keys/KEY_ID",
"EntityResult": {
"additionalAttributes": {
"email": "email@example.",
"uniqueId": 123456789
},
"name": "//iam.googleapis.com/projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT/keys/KEY_ID",
"assetType": "iam.googleapis.com/ServiceAccountKey",
"project": "projects/PROJECT",
"displayName": "projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT@PROJECT./keys/KEY_ID",
"createTime": "2022-05-26T17:35:07Z",
"versionedResources": [
{
"version": "v1",
"resource": {
"keyAlgorithm": "KEY_ALG_RSA_2048",
"keyOrigin": "GOOGLE_PROVIDED",
"keyType": "USER_MANAGED",
"name": "projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT@PROJECT./keys/KEY_ID",
"validAfterTime": "2022-05-26T17:35:07Z",
"validBeforeTime": "9999-12-31T23:59:59Z"
}
}
],
"organization": "organizations/ORGANIZATION",
"parentFullResourceName": "//iam.googleapis.com/projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT@PROJECT.",
"parentAssetType": "iam.googleapis.com/ServiceAccount"
}
}
]
输出消息
丰富资源操作可以返回以下输出消息:
| 输出消息 | 消息说明 |
|---|---|
|
操作成功。 |
Error executing action "Enrich resources". Reason:
ERROR_REASON |
操作失败。 检查与服务器的连接、输入参数或凭据。 |
脚本结果
下表列出了使用丰富资源操作时脚本结果输出的值:
| 脚本结果名称 | 值 |
|---|---|
is_success |
True 或 False |
获取资源快照
使用 Get Resource Snapshot 操作通过 Cloud Asset Inventory 获取资源的相关信息。
此操作不适用于 Google SecOps 实体。
操作输入
如需配置 Get Resource Snapshot 操作,请使用以下参数:
| 参数 | 说明 |
|---|---|
Resource Names |
必需 以逗号分隔的资源列表,用于获取详细信息。 如需配置此参数,请输入完整的元数据资源名称,格式如下: |
Fields To Return |
可选 要返回的字段的逗号分隔列表。 以以下格式输入每个字段: assets.FIELD
值示例如下: 该操作始终返回 默认值为 |
操作输出
获取资源快照操作提供以下输出:
| 操作输出类型 | 可用性 |
|---|---|
| 案例墙附件 | 不可用 |
| 案例墙链接 | 不可用 |
| “支持请求墙”表格 | 不可用 |
| 丰富化表 | 不可用 |
| JSON 结果 | 可用 |
| 输出消息 | 可用 |
| 脚本结果 | 可用 |
JSON 结果
以下示例展示了使用获取资源快照操作时收到的 JSON 结果输出:
Google Cloud的 JSON 结果
[ { "Entity": "//compute.googleapis.com/projects/example-project/zones/us-central1-a/instances/example-instance", "EntityResult": { "window": { "startTime": "2023-08-14T19:43:41.805828Z", "endTime": "2262-04-11T23:47:16.854775807Z" }, "asset": { "name": "//compute.googleapis.com/projects/example-project/zones/us-central1-a/instances/example-instance", "assetType": "compute.googleapis.com/Instance", "resource": { "version": "v1", "discoveryDocumentUri": "https://www.googleapis.com/discovery/v1/apis/compute/v1/rest", "discoveryName": "Instance", "parent": "//cloudresourcemanager.googleapis.com/projects/example-project-id", "data": { "description": "", "serviceAccounts": [ { "email": "user@example.com", "scopes": [ "https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/monitoring.write", "https://www.googleapis.com/auth/servicecontrol", "https://www.googleapis.com/auth/service.management.readonly", "https://www.googleapis.com/auth/trace.append" ] } ], "lastStartTimestamp": "2022-05-26T01:44:52.756-07:00", "deletionProtection": false, "name": "example-name", "keyRevocationActionType": "NONE_ON_KEY_REVOCATION", "canIpForward": false, "shieldedInstanceIntegrityPolicy": { "updateAutoLearnPolicy": true }, "zone": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a", "resourceStatus": {}, "scheduling": { "onHostMaintenance": "MIGRATE", "preemptible": false, "provisioningModel": "STANDARD", "automaticRestart": true }, "machineType": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/machineTypes/e2-micro", "confidentialInstanceConfig": { "enableConfidentialCompute": false }, "selfLink": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/instances/example-instance", "id": "example-id", "fingerprint": "example-fingerprint", "startRestricted": false, "networkInterfaces": [ { "network": "https://www.googleapis.com/compute/v1/projects/example-project/global/networks/example-network", "stackType": "IPV4_ONLY", "name": "example", "subnetwork": "https://www.googleapis.com/compute/v1/projects/example-project/regions/us-central1/subnetworks/example-network-subnet", "accessConfigs": [ { "type": "ONE_TO_ONE_NAT", "name": "External NAT", "natIP": "192.0.2.1", "networkTier": "PREMIUM" } ], "fingerprint": "example-fingerprint", "networkIP": "203.0.113.2" } ], "allocationAffinity": { "consumeAllocationType": "ANY_ALLOCATION" }, "labelFingerprint": "example-label", "shieldedInstanceConfig": { "enableSecureBoot": false, "enableVtpm": true, "enableIntegrityMonitoring": true }, "cpuPlatform": "Intel Broadwell", "creationTimestamp": "2022-05-26T01:44:40.323-07:00", "status": "RUNNING", "disks": [ { "guestOsFeatures": [ { "type": "VIRTIO_SCSI_MULTIQUEUE" }, { "type": "SEV_CAPABLE" }, { "type": "UEFI_COMPATIBLE" }, { "type": "GVNIC" } ], "interface": "SCSI", "shieldedInstanceInitialState": { "dbxs": [ { "content": "2gcDBhMRFQAAAAAAAAAAABENAAAAAvEOndK", "fileType": "BIN" } ], "dbx": [ { "fileType": "BIN", "content": "2gcDBhMRFQAAAAAAAAAAABENAAAAAvEOndK" } ] }, "diskSizeGb": "10", "deviceName": "example-device-name", "type": "PERSISTENT", "source": "https://www.googleapis.com/compute/v1/projects/example-project/zones/us-central1-a/disks/example-instance", "boot": true, "licenses": [ "https://www.googleapis.com/compute/v1/projects/example-project/global/licenses" ], "index": 0, "autoDelete": true, "mode": "READ_WRITE" } ], "tags": { "items": [ "http-server" ], "fingerprint": "example-fingerprint" }, "displayDevice": { "enableDisplay": false }, "reservationAffinity": { "consumeReservationType": "ANY_ALLOCATION" } }, "location": "us-central1-a" }, "ancestors": [ "projects/example-project-id", "organizations/example-org-id" ], "updateTime": "2023-08-14T19:43:41.805828Z" } } }, { "Entity": "//iam.googleapis.com/projects/example-project/serviceAccounts/example-account-id", "EntityResult": { "window": { "startTime": "2023-12-22T13:37:50Z", "endTime": "2262-04-11T23:47:16.854775807Z" }, "asset": { "name": "//iam.googleapis.com/projects/example-project/serviceAccounts/example-account-id", "assetType": "iam.googleapis.com/ServiceAccount", "resource": { "version": "v1", "discoveryDocumentUri": "https://iam.googleapis.com/$discovery/rest", "discoveryName": "ServiceAccount", "parent": "//cloudresourcemanager.googleapis.com/projects/example-project-id", "data": { "name": "projects/example-project/serviceAccounts/cloud-asset-inventory-auto@example-project.", "projectId": "example-project", "email": "cloud-asset-inventory-auto@example-project.", "uniqueId": "example-account-id", "displayName": "Cloud Asset Inventory Automation", "oauth2ClientId": "example-account-id" } }, "ancestors": [ "projects/example-project-id", "organizations/example-org-id" ], "updateTime": "2023-12-22T13:37:50Z" } } } ]
AWS 的 JSON 结果
[ { "Entity": "//cloudasset.googleapis.com/organizations/example-org-id/otherCloudConnections/aws/arn:aws:s3:::aps-max-test-bucket", "EntityResult": { "assets": [ { "window": { "startTime": "2024-01-24T17:51:03.412233028Z", "endTime": "2262-04-11T23:47:16.854775807Z" }, "asset": { "name": "//cloudasset.googleapis.com/organizations/example-org-id/otherCloudConnections/aws/arn:aws:s3:::aps-max-test-bucket", "assetType": "cloudasset.googleapis.com/AWS::S3::Bucket", "resource": { "version": "v1", "discoveryDocumentUri": "n/a", "discoveryName": "n/a", "data": { "dataSourceProvider": "AMAZON_WEB_SERVICES", "supplementaryConfigurations": { "PublicAccessBlockConfiguration": { "BlockPublicPolicy": true, "RestrictPublicBuckets": true, "BlockPublicAcls": true, "IgnorePublicAcls": true }, "TagSet": [ { "Key": "my-key2", "Value": "my-value2" }, { "Key": "my-key1", "Value": "my-value1" } ], "ServerSideEncryptionConfiguration": { "Rules": [ { "ApplyServerSideEncryptionByDefault": { "SSEAlgorithm": "AES256" }, "BucketKeyEnabled": true } ] }, "AccessControlPolicy": { "Grants": [ { "Grantee": { "DisplayName": "example", "ID": "example-id", "Type": "CanonicalUser" }, "Permission": "FULL_CONTROL" } ], "Owner": { "DisplayName": "example", "ID": "example-id" } } }, "configuration": { "Name": "aps-max-test-bucket", "CreationDate": "2023-12-04T15:29:50+00:00" }, "tags": { "my-key2": "my-value2", "my-key1": "my-value1" }, "originalResourceName": "arn:aws:s3:::aps-max-test-bucket", "awsAccount": "arn:aws:organizations::example-id:account/example-account/example-account-id" }, "location": "global" }, "ancestors": [ "organizations/example-org-id" ], "updateTime": "2024-01-24T17:51:03.412233028Z" } } ] } } ]
输出消息
获取资源快照操作可以返回以下输出消息:
| 输出消息 | 消息说明 |
|---|---|
Successfully returned information about the following resources
using Google Cloud Asset Inventory:
ASSET_IDENTIFIER
|
操作成功。 |
Error executing action "Get Resource Snapshot". Reason:
ERROR_REASON |
操作失败。 检查与服务器的连接、输入参数或凭据。 |
脚本结果
下表列出了使用获取资源快照操作时脚本结果输出的值:
| 脚本结果名称 | 值 |
|---|---|
is_success |
True 或 False |
列出服务账号角色
使用 List Service Account Roles 操作,通过 Cloud Asset Inventory 列出与 Google Cloud 服务账号相关的角色。
此操作不适用于 Google SecOps 实体。
操作输入
如需配置列出服务账号角色操作,请使用以下参数:
| 参数 | 说明 |
|---|---|
Service Accounts |
必需 要获取详细信息的服务账号的英文逗号分隔列表。 |
Check Roles |
可选 要检查的与服务账号相关的角色逗号分隔列表,例如 |
Check Permissions |
可选 要检查的与服务账号相关的权限的逗号分隔列表,例如 |
Expand Permissions |
可选 如果选择此项,操作会返回与资源相关的所有唯一权限的信息。 默认情况下未选中。 |
Max Roles To Return |
必需 要返回的与服务账号相关的角色数量。 默认值为 100。 |
Max Permissions To Return |
必需 要返回的与服务账号相关的权限数量。 |
操作输出
列出服务账号角色操作提供以下输出:
| 操作输出类型 | 可用性 |
|---|---|
| 案例墙附件 | 不可用 |
| 案例墙链接 | 不可用 |
| “支持请求墙”表格 | 不可用 |
| 丰富化表 | 不可用 |
| JSON 结果 | 可用 |
| 输出消息 | 可用 |
| 脚本结果 | 可用 |
JSON 结果
以下示例展示了使用列出服务账号角色操作时收到的 JSON 结果输出:
{
"roles": ["role1", "role2"],
"unique_permissions": ["permission1", "permission2"]
}
输出消息
列出服务账号角色操作可以返回以下输出消息:
| 输出消息 | 消息说明 |
|---|---|
|
操作成功。 |
Error executing action "List Service Account Roles". Reason:
ERROR_REASON |
操作失败。 检查与服务器的连接、输入参数或凭据。 |
Ping
使用 Ping 操作测试与 Cloud Asset Inventory 的连接。
此操作不适用于 Google SecOps 实体。
操作输入
无。
操作输出
Ping 操作提供以下输出:
| 操作输出类型 | 可用性 |
|---|---|
| 案例墙附件 | 不可用 |
| 案例墙链接 | 不可用 |
| “支持请求墙”表格 | 不可用 |
| 丰富化表 | 不可用 |
| JSON 结果 | 不可用 |
| 输出消息 | 可用 |
| 脚本结果 | 可用 |
输出消息
Ping 操作可以返回以下输出消息:
| 输出消息 | 消息说明 |
|---|---|
Successfully connected to the Google Cloud Asset Inventory
server with the provided connection parameters! |
操作成功。 |
Failed to connect to the Google Cloud Asset Inventory server!
|
操作失败。 |
脚本结果
下表列出了使用 Ping 操作时脚本结果输出的值:
| 脚本结果名称 | 值 |
|---|---|
is_success |
True 或 False |