收集 Menlo Security Isolation Platform (MSIP) 記錄

支援的服務:

本指南說明如何使用 Google Cloud Storage,將 Menlo Security Isolation Platform (MSIP) 記錄檔擷取至 Google SecOps。

Menlo Security 採用隔離式方法,將網頁瀏覽和文件擷取作業,拆分到使用者裝置和遠離端點的隔離式拋棄式虛擬容器 (DVC)。所有具風險的程式碼都會在隔離的 DVC 中執行,絕不會到達端點。系統只會將安全的顯示資料傳送至使用者的瀏覽器。這個平台提供完整的記錄功能,可記錄網頁存取、稽核事件、電子郵件安全、資料遺失防護違規和 SMTP 活動。

事前準備

請確認您符合下列必要條件:

  • Google SecOps 執行個體
  • Menlo Security 管理員入口網站的特殊存取權
  • 在 Menlo Security 建立 API 權杖的權限
  • 已啟用 Cloud Storage、Cloud Run、Pub/Sub 和 Cloud Scheduler API 的 GCP 專案

設定 Menlo Security API 存取權

如要讓 Cloud Run 函式擷取記錄,您必須建立具備 Log Export API 權限的 API 權杖。

建立 API 權杖

  1. 登入 Menlo Security 管理員入口網站 (https://admin.menlosecurity.com)。
  2. 依序前往「Settings」>「Authentication」>「API Tokens」。
  3. 按一下「Create Token」。
  4. 在「Token Name」欄位中,輸入描述性名稱 (例如 Chronicle GCS Integration)。
  5. 在「Permissions」部分,選取「Log Export API」。
  6. 按一下「建立」或「儲存」。
  7. 複製並妥善保存產生的 API 權杖。

重要事項:API 權杖只會顯示一次。建立後,請立即將金鑰儲存在安全的位置。

必要的 API 權限

  • API 權杖需要下列權限:

    權限/範圍 存取層級 目的
    Log Export API 讀取 從 Menlo Security API 擷取記錄

建立 Google Cloud Storage bucket

  1. 前往 Google Cloud 控制台。
  2. 選取專案或建立新專案。
  3. 在導覽選單中,依序前往「Cloud Storage」>「Bucket」。
  4. 按一下「建立值區」。
  5. 提供下列設定詳細資料:

    設定 值
    為 bucket 命名 輸入全域不重複的名稱 (例如 menlo-security-logs)
    位置類型 請根據需求選擇 (單一區域、雙區域、多區域)
    位置 選取位置 (例如 us-central1)
    儲存空間級別 標準 (建議用於經常存取的記錄)
    存取控管 統一 (建議)
    保護工具 選用:啟用物件版本管理或資料保留政策
  6. 點選「建立」。

建立 Cloud Run 函式的服務帳戶

建立服務帳戶

  1. 在 GCP 控制台中,依序前往「IAM & Admin」(IAM 與管理) >「Service Accounts」(服務帳戶)。
  2. 按一下「Create Service Account」(建立服務帳戶)。
  3. 提供下列設定詳細資料:
    • 服務帳戶名稱:輸入 menlo-logs-collector-sa
    • 服務帳戶說明:輸入 Service account for Cloud Run function to collect Menlo Security logs
  4. 按一下「建立並繼續」。
  5. 在「將專案存取權授予這個服務帳戶」部分,新增下列角色:
    1. 按一下「請選擇角色」。
    2. 搜尋並選取「Storage 物件管理員」。
    3. 點選「+ 新增其他角色」。
    4. 搜尋並選取「Cloud Run Invoker」。
    5. 點選「+ 新增其他角色」。
    6. 搜尋並選取「Cloud Functions 叫用者」。
  6. 按一下「繼續」。
  7. 按一下「完成」。

授予 GCS bucket 的 IAM 權限

  1. 依序前往「Cloud Storage」>「Bucket」。
  2. 點選 bucket 名稱 (menlo-security-logs)。
  3. 前往「權限」分頁。
  4. 按一下「授予存取權」。
  5. 提供下列設定詳細資料:
    • 新增主體:輸入服務帳戶電子郵件地址 (menlo-logs-collector-sa@PROJECT_ID.iam.gserviceaccount.com)
    • 指派角色:選取「Storage 物件管理員」
  6. 按一下「儲存」。

建立 Pub/Sub 主題

  1. 在 GCP 控制台中,依序前往「Pub/Sub」>「主題」。
  2. 按一下「建立主題」。
  3. 提供下列設定詳細資料:
    • 主題 ID:輸入 menlo-logs-trigger
    • 其他設定保留預設值
  4. 點選「建立」。

建立 Cloud Run 函式來收集記錄

  1. 在 GCP 控制台中,前往「Cloud Run」。
  2. 按一下「Create service」(建立服務)。
  3. 選取「函式」(使用直接修改建立函式)。
  4. 在「Configure」(設定) 部分,提供下列設定詳細資料:

    設定 值
    服務名稱 menlo-logs-collector
    區域 選取與 GCS bucket 相符的區域 (例如 us-central1)
    執行階段 選取「Python 3.12」或更新版本
  5. 在「Trigger (optional)」(觸發條件 (選用)) 部分:

    1. 按一下「+ 新增觸發條件」。
    2. 選取「Cloud Pub/Sub」。
    3. 在「Select a Cloud Pub/Sub topic」(選取 Cloud Pub/Sub 主題) 中,選擇「menlo-logs-trigger」。
    4. 按一下「儲存」。
  6. 在「Authentication」(驗證) 部分:

    1. 選取「需要驗證」。
    2. Identity and Access Management (IAM)。
  7. 向下捲動並展開「容器、網路、安全性」。

  8. 前往「安全性」分頁:

    • 「服務帳戶」:選取 menlo-logs-collector-sa
  9. 前往「容器」分頁:

    1. 按一下「Variables & Secrets」(變數與密鑰)。
    2. 針對每個環境變數,按一下「+ 新增變數」:
    變數名稱 範例值 說明
    GCS_BUCKET menlo-security-logs GCS bucket 名稱
    GCS_PREFIX menlo-logs 記錄檔的前置字串
    STATE_KEY menlo-logs/state.json 狀態檔案路徑
    MENLO_API_TOKEN your-menlo-api-token Menlo Security API 權杖
    MENLO_API_HOST logs.menlosecurity.com Menlo Security API 主機
    MENLO_LOG_TYPES web,audit,email,dlp 以半形逗號分隔的記錄類型
    LOOKBACK_HOURS 1 初始回溯期
  10. 在「Variables & Secrets」(變數與密鑰) 部分,向下捲動至「Requests」(要求):

    • 要求逾時:輸入 600 秒 (10 分鐘)
  11. 前往「設定」分頁:

    • 在「Resources」(資源) 部分:
      • 「記憶體」:選取「512 MiB」或以上
      • CPU:選取「1」
  12. 在「Revision scaling」(修訂版本資源調度) 部分:

    • 「執行個體數量下限」:輸入 0
    • 「執行個體數量上限」:輸入 100
  13. 點選「建立」。

  14. 等待服務建立完成 (1 至 2 分鐘)。

  15. 服務建立後,內嵌程式碼編輯器會自動開啟。

新增函式程式碼

  1. 在「進入點」欄位中輸入 main。
  2. 在內嵌程式碼編輯器中,建立兩個檔案:

    • main.py:
    import functions_framework
    from google.cloud import storage
    import os
    import json
    import urllib3
    import time
    import uuid
    from datetime import datetime, timezone, timedelta
    
    http = urllib3.PoolManager(
      timeout=urllib3.Timeout(connect=5.0, read=60.0),
      retries=False,
    )
    
    storage_client = storage.Client()
    
    GCS_BUCKET = os.environ.get('GCS_BUCKET')
    GCS_PREFIX = os.environ.get('GCS_PREFIX', 'menlo-logs')
    STATE_KEY = os.environ.get('STATE_KEY', 'menlo-logs/state.json')
    API_TOKEN = os.environ.get('MENLO_API_TOKEN')
    API_HOST = os.environ.get('MENLO_API_HOST', 'logs.menlosecurity.com')
    LOG_TYPES = os.environ.get('MENLO_LOG_TYPES', 'web').split(',')
    LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '1'))
    
    @functions_framework.cloud_event
    def main(cloud_event):
      if not all([GCS_BUCKET, API_TOKEN, API_HOST]):
        print('Error: Missing required environment variables')
        return
    
      try:
        bucket = storage_client.bucket(GCS_BUCKET)
        state = load_state(bucket)
        now = datetime.now(timezone.utc).replace(microsecond=0)
    
        if isinstance(state, dict) and state.get('last_event_time'):
          try:
            last_val = state['last_event_time']
            if last_val.endswith('Z'):
              last_val = last_val[:-1] + '+00:00'
            last_time = datetime.fromisoformat(last_val)
            last_time = last_time - timedelta(minutes=2)
          except Exception as e:
            print(f"Warning: Could not parse last_event_time: {e}")
            last_time = now - timedelta(hours=LOOKBACK_HOURS)
        else:
          last_time = now - timedelta(hours=LOOKBACK_HOURS)
    
        print(f"Fetching logs from {last_time.isoformat()} to {now.isoformat()}")
    
        total = 0
        newest_time = None
    
        for log_type in LOG_TYPES:
          log_type = log_type.strip()
          print(f"Fetching {log_type} logs...")
          events = fetch_logs(log_type, API_TOKEN, API_HOST, last_time, now)
    
          if events:
            object_key = f"{GCS_PREFIX}/{now:%Y/%m/%d}/menlo-{log_type}-{uuid.uuid4()}.ndjson"
            blob = bucket.blob(object_key)
    
            ndjson = '\n'.join(
              [json.dumps(ev, ensure_ascii=False) for ev in events]
            ) + '\n'
            blob.upload_from_string(ndjson, content_type='application/x-ndjson')
    
            print(f"Uploaded {len(events)} {log_type} events to gs://{GCS_BUCKET}/{object_key}")
            total += len(events)
    
            for ev in events:
              ev_time = ev.get('timestamp') or ev.get('time') or ev.get('created_at')
              if ev_time and (newest_time is None or str(ev_time) > str(newest_time)):
                newest_time = str(ev_time)
          else:
            print(f"No {log_type} events found")
    
        save_state(bucket, newest_time if newest_time else now.isoformat())
        print(f"Successfully processed {total} total events")
    
      except Exception as e:
        print(f'Error processing logs: {str(e)}')
        raise
    
    def fetch_logs(log_type, token, api_host, start, end):
      url = f"https://{api_host}/api/v1/logs/{log_type}"
      headers = {
        'Authorization': f'Token {token}',
        'Accept': 'application/json',
      }
      params = {
        'start': start.strftime('%Y-%m-%dT%H:%M:%SZ'),
        'end': end.strftime('%Y-%m-%dT%H:%M:%SZ'),
      }
      query = '&'.join(f'{k}={v}' for k, v in params.items())
      full_url = f'{url}?{query}'
    
      all_events = []
      backoff = 1.0
    
      while full_url:
        response = http.request('GET', full_url, headers=headers)
    
        if response.status == 429:
          retry_after = int(response.headers.get('Retry-After', str(int(backoff))))
          print(f"Rate limited. Waiting {retry_after}s...")
          time.sleep(retry_after)
          backoff = min(backoff * 2, 60.0)
          continue
    
        if response.status != 200:
          print(f"API error {response.status}: {response.data.decode('utf-8')}")
          break
    
        backoff = 1.0
        data = json.loads(response.data.decode('utf-8'))
        events = data if isinstance(data, list) else data.get('events', data.get('data', []))
        all_events.extend(events)
    
        full_url = data.get('next') if isinstance(data, dict) else None
    
      print(f"Total {log_type} events fetched: {len(all_events)}")
      return all_events
    
    def load_state(bucket):
      try:
        blob = bucket.blob(STATE_KEY)
        if blob.exists():
          return json.loads(blob.download_as_text())
      except Exception as e:
        print(f"Warning: Could not load state: {e}")
      return {}
    
    def save_state(bucket, last_event_time_iso):
      try:
        state = {
          'last_event_time': last_event_time_iso,
          'last_run': datetime.now(timezone.utc).isoformat()
        }
        blob = bucket.blob(STATE_KEY)
        blob.upload_from_string(
          json.dumps(state, indent=2),
          content_type='application/json'
        )
        print(f"Saved state: last_event_time={last_event_time_iso}")
      except Exception as e:
        print(f"Warning: Could not save state: {e}")
    
    • requirements.txt:
    functions-framework==3.*
    google-cloud-storage==2.*
    urllib3>=2.0.0
    
  3. 按一下「部署」,即可儲存並部署函式。

  4. 等待部署作業完成 (2 至 3 分鐘)。

