本頁適用於 Apigee 和 Apigee Hybrid。
本文將說明如何將 Apigee 與 Google Security Operations (Google SecOps) 整合。如果您使用 Google SecOps 做為 SIEM 解決方案,請按照本文中的步驟設定 Apigee,將記錄資料傳送至 SecOps。
為協助進行這項整合,Google SecOps 支援 Apigee 剖析器,可用於擷取 Apigee 記錄資料。另請參閱「將 Google Cloud 資料擷取至 Google Security Operations」。完成本文件中的設定步驟後,Apigee 記錄資料就會傳送至 Google SecOps。
如要瞭解如何將 SecOps 與其他 SIEM 解決方案整合,請參閱「將 Apigee 與 SIEM 解決方案整合」。
目標對象
這份文件的目標對象包括:
- API 管理員:負責確保 API 安全性、管理平台設定、支援營運效率,以及遵守安全性法規遵循規定。
- 安全分析師專注於主動偵測及調查 API 相關的安全事件,以降低風險並保護機密資料。
設定總覽
本文件所述的設定會使用 Apigee MessageLogging 政策,將各種 Apigee 記錄資料 (包括特定流程變數) 傳送至 SecOps。
Google SecOps 提供特殊的 Cloud Logging 篩選器,可將特定記錄類型 (包括 Apigee 記錄) 即時傳送至 Google SecOps。Google SecOps 支援 Apigee 剖析器,可將 Apigee 記錄資料擷取至 Google SecOps。另請參閱「將 Google Cloud 資料擷取至 Google Security Operations」。
必要條件
符合這些先決條件後,請按照本文件中的操作說明,將 Apigee 與 SecOps 例項整合。開始整合前,請確認您具備下列項目:
- Apigee 或 Apigee Hybrid 帳戶,具有管理權限,可開發及部署 API Proxy
- Google SecOps 帳戶
- 啟用 Cloud Logging,並瞭解如何設定及使用 Cloud Logging
- 瞭解 Apigee 流程變數
- 瞭解 Apigee MessageLogging 政策和一般政策使用和設定
- (選用) 瞭解如何使用 Google SecOps 剖析器解讀已擷取的記錄。 根據預設,SecOps 剖析器會內建,用於剖析並瞭解 MessageLogging 政策擷取的 Apigee 記錄。
- Google Cloud IAM 權限,可使用 Cloud Logging API 並將 IAM 角色授予 SecOps 服務帳戶
將 Apigee 與 SecOps 整合
如果您使用 Google SecOps 做為 SIEM 解決方案,請按照下列步驟將 Apigee 記錄資料傳送至 SecOps。這項作業有兩個基本步驟:
- 設定 MessageLogging 政策,將 Apigee 記錄資料傳送至 Cloud Logging
- 將 MessageLogging 政策附加至 Apigee proxy
完成本節所述的 MessageLogging 政策設定後,SecOps 就會剖析傳送至 Cloud Logging 的 Apigee 記錄資料。如要進一步瞭解剖析器,以及 Apigee 資料流變數資料如何對應至 SecOps 資料欄位,請參閱「將 Apigee 與 Google SecOps SIEM 整合」。另請參閱「收集 Apigee 記錄」。
請按照下列步驟,使用「MessageLogging」政策將 Apigee 與 SecOps 整合:
設定新的 MessageLogging 政策。請參閱「透過使用者介面附加和設定政策」。
以下是將資料傳送至 Cloud Logging 的 MessageLogging 政策範例。這項政策會指定要傳送至 Cloud Logging 的大量流程變數。您可以視需要新增或移除流程變數,這取決於您認為對 SecOps 分析而言重要的欄位。如要瞭解如何將 Apigee 流量變數資料對應至 SecOps 資料欄位,請參閱「將 Apigee 與 Google SecOps SIEM 整合」。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <MessageLogging continueOnError="false" enabled="true" name="ML-CloudLoggingSecOps"> <DisplayName>ML-CloudLoggingSecOps</DisplayName> <CloudLogging> <LogName>projects/{organization.name}/logs/Apigee-SecOps-Integration-{environment.name}</LogName> <Message contentType="application/json">{ "apiproduct.name": "{apiproduct.name}", "app.name": "{developer.app.name}", "cachehit":"{cachehit}", "client.country": "{client.country}", "client.cn": "{client.cn}", "client.ip": "{proxy.client.ip}", "client.locality": "{client.locality}", "client.port": "{client.port}", "client.scheme": "{client.scheme}", "client.state": "{client.state}", "developer.email": "{developer.email}", "environment.name": "{environment.name}", "error":"{is.error}", "error.state":"{error.state}", "error.message":"{escapeJSON(error.message)}", "fault.name":"{fault.name}", "messageid":"{messageid}", "organization.name": "{organization.name}", "proxy.name": "{apiproxy.name}", "proxy.basepath": "{proxy.basepath}", "proxy.pathsuffix": "{proxy.pathsuffix}", "proxy.proxyendpoint.name": "{proxy.name}", "proxy.revision":"{apiproxy.revision}", "request.content-length":"{request_msg.header.content-length}", "request.content-type":"{request_msg.header.content-type}", "request.host":"{request_msg.header.host}", "request.httpversion": "{request.version}", "request.url": "{client.scheme}://{request_msg.header.host}{request_msg.uri}", "request.user-agent":"{request.header.user-agent}", "request.verb": "{request.verb}", "request.x-b3-traceid": "{request.header.x-b3-traceid}", "request.x-cloud-trace-context": "{request.header.x-cloud-trace-context}", "response.content-length":"{response.header.content-length}", "response.content-type":"{response.header.content-type}", "response.status.code": "{message.status.code}", "system.region.name": "{system.region.name}", "system.timestamp": "{system.timestamp}", "system.uuid": "{system.uuid}", "target.cn": "{target.cn}", "target.country": "{target.country}", "target.host": "{target.host}", "target.ip": "{target.ip}", "target.locality": "{target.locality}", "target.organization": "{target.organization}", "target.port": "{target.port}", "target.scheme": "{target.scheme}", "target.state": "{target.state}", "target.url": "{request.url}" } </Message> <ResourceType>api</ResourceType> </CloudLogging> </MessageLogging>
在 API Proxy 中將政策附加為條件式步驟。其中一個選項是在 PostFlow 的 FaultRule 中附加政策,因為這類政策通常會觸發安全性相關錯誤。例如:
<PostFlow name="PostFlow"> <Request> <Step> <Condition>flow.isError == true)</Condition> <Name>ML-CloudLoggingSecOps</Name> </Step> </Request> </PostFlow>
使用此政策的 API Proxy 執行時,Apigee 記錄資料就會流向 Google SecOps。
另一個常見做法是將 MessageLogging 政策放入 ProxyEndpoint 回應的 PostClientFlow。
將 MessageLogging 政策套用至 API Proxy 時,請考慮下列建議:
- 將政策放入 FaultRule。建議您在 FaultRule 中記錄安全性例外狀況和政策違規情形。
- 將政策放入 PostFlow。PostFlow 是另一個適合記錄安全性問題的位置。
- 避免記錄成功的要求。針對以威脅為重點的安全監控,您通常會在發生錯誤 (發生錯誤時) 時記錄詳細資料。記錄每個成功要求的完整訊息內容,可能會產生過多記錄檔並增加費用。
- 請考慮針對特定用途使用自訂變數。舉例來說,如果您需要在錯誤流程中擷取原始要求 URI,可以在要求 PreFlow 中使用 AssignMessage 政策,將 URI 複製到自訂變數 (例如
original.request.uri
),然後在 MessageLogging 政策中記錄該變數。
最佳做法
使用 Google SecOps 設定 Apigee 時,請考慮下列最佳做法:
- 著重於安全性背景:只記錄可為安全性監控和威脅偵測提供寶貴背景資訊的流程變數。避免過度記錄與安全性無關的資料。
- 使用一致的記錄格式:在使用 SecOps 的 API Proxy 中維持一致的記錄格式。
- 使用安全的服務帳戶:請遵循安全性最佳做法,管理用於 SecOps 擷取作業的 Google Cloud 服務帳戶,並確保帳戶安全無虞。盡可能限制記錄檢視器的權限。
- 監控 SecOps 動態饋給:定期監控 SecOps 動態饋給的健康狀態,確保記錄能順利擷取且沒有錯誤。
- 使用 SecOps 規則和資訊主頁:將安全性相關記錄匯入 SecOps 後,請開發特定規則和資訊主頁,根據記錄的詳細資訊偵測並以視覺化方式呈現安全威脅。
疑難排解
本節說明使用 SecOps 設定 Apigee 時可能會遇到的幾個問題,以及需要檢查的事項。
問題:Cloud Logging 中未顯示安全性事件記錄
檢查事項:
- 請仔細檢查 MessageLogging 政策是否已正確設定
Condition
,以便在安全事件發生時觸發。 - 請確認 MessageLogging 政策已附加至適當的流程內容,例如 FaultRule 或 PostFlow。
- 請確認 Google Cloud 專案已啟用 Cloud Logging。
- 查看 Apigee Proxy 記錄中是否有任何與 MessageLogging Policy 相關的錯誤訊息。
問題:SecOps 中未顯示安全性事件記錄檔
- 請確認 SecOps 動態饋給已正確設定正確的專案 ID、記錄篩選器 (確保擷取安全性記錄政策中的記錄) 和服務帳戶憑證。
- 在 SecOps UI 中檢查 SecOps 動態饋給的狀態,查看是否有任何錯誤訊息或擷取問題。
- 確認 SecOps 使用的服務帳戶在 Google Cloud 專案中具有「記錄檢視器」角色。
安全性相關欄位在 SecOps 中未正確剖析
- 請在 Cloud Logging 中查看記錄的 JSON 結構,確認記錄格式正確無誤,且包含預期的欄位名稱。
- 確認已啟用適當的 Google Cloud 剖析器。
- 如果您懷疑有剖析問題,請檢查 SecOps 原始資料中的記錄項目樣本,瞭解剖析前擷取方式。如果系統無法如預期擷取特定欄位,您可能需要查看 SecOps 剖析器文件,或考慮是否需要自訂剖析器。
將 Apigee 與 Google SecOps SIEM 整合
下表將 Apigee 流程變數名稱對應至相等的 Google SecOps SIEM 欄位名稱。舉例來說,在 Cloud Logging 中查看 Apigee 記錄資料時,client.id
流程變數會對應至名為 principle_ip
的 SecOps SIEM 欄位。另請參閱「收集 Apigee 記錄」。
Apigee 流程變數 | SecOps SIEM 欄位名稱 | 說明 |
---|---|---|
client.country | principal.hostname | 與 ProxyEndpoint 收到的要求相關聯的 HTTP 主機 IP。 |
client.host | principal.location.country_or_region | 用戶端應用程式提供的 TLS/SSL 憑證中所列國家/地區。 Proxy request
principal.location.country_or_region 。 |
client.ip | principle.ip | 將訊息傳送至負載平衡器的用戶端或系統 IP 位址。例如,這可能是原始用戶端 IP 或負載平衡器 IP。 |
client.locality | principal.location.city | 用戶端提供的 TLS/SSL 憑證中的地區 (城市)。 |
client.port | principal.port | 與 ProxyEndpoint 來源用戶端要求相關聯的 HTTP 通訊埠。 |
client.state | principal.location.state | 用戶端提供的 TLS/SSL 憑證中的狀態。 |
organization.name | intermediary.cloud.project.name | Apigee 機構名稱。 |
proxy.client.ip | src.ip | Inbound 呼叫的 X-Forwarded-For 位址,即 Apigee 從上次外部 TCP 握手收到的 IP 位址。這可能是呼叫用戶端或負載平衡器。 |
proxy.name | intermediary.resource.name | ProxyEndpoint 的名稱屬性。 |
proxy.pathsuffix | intermediary.resource.attribute.labels[pathsuffix] | 「從用戶端傳送並在 ProxyEndpoint 中收到的網址中路徑後置字串的值。basepath 是位於最左邊的路徑元件,可用於在環境群組中唯一識別 API Proxy。假設您已設定 API Proxy 端點,並將 basepath 設為 /v2/weatherapi。在這種情況下,傳送至 https://myhost.example.net/v2/weatherapi/forecastrss?w=12797282 的要求,proxy.pathsuffix 變數會保留字串 /forecastrss。 |
proxy.url | intermediary.url | 「取得與 ProxyEndpoint 收到的 Proxy 要求相關聯的完整網址,包括任何存在的查詢參數。如需使用原始要求主機 (而非 proxy.url 中使用的路由器主機) 建構要求網址的範例,請參閱「存取要求訊息」。 |
request.uri | target.resource.name | 將回應傳回至 API Proxy 的目標服務網域名稱。 |
request.verb | 用於要求的 HTTP 動詞。例如 GET、PUT 和 DELETE。 | |
response.content | 目標傳回的回應訊息酬載內容。 | |
response.status.code | 要求傳回的回應代碼。您可以使用這個變數覆寫儲存在 message.status.code 中的回應狀態碼。詳情請參閱訊息。 | |
system.region.name | intermediary.location.name | 執行 Proxy 的資料中心區域名稱。 |
system.timestamp | 64 位元 (長) 整數,代表讀取這個變數的時間。這個值是自世界標準時間 1970 年 1 月 1 日午夜起經過的毫秒數。例如 1534783015000。 | |
system.uuid | intermediary.process.pid 或 intermediary.process.product_specific_process_id | 處理 Proxy 的訊息處理器的 UUID。 |
target.country | target.location.country_or_region | 目標伺服器提供的 TLS/SSL 憑證所屬國家/地區 |
target.host | 將回應傳回至 API Proxy 的目標服務網域名稱。 | |
target.ip | 將回應傳回至 API 代理程式的目標服務 IP 位址。 | |
target.locality | target.location.city | 目標伺服器提供的 TLS/SSL 憑證所在地 (城市) |
target.organization | 目標伺服器提供的 TLS/SSL 憑證組織。 | |
target.port | 傳回 API Proxy 回應的目標服務通訊埠號碼。 | |
target.scheme | 會根據要求訊息傳回 HTTP 或 HTTPS。 | |
target.state | target.location.state | 目標伺服器提供的 TLS/SSL 憑證狀態。 |
target.url | 在 TargetEndpoint XML 檔案中設定的網址,或動態目標網址 (如果在訊息流程中設定了 target.url)。這個變數不包含任何其他路徑元素或查詢參數。如果在範圍外呼叫或未設定,則會傳回空值。 注意:請使用附加至 TargetEndpoint 的 JavaScript 政策來設定這個變數。 |