收集 Forseti Open Source 記錄
本文說明如何使用 Google Cloud Storage V2,將 Forseti Open Source 記錄檔擷取至 Google Security Operations。
Forseti Security 是依據社群需求推出的一套開放原始碼工具,可協助您增強 Google Cloud Platform 環境的安全性。Forseti 會定期建立 GCP 資源的清查快照、掃描資源,確保存取權控管機制的設定符合需求,並提供 Cloud IAM 政策的瀏覽權限。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體。
- 已啟用 Cloud Storage API 的 GCP 專案。
- 建立及管理 GCS 值區的權限。
- 管理 Google Cloud Storage 值區的 IAM 政策的權限。
- 現有的 Forseti Security 部署作業 (例如使用 Google Compute Engine 上的 Forseti Terraform 模組部署)。
- 存取 Forseti 伺服器設定檔 (
forseti_conf_server.yaml)。
建立 Google Cloud Storage 值區
使用 Google Cloud 控制台
- 前往 Google Cloud Console。
- 選取專案或建立新專案。
- 在導覽選單中,依序前往「Cloud Storage」>「Bucket」。
- 按一下「建立值區」。
請提供下列設定詳細資料:
設定 值 為 bucket 命名 輸入全域不重複的名稱 (例如 forseti-violations-export)位置類型 根據需求選擇 (區域、雙區域、多區域) 位置 選取位置 (例如 us-central1)儲存空間級別 標準 (建議用於經常存取的記錄) 存取控管 統一 (建議) 保護工具 選用:啟用物件版本管理或保留政策 點選「建立」。
使用 gcloud 指令列工具
或者,您也可以使用 gcloud 指令建立值區:
gcloud storage buckets create gs://forseti-violations-export \
--location=us-central1 \
--default-storage-class=STANDARD
取代:
forseti-violations-export:您要使用的 bucket 名稱 (全域不重複)。us-central1:偏好的區域 (例如us-central1、europe-west1)。
設定 Forseti Security,將違規事項匯出至 GCS
Forseti Security 會使用 forseti_conf_server.yaml 檔案中的通知程式設定,將掃描器違規事項匯出至 Google Cloud Storage。
使用 SSH 連線至 Forseti 伺服器 VM:
gcloud compute ssh forseti-server-vm --project=YOUR_PROJECT_ID --zone=YOUR_ZONE將
YOUR_PROJECT_ID和YOUR_ZONE替換為 Forseti 部署值。開啟 Forseti 伺服器設定檔進行編輯:
sudo nano /home/ubuntu/forseti-security/configs/forseti_conf_server.yaml如果 Forseti 部署作業使用以 GCS 為基礎的設定,請從 Forseti 伺服器 bucket 下載檔案:
gsutil cp gs://YOUR_FORSETI_SERVER_BUCKET/configs/forseti_conf_server.yaml ~/forseti_conf_server.yaml前往
notifier區段,找出resources子區段。針對要匯出的每個違規事項資源類型,設定
gcs_violations通知器。新增或更新設定,方法如下:notifier: resources: - resource: iam_policy_violations should_notify: true notifiers: - name: gcs_violations configuration: data_format: csv gcs_path: gs://forseti-violations-export/violations/ - resource: firewall_rule_violations should_notify: true notifiers: - name: gcs_violations configuration: data_format: csv gcs_path: gs://forseti-violations-export/violations/ - resource: cloudsql_acl_violations should_notify: true notifiers: - name: gcs_violations configuration: data_format: csv gcs_path: gs://forseti-violations-export/violations/ - resource: bucket_acl_violations should_notify: true notifiers: - name: gcs_violations configuration: data_format: csv gcs_path: gs://forseti-violations-export/violations/ - resource: config_validator_violations should_notify: true notifiers: - name: gcs_violations configuration: data_format: csv gcs_path: gs://forseti-violations-export/violations/取代:
forseti-violations-export:您在上一個步驟中建立的 GCS bucket 名稱。violations/:用於整理違規檔案的選用前置路徑。
設定參數:
resource:違規事項資源類型。可用的資源類型取決於部署中啟用的 Forseti 掃描器。常見的類型包括iam_policy_violations、firewall_rule_violations、cloudsql_acl_violations、bucket_acl_violations、config_validator_violations、groups_settings_violations等。should_notify:設為true,即可啟用這類資源的通知。data_format:匯出資料的格式。有效值為csv或json。預設值為csv。gcs_path:匯出違規事項的 Cloud Storage 路徑。路徑開頭必須為gs://,結尾應為正斜線。
儲存設定檔。
如果您從 GCS 下載設定,請將更新後的檔案上傳回 Forseti 伺服器 bucket:
gsutil cp ~/forseti_conf_server.yaml gs://YOUR_FORSETI_SERVER_BUCKET/configs/forseti_conf_server.yaml重新載入 Forseti 伺服器設定:
forseti server configuration reload確認設定已成功載入:
forseti server configuration get | grep gcs_violations
擷取 Google SecOps 服務帳戶
Google SecOps 會使用專屬服務帳戶,從 GCS bucket 讀取資料。您必須授予這個服務帳戶值區存取權。
在 Google SecOps 中設定動態消息,擷取 Forseti Open Source 記錄
- 依序前往「SIEM 設定」>「動態饋給」。
- 按一下「新增動態消息」。
- 按一下「設定單一動態饋給」。
- 在「動態饋給名稱」欄位中輸入動態饋給名稱 (例如
Forseti Violations)。 - 選取「Google Cloud Storage V2」做為「來源類型」。
選取「Forseti Open Source」做為「記錄類型」。
按一下「取得服務帳戶」。
系統會顯示不重複的服務帳戶電子郵件地址,例如:
chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com複製這個電子郵件地址,後續步驟會用到。
點選「下一步」。
指定下列輸入參數的值:
- 儲存空間 bucket URL:輸入 GCS bucket URI,並加上前置路徑:
gs://forseti-violations-export/violations/- 取代:
forseti-violations-export:您的 GCS bucket 名稱。violations/:儲存記錄的選用前置字元/資料夾路徑 (如為根目錄,請留空)。
來源刪除選項:根據偏好設定選取刪除選項:
- 永不:移轉後一律不刪除任何檔案 (建議用於測試)。
- 刪除已轉移的檔案:成功轉移檔案後刪除檔案。
- 刪除已轉移的檔案和空白目錄:成功轉移後刪除檔案和空白目錄。
- 檔案存在時間上限:包含在過去天數內修改的檔案。預設值為 180 天。
- 資產命名空間:資產命名空間。
- 擷取標籤:要套用至這個動態饋給事件的標籤。
點選「下一步」。
在「Finalize」(完成) 畫面中檢查新的動態饋給設定,然後按一下「Submit」(提交)。
將 IAM 權限授予 Google SecOps 服務帳戶
Google SecOps 服務帳戶需要 GCS bucket 的「Storage 物件檢視者」角色。
使用 Google Cloud 控制台
- 依序前往「Cloud Storage」>「Buckets」。
- 按一下 bucket 名稱。
- 前往「權限」分頁標籤。
- 按一下「授予存取權」。
- 請提供下列設定詳細資料:
- 新增主體:貼上 Google SecOps 服務帳戶電子郵件地址。
- 指派角色:選取「Storage 物件檢視者」。
- 按一下 [儲存]。
使用 gcloud 指令列工具
或者,使用 gcloud 指令授予權限:
gcloud storage buckets add-iam-policy-binding gs://forseti-violations-export \
--member="serviceAccount:chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com" \
--role="roles/storage.objectViewer"
取代:
forseti-violations-export:bucket 名稱。chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com:Google SecOps 服務帳戶電子郵件地址。
使用 gsutil 指令列工具 (舊版)
gsutil iam ch serviceAccount:chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com:objectViewer \
gs://forseti-violations-export
驗證權限
如要確認權限是否已正確授予,請按照下列步驟操作:
gcloud storage buckets get-iam-policy gs://forseti-violations-export \
--flatten="bindings[].members" \
--filter="bindings.role:roles/storage.objectViewer"
輸出內容應會顯示 Google SecOps 服務帳戶電子郵件地址。
UDM 對應表
| 記錄欄位 | UDM 對應 | 邏輯 |
|---|---|---|
| data.resource_data.instanceGroupUrls | 關於 | 從 instanceGroupUrls 陣列合併 |
| data.resource_data.nodePools.*.statusMessage | metadata.description | nodePool.statusMessage 的值 |
| data.resource_type | metadata.event_type | 針對 kms_cryptokey/serviceaccount_key 設為 RESOURCE_PERMISSIONS_CHANGE,針對防火牆設為 RESOURCE_DELETION,針對 kubernetes_cluster 設為 STATUS_HEARTBEAT,否則設為 GENERIC_EVENT |
| data.scanner_index_id | metadata.product_log_id | 直接複製值,並轉換為字串 |
| metadata.product_name | 設為「FORSETI SECURITY」 | |
| metadata.vendor_name | 設為「FORSETI」 | |
| data.resource_data.direction | network.direction | 如果方向為「INGRESS」,請設為「INBOUND」 |
| data.resource_data.endpoint | principal.ip | 直接複製值 |
| data.resource_data.nodeConfig.oauthScopes.0 | principal.url | 直接複製值 |
| data.full_name、serviceAccount | principal.user.userid | 使用 grok 從 data.full_name 擷取,或設為 serviceAccount (如不為空白) |
| data.violation_data.protection_level、data.violation_data.purpose、data.violation_data.project_id、data.violation_data.node_pool_name、data.violation_data.violation_reason | security_result.detection_fields | 從多個鍵/值組合合併 |
| data.violation_type | security_result.category | 如果為 FIREWALL_BLACKLIST_VIOLATION,則設為 POLICY_VIOLATION;如果為 KE_VERSION_VIOLATION,則設為 UNKNOWN_CATEGORY;否則設為 ACL_VIOLATION |
| data.rule_name | security_result.rule_name | 直接複製值 |
| data.violation_type | security_result.summary | 直接複製值 |
| data.resource_data.zone | target.asset.attribute.cloud.availability_zone | 直接複製值 |
| target.asset.attribute.cloud.environment | 設為「GOOGLE_CLOUD_PLATFORM」 | |
| data.full_name | target.asset.attribute.cloud.project.id | 使用 grok 從 data.full_name 擷取 |
| data.resource_data.subnetwork | target.asset.attribute.cloud.vpc.name | 直接複製值 |
| data.resource_data.nodeConfig.machineType | target.asset.hardware | 從 machineType 和常數 CPU 平台合併 |
| data.resource_data.privateClusterConfig.privateEndpoint | target.ip | 直接複製值 |
| data.resource_data.versionTemplate.algorithm、data.resource_data.key_algorithm | target.labels | 演算法的合併鍵/值組合 (如有) |
| data.resource_data.location | target.location.name | 直接複製值 |
| data.resource_name | target.resource.name | 直接複製值 |
| data.resource_id | target.resource.product_object_id | 如果與 resource_name 不同,則直接複製值 |
| data.resource_type | target.resource.resource_subtype | 如果 resource_type 為 kubernetes_cluster,請設為「gke」 |
| data.resource_type | target.resource.resource_type | 根據原始 resource_type 對應至特定類型 |
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。