收集 Slack 稽核記錄
支援的國家/地區:
Google SecOps
SIEM
本文說明如何使用 Google Cloud Run 函式,將 Slack 稽核記錄擷取至 Google Security Operations。剖析器會處理兩種格式的 Slack 稽核記錄。系統會先將布林值正規化,並清除預先定義的欄位。然後將「message」欄位剖析為 JSON,並捨棄非 JSON 訊息。視特定欄位 (date_create
和 user_id
) 是否存在,剖析器會套用不同邏輯,將原始記錄檔欄位對應至 UDM,包括中繼資料、主體、網路、目標和相關資訊,並建構安全性結果。
事前準備
請確認您已完成下列事前準備事項:
- Google SecOps 執行個體
- Slack Enterprise Grid 租戶和管理控制台的專屬存取權
- GCP Cloud Run functions 和 Cloud Scheduler 的特殊存取權
收集 Slack 稽核記錄的必要條件 (應用程式 ID、OAuth 權杖、機構 ID)
- 登入 Enterprise Grid 機構的 Slack 管理控制台。
- 前往 https://api.slack.com/apps,然後依序點選「Create New App」>「From scratch」。
- 輸入「應用程式名稱」,然後選取「開發 Slack 工作區」。
- 點選「建立應用程式」。
- 前往左側邊欄的「OAuth 和權限」。
- 前往「範圍」部分,然後新增下列「使用者權杖範圍」:
- auditlogs:read
- 依序按一下「安裝到 Workspace」「允許」。
- 安裝完成後,請依序前往「機構層級應用程式」>「安裝至機構」。
- 使用機構擁有者/管理員帳戶授權應用程式。
- 複製並安全地儲存以
xoxp-
開頭的使用者 OAuth 權杖 (這是您的 SLACK_ADMIN_TOKEN)。 - 複製「機構 ID」,您可以在 Slack 管理控制台的「設定與權限」>「機構設定」下方找到該 ID。
設定目錄
- 在本機上建立新目錄,用於部署 Cloud Run 函式。
- 從 Chronicle 擷取指令碼 GitHub 存放區下載下列檔案:
- 從 slack 資料夾下載:
.env.yml
main.py
requirements.txt
- 從存放區的根目錄下載整個 common 目錄及其所有檔案:
common/__init__.py
common/auth.py
common/env_constants.py
common/ingest.py
common/status.py
common/utils.py
- 從 slack 資料夾下載:
- 將所有下載的檔案放入部署目錄。
目錄結構應如下所示:
deployment_directory/
├─common/
│ ├─__init__.py
│ ├─auth.py
│ ├─env_constants.py
│ ├─ingest.py
│ ├─status.py
│ └─utils.py
├─.env.yml
├─main.py
└─requirements.txt
在 Google Secret Manager 中建立密鑰
- 在 Google Cloud 控制台中,依序前往「Security」(安全性) >「Secret Manager」。
- 按一下「建立密鑰」。
- 提供 Chronicle 服務帳戶的下列設定詳細資料:
- 「Name」(名稱):輸入
chronicle-service-account
。 - 密鑰值:貼上 Google SecOps 擷取驗證 JSON 檔案的內容。
- 「Name」(名稱):輸入
- 按一下「建立密鑰」。
複製密鑰資源名稱,格式如下:
projects/<PROJECT_ID>/secrets/chronicle-service-account/versions/latest
再次按一下「建立密鑰」,建立第二個密鑰。
提供 Slack 權杖的下列設定詳細資料:
- 「Name」(名稱):輸入
slack-admin-token
。 - 密碼值:貼上 Slack 使用者 OAuth 權杖 (開頭為
xoxp-
)。
- 「Name」(名稱):輸入
按一下「建立密鑰」。
複製密鑰資源名稱,格式如下:
projects/<PROJECT_ID>/secrets/slack-admin-token/versions/latest
設定必要的執行階段環境變數
- 開啟部署目錄中的
.env.yml
檔案。 使用您的值設定環境變數:
CHRONICLE_CUSTOMER_ID: "<your-chronicle-customer-id>" CHRONICLE_REGION: us CHRONICLE_SERVICE_ACCOUNT: "projects/<PROJECT_ID>/secrets/chronicle-service-account/versions/latest" CHRONICLE_NAMESPACE: "" POLL_INTERVAL: "5" SLACK_ADMIN_TOKEN: "projects/<PROJECT_ID>/secrets/slack-admin-token/versions/latest"
- 取代下列項目:
<your-chronicle-customer-id>
:您的 Google SecOps 客戶 ID。<PROJECT_ID>
:您的 Google Cloud 專案 ID。- CHRONICLE_REGION:設為 Google SecOps 區域。有效值:
us
、asia-northeast1
、asia-south1
、asia-southeast1
、australia-southeast1
、europe
、europe-west2
、europe-west3
、europe-west6
、europe-west9
、europe-west12
、me-central1
、me-central2
、me-west1
、northamerica-northeast2
、southamerica-east1
。 - POLL_INTERVAL:函式的執行頻率間隔 (以分鐘為單位)。這個時間長度必須與 Cloud Scheduler 工作間隔相同。
- 取代下列項目:
儲存
.env.yml
檔案。
部署 Cloud Run 函式
- 在 Google Cloud 控制台中開啟終端機或 Cloud Shell。
前往部署目錄:
cd /path/to/deployment_directory
執行下列指令來部署 Cloud Run 函式:
gcloud functions deploy slack-audit-to-chronicle \ --entry-point main \ --trigger-http \ --runtime python39 \ --env-vars-file .env.yml \ --timeout 300s \ --memory 512MB \ --service-account <SERVICE_ACCOUNT_EMAIL>
- 將
<SERVICE_ACCOUNT_EMAIL>
替換為您要 Cloud Run 函式使用的服務帳戶電子郵件地址。
- 將
等待部署作業完成。
部署完成後,請記下輸出內容中的函式網址。
設定 Cloud Scheduler
- 在 Google Cloud 控制台中,依序前往「Cloud Scheduler」>「建立工作」。
- 提供下列設定詳細資料:
- 「Name」(名稱):輸入
slack-audit-scheduler
。 - 區域:選取您部署 Cloud Run 函式的區域。
- 頻率:輸入
*/5 * * * *
(每 5 分鐘執行一次,與POLL_INTERVAL
值相符)。 - 時區:選取「UTC」。
- 目標類型:選取「HTTP」。
- 網址:輸入部署輸出內容中的 Cloud Run 函式網址。
- HTTP 方法:選取「POST」。
- Auth 標頭:選取「新增 OIDC 權杖」。
- 服務帳戶:選取用於 Cloud Run 函式的服務帳戶。
- 「Name」(名稱):輸入
- 點選「建立」。
UDM 對應表
記錄欄位 | UDM 對應 | 邏輯 |
---|---|---|
action |
metadata.product_event_type |
直接從原始記錄中的 action 欄位對應。 |
actor.type |
principal.labels.value |
直接從 actor.type 欄位對應,並新增 actor.type 鍵。 |
actor.user.email |
principal.user.email_addresses |
直接從「actor.user.email 」欄位對應。 |
actor.user.id |
principal.user.product_object_id |
直接從「actor.user.id 」欄位對應。 |
actor.user.id |
principal.user.userid |
直接從「actor.user.id 」欄位對應。 |
actor.user.name |
principal.user.user_display_name |
直接從「actor.user.name 」欄位對應。 |
actor.user.team |
principal.user.group_identifiers |
直接從「actor.user.team 」欄位對應。 |
context.ip_address |
principal.ip |
直接從「context.ip_address 」欄位對應。 |
context.location.domain |
about.resource.attribute.labels.value |
直接從 context.location.domain 欄位對應,並新增 context.location.domain 鍵。 |
context.location.id |
about.resource.id |
直接從「context.location.id 」欄位對應。 |
context.location.name |
about.resource.name |
直接從「context.location.name 」欄位對應。 |
context.location.name |
about.resource.attribute.labels.value |
直接從 context.location.name 欄位對應,並新增 context.location.name 鍵。 |
context.location.type |
about.resource.resource_subtype |
直接從「context.location.type 」欄位對應。 |
context.session_id |
network.session_id |
直接從「context.session_id 」欄位對應。 |
context.ua |
network.http.user_agent |
直接從「context.ua 」欄位對應。 |
context.ua |
network.http.parsed_user_agent |
使用 parseduseragent 篩選器從 context.ua 欄位衍生而來的已剖析使用者代理程式資訊。 |
country |
principal.location.country_or_region |
直接從「country 」欄位對應。 |
date_create |
metadata.event_timestamp.seconds |
系統會將 date_create 欄位的紀元時間戳記轉換為時間戳記物件。 |
details.inviter.email |
target.user.email_addresses |
直接從「details.inviter.email 」欄位對應。 |
details.inviter.id |
target.user.product_object_id |
直接從「details.inviter.id 」欄位對應。 |
details.inviter.name |
target.user.user_display_name |
直接從「details.inviter.name 」欄位對應。 |
details.inviter.team |
target.user.group_identifiers |
直接從「details.inviter.team 」欄位對應。 |
details.reason |
security_result.description |
直接從 details.reason 欄位對應,如果是陣列,則以半形逗號串連。 |
details.type |
about.resource.attribute.labels.value |
直接從 details.type 欄位對應,並新增 details.type 鍵。 |
details.type |
security_result.summary |
直接從「details.type 」欄位對應。 |
entity.app.id |
target.resource.id |
直接從「entity.app.id 」欄位對應。 |
entity.app.name |
target.resource.name |
直接從「entity.app.name 」欄位對應。 |
entity.channel.id |
target.resource.id |
直接從「entity.channel.id 」欄位對應。 |
entity.channel.name |
target.resource.name |
直接從「entity.channel.name 」欄位對應。 |
entity.channel.privacy |
target.resource.attribute.labels.value |
直接從 entity.channel.privacy 欄位對應,並新增 entity.channel.privacy 鍵。 |
entity.file.filetype |
target.resource.attribute.labels.value |
直接從 entity.file.filetype 欄位對應,並新增 entity.file.filetype 鍵。 |
entity.file.id |
target.resource.id |
直接從「entity.file.id 」欄位對應。 |
entity.file.name |
target.resource.name |
直接從「entity.file.name 」欄位對應。 |
entity.file.title |
target.resource.attribute.labels.value |
直接從 entity.file.title 欄位對應,並新增 entity.file.title 鍵。 |
entity.huddle.date_end |
about.resource.attribute.labels.value |
直接從 entity.huddle.date_end 欄位對應,並新增 entity.huddle.date_end 鍵。 |
entity.huddle.date_start |
about.resource.attribute.labels.value |
直接從 entity.huddle.date_start 欄位對應,並新增 entity.huddle.date_start 鍵。 |
entity.huddle.id |
about.resource.attribute.labels.value |
直接從 entity.huddle.id 欄位對應,並新增 entity.huddle.id 鍵。 |
entity.huddle.participants.0 |
about.resource.attribute.labels.value |
直接從 entity.huddle.participants.0 欄位對應,並新增 entity.huddle.participants.0 鍵。 |
entity.huddle.participants.1 |
about.resource.attribute.labels.value |
直接從 entity.huddle.participants.1 欄位對應,並新增 entity.huddle.participants.1 鍵。 |
entity.type |
target.resource.resource_subtype |
直接從「entity.type 」欄位對應。 |
entity.user.email |
target.user.email_addresses |
直接從「entity.user.email 」欄位對應。 |
entity.user.id |
target.user.product_object_id |
直接從「entity.user.id 」欄位對應。 |
entity.user.name |
target.user.user_display_name |
直接從「entity.user.name 」欄位對應。 |
entity.user.team |
target.user.group_identifiers |
直接從「entity.user.team 」欄位對應。 |
entity.workflow.id |
target.resource.id |
直接從「entity.workflow.id 」欄位對應。 |
entity.workflow.name |
target.resource.name |
直接從「entity.workflow.name 」欄位對應。 |
id |
metadata.product_log_id |
直接從「id 」欄位對應。 |
ip |
principal.ip |
直接對應至「ip 」欄位。根據 action 欄位的邏輯判斷。預設為 USER_COMMUNICATION ,但會根據 action 的值變更為其他值,例如 USER_CREATION 、USER_LOGIN 、USER_LOGOUT 、USER_RESOURCE_ACCESS 、USER_RESOURCE_UPDATE_PERMISSIONS 或 USER_CHANGE_PERMISSIONS 。已硬式編碼為「SLACK_AUDIT」。如果存在 date_create ,請設為「Enterprise Grid」,否則如果存在 user_id ,請設為「稽核記錄」。已硬式編碼為「Slack」。已硬式編碼為「REMOTE」。如果 action 包含「user_login」或「user_logout」,請設為「SSO」。否則請設為「MACHINE」。提供的範例中未對應。預設值為「ALLOW」,但如果 action 為「user_login_failed」,則會設為「BLOCK」。如果 date_create 存在,請設為「Slack」,否則如果 user_id 存在,請設為「SLACK」。 |
user_agent |
network.http.user_agent |
直接從「user_agent 」欄位對應。 |
user_id |
principal.user.product_object_id |
直接從「user_id 」欄位對應。 |
username |
principal.user.product_object_id |
直接從「username 」欄位對應。 |
還有其他問題嗎?向社群成員和 Google SecOps 專業人員尋求答案。