将 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. 创建服务账号。

  2. 创建自定义 IAM 角色。

  3. 向您的服务账号授予必要的角色。

  4. 选择并配置以下身份验证方法之一:

    • 方法 1:Workload Identity(推荐):此方法使用服务账号模拟来获取短期有效的临时访问令牌,因此无需存储任何密钥。

    • 方法 2:服务账号 JSON 密钥:此方法依赖于静态、长期有效的密钥文件。仅当您的环境中没有 Workload Identity 时,才使用此方法。

创建服务账号

如需创建服务账号,请完成以下步骤:

  1. 在 Google Cloud 控制台中,前往凭证。

    转到“凭据”页面

  2. 从创建凭证菜单中,选择服务账号。

  3. 在服务账号名称字段中输入名称,然后点击创建并继续。

  4. 依次点击继续 > 完成,跳过可选的角色分配和主账号访问权限界面。

  5. 复制服务账号邮箱,以便在配置步骤中使用。

创建自定义 IAM 角色

如需为集成提供所需的搜索功能,请创建自定义角色:

  1. 在 Google Cloud 控制台中,前往 IAM 和管理 > 角色。

    打开“角色”

  2. 点击创建角色,然后提供标题(例如“SecOps 资产搜索者”)和唯一 ID。

  3. 将角色发布阶段设置为正式版。

  4. 点击添加权限,然后添加 cloudasset.assets.searchAllResources。

  5. 点击创建。

向服务账号授予角色

如需允许集成访问您的资源,请向您的服务账号授予以下角色:

  1. 在 Google Cloud 控制台中,前往 IAM 和管理 > IAM。

  2. 找到您的服务账号,然后点击修改修改主账号。

  3. 点击添加其他角色,然后选择以下角色:

    • 上一步中创建的自定义 IAM 角色。

    • Cloud Asset Viewer。

    • Service Usage Consumer(仅在使用 Quota Project ID 时需要)。

  4. 点击保存。

配置 Workload Identity 凭证

请选择此方法或 JSON 密钥方法来对集成进行身份验证。 Workload Identity 是推荐且更安全的方法,因为它通过服务账号模拟使用短期有效的临时访问令牌,从而无需存储或轮替长期有效的密钥。

识别唯一实例身份

如需使用 Workload Identity 进行身份验证,您必须向 Google SecOps 实例授予模拟服务账号的权限。这样,实例就可以安全地访问 Google Cloud 资源。

  1. 在 Google SecOps 中,前往内容中心 > 响应集成。

  2. 选择 Cloud Asset Inventory 集成,然后在 Workload Identity Email 中输入您的服务账号邮箱。

  3. 依次点击保存 > 测试。测试预计会失败。

  4. 点击测试右侧的 close_small,然后在出错提示中搜索以 gke-init-python@... 或 soar-python@... 开头的身份电子邮件。

  5. 复制此唯一邮箱。

在 Google Cloud中授权实例身份

检索到 Google SecOps 实例的唯一身份后,您必须授权该实例访问您的Google Cloud 资源。此步骤会启用服务账号模拟,使平台能够生成短期有效的令牌并代表您执行操作,而无需使用静态密钥。

  1. 在 Google Cloud 控制台中,前往 IAM 和管理 > 服务账号。

    转到“服务账号”

  2. 选择目标服务账号,然后依次前往权限 > 授予访问权限。

  3. 将唯一邮箱粘贴到新的主账号字段中,并分配 Service Account Token Creator 角色 (roles/iam.serviceAccountTokenCreator)。

授予配额项目访问权限

使用 Workload Identity 进行身份验证时,您必须在集成设置中指定 Quota Project ID,以跟踪 API 使用情况和结算。

如需授权,您必须向服务账号授予指定配额项目的以下角色:

  1. 在 Google Cloud 控制台中,前往 IAM 和管理 > IAM,然后选择您的项目。

    转到 IAM

  2. 在主账号列表中找到您的服务账号,然后点击该账号的修改(修改主账号)。

  3. 点击添加其他角色,然后选择 Service Usage Consumer 角色 (roles/serviceusage.serviceUsageConsumer)。

  4. 点击保存。

