收集 Proofpoint TAP Threats 日志

支持的平台:

本文档介绍了如何使用 Google Cloud Storage V2 将 Proofpoint TAP Threats 日志注入到 Google Security Operations。

Proofpoint Targeted Attack Protection (TAP) 是一种先进的电子邮件安全平台,可检测、分析和阻止通过电子邮件传递的威胁,包括恶意附件和网址。TAP SIEM API 可提供有关您环境中观察到的威胁事件的近乎实时的数据,包括被阻止和已传递的邮件、被阻止和允许的点击,以及关联的威胁元数据,例如威胁分类、网址、附件和发件人信息。这些事件可用于检测基于电子邮件的活跃攻击、丰富安全调查,以及触发自动响应工作流。

准备工作

请确保满足以下前提条件:

  • Google SecOps 实例
  • 已启用 Cloud Storage API 的 GCP 项目
  • 创建和管理 GCS 存储分区的权限
  • 创建 Cloud Run 服务、Pub/Sub 主题和 Cloud Scheduler 作业的权限
  • 已订阅 Proofpoint TAP 并可访问威胁洞察信息中心
  • 具有访问 SIEM API 权限的 TAP API 服务凭据(服务正文和密钥)

生成 Proofpoint TAP API 服务凭据

  1. 登录 Proofpoint TAP 威胁洞察信息中心
  2. 依次前往设置 > 已关联的应用 > 服务凭据
  3. 点击创建新凭据
  4. 生成的服务凭据对话框中,复制并安全存储以下信息:

    • 服务正文:用于 API 身份验证的正文标识符
    • Secret:用于 API 身份验证的密钥

验证 API 访问权限

  • 在继续进行集成之前,请先测试您的凭据:

    PRINCIPAL="your-service-principal"
    SECRET="your-secret"
    
    # Test SIEM API access (fetch last 5 minutes of events)
    curl -s "https://tap-api-v2.proofpoint.com/v2/siem/all?format=json&sinceSeconds=300" \
      --user "${PRINCIPAL}:${SECRET}"
    

    如果请求成功,响应会返回一个 JSON 对象,其中包含 messagesBlockedmessagesDeliveredclicksBlockedclicksPermitted 数组。

    • 如果您收到 401 错误,请验证您的服务正文和密钥是否正确。
    • 如果您收到 403 错误,请确认您的账号已启用 TAP API 访问权限。

