איסוף יומנים של SAP BTP
במאמר הזה מוסבר איך להטמיע יומנים של SAP Business Technology Platform (BTP) ב-Google Security Operations באמצעות Cloud Storage V2.
SAP Business Technology Platform (BTP) היא פלטפורמה בענן שמספקת יכולות של פיתוח אפליקציות, שילוב, ניהול נתונים וניתוח נתונים. הוא יוצר יומני ביקורת אבטחה, יומני גישה ויומני אירועים של שירותים, שחיוניים למעקב אחרי הפעילות בפלטפורמה ולזיהוי איומי אבטחה. פונקציית Cloud Run דוגמת את ה-API לאחזור יומני ביקורת של שירות ניהול יומני הביקורת של SAP לפי לוח זמנים, כותבת יומנים לקטגוריה של Cloud Storage בפורמט NDJSON, ו-Google SecOps מטמיעה אותם דרך פיד של Cloud Storage V2.
לפני שמתחילים
חשוב לוודא שיש לכם את הדברים הבאים:
- מכונה של Google SecOps
- פרויקט ב- Google Cloud עם Cloud Storage API מופעל
- הרשאות ליצירה ולניהול של קטגוריות של Cloud Storage
- הרשאות לניהול כללי מדיניות של ניהול זהויות והרשאות גישה (IAM) בקטגוריות של Cloud Storage
- הרשאות ליצירת שירותי Cloud Run, נושאי Pub/Sub ומשימות ב-Cloud Scheduler
- גישת אדמין ל-SAP BTP עם הרשאות להגדרת אחזור של יומן הביקורת (Space Developer במרחב היעד של Cloud Foundry, ויכולת להוסיף הרשאות ברמת החשבון הגלובלי)
שירות ניהול יומני הביקורת (שם טכני:
auditlog-management) שמוקצה לחשבון המשנה שלכם ב-SAP BTP
יצירת קטגוריה של Cloud Storage
- נכנסים למסוף Google Cloud.
- בוחרים את הפרויקט או יוצרים פרויקט חדש.
- בתפריט הניווט, נכנסים ל-Cloud Storage > Buckets.
- לוחצים על Create bucket.
ממלאים את פרטי ההגדרה הבאים:
הגדרה ערך Name your bucket מזינים שם ייחודי ברמה גלובלית (לדוגמה, sap-btp-logs)סוג המיקום בוחרים לפי הצרכים (אזור, שני אזורים, מספר אזורים) Location בוחרים את המיקום (לדוגמה, us-central1)סוג אחסון (storage class) רגיל (מומלץ ליומנים שהגישה אליהם תכופה) בקרת גישה אחידה (מומלץ) כלי הגנה אופציונלי: הפעלת ניהול גרסאות של אובייקטים או מדיניות שמירת נתונים לוחצים על יצירה.
איסוף פרטי הכניסה ל-SAP BTP API
יצירת מכונה של Audit Log Management Service
- נכנסים אל SAP BTP Cockpit.
- מוודאים שההרשאה Audit Log Management Service מוקצית לחשבון המשנה: בתצוגה של חשבון המשנה, עוברים אל Entitlements > Edit > Add Service Plans (ההרשאות מוקצות מהחשבון הגלובלי).
- עוברים לחשבון המשנה.
- עוברים אל Services > Instances and Subscriptions.
- לוחצים על יצירה.
- מזינים את פרטי ההגדרה הבאים:
- Service: בוחרים באפשרות Audit Log Management Service (השם הטכני:
auditlog-management). - תוכנית: בוחרים באפשרות ברירת מחדל.
- Runtime Environment: בוחרים באפשרות Cloud Foundry.
- מרחב: בוחרים את המרחב הרצוי.
- שם המכונה: מזינים שם (לדוגמה,
auditlog-management-secops).
- Service: בוחרים באפשרות Audit Log Management Service (השם הטכני:
- לוחצים על יצירה.
יצירת מפתח שירות
- ב-SAP BTP Cockpit, עוברים אל Services > Instances and Subscriptions ובוחרים את המכונה של שירות
auditlog-management. - בוחרים באפשרות Create Service Key.
- מזינים שם (לדוגמה,
google-secops-integration). - לוחצים על יצירה.
מעתיקים ושומרים את הפרטים הבאים ממפתח השירות במיקום מאובטח:
- url: כתובת ה-URL הבסיסית לבקשות לאחזור יומן הביקורת.
- uaa.url: כתובת ה-URL הבסיסית של שרת ה-OAuth. נקודת הקצה של הטוקן היא
<uaa.url>/oauth/token. - uaa.clientid: מזהה הלקוח ב-OAuth.
- uaa.clientsecret: סוד הלקוח של OAuth.
בדיקת הגישה ל-API
לפני שממשיכים בתהליך השילוב, בודקים את פרטי הכניסה:
# Replace with your actual credentials from the service key UAA_URL="https://your-subdomain.authentication.region.hana.ondemand.com" CLIENT_ID="your-client-id" CLIENT_SECRET="your-client-secret" API_URL="https://auditlog-management.cfapps.us10.hana.ondemand.com" # Get OAuth token TOKEN=$(curl -s -X POST "${UAA_URL}/oauth/token" \ -u "${CLIENT_ID}:${CLIENT_SECRET}" \ -d "grant_type=client_credentials" \ -H "Content-Type: application/x-www-form-urlencoded" | jq -r '.access_token') # Test API access: the API takes time_from/time_to in UTC without a # timezone suffix and returns a JSON array at the root. When the result # set is chunked, the next chunk's handle arrives in the "Paging" # response header. curl -v -H "Authorization: Bearer ${TOKEN}" \ "${API_URL}/auditlog/v2/auditlogrecords?time_from=2026-08-07T00:00:00&time_to=2026-08-07T01:00:00"
יצירת חשבון שירות לפונקציית Cloud Run
לפונקציית Cloud Run נדרש חשבון שירות עם הרשאות כתיבה בקטגוריה של Cloud Storage, וצריך להפעיל אותה באמצעות Pub/Sub.
יצירת חשבון השירות
- במסוף GCP, נכנסים לדף IAM & Admin > Service Accounts.
- לוחצים על Create Service Account.
- מזינים את פרטי ההגדרה הבאים:
- שם חשבון השירות: מזינים
sap-btp-collector-sa. - Service account description: מזינים
Service account for Cloud Run function to collect SAP BTP logs.
- שם חשבון השירות: מזינים
- לוחצים על יצירה והמשך.
- בקטע Grant this service account access to project, מוסיפים את התפקידים הבאים:
- לוחצים על בחירת תפקיד.
- מחפשים את התפקיד Storage Object Admin ובוחרים אותו.
- לוחצים על + הוספת תפקיד.
- מחפשים את התפקיד Cloud Run Invoker ובוחרים בו.
- לוחצים על + הוספת תפקיד.
- מחפשים את התפקיד Cloud Functions Invoker ובוחרים אותו.
- לוחצים על Continue.
- לוחצים על סיום.
התפקידים האלה נדרשים כדי:
- אדמין של אובייקטים באחסון: כתיבת יומנים בקטגוריה של Cloud Storage וניהול קובצי תמונת מצב
- Cloud Run Invoker: מאפשר ל-Pub/Sub להפעיל את הפונקציה
- מפעיל פונקציות של Cloud Functions: מאפשר להפעיל פונקציות
הענקת הרשאות IAM בקטגוריה של Cloud Storage
נותנים לחשבון השירות הרשאות כתיבה בקטגוריה של Cloud Storage:
- נכנסים לדף Cloud Storage > Buckets.
- לוחצים על שם הקטגוריה (לדוגמה,
sap-btp-logs). - עוברים לכרטיסייה Permissions.
- לוחצים על הענקת גישה.
- מזינים את פרטי ההגדרה הבאים:
- הוספת חשבונות משתמשים: מזינים את כתובת האימייל של חשבון השירות (לדוגמה,
sap-btp-collector-sa@your-project.iam.gserviceaccount.com). - הקצאת תפקידים: בוחרים באפשרות אדמין של אובייקטים באחסון.
- הוספת חשבונות משתמשים: מזינים את כתובת האימייל של חשבון השירות (לדוגמה,
- לוחצים על Save.
יוצרים נושא Pub/Sub
יוצרים נושא Pub/Sub ש-Cloud Scheduler יפרסם בו ופונקציית Cloud Run תירשם אליו.
- במסוף GCP, נכנסים לדף Pub/Sub > Topics.
- לוחצים על Create topic.
- מזינים את פרטי ההגדרה הבאים:
- מזהה הנושא: מזינים את הערך
sap-btp-trigger. - משאירים את ההגדרות האחרות כברירת מחדל.
- מזהה הנושא: מזינים את הערך
- לוחצים על יצירה.
יצירת פונקציית Cloud Run לאיסוף יומנים
הודעות Pub/Sub מ-Cloud Scheduler יפעילו את פונקציית Cloud Run כדי לאחזר יומני ביקורת מ-Audit Log Management Service retrieval API ולכתוב אותם ב-Cloud Storage.
- במסוף GCP, נכנסים ל-Cloud Run.
- לוחצים על Create service.
- בוחרים באפשרות Function (שימוש בעורך ישיר כדי ליצור פונקציה).
בקטע Configure, מזינים את פרטי ההגדרה הבאים:
הגדרה ערך שם השירות sap-btp-collectorאזור בוחרים את האזור שתואם לקטגוריה של Cloud Storage (לדוגמה, us-central1)זמן ריצה בוחרים באפשרות Python 3.12 או גרסה עדכנית יותר. בקטע טריגר (אופציונלי):
- לוחצים על + הוספת טריגר.
- בוחרים באפשרות Cloud Pub/Sub.
- בקטע Select a Cloud Pub/Sub topic, בוחרים את הנושא
sap-btp-trigger. - לוחצים על Save.
בקטע אימות:
- לוחצים על דרישת אימות.
- בודקים את ניהול הזהויות והרשאות הגישה (IAM).
מרחיבים את הקטע Containers, Networking, Security.
עוברים לכרטיסייה אבטחה:
- חשבון שירות: בוחרים את חשבון השירות
sap-btp-collector-sa.
- חשבון שירות: בוחרים את חשבון השירות
עוברים לכרטיסייה מאגרי תגים:
- לוחצים על Variables & Secrets.
- לוחצים על + Add variable לכל משתנה סביבה:
שם משתנה ערך לדוגמה תיאור GCS_BUCKETsap-btp-logsשם הקטגוריה של Cloud Storage GCS_PREFIXsap-btpקידומת לקובצי יומן STATE_KEYsap-btp-state.jsonנתיב קובץ תמונת המצב, מחוץ לקידומת של היומן SAP_API_URLhttps://auditlog-management.cfapps.us10.hana.ondemand.comהערך urlמהמפתח לנותני שירותSAP_UAA_URLhttps://your-subdomain.authentication.region.hana.ondemand.comכתובת ה-URL של נקודת הקצה של טוקן OAuth SAP_CLIENT_IDyour-client-idמזהה לקוח ב-OAuth SAP_CLIENT_SECRETyour-client-secretסוד לקוח OAuth LOOKBACK_HOURS24תקופת המבט לאחור הראשונית בכרטיסייה Variables & Secrets, עוברים אל Requests:
- Request timeout: מזינים
600שניות (10 דקות).
- Request timeout: מזינים
עוברים לכרטיסייה הגדרות בקטע מאגרים:
- בקטע Resources:
- זיכרון: בוחרים באפשרות 512 MiB או יותר.
- מעבד (CPU): בוחרים באפשרות 1.
- לוחצים על סיום.
- בקטע Resources:
עוברים אל Execution environment:
- בוחרים באפשרות ברירת מחדל (מומלץ).
בקטע Revision scaling:
- מספר מינימלי של מכונות: מזינים
0. - Maximum number of instances: מזינים
100(או משנים בהתאם לעומס הצפוי).
- מספר מינימלי של מכונות: מזינים
לוחצים על יצירה.
ממתינים ליצירת השירות (דקה או שתיים).
אחרי שיוצרים את השירות, עורך הקוד המוטבע נפתח באופן אוטומטי.
הוספת קוד הפונקציה
- מזינים main בשדה Function entry point.
בעורך הקוד, יוצרים שני קבצים:
הקובץ הראשון – main.py:
import functions_framework from google.cloud import storage import hashlib import json import os import urllib3 from datetime import datetime, timezone, timedelta import time import base64 import uuid # Initialize HTTP client with timeouts http = urllib3.PoolManager( timeout=urllib3.Timeout(connect=5.0, read=30.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', 'sap-btp') STATE_KEY = os.environ.get('STATE_KEY', 'sap-btp-state.json') SEEN_KEY = STATE_KEY + '.seen' API_URL = os.environ.get('SAP_API_URL') UAA_URL = os.environ.get('SAP_UAA_URL') CLIENT_ID = os.environ.get('SAP_CLIENT_ID') CLIENT_SECRET = os.environ.get('SAP_CLIENT_SECRET') LOOKBACK_HOURS = int(os.environ.get('LOOKBACK_HOURS', '24')) def parse_datetime(value: str) -> datetime: """Parse ISO datetime string to datetime object.""" if value.endswith("Z"): value = value[:-1] + "+00:00" return datetime.fromisoformat(value) # message_uuid is the identifier of an audit log record; the parser maps it to # metadata.product_log_id. ID_FIELDS = ('message_uuid',) def event_keys(event): """Return every identity this event can be recognised by.""" keys = {'sha256:' + hashlib.sha256( json.dumps(event, sort_keys=True, ensure_ascii=False).encode('utf-8') ).hexdigest()} for field in ID_FIELDS: value = event.get(field) if value: keys.add(f'{field}:{value}') return keys def get_oauth_token(): """Get OAuth 2.0 access token using client credentials flow.""" token_url = f"{UAA_URL.rstrip('/')}/oauth/token" credentials = f"{CLIENT_ID}:{CLIENT_SECRET}" encoded_credentials = base64.b64encode(credentials.encode('utf-8')).decode('utf-8') headers = { 'Authorization': f'Basic {encoded_credentials}', 'Content-Type': 'application/x-www-form-urlencoded', 'Accept': 'application/json' } body = 'grant_type=client_credentials' backoff = 1.0 max_retries = 3 for attempt in range(max_retries): response = http.request('POST', token_url, body=body, headers=headers) if response.status == 429: retry_after = int(response.headers.get('Retry-After', str(int(backoff)))) print(f"Rate limited (429) on token request. Retrying after {retry_after}s...") time.sleep(retry_after) backoff = min(backoff * 2, 30.0) continue if response.status != 200: raise RuntimeError(f"Failed to get access token: {response.status} - {response.data.decode('utf-8')}") data = json.loads(response.data.decode('utf-8')) return data['access_token'] raise RuntimeError(f"Failed to get token after {max_retries} retries due to rate limiting") @functions_framework.cloud_event def main(cloud_event): """ Cloud Run function triggered by Pub/Sub to fetch SAP BTP audit logs and write to GCS. Args: cloud_event: CloudEvent object containing Pub/Sub message """ if not all([GCS_BUCKET, API_URL, UAA_URL, CLIENT_ID, CLIENT_SECRET]): # Raise rather than return: a bare return acks the Pub/Sub message and # reports the run as successful, silently discarding the schedule tick. raise RuntimeError('Missing required environment variables') try: bucket = storage_client.bucket(GCS_BUCKET) # Load state state = load_state(bucket, STATE_KEY) seen_keys = load_seen(bucket, SEEN_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"]) 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) print(f"Fetching audit logs from {last_time.isoformat()} to {now.isoformat()}") # Get OAuth token token = get_oauth_token() # Fetch audit logs records, newest_event_time = fetch_audit_logs( token=token, start_time=last_time, end_time=now, ) # Drop the events already written by a previous run (overlap window) fresh = [r for r in records if not (event_keys(r) & seen_keys)] if not fresh: print("No new audit log records found.") return # Write to GCS as NDJSON timestamp = now.strftime('%Y%m%d_%H%M%S') # The random suffix keeps concurrent executions (Pub/Sub delivers at # least once) from overwriting each other's object within one second. object_key = f"{GCS_PREFIX}/audit_{timestamp}_{uuid.uuid4().hex[:8]}.ndjson" blob = bucket.blob(object_key) ndjson = '\n'.join([json.dumps(record, ensure_ascii=False) for record in fresh]) + '\n' blob.upload_from_string(ndjson, content_type='application/x-ndjson') print(f"Wrote {len(fresh)} records to gs://{GCS_BUCKET}/{object_key}") # Remember every fetched record so the next overlap window is deduplicated save_seen(bucket, SEEN_KEY, records) # Update state with newest event time. The watermark must be an event # timestamp, never wall clock: a wall-clock watermark skips every event # the vendor indexes late. if not newest_event_time: raise RuntimeError('Records were returned but no event timestamp could be parsed') save_state(bucket, STATE_KEY, newest_event_time) print(f"Successfully processed {len(fresh)} records") except Exception as e: print(f'Error processing audit logs: {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}") raise return {} def save_state(bucket, key, last_event_time_iso: str): """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}") raise def load_seen(bucket, key): """Load the event keys written by the previous run.""" try: blob = bucket.blob(key) if blob.exists(): return set(json.loads(blob.download_as_text())) except Exception as e: print(f"Warning: Could not load seen keys: {e}") raise return set() def save_seen(bucket, key, records): """Save the keys of every fetched record for the next overlap window.""" try: keys = set() for record in records: keys |= event_keys(record) blob = bucket.blob(key) blob.upload_from_string( json.dumps(sorted(keys)), content_type='application/json' ) print(f"Saved {len(keys)} seen keys") except Exception as e: print(f"Warning: Could not save seen keys: {e}") raise def fetch_audit_logs(token: str, start_time: datetime, end_time: datetime): """ Fetch audit logs from the Audit Log Management Service retrieval API. The API takes time_from/time_to in UTC without a timezone designator and returns a JSON array at the root (HTTP 204 when the window is empty). When the result set is chunked, the next chunk's handle arrives in the "Paging" response header as handle=<value> and is passed back as the handle query parameter; the server chunk size is fixed at 500 records. Args: token: OAuth 2.0 access token start_time: Start time for log query end_time: End time for log query Returns: Tuple of (records list, newest_event_time ISO string) Raises: RuntimeError: on any API failure, so a failed fetch can never be mistaken for an empty result. """ base_url = API_URL.rstrip('/') endpoint = f"{base_url}/auditlog/v2/auditlogrecords" headers = { 'Authorization': f'Bearer {token}', 'Accept': 'application/json', 'User-Agent': 'GoogleSecOps-SAPBTPCollector/1.0' } records = [] newest_time = None page_num = 0 backoff = 1.0 rate_limit_retries = 0 token_refreshed = False # The API expects UTC timestamps with no timezone suffix. time_from = start_time.strftime('%Y-%m-%dT%H:%M:%S') time_to = end_time.strftime('%Y-%m-%dT%H:%M:%S') handle = None from urllib.parse import urlencode while True: page_num += 1 # Rebuild the full parameter set on every request. params = {'time_from': time_from, 'time_to': time_to} if handle: params['handle'] = handle url = f"{endpoint}?{urlencode(params)}" response = http.request('GET', url, headers=headers) # The documented rate limit is 4 requests per second (burst 20). if response.status == 429: rate_limit_retries += 1 if rate_limit_retries > 5: raise RuntimeError('Rate limited repeatedly; giving up without advancing the watermark') retry_after = response.headers.get('Retry-After') try: delay = float(retry_after) if retry_after else backoff except (TypeError, ValueError): delay = backoff delay = min(max(delay, 1.0), 60.0) print(f"Rate limited (429). Retrying after {delay}s...") time.sleep(delay) backoff = min(backoff * 2, 30.0) continue backoff = 1.0 rate_limit_retries = 0 if response.status == 401: # One refresh per run: a second consecutive 401 means the audit # service rejects tokens UAA still issues, and retrying forever # would hammer both services until the platform kills the run. if token_refreshed: raise RuntimeError('Audit log request still unauthorized after a token refresh') print("Token expired, refreshing...") token = get_oauth_token() headers['Authorization'] = f'Bearer {token}' token_refreshed = True continue token_refreshed = False if response.status == 204: # Documented empty result for the requested window. break if response.status != 200: raise RuntimeError( f"Audit log request failed: {response.status} - " f"{response.data.decode('utf-8')}" ) data = json.loads(response.data.decode('utf-8')) # The records arrive as a JSON array at the root. Tolerate wrapped # shapes defensively, but never call .get on a list: doing so # crashed previous revisions of this function. if isinstance(data, list): page_results = data elif isinstance(data, dict): page_results = data.get('value', data.get('results', [])) else: page_results = [] print(f"Page {page_num}: Retrieved {len(page_results)} audit records") records.extend(page_results) # Track newest event time. Parse before assigning: an unparseable # stamp must never become the persisted watermark. for record in page_results: event_time = record.get('time') or record.get('timestamp') if not event_time: continue try: parsed = parse_datetime(event_time) except Exception as e: print(f"Warning: Could not parse event time: {e}") continue if newest_time is None or parsed > parse_datetime(newest_time): newest_time = event_time # More chunks are signaled only by the Paging response header. paging = response.headers.get('Paging') or response.headers.get('paging') or '' handle = paging.split('=', 1)[1] if '=' in paging else None if not handle: break print(f"Retrieved {len(records)} total audit records from {page_num} pages") return records, newest_timeהקובץ השני – requirements.txt:
functions-framework==3.* google-cloud-storage==2.* urllib3>=2.0.0
לוחצים על Deploy כדי לשמור ולפרוס את הפונקציה.
מחכים שהפריסה תסתיים (2-3 דקות).
יצירת משימה ב-Cloud Scheduler
Cloud Scheduler יפרסם הודעות בנושא Pub/Sub במרווחי זמן קבועים, ויפעיל את פונקציית Cloud Run.
- במסוף GCP, נכנסים ל-Cloud Scheduler.
- לוחצים על Create Job.
ממלאים את פרטי ההגדרה הבאים:
הגדרה ערך שם sap-btp-collector-hourlyאזור בוחרים את אותו אזור כמו של פונקציית Cloud Run. תדירות 0 * * * *(כל שעה, בשעה עגולה)אזור זמן בחירת אזור זמן (מומלץ לבחור ב-UTC) סוג היעד Pub/Sub נושא בוחרים את הנושא sap-btp-triggerגוף ההודעה {}(אובייקט JSON ריק)לוחצים על יצירה.
אפשרויות לתדירות התזמון
בוחרים את התדירות בהתאם לנפח היומן ולדרישות לגבי זמן האחזור:
| תדירות | ביטוי Cron | תרחיש לדוגמה |
|---|---|---|
| כל 5 דקות | */5 * * * * |
נפח גבוה, זמן אחזור נמוך |
| כל 15 דקות | */15 * * * * |
נפח חיפושים בינוני |
| כל שעה | 0 * * * * |
רגיל (מומלץ) |
| כל 6 שעות | 0 */6 * * * |
נפח נמוך, עיבוד ברצף (batch processing) |
| יומי | 0 0 * * * |
איסוף נתונים היסטוריים |
בדיקת השילוב
- במסוף Cloud Scheduler, מוצאים את המשימה (
sap-btp-collector-hourly). - לוחצים על הפעלה ידנית כדי להפעיל את המשימה באופן ידני.
- מחכים כמה שניות ועוברים אל Cloud Run > Services > sap-btp-collector > Logs.
מוודאים שהפונקציה בוצעה בהצלחה. חפשו את:
Fetching audit logs from YYYY-MM-DDTHH:MM:SS+00:00 to YYYY-MM-DDTHH:MM:SS+00:00 Page 1: Retrieved X audit records Wrote X records to gs://sap-btp-logs/sap-btp/audit_YYYYMMDD_HHMMSS.ndjson Successfully processed X recordsבודקים את הקטגוריה של Cloud Storage (
sap-btp-logs) כדי לוודא שיומני הביקורת נכתבו.
אם מופיעות שגיאות ביומנים:
- HTTP 401: צריך לבדוק את פרטי הכניסה של OAuth במשתני הסביבה, או שהתוקף של האסימון פג (הפונקציה מטפלת ברענון באופן אוטומטי)
- HTTP 403: צריך לוודא שמפתח השירות שייך למכונה של
auditlog-managementבאותו חשבון משנה שהיומנים שלו צפויים להתקבל. אוספי התפקידים של המשתמשים לא חלים על אסימונים של פרטי כניסה של לקוחות. - HTTP 429: הגבלת קצב של יצירת בקשות – הפונקציה תנסה שוב באופן אוטומטי עם השהיה (backoff)
- Failed to get access token: צריך לוודא שהערכים של
SAP_UAA_URL,SAP_CLIENT_IDו-SAP_CLIENT_SECRETנכונים.
הגדרת פיד ב-Google SecOps כדי להטמיע יומנים של SAP BTP
- עוברים אל הגדרות > ניהול נתונים > פידים. אם אתם משתמשים בפלטפורמה של SIEM בלבד, עוברים אל הגדרות > פידים.
- לוחצים על הוספת פיד חדש.
- לוחצים על הגדרת פיד יחיד.
- בשדה שם הפיד, מזינים שם לפיד (לדוגמה,
SAP BTP Logs). - בוחרים באפשרות Google Cloud Storage V2 בתור סוג המקור.
- בוחרים באפשרות Sap Business Technology Platform בתור סוג היומן.
לוחצים על Get Service Account (קבלת חשבון שירות). תוצג כתובת אימייל ייחודית של חשבון שירות, לדוגמה:
chronicle-12345678@chronicle-gcp-prod.iam.gserviceaccount.comמעתיקים את כתובת האימייל הזו. תצטרכו אותו בשלב הבא.
לוחצים על הבא.
מציינים ערכים לפרמטרים הבאים של הקלט:
כתובת ה-URL של קטגוריית האחסון: מזינים את ה-URI של קטגוריית Cloud Storage עם נתיב הקידומת:
gs://sap-btp-logs/sap-btp/- מחליפים את:
-
sap-btp-logs: השם של הקטגוריה ב-Cloud Storage. -
sap-btp/: הנתיב שבו נשמרים היומנים.
-
- מחליפים את:
אפשרות מחיקת המקור: בוחרים את אפשרות המחיקה המועדפת:
- אף פעם לא למחוק קבצים: אף פעם לא למחוק קבצים מהמקור (מומלץ לבדיקה).
- Delete transferred files and empty directories: מחיקת קבצים וספריות ריקות מהמקור אחרי שהאחזור הושלם בהצלחה.
גיל הקובץ המקסימלי: כולל קבצים ששונו במספר הימים האחרונים (ברירת המחדל היא 180 ימים).
מרחב השמות של הנכס: מרחב השמות של הנכס.
תוויות הטמעה: התווית שתתווסף לאירועים מהפיד הזה.
לוחצים על הבא.
בודקים את הגדרות הפיד החדש במסך סיום ולוחצים על שליחה.
מתן הרשאות IAM לחשבון השירות של Google SecOps
לחשבון השירות של Google SecOps נדרשים שני תפקידים בקטגוריה של Cloud Storage: צפייה באובייקט אחסון כדי לקרוא את אובייקטי היומן, ותפקיד ברמת הקטגוריה כדי לקרוא את המטא-נתונים של הקטגוריה.
- נכנסים לדף Cloud Storage > Buckets.
- לוחצים על שם הקטגוריה (
sap-btp-logs). - עוברים לכרטיסייה Permissions.
- לוחצים על הענקת גישה.
- מזינים את פרטי ההגדרה הבאים:
- הוספת חשבונות משתמשים: מדביקים את כתובת האימייל של חשבון השירות של Google SecOps.
- הקצאת תפקידים: בוחרים את שני התפקידים הבאים:
- צפייה באובייקטים של אחסון: קריאת אובייקטים של יומנים.
- קריאה בקטגוריה באחסון מדור קודם: קריאת המטא-נתונים של הקטגוריה. אם בחרתם באפשרות המחיקה Delete transferred files and empty directories, בחרו במקום זאת באפשרות Storage Legacy Bucket Writer, שגם מעניקה את הרשאת המחיקה.
לוחצים על Save.
טבלת מיפוי UDM
| שדה ביומן | מיפוי UDM | Logic (פונקציה לוגית) |
|---|---|---|
time |
metadata.event_timestamp |
נותח בתור ISO8601 |
principal_present |
metadata.event_type |
מופה: true ← STATUS_UPDATE |
user_present |
metadata.event_type |
מופה: true ← USER_RESOURCE_ACCESS, true ← USER_UNCATEGORIZED |
json_message_uuid |
metadata.product_log_id |
מיפוי ישיר |
host |
principal.asset.hostname |
מיפוי ישיר |
key |
principal.asset.ip |
מופה: ip ← value |
principal_ip |
principal.asset.ip |
ממוזג |
value |
principal.asset.ip |
ממוזג |
host |
principal.hostname |
מיפוי ישיר |
key |
principal.ip |
מופה: ip ← value |
principal_ip |
principal.ip |
ממוזג |
value |
principal.ip |
ממוזג |
principal_user_role |
principal.user.attribute.roles |
ממוזג |
key |
principal.user.email_addresses |
מופה: "new","old" ← value2, "new","old" ← value1 |
key1 |
principal.user.email_addresses |
מופה: emails ← value2, userName ← value1 |
key2 |
principal.user.email_addresses |
מופה: value ← value2 |
value1 |
principal.user.email_addresses |
מופה: ^.+@.+$ ← value1 |
value2 |
principal.user.email_addresses |
ממוזג |
user |
principal.user.user_display_name |
מיפוי ישיר |
json_message.data_subject.id.userid |
principal.user.userid |
מיפוי ישיר |
value1 |
principal.user.userid |
מיפוי ישיר |
category |
security_result.category_details |
ממוזג |
als_service_id_label |
security_result.detection_fields |
ממוזג |
app_or_service_id_label |
security_result.detection_fields |
ממוזג |
attri_label |
security_result.detection_fields |
ממוזג |
attribute_label |
security_result.detection_fields |
ממוזג |
attribute_label1 |
security_result.detection_fields |
ממוזג |
custom_status_label |
security_result.detection_fields |
ממוזג |
custom_success_label |
security_result.detection_fields |
ממוזג |
custom_type_label |
security_result.detection_fields |
ממוזג |
desc_label |
security_result.detection_fields |
ממוזג |
format_version_label |
security_result.detection_fields |
ממוזג |
key |
security_result.detection_fields |
מיפוי: json_message ← message_label, id ← attribute_label, "new","old" ← `attribu... |
message_id_label |
security_result.detection_fields |
ממוזג |
message_label |
security_result.detection_fields |
ממוזג |
message_label_json_message |
security_result.detection_fields |
ממוזג |
message_label_msgId |
security_result.detection_fields |
ממוזג |
message_label_msgNo |
security_result.detection_fields |
ממוזג |
message_label_uuid |
security_result.detection_fields |
ממוזג |
message_label_version |
security_result.detection_fields |
ממוזג |
org_id_label |
security_result.detection_fields |
ממוזג |
space_id_label |
security_result.detection_fields |
ממוזג |
tenant_label |
security_result.detection_fields |
ממוזג |
key |
security_result.severity |
מיפוי: level ← INFORMATIONAL, level ← MEDIUM, level ← UNKNOWN_SEVERITY |
level |
security_result.severity |
מופה: INFO ← INFORMATIONAL |
value |
security_result.severity |
מופה: INFO ← INFORMATIONAL, WARN ← MEDIUM |
level |
security_result.severity_details |
מיפוי ישיר |
value1 |
target.resource.product_object_id |
מיפוי ישיר |
key1 |
target.resource.resource_type |
מופה: clusterID ← CLUSTER |
| לא רלוונטי | metadata.event_type |
קבוע: GENERIC_EVENT |
| לא רלוונטי | metadata.product_name |
קבוע: SAP_BTP |
| לא רלוונטי | metadata.vendor_name |
קבוע: SAP_BTP |
| לא רלוונטי | security_result.severity |
קבוע: INFORMATIONAL |
| לא רלוונטי | target.resource.resource_type |
קבוע: CLUSTER |
יומן שינויים
הצגת יומן השינויים של המנתח הזה
הבעיה עדיין לא נפתרה? קבלת תשובות מחברי הקהילה וממומחי Google SecOps.