Slack 監査ログを収集する
このドキュメントでは、Google Cloud Run functions を使用して Slack 監査ログを Google Security Operations に取り込む方法について説明します。パーサーは、Slack 監査ログの 2 つの形式を処理します。まず、ブール値を正規化し、事前定義されたフィールドをクリアします。次に、「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 & Permissions] に移動します。
- [Scopes] セクションに移動し、次の User Token Scope を追加します。
- auditlogs:read
- [Install to Workspace] [Allow] をクリックします。
- インストールが完了したら、[組織レベルのアプリ> 組織にインストール] に移動します。
- 組織のオーナー/管理者アカウントでアプリを承認します。
xoxp-
で始まる ユーザー OAuth トークン(SLACK_ADMIN_TOKEN)をコピーして安全に保存します。- Slack 管理コンソールで [設定と権限] > [組織の設定] に移動し、組織 ID をコピーします。
ディレクトリの設定
- Cloud Run 関数のデプロイ用に、ローカルマシンに新しいディレクトリを作成します。
- Chronicle ingestion-scripts 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 コンソールで、[セキュリティ] > [Secret Manager] に移動します。
- [シークレットの作成] をクリックします。
- Chronicle サービス アカウントについて、次の構成の詳細を指定します。
- 名前: 「
chronicle-service-account
」と入力します。 - シークレット値: Google SecOps の取り込み認証 JSON ファイルの内容を貼り付けます。
- 名前: 「
- [シークレットの作成] をクリックします。
次の形式でシークレット リソース名をコピーします。
projects/<PROJECT_ID>/secrets/chronicle-service-account/versions/latest
[シークレットを作成] をもう一度クリックして、2 つ目のシークレットを作成します。
Slack トークンの次の構成の詳細を指定します。
- 名前: 「
slack-admin-token
」と入力します。 - シークレット値: Slack ユーザー OAuth トークン(
xoxp-
で始まる)を貼り付けます。
- 名前: 「
[シークレットの作成] をクリックします。
次の形式でシークレット リソース名をコピーします。
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 関数で使用するサービス アカウントのメールアドレスに置き換えます。
デプロイが完了するまで待ちます。
デプロイが完了したら、出力から関数 URL をメモします。
Cloud Scheduler を設定する
- Google Cloud コンソールで、[Cloud Scheduler] > [ジョブを作成] に移動します。
- 次の構成の詳細を入力します。
- 名前: 「
slack-audit-scheduler
」と入力します。 - リージョン: Cloud Run functions の関数をデプロイしたリージョンと同じリージョンを選択します。
- 頻度:
*/5 * * * *
と入力します(POLL_INTERVAL
値に合わせて 5 分ごとに実行されます)。 - タイムゾーン: [UTC] を選択します。
- ターゲット タイプ: [HTTP] を選択します。
- URL: デプロイ出力から Cloud Run 関数の URL を入力します。
- HTTP メソッド: [POST] を選択します。
- Auth ヘッダー: [OIDC トークンを追加] を選択します。
- サービス アカウント: Cloud Run functions に使用したサービス アカウントと同じアカウントを選択します。
- 名前: 「
- [作成] をクリックします。
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 のプロフェッショナルから回答を得ることができます。