收集 Atlassian Confluence 記錄

支援的國家/地區:

本文說明如何將 Atlassian Confluence 記錄擷取至 Google Security Operations。剖析器會先嘗試使用專為 Atlassian Confluence 記錄設計的規則運算式 (grok 模式),從原始記錄訊息中擷取欄位。如果 Grok 剖析失敗或記錄檔為 JSON 格式,程式碼會嘗試將訊息剖析為 JSON。最後,系統會將擷取的欄位對應至 Google SecOps UDM 架構,並加入額外背景資訊。

事前準備

請確認您已完成下列事前準備事項:

  • Google SecOps 執行個體
  • 可存取稽核記錄的 Atlassian Confluence Cloud 帳戶,或具備管理員存取權的 Confluence Data Center/Server
  • AWS 相關方法:AWS (S3、IAM、Lambda、EventBridge) 的特殊權限
  • Bindplane 方法:Windows 2016 以上版本或 Linux 主機 (含 systemd)

整合選項總覽

本指南提供兩種整合路徑:

  • 選項 1:透過 BindPlane + Syslog 傳送 Confluence Data Center/Server 資料
  • 選項 2:透過 AWS Lambda + S3 (JSON 格式) 取得 Confluence Cloud 稽核記錄

請選擇最符合 Confluence 部署類型和基礎架構的選項。

選項 1:透過 Bindplane + Syslog 傳送 Confluence Data Center/Server

這個選項會設定 Confluence Data Center 或 Server,透過系統記錄將記錄傳送至 Bindplane 代理程式,然後轉送至 Google SecOps。

取得 Google SecOps 擷取驗證檔案

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「收集代理程式」
  3. 下載擷取驗證檔案。將檔案安全地儲存在要安裝 Bindplane 的系統上。

取得 Google SecOps 客戶 ID

  1. 登入 Google SecOps 控制台。
  2. 依序前往「SIEM 設定」>「設定檔」
  3. 複製並儲存「機構詳細資料」專區中的客戶 ID

安裝 Bindplane 代理程式

請按照下列操作說明,在 Windows 或 Linux 作業系統上安裝 Bindplane 代理程式。

Windows 安裝

  1. 以管理員身分開啟「命令提示字元」或「PowerShell」
  2. 執行下列指令:

    msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet
    

Linux 安裝

  1. 開啟具備根層級或 sudo 權限的終端機。
  2. 執行下列指令:

    sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh
    

其他安裝資源

設定 Bindplane 代理程式,擷取系統記錄檔並傳送至 Google SecOps

  1. 存取設定檔:

    1. 找出 config.yaml 檔案。通常位於 Linux 的 /etc/bindplane-agent/ 目錄,或 Windows 的安裝目錄。
    2. 使用文字編輯器 (例如 nanovi 或記事本) 開啟檔案。
  2. 按照下列方式編輯 config.yaml 檔案:

    receivers:
      udplog:
        # Replace the port and IP address as required
        listen_address: "0.0.0.0:514"
    
    exporters:
      chronicle/chronicle_w_labels:
        compression: gzip
        # Adjust the path to the credentials file you downloaded
        creds_file_path: '/path/to/ingestion-authentication-file.json'
        # Replace with your actual customer ID
        customer_id: YOUR_CUSTOMER_ID
        endpoint: malachiteingestion-pa.googleapis.com
        log_type: 'ATLASSIAN_CONFLUENCE'
        raw_log_field: body
        ingestion_labels:
    
    service:
      pipelines:
        logs/confluence:
          receivers:
            - udplog
          exporters:
            - chronicle/chronicle_w_labels
    
    • 視基礎架構需求,替換通訊埠和 IP 位址。
    • <YOUR_CUSTOMER_ID_HERE> 替換為實際的客戶 ID。
    • /path/to/ingestion-authentication-file.json 更新為「取得 Google SecOps 擷取驗證檔案」部分中驗證檔案的儲存路徑。

重新啟動 Bindplane 代理程式,以套用變更

  • 如要在 Linux 中重新啟動 Bindplane 代理程式,請執行下列指令:

    sudo systemctl restart bindplane-agent
    
  • 如要在 Windows 中重新啟動 Bindplane 代理程式,可以使用「服務」控制台,或輸入下列指令:

    net stop BindPlaneAgent && net start BindPlaneAgent
    

