Signal Sciences WAF 로그 수집

다음에서 지원:

이 문서에서는 Google Cloud 스토리지로 Signal Sciences WAF 로그를 Google Security Operations에 수집하는 방법을 설명합니다. 파서는 Signal Sciences 로그를 JSON 형식에서 Chronicle의 통합 데이터 모델(UDM)로 변환합니다. 두 가지 기본 메시지 구조를 처리합니다. 'RPC.PreRequest/PostRequest' 메시지는 Grok 패턴을 사용하여 파싱되고 다른 메시지는 JSON 객체로 처리되어 관련 필드를 추출하고 UDM 스키마에 매핑합니다.

시작하기 전에

다음 기본 요건이 충족되었는지 확인합니다.

  • Google SecOps 인스턴스
  • VPC 흐름이 Google Cloud 환경에서 설정되어 활성 상태임
  • Signal Sciences WAF에 대한 액세스 권한

스토리지 버킷 만들기 Google Cloud

  1. Google Cloud 콘솔에 로그인합니다.
  2. Cloud Storage 버킷 페이지로 이동합니다.

    버킷으로 이동

  3. 만들기를 클릭합니다.

  4. 버킷 만들기 페이지에서 버킷 정보를 입력합니다. 다음 각 단계를 완료한 후 계속을 클릭하여 다음 단계로 진행합니다.

    1. 시작하기 섹션에서 다음을 수행합니다.

      • 버킷 이름 요구사항을 충족하는 고유한 이름을 입력합니다 (예: vpcflow-logs).
      • 계층적 네임스페이스를 사용 설정하려면 펼치기 화살표를 클릭하여 파일 지향 및 데이터 집약적인 워크로드에 최적화 섹션을 펼친 다음 이 버킷에서 계층적 네임스페이스 사용 설정을 선택합니다.
      • 버킷 라벨을 추가하려면 펼치기 화살표를 클릭하여 라벨 섹션을 펼칩니다.
      • 라벨 추가를 클릭하고 라벨의 키와 값을 지정합니다.
    2. 데이터 저장 위치 선택 섹션에서 다음을 수행합니다.

      • 위치 유형을 선택합니다.
      • 위치 유형 메뉴를 사용하여 버킷 내 객체 데이터가 영구적으로 저장될 위치를 선택합니다.
      • 버킷 간 복제를 설정하려면 버킷 간 복제 설정 섹션을 펼칩니다.
    3. 데이터의 스토리지 클래스 선택 섹션에서 버킷에 기본 스토리지 클래스를 선택하거나, 버킷 데이터의 자동 스토리지 클래스 관리에 자동 클래스를 선택합니다.

    4. 객체 액세스를 제어하는 방식 선택 섹션에서 공개 액세스 방지를 적용하지 않음을 선택하고 버킷의 객체에 대한 액세스 제어 모델을 선택합니다.

    5. 객체 데이터 보호 방법 선택 섹션에서 다음을 수행합니다.

      • 버킷에 설정할 데이터 보호 아래의 옵션을 선택합니다.
      • 객체 데이터의 암호화 방법을 선택하려면 데이터 암호화라는 펼치기 화살표를 클릭하고 데이터 암호화 방법을 선택합니다.
  5. 만들기를 클릭합니다.

Signal Sciences WAF API 키 구성

  1. Signal Sciences WAF 웹 UI에 로그인합니다.
  2. 내 프로필 > API 액세스 토큰으로 이동합니다.
  3. API 액세스 토큰 추가를 클릭합니다.
  4. 설명이 포함된 고유한 이름을 지정합니다 (예: Google SecOps).
  5. API 액세스 토큰 만들기를 클릭합니다.
  6. 토큰을 복사하여 안전한 위치에 저장합니다.
  7. 이해했습니다를 클릭하여 토큰 만들기를 마칩니다.