建立 Cloud Scheduler 工作

  1. 在 GCP 控制台中,前往「Cloud Scheduler」。
  2. 點選「建立工作」。
  3. 提供下列設定詳細資料:

    設定 值
    名稱 menlo-logs-collector-hourly
    區域 選取與 Cloud Run 函式相同的區域
    頻率 0 * * * * (每小時整點)
    時區 選取時區 (建議選取世界標準時間)
    目標類型 Pub/Sub
    主題 選取「menlo-logs-trigger」
    郵件內文 {} (空白 JSON 物件)
  4. 點選「建立」。

測試整合

  1. 在 Cloud Scheduler 控制台中,找到您的工作 (menlo-logs-collector-hourly)。
  2. 按一下「強制執行」,手動觸發工作。
  3. 稍等幾秒鐘。
  4. 依序前往「Cloud Run」>「服務」。
  5. 按一下「menlo-logs-collector」。
  6. 點選「記錄」分頁標籤。
  7. 確認函式是否執行成功。尋找:

    Fetching logs from YYYY-MM-DDTHH:MM:SS+00:00 to YYYY-MM-DDTHH:MM:SS+00:00
    Fetching web logs...
    Total web events fetched: X
    Uploaded X web events to gs://menlo-security-logs/menlo-logs/YYYY/MM/DD/menlo-web-UUID.ndjson
    Successfully processed X total events
    
  8. 依序前往「Cloud Storage」>「Bucket」。

  9. 按一下「menlo-security-logs」。

  10. 前往 menlo-logs/ 資料夾。

  11. 確認已建立新的 .ndjson 檔案,且日期為當天。