创建 Google Cloud Storage 存储桶

  1. 前往 Google Cloud 控制台
  2. 选择您的项目或创建新项目。
  3. 在导航菜单中,依次前往 Cloud Storage > 存储分区
  4. 点击创建存储分区
  5. 提供以下配置详细信息:

    设置
    为存储桶命名 输入一个全局唯一的名称(例如 proofpoint-tap-threats-logs
    位置类型 根据您的需求进行选择(区域级、双区域、多区域)
    位置 选择营业地点(例如 us-central1
    存储类别 标准(建议用于经常访问的日志)
    访问权限控制 均匀(推荐)
    保护工具 可选:启用对象版本控制或保留政策
  6. 点击创建

为 Cloud Run 函数创建服务账号

Cloud Run 函数需要一个服务账号,该账号具有写入 GCS 存储桶的权限,并且可以由 Pub/Sub 调用。

创建服务账号

  1. GCP 控制台中,依次前往 IAM 和管理 > 服务账号
  2. 点击创建服务账号
  3. 提供以下配置详细信息:
    • 服务账号名称:输入 tap-threats-collector-sa
    • 服务账号说明:输入 Service account for Cloud Run function to collect Proofpoint TAP Threats logs
  4. 点击创建并继续
  5. 向此服务账号授予对项目的访问权限部分中,添加以下角色:
    1. 点击选择角色
    2. 搜索并选择 Storage Object Admin
    3. 点击 + 添加其他角色
    4. 搜索并选择 Cloud Run Invoker
    5. 点击 + 添加其他角色
    6. 搜索并选择 Cloud Functions Invoker
  6. 点击继续
  7. 点击完成

必须拥有这些角色,才能:

  • Storage Object Admin:将威胁事件数据写入 GCS 存储桶并管理状态文件
  • Cloud Run Invoker:允许 Pub/Sub 调用函数
  • Cloud Functions Invoker:允许调用函数

授予对 GCS 存储桶的 IAM 权限

向服务账号授予对 GCS 存储桶的写入权限:

  1. 前往 Cloud Storage > 存储分区
  2. 点击您的存储桶名称。
  3. 前往权限标签页。
  4. 点击授予访问权限
  5. 提供以下配置详细信息:
    • 添加主账号:输入服务账号电子邮件地址(例如 tap-threats-collector-sa@PROJECT_ID.iam.gserviceaccount.com
    • 分配角色:选择 Storage Object Admin
  6. 点击保存

创建 Pub/Sub 主题

创建一个 Pub/Sub 主题,Cloud Scheduler 将向该主题发布消息,而 Cloud Run 函数将订阅该主题。

  1. GCP 控制台中,前往 Pub/Sub > 主题
  2. 点击创建主题
  3. 提供以下配置详细信息:
    • 主题 ID:输入 tap-threats-collector-trigger
    • 将其他设置保留为默认值
  4. 点击创建

创建 Cloud Run 函数以收集威胁事件

Cloud Run 函数将由来自 Cloud Scheduler 的 Pub/Sub 消息触发,以从 Proofpoint TAP SIEM API 中提取威胁事件,并将结果写入 GCS。

  1. GCP 控制台中,前往 Cloud Run
  2. 点击创建服务
  3. 选择函数(使用内嵌编辑器创建函数)。
  4. 配置部分中,提供以下配置详细信息:

    设置
    Service 名称 tap-threats-collector
    区域 选择与您的 GCS 存储桶匹配的区域(例如 us-central1
    运行时 选择 Python 3.12 或更高版本
  5. 触发器(可选)部分中:

    1. 点击 + 添加触发器
    2. 选择 Cloud Pub/Sub
    3. 选择 Cloud Pub/Sub 主题部分,选择主题 tap-threats-collector-trigger
    4. 点击保存
  6. 身份验证部分中:

    1. 选择需要进行身份验证
    2. 检查 Identity and Access Management (IAM)
  7. 向下滚动并展开容器、网络、安全性

  8. 前往安全性标签页:

    • 服务账号:选择服务账号 tap-threats-collector-sa
  9. 前往容器标签页:

    1. 点击变量和密钥
    2. 为每个环境变量点击+ 添加变量
    变量名称 示例值 说明
    GCS_BUCKET proofpoint-tap-threats-logs GCS 存储桶名称
    GCS_PREFIX tap-threats 日志文件的前缀
    STATE_KEY tap-threats/state.json 状态文件路径
    TAP_PRINCIPAL your-service-principal TAP API 服务正文
    TAP_SECRET your-secret TAP API Secret
    LOOKBACK_HOURS 1 初始回溯期(以小时为单位,最长 7 天)
  10. 变量和 Secret 部分中,向下滚动到请求

    • 请求超时:输入 540 秒(9 分钟)
  11. 前往设置标签页:

    • 资源部分中:
      • 内存:选择 512 MiB 或更高值
      • CPU:选择 1
  12. 修订版本伸缩部分中:

    • 实例数下限:输入 0
    • 实例数上限:输入 100(或根据预期负载进行调整)
  13. 点击创建

  14. 等待服务创建完成(1-2 分钟)。

  15. 创建服务后,系统会自动打开内嵌代码编辑器

添加函数代码

  1. 入口点字段中输入 main
  2. 在内嵌代码编辑器中,创建两个文件:

    • 第一个文件 - main.py:

      import functions_framework
      from google.cloud import storage
      import json
      import os
      import urllib3
      from datetime import datetime, timezone, timedelta
      import time
      import base64
      
      # Initialize HTTP client with timeouts
      http = urllib3.PoolManager(
        timeout=urllib3.Timeout(connect=10.0, read=60.0),
        retries=False,
      )
      
      # Initialize Storage client
      storage_client = storage.Client()
      
      # Environment variables
      GCS_BUCKET = os.environ.get('GCS_BUCKET')
      GCS_PREFIX = os.environ.get('GCS_PREFIX', 'tap-threats').strip('/')
      STATE_KEY = os.environ.get('STATE_KEY') or f"{GCS_PREFIX}/state.json"
      TAP_PRINCIPAL = os.environ.get('TAP_PRINCIPAL')
      TAP_SECRET = os.environ.get('TAP_SECRET')
      LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '1'))
      
      API_BASE = 'https://tap-api-v2.proofpoint.com'
      
      def get_auth_header():
        """Build HTTP Basic Authentication header."""
        auth_string = f"{TAP_PRINCIPAL}:{TAP_SECRET}"
        auth_bytes = auth_string.encode('utf-8')
        auth_b64 = base64.b64encode(auth_bytes).decode('utf-8')
        return f"Basic {auth_b64}"
      
      @functions_framework.cloud_event
      def main(cloud_event):
        """
        Cloud Run function triggered by Pub/Sub to fetch Proofpoint TAP
        SIEM threat events and write to GCS.
      
        The function queries the TAP SIEM API /v2/siem/all endpoint to
        retrieve blocked and delivered messages, blocked and permitted
        clicks, and associated threat metadata.
      
        Args:
          cloud_event: CloudEvent object containing Pub/Sub message
        """
      
        if not all([GCS_BUCKET, TAP_PRINCIPAL, TAP_SECRET]):
          print('Error: Missing required environment variables')
          return
      
        try:
          bucket = storage_client.bucket(GCS_BUCKET)
      
          # Load state
          state = load_state(bucket, STATE_KEY)
      
          # Determine time window
          now = datetime.now(timezone.utc)
          last_time = None
      
          if isinstance(state, dict) and state.get('last_event_time'):
            try:
              last_time = parse_datetime(state['last_event_time'])
              # Overlap by 2 minutes to catch delayed events
              last_time = last_time - timedelta(minutes=2)
            except Exception as e:
              print(f"Warning: Could not parse last_event_time: {e}")
      
          if last_time is None:
            last_time = now - timedelta(hours=LOOKBACK_HOURS)
      
          # TAP SIEM API allows max 1 hour per request and max 7 days lookback
          if (now - last_time) > timedelta(days=7):
            last_time = now - timedelta(days=7)
            print("Warning: Lookback capped to 7 days (TAP API limit)")
      
          print(f"Fetching threats from {last_time.isoformat()} to {now.isoformat()}")
      
          # Fetch threat events from the SIEM API
          all_events = fetch_siem_events(last_time, now)
      
          if not all_events:
            print("No threat events found in the specified time window.")
            save_state(bucket, STATE_KEY, now.isoformat())
            return
      
          # Write to GCS as NDJSON
          timestamp = now.strftime('%Y%m%d_%H%M%S')
          object_key = f"{GCS_PREFIX}/tap_threats_{timestamp}.ndjson"
          blob = bucket.blob(object_key)
      
          ndjson = '\n'.join(
            [json.dumps(record, ensure_ascii=False) for record in all_events]
          ) + '\n'
          blob.upload_from_string(ndjson, content_type='application/x-ndjson')
      
          print(f"Wrote {len(all_events)} records to gs://{GCS_BUCKET}/{object_key}")
      
          # Update state
          save_state(bucket, STATE_KEY, now.isoformat())
      
          print(f"Successfully collected {len(all_events)} threat events")
      
        except Exception as e:
          print(f'Error processing TAP threats: {str(e)}')
          raise
      
      def load_state(bucket, key):
        """Load state from GCS."""
        try:
          blob = bucket.blob(key)
          if blob.exists():
            state_data = blob.download_as_text()
            return json.loads(state_data)
        except Exception as e:
          print(f"Warning: Could not load state: {e}")
        return {}
      
      def save_state(bucket, key, last_event_time_iso):
        """Save the last event timestamp to GCS state file."""
        try:
          state = {'last_event_time': last_event_time_iso}
          blob = bucket.blob(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}")
      
      def parse_datetime(value):
        """Parse ISO datetime string to datetime object."""
        if value.endswith('Z'):
          value = value[:-1] + '+00:00'
        return datetime.fromisoformat(value)
      
      def fetch_siem_events(start_time, end_time):
        """
        Fetch threat events from the TAP SIEM API by querying
        in 1-hour intervals within the specified time window.
      
        Returns individual event records from messagesBlocked,
        messagesDelivered, clicksBlocked, and clicksPermitted arrays,
        each tagged with an _eventType field.
      
        Args:
          start_time: Start of the time window (datetime)
          end_time: End of the time window (datetime)
      
        Returns:
          List of event dictionaries
        """
        headers = {
          'Authorization': get_auth_header(),
          'Accept': 'application/json',
          'User-Agent': 'GoogleSecOps-TAPThreatsCollector/1.0',
        }
      
        all_events = []
        current_start = start_time
        backoff = 1.0
      
        while current_start < end_time:
          # TAP SIEM API allows max 1 hour per request
          current_end = min(current_start + timedelta(hours=1), end_time)
      
          interval = (
            f"{current_start.strftime('%Y-%m-%dT%H:%M:%SZ')}"
            f"/{current_end.strftime('%Y-%m-%dT%H:%M:%SZ')}"
          )
          url = f"{API_BASE}/v2/siem/all?format=json&interval={interval}"
      
          try:
            response = http.request('GET', url, headers=headers)
      
            if response.status == 429:
              retry_after = int(
                response.headers.get('Retry-After', str(int(backoff)))
              )
              print(f"Rate limited (429). Retrying after {retry_after}s...")
              time.sleep(retry_after)
              backoff = min(backoff * 2, 60.0)
              continue
      
            backoff = 1.0
      
            if response.status != 200:
              print(f"SIEM API HTTP Error: {response.status}")
              response_text = response.data.decode('utf-8')
              print(f"Response body: {response_text[:500]}")
              current_start = current_end
              continue
      
            data = json.loads(response.data.decode('utf-8'))
      
            # Collect events from all categories with type tagging
            event_types = {
              'messagesBlocked': 'MESSAGE_BLOCKED',
              'messagesDelivered': 'MESSAGE_DELIVERED',
              'clicksBlocked': 'CLICK_BLOCKED',
              'clicksPermitted': 'CLICK_PERMITTED',
            }
      
            interval_count = 0
            for key, event_type in event_types.items():
              for event in data.get(key, []):
                event['_eventType'] = event_type
                all_events.append(event)
                interval_count += 1
      
            print(
              f"Interval {interval}: {interval_count} events, "
              f"{len(all_events)} total so far"
            )
      
          except Exception as e:
            print(f"Error fetching SIEM events: {e}")
      
          current_start = current_end
      
        return all_events
      
    • 第二个文件 - requirements.txt:

      functions-framework==3.*
      google-cloud-storage==2.*
      urllib3>=2.0.0
      
  3. 点击部署以保存并部署该函数。

  4. 等待部署完成(2-3 分钟)。

创建 Cloud Scheduler 作业

Cloud Scheduler 会定期向 Pub/Sub 主题发布消息,从而触发 Cloud Run 函数。

  1. GCP Console 中,前往 Cloud Scheduler
  2. 点击创建作业
  3. 提供以下配置详细信息:

    设置
    名称 tap-threats-collector-hourly
    区域 选择与 Cloud Run 函数相同的区域
    频率 0 * * * *(每小时一次,整点时)
    时区 选择时区(建议选择世界协调时间 [UTC])
    目标类型 Pub/Sub
    主题 选择主题 tap-threats-collector-trigger
    消息正文 {}(空 JSON 对象)
  4. 点击创建

时间表频率选项

根据日志量和延迟时间要求选择频次:

频率 Cron 表达式 使用场景
每隔 15 分钟 */15 * * * * 威胁数量较多的高流量环境
每小时 0 * * * * 标准(推荐)
每 6 小时 0 */6 * * * 低容量环境

测试集成

  1. Cloud Scheduler 控制台中,找到您的作业。
  2. 点击强制运行以手动触发作业。
  3. 等待几秒钟。
  4. 前往 Cloud Run > 服务
  5. 点击函数名称 tap-threats-collector
  6. 点击日志标签页。
  7. 验证函数是否已成功执行。查找:

    Fetching threats from YYYY-MM-DDTHH:MM:SS+00:00 to YYYY-MM-DDTHH:MM:SS+00:00
    Interval .../...: X events, Y total so far
    Wrote Z records to gs://proofpoint-tap-threats-logs/tap-threats/tap_threats_YYYYMMDD_HHMMSS.ndjson
    Successfully collected Z threat events
    
  8. 前往 Cloud Storage > 存储分区

  9. 点击您的存储桶名称。

  10. 前往前缀文件夹 tap-threats/

  11. 验证是否已创建具有当前时间戳的新 .ndjson 文件。

如果您在日志中看到错误,请执行以下操作:

  • HTTP 401:检查环境变量中的 TAP_PRINCIPAL 和 TAP_SECRET。验证服务正文和 Secret 是否正确。
  • HTTP 403:确认您的 TAP 账号已启用 API 访问权限。
  • HTTP 429:速率限制 - 函数将自动重试并进行退避。请考虑降低安排的频次。
  • 未发现任何威胁事件:如果在时间窗口内未检测到任何威胁,则这是正常现象。TAP 仅报告由 网址 Defense 或 Attachment Defense 识别的威胁。
  • 缺少环境变量:检查是否已设置所有必需的变量。

在 Google SecOps 中配置 Feed 以注入 Proofpoint TAP Threats 日志

  1. 依次前往 SIEM 设置 > Feed
  2. 点击添加新 Feed
  3. 点击配置单个 Feed
  4. Feed 名称字段中,输入 Feed 的名称(例如 Proofpoint TAP Threats)。
  5. 选择 Google Cloud Storage V2 作为来源类型
  6. 选择 Proofpoint Tap Threats 作为日志类型
  7. 点击获取服务账号。系统会显示一个唯一的服务账号电子邮件地址,例如:

    chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com
    
  8. 复制此电子邮件地址,以便在下一步中使用。

  9. 点击下一步

  10. 为以下输入参数指定值:

    • 存储桶网址:输入带有前缀路径的 GCS 存储桶 URI:

      gs://proofpoint-tap-threats-logs/tap-threats/
      
      • 替换:
        • proofpoint-tap-threats-logs:您的 GCS 存储桶名称。
        • tap-threats:存储日志的可选前缀/文件夹路径(留空表示根目录)。
    • 来源删除选项:根据您的偏好选择删除选项:

      • 永不:转移后永不删除任何文件(建议用于测试)。
      • 删除已转移的文件:在成功转移后删除文件。
      • 删除已转移的文件和空目录:成功转移后删除文件和空目录。
    • 文件存在时间上限:包含在过去指定天数内修改的文件(默认值为 180 天)

    • 资产命名空间资产命名空间

    • 注入标签:要应用于此 Feed 中事件的标签

  11. 点击下一步

  12. 最终确定界面中查看新的 Feed 配置,然后点击提交

向 Google SecOps 服务账号授予 IAM 权限

Google SecOps 服务账号需要您的 GCS 存储桶的 Storage Object Viewer 角色。

  1. 前往 Cloud Storage > 存储分区
  2. 点击您的存储桶名称。
  3. 前往权限标签页。
  4. 点击授予访问权限
  5. 提供以下配置详细信息:
    • 添加主账号:粘贴 Google SecOps 服务账号电子邮件地址
    • 分配角色:选择 Storage Object Viewer
  6. 点击保存

UDM 映射表

日志字段 UDM 映射 逻辑
detectionType_label additional.fields 已合并
geoTargeted_label additional.fields 已合并
notable_label additional.fields 已合并
verticallyTargeted_label additional.fields 已合并
identifiedAt metadata.event_timestamp 解析为 ISO8601
has_principal metadata.event_type 已映射:trueNETWORK_CONNECTIONtrueSTATUS_UPDATE
type metadata.product_event_type 直接映射
id metadata.product_log_id 直接映射
_associations security_result.associations 已合并
_techniques security_result.attack_details.techniques 已合并
_category security_result.category 已合并
_category_details security_result.category_details 已合并
notable security_result.priority 已映射:trueHIGH_PRIORITY
name security_result.threat_name 直接映射
status security_result.threat_status 映射:activeACTIVEclearedCLEARED
_verdict_info security_result.verdict_info 已合并
不适用 metadata.event_type 常量:NETWORK_CONNECTION
不适用 metadata.product_event_type 常量:Proofpoint_Threats_Feed
不适用 metadata.product_name 常量:TAP Threats
不适用 metadata.vendor_name 常量:Proofpoint
不适用 security_result.priority 常量:HIGH_PRIORITY
不适用 security_result.threat_status 常量:ACTIVE
identifiedAt security_result.first_discovered_time 从变更日志映射
severityScore threat_result.severity 从变更日志映射
attackSpread security_result.verdict_info.global_customer_count 从变更日志映射
actors security_result.associations.associated_actors 从变更日志映射
families security_result.associations.associated_actors 从变更日志映射
malware security_result.associations.associated_actors 从变更日志映射
brands security_result.associations.associated_actors 从变更日志映射

更新日志

查看相应解析器的更改日志

需要更多帮助?获得社区成员和 Google SecOps 专业人士的解答。