收集 Forseti Open Source 日志

支持的平台:

本文档介绍了如何使用 Google Cloud Storage V2 将 Forseti 开源日志注入到 Google Security Operations。

Forseti Security 是一个社区驱动的开源工具集合,可帮助您提高 Google Cloud Platform 环境的安全性。Forseti 会定期拍摄 GCP 资源的库存快照,扫描资源以确保访问权限控制措施按预期设置,并提供 Cloud IAM 政策的可见性。

准备工作

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

  • Google SecOps 实例。
  • 已启用 Cloud Storage API 的 GCP 项目。
  • 创建和管理 GCS 存储分区的权限。
  • 管理 GCS 存储分区上的 IAM 政策的权限。
  • 现有的 Forseti Security 部署(例如,使用 Google Compute Engine 上的 Forseti Terraform 模块部署)。
  • 对 Forseti 服务器配置文件 (forseti_conf_server.yaml) 的访问权限。

创建 Google Cloud Storage 存储分区

使用 Google Cloud 控制台

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

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

使用 gcloud 命令行工具

或者,使用 gcloud 命令创建存储桶:

gcloud storage buckets create gs://forseti-violations-export \
    --location=us-central1 \
    --default-storage-class=STANDARD

  • forseti-violations-export:您所需的存储桶名称(全局唯一)。
  • us-central1:您的首选区域(例如 us-central1europe-west1)。

配置 Forseti Security 以将违规情况导出到 GCS

Forseti Security 使用 forseti_conf_server.yaml 文件中的通知程序配置将扫描器违规情况导出到 Google Cloud Storage。

  1. 使用 SSH 连接到 Forseti 服务器虚拟机:

    gcloud compute ssh forseti-server-vm --project=YOUR_PROJECT_ID --zone=YOUR_ZONE
    

    YOUR_PROJECT_IDYOUR_ZONE 替换为您的 Forseti 部署值。

  2. 打开 Forseti 服务器配置文件以进行修改:

    sudo nano /home/ubuntu/forseti-security/configs/forseti_conf_server.yaml
    

    如果您的 Forseti 部署使用基于 GCS 的配置,请从 Forseti 服务器存储桶下载该文件:

    gsutil cp gs://YOUR_FORSETI_SERVER_BUCKET/configs/forseti_conf_server.yaml ~/forseti_conf_server.yaml
    
  3. 前往 notifier 部分,找到 resources 子部分。

  4. 对于要导出的每种违规资源类型,配置 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 存储桶名称。
    • violations/:用于整理违规文件的可选前缀路径。

    配置参数

    • resource:违规资源类型。可用的资源类型取决于您的部署中启用了哪些 Forseti 扫描器。常见类型包括 iam_policy_violationsfirewall_rule_violationscloudsql_acl_violationsbucket_acl_violationsconfig_validator_violationsgroups_settings_violations 等。
    • should_notify:设置为 true 可针对相应资源类型启用通知。
    • data_format:导出数据的格式。有效值为 csvjson。默认值为 csv
    • gcs_path:将导出违规情况的 Cloud Storage 路径。路径必须以 gs:// 开头,并且应包含尾部斜杠。
  5. 保存配置文件。

  6. 如果您是从 GCS 下载的配置,请将更新后的文件上传回 Forseti 服务器分区:

    gsutil cp ~/forseti_conf_server.yaml gs://YOUR_FORSETI_SERVER_BUCKET/configs/forseti_conf_server.yaml
    
  7. 重新加载 Forseti 服务器配置:

    forseti server configuration reload
    
  8. 验证配置是否已成功加载:

    forseti server configuration get | grep gcs_violations
    

检索 Google SecOps 服务账号

Google SecOps 使用唯一的服务账号从您的 GCS 存储分区中读取数据。您必须授予此服务账号对您的存储分区的访问权限。

在 Google SecOps 中配置 Feed 以注入 Forseti 开源日志

  1. 依次前往 SIEM 设置 > Feed
  2. 点击添加新 Feed
  3. 点击配置单个 Feed
  4. Feed 名称字段中,输入 Feed 的名称(例如 Forseti Violations)。
  5. 选择 Google Cloud Storage V2 作为来源类型
  6. 选择 Forseti 开源作为日志类型

  7. 点击获取服务账号

  8. 系统会显示一个唯一的服务账号电子邮件地址,例如:

    chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.com
    
  9. 复制此电子邮件地址。您将在下一步骤中用到它。

  10. 点击下一步

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

    • 存储分区网址:输入带有前缀路径的 GCS 存储分区 URI:
    gs://forseti-violations-export/violations/
    
    • 替换:
      • forseti-violations-export:您的 GCS 存储分区名称。
      • violations/:存储日志的可选前缀/文件夹路径(留空表示根目录)。
    • 来源删除选项:根据您的偏好选择删除选项:

      • 永不:永不删除转移后的任何文件(建议用于测试)。
      • 删除已转移的文件:在成功转移后删除文件。
      • 删除已转移的文件和空目录:在成功转移后删除文件和空目录。
    • 文件存在时间上限:包含在过去指定天数内修改的文件。默认值为 180 天。
    • 资产命名空间资产命名空间
    • 注入标签:要应用于此 Feed 中事件的标签。
  12. 点击下一步

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

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

Google SecOps 服务账号需要对您的 GCS 存储分区具有 Storage Object Viewer 角色。

使用 Google Cloud 控制台

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

使用 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:您的存储桶名称。
  • 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 专业人士的解答。