如果記錄中顯示錯誤:

  • HTTP 401:確認 MENLO_API_TOKEN 環境變數正確無誤
  • HTTP 403:確認 API 權杖具備 Log Export API 權限
  • HTTP 429:頻率限制 - 函式會自動重試,並採用輪詢機制
  • 缺少環境變數:確認 Cloud Run 函式設定中已設定所有必要變數

擷取 Google SecOps 服務帳戶

  1. 依序前往「設定」>「資料管理」>「動態饋給」。如果使用的是 SIEM 專用平台,請依序前往「設定」>「動態饋給」。
  2. 按一下「新增動態饋給」。
  3. 按一下「設定單一動態饋給」。
  4. 在「Feed name」(動態饋給名稱) 欄位中,輸入動態饋給名稱 (例如 Menlo Security MSIP Logs)。
  5. 選取「Google Cloud Storage V2」做為「來源類型」。
  6. 在「Log type」(記錄類型) 中選取「Menlo Security」。
  7. 按一下「Get Service Account」。系統會顯示專屬服務帳戶電子郵件地址,例如:

    chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com
    
  8. 複製這個電子郵件地址,下一個步驟將會用到。

  9. 點選「下一步」。

  10. 指定下列輸入參數的值:

    • Storage bucket URL:輸入 GCS bucket URI,並加上前置字元路徑:

      gs://menlo-security-logs/menlo-logs/
      
    • 來源刪除選項:根據偏好選取刪除選項:

      • Never:轉移後一律不刪除任何檔案 (建議用於測試)。
      • 刪除已轉移的檔案:在成功轉移後刪除檔案。
      • 刪除已轉移的檔案和空白目錄:成功轉移後,刪除檔案和空白目錄。

      • 檔案存在時間上限:納入過去幾天內修改過的檔案 (預設為 180 天)

      • 資產命名空間:資產命名空間

      • 擷取標籤:要套用至這個動態饋給事件的標籤

  11. 點選「下一步」。

  12. 在「完成」畫面中檢查新的新聞動態消息設定,然後按一下「提交」。

