將 Cloud Asset Inventory 與 Google SecOps 整合

本文說明如何將 Cloud 資產清查與 Google Security Operations (Google SecOps) 整合。

整合版本:12.0

在 Google SecOps 平台中,Cloud Asset Inventory 的整合功能稱為「Google Cloud Asset Inventory」

事前準備

如要使用這項整合功能,您需要身分與存取權管理 (IAM) 角色和Google Cloud 服務帳戶。

建立及設定自訂 IAM 角色

如要建立自訂 IAM 角色並為其設定特定權限,請完成下列步驟:

  1. 前往 Google Cloud 控制台的 IAM「Roles」(角色) 頁面。

    前往「Roles」(角色)

  2. 按一下「建立角色」,建立具有整合項目所需權限的自訂角色。

  3. 如果是新的自訂角色,請提供「名稱」、「說明」和專屬「ID」

  4. 將「角色發布階段」設為「正式發布」

  5. 將下列權限新增至建立的角色:

    cloudasset.assets.searchAllResources
    

建立及設定服務帳戶

如要將 Cloud Asset Inventory 與 Google SecOps 整合,您可以使用現有服務帳戶或建立新帳戶。如需建立服務帳戶的指引,請參閱「建立服務帳戶」。

整合 Cloud Asset Inventory 時,您需要授予服務帳戶在上一節建立的自訂角色和 Cloud Asset Viewer 角色。

如果您未使用工作負載身分電子郵件設定整合,請在建立服務帳戶後以 JSON 格式建立服務帳戶金鑰。設定整合參數時,您必須提供下載的 JSON 金鑰檔案完整內容。

基於安全考量,建議您使用工作負載身分電子郵件地址,而非服務帳戶 JSON 金鑰。如要進一步瞭解工作負載身分,請參閱「工作負載身分」。

將自訂角色指派給現有主體

將新的自訂角色授予所選主體後,該主體就能變更機構中任何使用者的權限。

如要將自訂角色授予現有主體,請完成下列步驟:

  1. 前往 Google Cloud 控制台的「IAM」(身分與存取權管理) 頁面。

    前往「IAM」(身分與存取權管理) 頁面

  2. 在「Filter」(篩選器) 欄位中,貼上您用於 Cloud Asset Inventory 整合的「Workload Identity Email」(工作負載身分識別電子郵件地址) 值,然後搜尋現有主體。

  3. 按一下「Edit principal」(編輯主體)。系統會開啟「編輯『PROJECT』的存取權」對話方塊。

  4. 在「指派角色」下方,按一下 「新增其他角色」

  5. 選取 Cloud Asset Inventory 的預先定義角色

  6. 按一下 [儲存]

整合參數

整合 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 檔案的內容。

您可以設定這個參數或 Workload Identity Email 參數。

如要設定這個參數,請提供您在建立服務帳戶時下載的服務帳戶金鑰 JSON 檔案完整內容。

Quota Project ID 選用

您用於 Google Cloud API 和帳單的專案 ID。 Google Cloud 如要使用這個參數,您必須將 Service Usage Consumer 角色授予服務帳戶。

如果未設定這個參數的值,整合服務會從您的 Google Cloud 服務帳戶擷取專案 ID。

Workload Identity Email 選用

服務帳戶的用戶端電子郵件地址。

您可以設定這個參數或 User's Service Account 參數。

如要使用 Workload Identity Federation 模擬服務帳戶,請將 Service Account Token Creator 角色授予服務帳戶。如要進一步瞭解工作負載身分和使用方式,請參閱「工作負載的身分」。

Verify SSL 必要

如果選取這個選項,整合服務會驗證連線至 Cloud Asset Inventory 伺服器的 SSL 憑證是否有效。

(此為預設選項)。

如需在 Google SecOps 中設定整合功能的詳細操作說明,請參閱「設定整合功能」。

如有需要,您之後可以變更。設定整合執行個體後,您就可以在劇本中使用該執行個體。如要進一步瞭解如何設定及支援多個執行個體,請參閱「支援多個執行個體」。

動作

如要進一步瞭解動作,請參閱「回覆『你的工作台』中的待處理動作」和「執行手動動作」。

充實資源

使用「Enrich Resource」(充實資源) 動作,透過 Cloud Asset Inventory 充實資源的相關資訊。 Google Cloud

這項操作不會在 Google SecOps 實體上執行。

動作輸入內容

如要設定「Enrich Resource」動作,請使用下列參數:

參數 說明
Resource Names 必要

以半形逗號分隔的清單,內含要擷取詳細資料的資源名稱。

如要設定這個參數,請輸入完整的中繼資料資源名稱,格式如下://cloudresourcemanager.googleapis.com/projects/PROJECT_ID

Fields To Return 選填

以半形逗號分隔的欄位清單,用於指定要傳回的欄位。

預設值為 *

值範例如下: assetTypeprojectfoldersorganizationdisplayNamedescriptionlocationlabelsnetworkTagskmsKeyscreateTimeupdateTimestateadditionalAttributesparentFullResourceNameparentAssetType

動作一律會傳回 displayName 欄位。

您也可以設定進階篩選器。舉例來說,如要從 additionalAttributes 傳回特定鍵,請輸入 additionalAttributes.{key}。如要從 additionalAttributes 排除特定鍵,請輸入 -additionalAttributes.{key}

動作輸出內容

「Enrich Resource」動作會提供下列輸出內容:

動作輸出類型 可用性
案件總覽附件 無法使用
案件總覽連結 無法使用
案件訊息牆表格 無法使用
補充資訊表格 無法使用
JSON 結果 可用
輸出訊息 可用
指令碼結果 可用
JSON 結果

以下範例顯示使用「Enrich Resource」動作時收到的 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

動作失敗。

檢查伺服器的連線、輸入參數或憑證。

指令碼結果

下表列出使用「Enrich Resource」(擴充資源) 動作時,指令碼結果輸出的值:

指令碼結果名稱
is_success TrueFalse

取得資源快照

使用「取得資源快照」動作,透過 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 TrueFalse

列出服務帳戶角色

使用「列出服務帳戶角色」動作,透過 Cloud Asset Inventory 列出與 Google Cloud 服務帳戶相關的角色。

這項操作不會在 Google SecOps 實體上執行。

動作輸入內容

如要設定「List Service Account Roles」(列出服務帳戶角色) 動作,請使用下列參數:

參數 說明
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」動作測試與 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 TrueFalse

還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。