在 Confluence Data Center/Server 上設定 Syslog 轉送

  1. 透過 SSH 或 RDP 登入 Confluence 伺服器。
  2. 找出 Log4j 設定檔:
    • Log4j2:<confluence-install>/confluence/WEB-INF/classes/log4j2.xml
  3. 編輯設定檔,新增 SyslogAppender:

    <Configuration>
      <Appenders>
        <!-- Existing appenders -->
    
        <Syslog name="SyslogAppender" 
                host="BINDPLANE_AGENT_IP" 
                port="514" 
                protocol="UDP"
                facility="LOCAL0"
                format="RFC5424">
          <PatternLayout pattern="%d{ISO8601} %p [%t] [%c{1}] %m%n"/>
        </Syslog>
      </Appenders>
    
      <Loggers>
        <Root level="info">
          <AppenderRef ref="SyslogAppender"/>
          <!-- Other appender refs -->
        </Root>
    
        <!-- Audit logger -->
        <Logger name="com.atlassian.confluence.event.events.security.AuditEvent" level="info" additivity="false">
          <AppenderRef ref="SyslogAppender"/>
        </Logger>
      </Loggers>
    </Configuration>
    
    • BINDPLANE_AGENT_IP 替換為 BindPlane 代理程式的 IP 位址。
  4. 重新啟動 Confluence 以套用變更:

    sudo systemctl restart confluence
    