配置 JSON 密钥

选择此方法或 Workload Identity 方法来对集成进行身份验证。仅当您的环境中无法使用 Workload Identity 时,才使用 JSON 密钥方法。Workload Identity 是推荐且更安全的方法。此方法依赖于静态、长期有效的密钥文件,需要手动管理和轮替。

请按照以下步骤生成对集成进行身份验证所需的 JSON 密钥文件:

  1. 在 Google Cloud 控制台中,前往 IAM 和管理 > 服务账号,然后选择您创建的服务账号。

    转到“服务账号”

  2. 前往密钥标签页。

  3. 依次点击添加密钥 > 创建新密钥。

  4. 选择 JSON 作为密钥类型,然后点击创建。JSON 文件会下载到您的计算机。

  5. 复制此文件的全部内容,并在集成配置期间将其粘贴到 User's Service Account 中。

集成参数

Cloud Asset Inventory 集成需要以下参数:

参数 说明
API Root 必需

Cloud Asset Inventory 实例的 API 根。

默认值为 https://cloudasset.googleapis.com。

Organization ID 可选

要在 Cloud Asset Inventory 集成中使用的组织 ID。

Project ID 可选

要用于 Cloud Asset Inventory 集成的项目 ID。如果未提供任何值,集成会从 User's Service Account 参数中提供的 JSON 文件内容中检索项目 ID。

User's Service Account 必需

服务账号 JSON 密钥文件的完整内容。

Quota Project ID 可选

您用于 Google Cloud API 和结算的 Google Cloud 项目 ID。此参数要求您向服务账号授予 Service Usage Consumer 角色。

如果未提供任何值,则集成会从您的 Google Cloud 服务账号中检索项目 ID。

Workload Identity Email 可选。

用于 Workload Identity 模拟的服务账号的客户端邮箱。

Verify SSL 必需

如果选中此选项,集成会在连接到 Cloud Asset Inventory 服务器时验证 SSL 证书。

默认处于启用状态。

如需了解如何在 Google SecOps 中配置集成,请参阅配置集成。

如有需要,您可以在后续阶段进行更改。配置集成实例后,您可以在 playbook 中使用该实例。如需详细了解如何配置和支持多个实例,请参阅支持多个实例。

操作

如需详细了解操作,请参阅 在工作桌上响应待处理的操作和在案例中运行手动操作。

丰富资源

使用丰富资源操作,通过 Cloud Asset Inventory 丰富 Google Cloud资源的相关信息。

此操作不会在 Google SecOps 实体上运行。

操作输入

如需配置丰富资源操作,请使用以下参数:

参数 说明
Resource Names 必需

一个逗号分隔列表,其中包含要提取详细信息的资源的资源名称。

如需配置此参数,请按以下格式输入完整的元数据资源名称://cloudresourcemanager.googleapis.com/projects/PROJECT_ID。

Fields To Return 可选

要返回的字段的逗号分隔列表。

默认值为 *。

值示例如下:assetType、project、folders、organization、displayName、description、location、labels、networkTags、kmsKeys、createTime、updateTime、state、additionalAttributes、parentFullResourceName、parentAssetType。

该操作始终会返回 displayName 字段。

您还可以选择配置高级过滤器。例如,如需从 additionalAttributes 返回特定键,请输入 additionalAttributes.{key}。如需从 additionalAttributes 中排除特定键,请输入 -additionalAttributes.{key}。

操作输出

Enrich Resource 操作会提供以下输出:

操作输出类型 可用性
案例墙附件 不可用
案例墙链接 不可用
案例墙表格 不可用
丰富化表 不可用
JSON 结果 可用
输出消息 可用
脚本结果 可用
JSON 结果

以下示例展示了使用丰富资源操作时收到的 JSON 结果输出:

