將 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 (建議做法):這個方法會使用服務帳戶模擬功能,產生短期臨時存取權杖,因此不需要儲存任何密碼。
選項 2:服務帳戶 JSON 金鑰:這個方法依賴靜態的長期密鑰檔案。只有在環境中無法使用 Workload Identity 時,才使用這個方法。
建立服務帳戶
如要建立服務帳戶,請完成下列步驟:
前往 Google Cloud 控制台的「憑證」頁面。
在「建立憑證」選單中,選取「服務帳戶」。
在「Service account name」(服務帳戶名稱) 欄位中輸入名稱,然後按一下「Create and continue」(建立並繼續)。
按一下「繼續」>「完成」,略過選用的角色指派和主體存取畫面。
複製服務帳戶電子郵件地址,以供設定步驟使用。
建立自訂 IAM 角色
如要為整合功能提供必要的搜尋功能,請建立自訂角色:
在 Google Cloud 控制台中,依序前往「IAM & Admin」(IAM 與管理)>「Roles」(角色)。
按一下「建立角色」,然後提供「名稱」 (例如「SecOps 資產搜尋者」) 和專屬「ID」。
將「角色發布階段」設為「正式發布」。
按一下「新增權限」,然後新增
cloudasset.assets.searchAllResources。點選「建立」。
將角色授予服務帳戶
如要讓整合服務存取資源,請將下列角色授予服務帳戶:
在 Google Cloud 控制台中,依序前往「IAM & Admin」(IAM 與管理)>「IAM」(身分與存取權管理)。
找出服務帳戶,然後按一下「Edit principal」(編輯主體)。
按一下「Add another role」(新增其他角色),然後選取下列項目:
在上一個步驟中建立的自訂 IAM 角色。
Cloud Asset 檢視者。
服務使用情形消費者 (僅在使用
Quota Project ID時需要)。
按一下 [儲存]。
設定 Workload Identity 憑證
選擇這個方法或 JSON 金鑰方法,驗證整合服務。 Workload Identity 採用服務帳戶模擬功能,使用短期臨時存取權杖,因此建議採用這種更安全的方法,因為這樣就不必儲存或輪替長期有效的密鑰。
找出專屬執行個體 ID
如要使用 Workload Identity 進行驗證,必須授予 Google SecOps 執行個體模擬服務帳戶的權限。這樣執行個體就能安全地存取 Google Cloud 資源。
在 Google SecOps 中,依序前往「Content Hub」>「Response Integrations」。
選取「Web Risk」整合服務,然後在
Workload Identity Email中輸入服務帳戶電子郵件地址。依序點選「儲存」>「測試」。測試預計會失敗。
按一下「測試」旁的「close_small」close_small按鈕,然後搜尋以
gke-init-python@...或soar-python@...開頭的身分電子郵件地址錯誤訊息。複製這個專屬電子郵件地址,然後在整合設定期間貼到
Workload Identity Email中。
在 Google Cloud中授權執行個體身分
擷取 Google SecOps 執行個體的專屬身分後,您必須授權該身分存取Google Cloud 資源。這個步驟會啟用服務帳戶模擬功能,讓平台產生短期權杖並代您執行動作,不必使用靜態金鑰。
在 Google Cloud 控制台中,依序前往「IAM & Admin」(IAM 與管理) >「Service Accounts」(服務帳戶)。
選取目標服務帳戶,然後依序前往「權限」> 授予存取權。
將專屬電子郵件地址貼到「New principals」(新增主體) 欄位。
指派「服務帳戶權杖建立者」角色 (
roles/iam.serviceAccountTokenCreator)。
授予配額專案存取權
使用 Workload Identity 進行驗證時,您必須在整合設定中指定 Quota Project ID,才能追蹤 API 使用量和帳單。
如要授權,您必須在指定配額專案中,將下列角色授予服務帳戶:
在 Google Cloud 控制台中,前往「IAM 與管理」>「IAM」,然後選取專案。
在主體清單中找到服務帳戶,然後按一下該帳戶的「編輯」(編輯主體)。
按一下「Add another role」(新增其他角色),然後選取「Service Usage Consumer」(服務使用情形消費者) 角色 (
roles/serviceusage.serviceUsageConsumer)。按一下 [儲存]。
設定 JSON 金鑰
選擇此方法或 Workload Identity 方法,驗證整合。只有在環境中無法使用 Workload Identity 時,才使用 JSON 金鑰方法。建議您採用 Workload Identity,因為這種做法更安全。這個方法依賴靜態的長期密鑰檔案,需要手動管理和輪替。
請按照下列步驟產生驗證整合作業所需的 JSON 金鑰檔:
在 Google Cloud 控制台中,依序前往「IAM & Admin」(IAM 與管理)>「Service Accounts」(服務帳戶),然後選取您建立的服務帳戶。
前往「金鑰」分頁。
依序點選「新增金鑰」>「建立新的金鑰」。
選取「
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 和帳單的專案 ID。 Google Cloud 如要使用這個參數,您必須將 如未提供值,整合服務會從 Google Cloud 服務帳戶擷取專案 ID。 |
Workload Identity Email |
選用。
用於 Workload Identity 模擬的服務帳戶用戶端電子郵件地址。 |
Verify SSL |
必要
如果選取這個選項,整合服務會在連線至 Cloud Asset Inventory 伺服器時驗證 SSL 憑證。 (預設為啟用)。 |
如需在 Google SecOps 中設定整合功能的操作說明,請參閱「設定整合功能」。
如有需要,您可以在稍後階段進行變更。設定整合執行個體後,您就可以在應對手冊中使用該執行個體。如要進一步瞭解如何設定及支援多個執行個體,請參閱「支援多個執行個體」。
動作
如要進一步瞭解動作,請參閱「 從工作台回覆待處理動作」和「執行手動動作」。
充實資源
使用「Enrich Resource」(充實資源) 動作,透過 Cloud Asset Inventory 充實資源的相關資訊。 Google Cloud
這項操作不會在 Google SecOps 實體上執行。
動作輸入內容
如要設定「Enrich Resource」(擴充資源) 動作,請使用下列參數:
| 參數 | 說明 |
|---|---|
Resource Names |
必要
以半形逗號分隔的清單,內含要擷取詳細資料的資源名稱。 如要設定這個參數,請輸入完整的中繼資料資源名稱,格式如下: |
Fields To Return |
選填
以逗號分隔的欄位清單,用於指定要傳回的欄位。 預設值為 值範例如下:
動作一律會傳回 您也可以設定進階篩選器。舉例來說,如要從 |
動作輸出內容
「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」動作可以傳回下列輸出訊息:
| 輸出訊息 | 訊息說明 |
|---|---|
|
動作成功。 |
Error executing action "Enrich resources". Reason:
ERROR_REASON |
動作失敗。 檢查伺服器的連線、輸入參數或憑證。 |
指令碼結果
下表列出使用「Enrich Resource」(擴充資源) 動作時,指令碼結果輸出的值:
| 指令碼結果名稱 | 值 |
|---|---|
is_success |
True或False |
取得資源快照
使用「取得資源快照」動作,透過 Cloud Asset Inventory 取得資源相關資訊。
這項操作不會在 Google SecOps 實體上執行。
動作輸入內容
如要設定「取得資源快照」動作,請使用下列參數:
| 參數 | 說明 |
|---|---|
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.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
|
動作成功。 |
Error executing action "Get Resource Snapshot". Reason:
ERROR_REASON |
動作失敗。 檢查伺服器的連線、輸入參數或憑證。 |
指令碼結果
下表列出使用「取得資源快照」動作時,指令碼結果輸出的值:
| 指令碼結果名稱 | 值 |
|---|---|
is_success |
True或False |
列出服務帳戶角色
使用「列出服務帳戶角色」動作,透過 Cloud Asset Inventory 列出與 Google Cloud 服務帳戶相關的角色。
這項操作不會在 Google SecOps 實體上執行。
動作輸入內容
如要設定「List Service Account Roles」(列出服務帳戶角色) 動作,請使用下列參數:
| 參數 | 說明 |
|---|---|
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」動作測試與 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 專業人員尋求答案。