選項 B:設定 rsyslog 轉送本機記錄檔

  1. 設定 Confluence 將記錄檔寫入檔案 (預設行為)。
  2. 如果沒有 rsyslog,請安裝:

    sudo apt-get install rsyslog  # Debian/Ubuntu
    sudo yum install rsyslog      # RHEL/CentOS
    
  3. 建立 rsyslog 設定檔 /etc/rsyslog.d/confluence.conf

    # Forward Confluence logs to BindPlane
    $ModLoad imfile
    
    # Application logs
    $InputFileName /opt/atlassian/confluence/logs/atlassian-confluence.log
    $InputFileTag confluence-app:
    $InputFileStateFile stat-confluence-app
    $InputFileSeverity info
    $InputFileFacility local0
    $InputRunFileMonitor
    
    # Audit logs (JSON format in DC/Server)
    $InputFileName /var/atlassian/application-data/confluence/log/audit/*.json
    $InputFileTag confluence-audit:
    $InputFileStateFile stat-confluence-audit
    $InputFileSeverity info
    $InputFileFacility local1
    $InputRunFileMonitor
    
    # Forward to BindPlane agent
    *.* @@BINDPLANE_AGENT_IP:514
    
    • BINDPLANE_AGENT_IP 替換為 Bindplane 代理程式的 IP 位址。
    • 根據 Confluence 安裝位置調整記錄檔路徑:
      • 應用程式記錄檔通常會:<confluence-install>/logs/<local-home>/logs/
      • 稽核記錄:<confluence-home>/log/audit/*.json
  4. 重新啟動 rsyslog:

    sudo systemctl restart rsyslog
    

選項 2:透過 AWS Lambda + S3 取得 Confluence Cloud 稽核記錄

收集 Confluence Cloud API 憑證

  1. 登入 Atlassian 帳戶
  2. 前往 https://id.atlassian.com/manage-profile/security/api-tokens
  3. 按一下「Create API Token」(建立 API 憑證)
  4. 輸入權杖的標籤 (例如 Google Security Operations Integration)。
  5. 點選「建立」
  6. 複製並妥善儲存 API 權杖。
  7. 記下 Confluence Cloud 網站網址 (例如 https://yoursite.atlassian.net)。
  8. 記下 Atlassian 帳戶電子郵件地址 (用於驗證)。

為 Google SecOps 設定 AWS S3 值區和 IAM

  1. 按照這份使用者指南建立 Amazon S3 bucket建立 bucket
  2. 儲存 bucket 的「名稱」和「地區」,以供日後參考 (例如 confluence-audit-logs)。
  3. 請按照這份使用者指南建立使用者建立 IAM 使用者
  4. 選取建立的「使用者」
  5. 選取「安全憑證」分頁標籤。
  6. 在「Access Keys」部分中,按一下「Create Access Key」
  7. 選取「第三方服務」做為「用途」
  8. 點選「下一步」
  9. 選用:新增說明標記。
  10. 按一下「建立存取金鑰」
  11. 按一下「下載 CSV 檔案」,儲存「存取金鑰」和「私密存取金鑰」以供日後參考。
  12. 按一下 [完成]
  13. 選取「權限」分頁標籤。
  14. 在「權限政策」部分中,按一下「新增權限」
  15. 選取「新增權限」
  16. 選取「直接附加政策」
  17. 搜尋 AmazonS3FullAccess 政策。
  18. 選取政策。
  19. 點選「下一步」
  20. 按一下「Add permissions」。

設定 S3 上傳的身分與存取權管理政策和角色

  1. 在 AWS 控制台中,依序前往「IAM」>「Policies」>「Create policy」>「JSON」分頁標籤
  2. 輸入下列政策:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Sid": "AllowPutObjects",
          "Effect": "Allow",
          "Action": "s3:PutObject",
          "Resource": "arn:aws:s3:::confluence-audit-logs/*"
        },
        {
          "Sid": "AllowGetStateObject",
          "Effect": "Allow",
          "Action": "s3:GetObject",
          "Resource": "arn:aws:s3:::confluence-audit-logs/confluence-audit/state.json"
        }
      ]
    }
    
    • 如果您輸入其他 bucket 名稱,請替換 confluence-audit-logs
  3. 依序點選「下一步」>「建立政策」

  4. 將政策命名為 ConfluenceAuditToS3Policy

  5. 依序前往「IAM」>「Roles」>「Create role」>「AWS service」>「Lambda」

  6. 附加新建立的政策 ConfluenceAuditToS3Policy

  7. 為角色命名 ConfluenceAuditLambdaRole,然後按一下「建立角色」

建立 Lambda 函式

  1. AWS 控制台中,依序前往「Lambda」> Functions
  2. 依序點選「建立函式」>「從頭開始撰寫」
  3. 請提供下列設定詳細資料:

    設定
    名稱 ConfluenceAuditToS3
    執行階段 Python 3.13
    架構 x86_64
    執行角色 ConfluenceAuditLambdaRole
  4. 建立函式後,開啟「程式碼」分頁,刪除存根並輸入下列程式碼:

    import json
    import os
    import boto3
    from datetime import datetime, timezone, timedelta
    from urllib import request, parse, error
    from base64 import b64encode
    
    # Environment variables
    S3_BUCKET = os.environ['S3_BUCKET']
    S3_PREFIX = os.environ.get('S3_PREFIX', 'confluence-audit/')
    STATE_KEY = os.environ.get('STATE_KEY', 'confluence-audit/state.json')
    CONFLUENCE_URL = os.environ['CONFLUENCE_URL']  # e.g., https://yoursite.atlassian.net
    CONFLUENCE_EMAIL = os.environ['CONFLUENCE_EMAIL']
    CONFLUENCE_API_TOKEN = os.environ['CONFLUENCE_API_TOKEN']
    MAX_RECORDS = int(os.environ.get('MAX_RECORDS', '1000'))
    
    s3_client = boto3.client('s3')
    
    def lambda_handler(event, context):
        """Fetch Confluence Cloud audit logs and write to S3."""
    
        # Read last execution state
        start_date = get_last_execution_time()
        end_date = datetime.now(timezone.utc)
    
        print(f"Fetching audit logs from {start_date} to {end_date}")
    
        # Fetch audit records
        records = fetch_audit_logs(start_date, end_date)
    
        if not records:
            print("No new audit records found.")
            save_state(end_date)
            return {'statusCode': 200, 'body': 'No new records'}
    
        # Write to S3
        timestamp = end_date.strftime('%Y%m%d_%H%M%S')
        object_key = f"{S3_PREFIX}audit_{timestamp}.json"
    
        s3_client.put_object(
            Bucket=S3_BUCKET,
            Key=object_key,
            Body='\n'.join(json.dumps(record) for record in records),
            ContentType='application/json'
        )
    
        print(f"Wrote {len(records)} records to s3://{S3_BUCKET}/{object_key}")
    
        # Update state
        save_state(end_date)
    
        return {
            'statusCode': 200,
            'body': f"Processed {len(records)} records"
        }
    
    def get_last_execution_time():
        """Retrieve the last execution timestamp from S3 state file."""
        try:
            response = s3_client.get_object(Bucket=S3_BUCKET, Key=STATE_KEY)
            state = json.loads(response['Body'].read())
            return datetime.fromisoformat(state['last_execution'])
        except s3_client.exceptions.NoSuchKey:
            # First run: fetch logs from last 24 hours
            return datetime.now(timezone.utc) - timedelta(hours=24)
        except Exception as e:
            print(f"Error reading state: {e}")
            return datetime.now(timezone.utc) - timedelta(hours=24)
    
    def save_state(execution_time):
        """Save the execution timestamp to S3 state file."""
        state = {'last_execution': execution_time.isoformat()}
        s3_client.put_object(
            Bucket=S3_BUCKET,
            Key=STATE_KEY,
            Body=json.dumps(state),
            ContentType='application/json'
        )
    
    def fetch_audit_logs(start_date, end_date):
        """Fetch audit logs from Confluence Cloud REST API."""
        records = []
        start_param = int(start_date.timestamp() * 1000)  # milliseconds
        end_param = int(end_date.timestamp() * 1000)
    
        # Build authentication header
        auth_string = f"{CONFLUENCE_EMAIL}:{CONFLUENCE_API_TOKEN}"
        auth_bytes = auth_string.encode('ascii')
        auth_b64 = b64encode(auth_bytes).decode('ascii')
    
        headers = {
            'Authorization': f'Basic {auth_b64}',
            'Accept': 'application/json'
        }
    
        # Confluence Cloud Audit API endpoint
        url = f"{CONFLUENCE_URL}/wiki/rest/api/audit?startDate={start_param}&endDate={end_param}&limit=1000"
    
        try:
            req = request.Request(url, headers=headers)
            with request.urlopen(req) as response:
                data = json.loads(response.read())
                records = data.get('results', [])
                print(f"Retrieved {len(records)} audit records")
        except error.HTTPError as e:
            print(f"HTTP Error: {e.code} - {e.reason}")
            print(e.read().decode())
        except Exception as e:
            print(f"Error fetching audit logs: {e}")
    
        return records[:MAX_RECORDS]
    
  5. 依序前往「設定」>「環境變數」

  6. 依序點選「編輯」> 新增環境變數

  7. 輸入下列環境變數,並將 換成您的值。

    範例值
    S3_BUCKET confluence-audit-logs
    S3_PREFIX confluence-audit/
    STATE_KEY confluence-audit/state.json
    CONFLUENCE_URL https://yoursite.atlassian.net
    CONFLUENCE_EMAIL your-email@example.com
    CONFLUENCE_API_TOKEN your-api-token-here
    MAX_RECORDS 1000
  8. 選取「設定」分頁標籤。

  9. 在「一般設定」面板中,按一下「編輯」

  10. 將「Timeout」(逾時間隔) 變更為「5 minutes (300 seconds)」(5 分鐘 (300 秒)),然後按一下「Save」(儲存)

建立 EventBridge 排程

  1. 依序前往「Amazon EventBridge」>「Scheduler」>「Create schedule」
  2. 提供下列設定詳細資料:
    • 週期性時間表費率 (1 hour)。
    • 目標:您的 Lambda 函式 ConfluenceAuditToS3
    • 名稱ConfluenceAuditToS3-1h
  3. 按一下「建立時間表」

選用:為 Google SecOps 建立唯讀 IAM 使用者和金鑰

  1. 前往 AWS 控制台 > IAM > Users
  2. 點選 [Add users] (新增使用者)。
  3. 提供下列設定詳細資料:
    • 使用者:輸入 secops-confluence-reader
    • 存取類型:選取「存取金鑰 - 程式輔助存取」
  4. 點選「下一步」
  5. 依序點選「直接附加政策」>「建立政策」
  6. 在 JSON 編輯器中輸入下列政策:

    {
      "Version": "2012-10-17",
      "Statement": [
        {
          "Effect": "Allow",
          "Action": ["s3:GetObject"],
          "Resource": "arn:aws:s3:::confluence-audit-logs/*"
        },
        {
          "Effect": "Allow",
          "Action": ["s3:ListBucket"],
          "Resource": "arn:aws:s3:::confluence-audit-logs"
        }
      ]
    }
    
  7. 將名稱設為 secops-reader-policy

  8. 依序前往「建立政策」> 搜尋/選取 >「下一步」>「新增權限」

  9. 依序前往「安全憑證」>「存取金鑰」>「建立存取金鑰」

  10. 下載 CSV (這些值會輸入至動態饋給)。

在 Google SecOps 中設定動態饋給,擷取 Confluence 記錄

  1. 依序前往「SIEM 設定」>「動態饋給」
  2. 按一下「新增動態消息」
  3. 在「動態饋給名稱」欄位中輸入動態饋給名稱 (例如 Confluence Cloud Audit Logs)。
  4. 選取「Amazon S3 V2」做為「來源類型」
  5. 選取「Atlassian Confluence」做為「記錄類型」
  6. 點選「下一步」
  7. 指定下列輸入參數的值:
    • S3 URIs3://confluence-audit-logs/confluence-audit/
    • 來源刪除選項:根據偏好設定選取刪除選項。
    • 檔案存在時間上限:包含在過去天數內修改的檔案。預設值為 180 天。
    • 存取金鑰 ID:具有 S3 儲存空間存取權的使用者存取金鑰。
    • 存取密鑰:具有 S3 bucket 存取權的使用者私密金鑰。
    • 資產命名空間資產命名空間
    • 擷取標籤:套用至這個動態饋給事件的標籤。
  8. 點選「下一步」
  9. 在「完成」畫面中檢查新的動態饋給設定,然後按一下「提交」

UDM 對應表

記錄欄位 UDM 對應 邏輯
代理程式 read_only_udm.network.http.user_agent 取自「代理人」欄位的值。
app_protocol read_only_udm.network.application_protocol 衍生自「app_protocol」欄位。如果「app_protocol」包含「HTTPS」、「HTTP」、「SSH」或「RDP」,系統會使用對應的通訊協定。否則預設為「UNKNOWN_APPLICATION_PROTOCOL」。
app_protocol read_only_udm.network.application_protocol_version 取自「app_protocol」欄位的值。
auditType.action read_only_udm.security_result.action 衍生自「auditType.action」欄位。如果「auditType.action」包含「successful」,則值會設為「ALLOW」。如果包含「restricted」,則值會設為「BLOCK」。
auditType.action read_only_udm.security_result.summary 如果「auditType」不為空白,且「auditType_area」為「SECURITY」,則值取自「auditType.action」欄位。
auditType.actionI18nKey read_only_udm.metadata.product_event_type 如果「auditType」不為空白,則取自「auditType.actionI18nKey」欄位的值。
auditType.area read_only_udm.security_result.detection_fields.value 從「auditType.area」欄位取得值,並指派給偵測欄位的「value」欄位,且「key」欄位設為「auditType area」。如果「auditType」不為空白,系統就會執行這項對應作業。
auditType.category read_only_udm.security_result.category_details 如果「auditType」不為空白,則取自「auditType.category」欄位的值。
auditType.categoryI18nKey read_only_udm.security_result.detection_fields.value 從「auditType.categoryI18nKey」欄位取得值,並指派給偵測欄位的「value」欄位,而「key」欄位則設為「auditType categoryI18nKey」。如果「auditType」不為空白,系統就會執行這項對應作業。
auditType.level read_only_udm.security_result.detection_fields.value 從「auditType.level」欄位取得值,並指派給偵測欄位的「value」欄位,而「key」欄位則設為「auditType level」。如果「auditType」不為空白,系統就會執行這項對應作業。
author.displayName read_only_udm.principal.user.user_display_name 取自「author.displayName」欄位的值。
author.externalCollaborator read_only_udm.security_result.about.resource.attribute.labels.value 從「author.externalCollaborator」欄位取得值,並指派給「key」欄位設為「externalCollaborator」的標籤「value」欄位。
author.id read_only_udm.principal.user.userid 當「author.type」為「user」且「principal_user_present」為「false」時,取自「author.id」欄位的值。
author.isExternalCollaborator read_only_udm.security_result.about.resource.attribute.labels.value 從「author.isExternalCollaborator」欄位取得值,並指派給「value」欄位,標籤的「key」欄位則設為「isExternalCollaborator」。
author.name read_only_udm.principal.user.user_display_name 當「author.type」為「user」且「principal_user_present」為「false」時,取自「author.name」欄位的值。
bytes_in read_only_udm.network.received_bytes 如果「bytes_in」欄位包含數字,則取自該欄位的值。否則預設為 0。
category read_only_udm.security_result.category_details 取自「category」欄位的值。
changedValues read_only_udm.principal.resource.attribute.labels 逐一迭代「changedValues」中的每個元素,並使用「changedValue[index][key]」等鍵和「changedValues」陣列中的對應值建立標籤。
建立日期 read_only_udm.metadata.event_timestamp 取自「creationDate」欄位的值,會剖析為 UNIX 或 UNIX_MS 時間戳記。
extraAttributes read_only_udm.principal.resource.attribute.labels 逐一疊代「extraAttributes」中的每個元素,並根據「name」和「nameI18nKey」欄位建立含有鍵的標籤,以及來自對應「value」欄位的值。
http_verb read_only_udm.network.http.method 值取自「http_verb」欄位。
ip read_only_udm.target.ip 取自「ip」欄位的值。
principal_host read_only_udm.principal.hostname 取自「principal_host」欄位的值。
referral_url read_only_udm.network.http.referral_url 值取自「referral_url」欄位。
remoteAddress read_only_udm.principal.ip 取自「remoteAddress」欄位的值,並剖析為 IP 位址。
response_code read_only_udm.network.http.response_code 取自「response_code」欄位的值。
session_duration read_only_udm.additional.fields.value.string_value 從「session_duration」欄位取得值,並指派給「key」欄位設為「Session Duration」的標籤「string_value」欄位。
來源 read_only_udm.principal.ip 從「來源」欄位取得的值,並剖析為 IP 位址。
src_ip read_only_udm.principal.ip 如果「remoteAddress」為空白,則取自「src_ip」欄位的值。
摘要 read_only_udm.security_result.summary 值取自「摘要」欄位。
sysAdmin read_only_udm.security_result.about.resource.attribute.labels.value 從「sysAdmin」欄位取得值,並指派給「key」欄位設為「sysAdmin」的標籤「value」欄位。
superAdmin read_only_udm.security_result.about.resource.attribute.labels.value 從「superAdmin」欄位取得值,並指派給「key」欄位設為「superAdmin」的標籤「value」欄位。
target_url read_only_udm.target.url 值取自「target_url」欄位。
時間戳記 read_only_udm.metadata.event_timestamp 從「時間戳記」欄位取得的值,並剖析為日期和時間字串。
user_id read_only_udm.principal.user.userid 取自「user_id」欄位的值。
read_only_udm.metadata.event_type 這個欄位的值取決於一系列檢查作業,預設為「GENERIC_EVENT」。系統會根據「principal_host」、「user_id」、「has_principal」和「author.type」等其他欄位的存在與內容,將這個欄位設為「NETWORK_HTTP」、「USER_UNCATEGORIZED」或「STATUS_UPDATE」等特定值。
read_only_udm.metadata.vendor_name 設為「ATLASSIAN」。
read_only_udm.metadata.product_name 設為「CONFLUENCE」。
read_only_udm.metadata.log_type 設為「ATLASSIAN_CONFLUENCE」。
read_only_udm.principal.user.user_display_name 這個欄位的值可能來自「author.displayName」或「affectedObject.name」,視情況而定。
read_only_udm.target.process.pid 這個欄位的值可能來自「principal_host」或「pid」,視情況而定。
read_only_udm.principal.resource.attribute.labels 這個欄位會填入從「affectedObjects」、「changedValues」和「extraAttributes」等欄位衍生的各種標籤。這些標籤的鍵和值會根據這些欄位的特定內容動態產生。

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