[
  {
    "Entity": "//iam.googleapis.com/projects/PROJECT/serviceAccounts/SERVICE_ACCOUNT/keys/KEY_ID",
    "EntityResult": {
      "additionalAttributes": {
        "email": "email@example.iam.gserviceaccount.com",
        "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.iam.gserviceaccount.com/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.iam.gserviceaccount.com/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.iam.gserviceaccount.com",
      "parentAssetType": "iam.googleapis.com/ServiceAccount"
    }
  }
]
输出消息

Enrich Resource 操作可能会返回以下输出消息:

输出消息 消息说明

Successfully enriched the following resources using information from Google Cloud Asset Inventory: ASSET_IDENTIFIER

Action wasn't able to enrich the following resources using information from Google Cloud Asset Inventory: ASSET_IDENTIFIER

None of the provided resources were enriched.

操作成功。
Error executing action "Enrich resources". Reason: ERROR_REASON

操作失败。

请检查与服务器的连接、输入参数或凭证。

脚本结果

下表列出了使用丰富资源操作时脚本结果输出的值:

脚本结果名称 值
is_success True 或 False

获取资源快照

使用 Get Resource Snapshot 操作,通过 Cloud Asset Inventory 获取资源的相关信息。

此操作不会在 Google SecOps 实体上运行。

操作输入

如需配置获取资源快照操作,请使用以下参数:

参数 说明
Resource Names 必需

要提取其详细信息的资源的英文逗号分隔列表。

如需配置此参数,请按以下格式输入完整的元数据资源名称://cloudresourcemanager.googleapis.com/projects/PROJECT_ID。

Fields To Return 可选

要返回的字段的逗号分隔列表。

请按以下格式输入每个字段:

assets.FIELD

值示例如下:assets.asset.name, assets.asset.assetType, assets.asset.resource.data。

该操作始终会返回 assets.asset.name 字段。

默认值为 *。

操作输出

获取资源快照操作会提供以下输出:

操作输出类型 可用性
案例墙附件 不可用
案例墙链接 不可用
案例墙表格 不可用
丰富化表 不可用
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.iam.gserviceaccount.com",
           "projectId": "example-project",
           "email": "cloud-asset-inventory-auto@example-project.iam.gserviceaccount.com",
           "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

Action wasn't able to return information about the following resources using Google Cloud Asset Inventory: ASSET_IDENTIFIER.

No information was found for the provided resources.

操作成功。
Error executing action "Get Resource Snapshot". Reason: ERROR_REASON

操作失败。

请检查与服务器的连接、输入参数或凭证。

脚本结果

下表列出了使用获取资源快照操作时脚本结果输出的值:

脚本结果名称 值
is_success True 或 False

列出服务账号角色

使用列出服务账号角色操作,通过 Cloud Asset Inventory 列出与 Google Cloud 服务账号相关的角色。

此操作不会在 Google SecOps 实体上运行。

操作输入

如需配置列出服务账号角色操作,请使用以下参数:

参数 说明
Service Accounts 必需

要提取其详细信息的服务账号的逗号分隔列表。

Check Roles 可选

要检查的与服务账号相关的角色的逗号分隔列表,例如 roles/cloudasset.owner。

Check Permissions 可选

以逗号分隔列表形式列出的权限,用于检查与服务账号相关的权限,例如 cloudasset.assets.listResource 。

Expand Permissions 可选

如果选择此选项,该操作会返回与资源相关的所有唯一权限的相关信息。

默认情况下不选择。

Max Roles To Return 必需

要返回的与服务账号相关的角色数量。

默认值为 100。

Max Permissions To Return 必需

要返回的与服务账号相关的权限数量。

操作输出

列出服务账号角色操作提供以下输出:

操作输出类型 可用性
案例墙附件 不可用
案例墙链接 不可用
案例墙表格 不可用
丰富化表 不可用
JSON 结果 可用
输出消息 可用
脚本结果 可用
JSON 结果

以下示例展示了使用列出服务账号角色操作时收到的 JSON 结果输出:

{
   "roles": ["role1", "role2"],
   "unique_permissions": ["permission1", "permission2"]
}
输出消息

列出服务账号角色操作可以返回以下输出消息:

输出消息 消息说明

Successfully enriched for the following service accounts using information from Google Cloud Asset Inventory: ASSET_IDENTIFIER

Action wasn't able to enrich the following service accounts using information from Google Cloud Asset Inventory: ASSET_IDENTIFIER

None of the service accounts were enriched.

操作成功。
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

需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。