將 IAM 權限授予 Google SecOps 服務帳戶

  1. 依序前往「Cloud Storage」>「Bucket」。
  2. 按一下「menlo-security-logs」。
  3. 前往「權限」分頁。
  4. 按一下「授予存取權」。
  5. 提供下列設定詳細資料:
    • 新增主體:貼上 Google SecOps 服務帳戶電子郵件地址
    • 指派角色:選取「Storage 物件檢視者」
  6. 按一下「儲存」。

UDM 對應表

記錄欄位 UDM 對應 邏輯
customer_name intermediary.hostname 如果 customer_name 不是 IP,則設定
customer_name intermediary.ip 如果 IP 是從 customer_name 擷取,或從 xff_ip IP 擷取
xff_ip intermediary.ip
event_data.event_time metadata.event_timestamp 使用 grok 和日期篩選器剖析
request_type metadata.event_type 根據這些欄位設定條件式邏輯
has_principal metadata.event_type
has_top_url metadata.event_type
has_dest metadata.event_type
log_type metadata.log_type 直接複製值
event_data.name metadata.product_event_type 直接複製值
reqId metadata.product_log_id 直接複製值
event_data.version metadata.product_version 直接複製值
event_data.protocol network.application_protocol 使用預先定義的通訊協定清單對應
request_type network.http.method 直接複製值
參照網址 network.http.referral_url 直接複製值
response_code network.http.response_code 已轉換為整數
event_data.user-agent network.http.user_agent 直接複製值
full_session_id network.session_id 直接複製值
browser_and_version principal.application 直接複製值
event_data.x-client-ip principal.asset.ip event_data.x-client-ip 的值 (如果不是空白),否則為 src_ip
src_ip principal.asset.ip
群組 principal.group.product_object_id 直接複製值
event_data.x-client-ip principal.ip event_data.x-client-ip 的值 (如果不是空白),否則為 src_ip
src_ip principal.ip
區域 principal.location.country_or_region 如果區域值不為空白,則為區域值,否則為 egress_country
egress_country principal.location.country_or_region
region_name principal.location.name 直接複製值
egress_ip principal.nat_ip 直接複製值
event_data.userid principal.user.email_addresses 與電子郵件規則運算式相符時合併
event_data.userid principal.user.userid 直接複製值
event_data.domain security_result.about.administrative_domain 直接複製值
event_data.url security_result.about.url 直接複製值
event_data.pe_action security_result.action 對應至 ALLOW、BLOCK 或 ALLOW_WITH_MODIFICATION
event_data.categories security_result.category_details 從 event_data.categories (擷取或直接) 和 casb_cat_name 合併
casb_cat_name security_result.category_details
event_data.risk_score security_result.confidence_details 直接複製值
content-type security_result.detection_fields 合併自多個標籤欄位
產品 security_result.detection_fields
威脅 security_result.detection_fields
virusDetails security_result.detection_fields
sandboxResult security_result.detection_fields
fullScanResult security_result.detection_fields
tab_id security_result.detection_fields
pe_reason security_result.detection_fields
ua_type security_result.detection_fields
email_isolation_state security_result.detection_fields
document_url security_result.detection_fields
archive_path security_result.detection_fields
casb_app_name security_result.detection_fields
casb_fun_name security_result.detection_fields
casb_org_name security_result.detection_fields
casb_profile_id security_result.detection_fields
casb_profile_name security_result.detection_fields
casb_profile_type security_result.detection_fields
casb_risk_score security_result.detection_fields
connId security_result.detection_fields
origin_country security_result.detection_fields
egress_country security_result.detection_fields
is_casb_ddl security_result.detection_fields
is_iframe security_result.detection_fields
parent_file_id security_result.detection_fields
parent_filename security_result.detection_fields
parent_sha256 security_result.detection_fields
parent_tid security_result.detection_fields
root_file_id security_result.detection_fields
root_filename security_result.detection_fields
root_sha256 security_result.detection_fields
casb_risk_score security_result.risk_score 已轉換為浮點數
casb_profile_id security_result.rule_id 直接複製值
pe_rulename security_result.rule_name 直接複製值
casb_profile_name security_result.rule_set 直接複製值
casb_profile_type security_result.rule_type 直接複製值
event_data.severity security_result.severity_details 直接複製值
magicName security_result.summary 串連為「%{magicName} is %{threats}.」
威脅 security_result.summary
threat_types security_result.threat_name 直接複製值
origin_ip src.ip 直接複製值
origin_country src.location.country_or_region 直接複製值
event_data.dst target.asset.ip 使用 grok IP 模式從 event_data.dst 或 dst 擷取
dst target.asset.ip
filename target.file.full_path 直接複製值
mimeType target.file.mime_type 直接複製值
sha256 target.file.sha256 直接複製值
file_size target.file.size 先轉換為浮點數,再轉換為無正負號整數
event_data.dst target.ip 使用 grok IP 模式從 event_data.dst 或 dst 擷取
dst target.ip
top_url target.url 使用 URI grok 模式擷取
metadata.product_name metadata.product_name 設為「MENLO SECURITY」
metadata.vendor_name metadata.vendor_name 設為「MENLO SECURITY」
region event.idm.read_only_udm.principal.location.country_or_region 從變更記錄對應
region_name event.idm.read_only_udm.principal.location.name 從變更記錄對應
src_ip event.idm.read_only_udm.principal.ip 和 event.idm.read_only_udm.principal.asset.ip 從變更記錄對應
groups event.idm.read_only_udm.principal.group.product_object_id 從變更記錄對應
content-type event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
product event.idm.read_only_udm.security_result.detection_fields 從變更記錄對應
mimeType event.idm.read_only_udm.target.file.mime_type 從變更記錄對應

變更記錄

查看這個剖析器的變更記錄

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