Linux 호스트에 스크립트를 배포하여 Signal Sciences에서 로그를 가져와 Google Cloud에 저장합니다.

  1. SSH를 사용하여 Linux 호스트에 로그인합니다.
  2. Signal Sciences WAF JSON을 Cloud Storage 버킷에 저장하는 python lib를 설치합니다.

    pip install google-cloud-storage
    
  3. 환경 변수를 설정하여 Google Cloud의 사용자 인증 정보가 있는 JSON 파일을 호출합니다.

    export GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service-account-key.json"
    
  4. 이 정보는 하드코딩하면 안 되므로 다음 환경 변수를 구성합니다.

    export SIGSCI_EMAIL=<Signal_Sciences_account_email>
    export SIGSCI_TOKEN=<Signal_Sciences_API_token>
    export SIGSCI_CORP=<Corporation_name_in_Signal_Sciences>
    
  5. 다음 스크립트를 실행합니다.

    import sys
    import requests
    import os
    import calendar
    import json
    from datetime import datetime, timedelta
    from google.cloud import storage
    
    # Check if all necessary environment variables are set
    
    if 'SIGSCI_EMAIL' not in os.environ or 'SIGSCI_TOKEN' not in os.environ or 'SIGSCI_CORP' not in os.environ:
    print("ERROR: You need to define SIGSCI_EMAIL, SIGSCI_TOKEN, and SIGSCI_CORP environment variables.")
    print("Please fix and run again. Existing...")
    sys.exit(1)  # Exit if environment variables are not set
    
    # Define the Google Cloud Storage bucket name and output file name
    
    bucket_name = 'Your_GCS_Bucket'  # Replace with your GCS bucket name
    output_file_name = 'signal_sciences_logs.json'
    
    # Initialize Google Cloud Storage client
    
    storage_client = storage.Client()
    
    # Function to upload data to Google Cloud Storage
    
    def upload_to_gcs(bucket_name, data, destination_blob_name):
        bucket = storage_client.bucket(bucket_name)
        blob = bucket.blob(destination_blob_name)
        blob.upload_from_string(data, content_type='application/json')
        print(f"Data uploaded to {destination_blob_name} in bucket {bucket_name}")
    
    # Signal Sciences API information
    
    api_host = 'https://dashboard.signalsciences.net'
    # email = 'user@domain.com'  # Signal Sciences account email
    # token = 'XXXXXXXX-XXXX-XXX-XXXX-XXXXXXXXXXXX'  # API token for authentication
    # corp_name = 'Domain'  # Corporation name in Signal Sciences
    # site_names = ['testenv']  # Replace with your actual site names
    
    # List of comma-delimited sites that you want to extract data from
    
    site_names = [ 'site123', 'site345' ]        # Define all sites to pull logs from
    
    email = os.environ.get('SIGSCI_EMAIL')       # Signal Sciences account email
    token = os.environ.get('SIGSCI_TOKEN')       # API token for authentication
    corp_name = os.environ.get('SIGSCI_CORP')    # Corporation name in Signal Sciences
    
    # Calculate the start and end timestamps for the previous hour in UTC
    
    until_time = datetime.utcnow().replace(minute=0, second=0, microsecond=0)
    from_time = until_time - timedelta(hours=1)
    until_time = calendar.timegm(until_time.utctimetuple())
    from_time = calendar.timegm(from_time.utctimetuple())
    
    # Prepare HTTP headers for the API request
    
    headers = {
        'Content-Type': 'application/json',
        'x-api-user': email,
        'x-api-token': token
    }
    
    # Collect logs for each site
    
    collected_logs = []
    
    for site_name in site_names:
        url = f"{api_host}/api/v0/corps/{corp_name}/sites/{site_name}/feed/requests?from={from_time}&until={until_time}"
        while True:
            response = requests.get(url, headers=headers)
            if response.status_code != 200:
                print(f"Error fetching logs: {response.text}", file=sys.stderr)
                break
    
            # Parse the JSON response
    
            data = response.json()
            collected_logs.extend(data['data'])  # Add the log messages to our list
    
            # Pagination: check if there is a next page
    
            next_url = data.get('next', {}).get('uri')
            if not next_url:
                break
            url = api_host + next_url
    
    # Convert the collected logs to a newline-delimited JSON string
    
    json_data = '\n'.join(json.dumps(log) for log in collected_logs)
    
    # Save the newline-delimited JSON data to a GCS bucket
    
    upload_to_gcs(bucket_name, json_data, output_file_name)
    

    피드 설정

피드를 구성하려면 다음 단계를 따르세요.

  1. SIEM 설정 > 피드로 이동합니다.
  2. 새 피드 추가를 클릭합니다.
  3. 다음 페이지에서 단일 피드 구성을 클릭합니다.
  4. 피드 이름 필드에 피드 이름을 입력합니다 (예: Signal Sciences WAF Logs).
  5. 소스 유형으로 Google Cloud Storage를 선택합니다.
  6. 로그 유형으로 Signal Sciences WAF를 선택합니다.
  7. Chronicle 서비스 계정으로 서비스 계정 가져오기를 클릭합니다.
  8. 다음을 클릭합니다.
  9. 다음 입력 매개변수의 값을 지정합니다.

    • 스토리지 버킷 URI:gs://my-bucket/<value> 형식의 Google Cloud 스토리지 버킷 URL입니다.
    • URI Is A: 하위 디렉터리가 포함된 디렉터리를 선택합니다.
    • 소스 삭제 옵션: 환경설정에 따라 삭제 옵션을 선택합니다.

  10. 다음을 클릭합니다.

  11. 확정 화면에서 새 피드 구성을 검토한 다음 제출을 클릭합니다.

UDM 매핑 테이블

로그 필드 UDM 매핑 논리
CLIENT-IP target.ip CLIENT-IP 헤더 필드에서 추출했습니다.
CLIENT-IP target.port CLIENT-IP 헤더 필드에서 추출했습니다.
연결 security_result.about.labels 값은 원시 로그 Connection 필드에서 가져와 security_result.about.labels에 매핑됩니다.
Content-Length security_result.about.labels 값은 원시 로그 Content-Length 필드에서 가져와 security_result.about.labels에 매핑됩니다.
Content-Type security_result.about.labels 값은 원시 로그 Content-Type 필드에서 가져와 security_result.about.labels에 매핑됩니다.
생성됨 metadata.event_timestamp 값은 원시 로그 created 필드에서 가져와 metadata.event_timestamp에 매핑됩니다.
details.headersIn security_result.about.resource.attribute.labels 값은 원시 로그 details.headersIn 필드에서 가져와 security_result.about.resource.attribute.labels에 매핑됩니다.
details.headersOut security_result.about.resource.attribute.labels 값은 원시 로그 details.headersOut 필드에서 가져와 security_result.about.resource.attribute.labels에 매핑됩니다.
details.id principal.process.pid 값은 원시 로그 details.id 필드에서 가져와 principal.process.pid에 매핑됩니다.
details.method network.http.method 값은 원시 로그 details.method 필드에서 가져와 network.http.method에 매핑됩니다.
details.protocol network.application_protocol 값은 원시 로그 details.protocol 필드에서 가져와 network.application_protocol에 매핑됩니다.
details.remoteCountryCode principal.location.country_or_region 값은 원시 로그 details.remoteCountryCode 필드에서 가져와 principal.location.country_or_region에 매핑됩니다.
details.remoteHostname target.hostname 값은 원시 로그 details.remoteHostname 필드에서 가져와 target.hostname에 매핑됩니다.
details.remoteIP target.ip 값은 원시 로그 details.remoteIP 필드에서 가져와 target.ip에 매핑됩니다.
details.responseCode network.http.response_code 값은 원시 로그 details.responseCode 필드에서 가져와 network.http.response_code에 매핑됩니다.
details.responseSize network.received_bytes 값은 원시 로그 details.responseSize 필드에서 가져와 network.received_bytes에 매핑됩니다.
details.serverHostname principal.hostname 값은 원시 로그 details.serverHostname 필드에서 가져와 principal.hostname에 매핑됩니다.
details.serverName principal.asset.network_domain 값은 원시 로그 details.serverName 필드에서 가져와 principal.asset.network_domain에 매핑됩니다.
details.tags security_result.detection_fields 값은 원시 로그 details.tags 필드에서 가져와 security_result.detection_fields에 매핑됩니다.
details.tlsCipher network.tls.cipher 값은 원시 로그 details.tlsCipher 필드에서 가져와 network.tls.cipher에 매핑됩니다.
details.tlsProtocol network.tls.version 값은 원시 로그 details.tlsProtocol 필드에서 가져와 network.tls.version에 매핑됩니다.
details.userAgent network.http.user_agent 값은 원시 로그 details.userAgent 필드에서 가져와 network.http.user_agent에 매핑됩니다.
details.uri network.http.referral_url 값은 원시 로그 details.uri 필드에서 가져와 network.http.referral_url에 매핑됩니다.
eventType metadata.product_event_type 값은 원시 로그 eventType 필드에서 가져와 metadata.product_event_type에 매핑됩니다.
headersIn security_result.about.labels 값은 원시 로그 headersIn 필드에서 가져와 security_result.about.labels에 매핑됩니다.
headersOut security_result.about.labels 값은 원시 로그 headersOut 필드에서 가져와 security_result.about.labels에 매핑됩니다.
id principal.process.pid 값은 원시 로그 id 필드에서 가져와 principal.process.pid에 매핑됩니다.
메시지 metadata.description 값은 원시 로그 message 필드에서 가져와 metadata.description에 매핑됩니다.
method network.http.method 값은 원시 로그 method 필드에서 가져와 network.http.method에 매핑됩니다.
ModuleVersion metadata.ingestion_labels 값은 원시 로그 ModuleVersion 필드에서 가져와 metadata.ingestion_labels에 매핑됩니다.
msgData.actions security_result.action 값은 원시 로그 msgData.actions 필드에서 가져와 security_result.action에 매핑됩니다.
msgData.changes target.resource.attribute.labels 값은 원시 로그 msgData.changes 필드에서 가져와 target.resource.attribute.labels에 매핑됩니다.
msgData.conditions security_result.description 값은 원시 로그 msgData.conditions 필드에서 가져와 security_result.description에 매핑됩니다.
msgData.detailLink network.http.referral_url 값은 원시 로그 msgData.detailLink 필드에서 가져와 network.http.referral_url에 매핑됩니다.
msgData.name target.resource.name 값은 원시 로그 msgData.name 필드에서 가져와 target.resource.name에 매핑됩니다.
msgData.reason security_result.summary 값은 원시 로그 msgData.reason 필드에서 가져와 security_result.summary에 매핑됩니다.
msgData.sites network.http.user_agent 값은 원시 로그 msgData.sites 필드에서 가져와 network.http.user_agent에 매핑됩니다.
프로토콜 network.application_protocol 값은 원시 로그 protocol 필드에서 가져와 network.application_protocol에 매핑됩니다.
remoteCountryCode principal.location.country_or_region 값은 원시 로그 remoteCountryCode 필드에서 가져와 principal.location.country_or_region에 매핑됩니다.
remoteHostname target.hostname 값은 원시 로그 remoteHostname 필드에서 가져와 target.hostname에 매핑됩니다.
remoteIP target.ip 값은 원시 로그 remoteIP 필드에서 가져와 target.ip에 매핑됩니다.
responseCode network.http.response_code 값은 원시 로그 responseCode 필드에서 가져와 network.http.response_code에 매핑됩니다.
responseSize network.received_bytes 값은 원시 로그 responseSize 필드에서 가져와 network.received_bytes에 매핑됩니다.
serverHostname principal.hostname 값은 원시 로그 serverHostname 필드에서 가져와 principal.hostname에 매핑됩니다.
serverName principal.asset.network_domain 값은 원시 로그 serverName 필드에서 가져와 principal.asset.network_domain에 매핑됩니다.
tags security_result.detection_fields 값은 원시 로그 tags 필드에서 가져와 security_result.detection_fields에 매핑됩니다.
타임스탬프 metadata.event_timestamp 값은 원시 로그 timestamp 필드에서 가져와 metadata.event_timestamp에 매핑됩니다.
tlsCipher network.tls.cipher 값은 원시 로그 tlsCipher 필드에서 가져와 network.tls.cipher에 매핑됩니다.
tlsProtocol network.tls.version 값은 원시 로그 tlsProtocol 필드에서 가져와 network.tls.version에 매핑됩니다.
URI target.url 값은 원시 로그 URI 필드에서 가져와 target.url에 매핑됩니다.
userAgent network.http.user_agent 값은 원시 로그 userAgent 필드에서 가져와 network.http.user_agent에 매핑됩니다.
uri network.http.referral_url 값은 원시 로그 uri 필드에서 가져와 network.http.referral_url에 매핑됩니다.
X-ARR-SSL network.tls.client.certificate.issuer 값은 grok 및 kv 필터를 사용하여 X-ARR-SSL 헤더 필드에서 추출됩니다.
metadata.event_type 이벤트 유형은 타겟 및 주 구성원 정보의 존재 여부에 따라 파서에 의해 결정됩니다. 타겟과 주 구성원이 모두 있는 경우 이벤트 유형은 NETWORK_HTTP입니다. 주 구성원만 있는 경우 이벤트 유형은 STATUS_UPDATE입니다. 그렇지 않으면 이벤트 유형은 GENERIC_EVENT입니다.
metadata.log_type 값은 SIGNAL_SCIENCES_WAF로 하드코딩되어 있습니다.
metadata.product_name 값은 Signal Sciences WAF로 하드코딩되어 있습니다.
metadata.vendor_name 값은 Signal Sciences로 하드코딩되어 있습니다.
principal.asset.hostname 값은 principal.hostname 필드에서 가져옵니다.
target.asset.hostname 값은 target.hostname 필드에서 가져옵니다.
target.asset.ip 값은 target.ip 필드에서 가져옵니다.
target.user.user_display_name 값은 grok 필터를 사용하여 message_data 필드에서 추출됩니다.
target.user.userid 값은 grok 필터를 사용하여 message_data 필드에서 추출됩니다.

도움이 더 필요하신가요? 커뮤니티 회원 및 Google SecOps 전문가로부터 답변을 받으세요.