按照這些操作說明建立 Google Cloud Armor 安全性政策,以篩選應用程式傳入的流量。如要瞭解安全性政策的概念資訊,請參閱 Google Cloud Armor 安全性政策總覽。
事前準備
設定安全性政策前,請先執行下列操作:
請務必熟悉外部應用程式負載平衡器的概念。
檢查現有的後端服務,找出尚未附加安全性政策的服務。這些後端服務及其相關後端並未受到 Google Cloud Armor 保護。如要新增 Google Cloud Armor 提供的防護機制,請按照本文中的操作說明,將新建立或現有的安全性政策附加至後端服務。
為 Google Cloud Armor 安全性政策設定 IAM 權限
下列作業需要具備身分與存取權管理 (IAM) Compute 安全性管理員角色 (roles/compute.securityAdmin
):
- 設定、修改、更新及刪除 Google Cloud Armor 安全性政策
- 使用下列 API 方法:
SecurityPolicies insert
SecurityPolicies delete
SecurityPolicies patch
SecurityPolicies addRule
SecurityPolicies patchRule
SecurityPolicies removeRule
具備 Compute 網路管理員角色 (roles/compute.networkAdmin
) 的使用者可以執行下列操作:
- 為後端服務設定 Google Cloud Armor 安全性政策
- 使用下列 API 方法:
BackendServices setSecurityPolicy
BackendServices list
(僅限gcloud
)
具有安全性管理員角色 (roles/iam.securityAdmin
)和 Compute Network 管理員角色的使用者,可以使用 SecurityPolicies
API 方法 get
、list
和 getRule
查看 Google Cloud Armor 安全性政策。
設定自訂角色的 IAM 權限
下表列出 IAM 角色的基本權限,以及相關的 API 方法。
IAM 權限 | API 方法 |
---|---|
compute.securityPolicies.create |
SecurityPolicies insert |
compute.securityPolicies.delete |
SecurityPolicies delete |
compute.securityPolicies.get |
SecurityPolicies get SecurityPolicies getRule |
compute.securityPolicies.list |
SecurityPolicies list |
compute.securityPolicies.use |
BackendServices setSecurityPolicy |
compute.securityPolicies.update |
SecurityPolicies patch SecurityPolicies addRule SecurityPolicies patchRule SecurityPolicies removeRule |
compute.backendServices.setSecurityPolicy |
BackendServices setSecurityPolicy |
建立安全性政策
您可以使用 Google Cloud 控制台、Google Cloud CLI 或 REST API 設定 Google Cloud Armor 安全性政策、規則和運算式。使用 gcloud CLI 建立安全性政策時,請使用 --type
旗標指定安全性政策是後端安全性政策還是邊緣安全性政策。
如果您不熟悉安全性政策設定,建議您查看安全性政策範例。
運算式範例
以下是範例運算式。如要進一步瞭解運算式,請參閱 Google Cloud Armor 自訂規則語言參考資料。
如果您要設定使用 ISO 3166-1 alpha 2 國家/地區代碼的規則或運算式,Google Cloud Armor 會個別處理每個代碼。Google Cloud Armor 規則和運算式會明確使用這些區域代碼來允許或拒絕要求。
下列運算式會比對 IP 位址
1.2.3.4
的請求,並在 user-agent 標頭中包含字串example
:inIpRange(origin.ip, '1.2.3.4/32') && has(request.headers['user-agent']) && request.headers['user-agent'].contains('example')
或者,您也可以使用
origin.user_ip
屬性,比對自訂用戶端 IP 位址標頭的 IP 位址範圍:inIpRange(origin.user_ip, '1.2.3.4/32') && has(request.headers['user-agent']) && request.headers['user-agent'].contains('example')
以下運算式會比對含有特定值 Cookie 的要求:
has(request.headers['cookie']) && request.headers['cookie'].contains('cookie_name=cookie_value')
以下運算式會比對來自
AU
區域的要求:origin.region_code == 'AU'
下列運算式會比對區域
AU
中不在指定 IP 範圍內的要求:origin.region_code == "AU" && !inIpRange(origin.ip, '1.2.3.0/24')
如果 URI 符合規則運算式,以下運算式會比對要求,並提供特定檔案的編號可變路徑:
request.path.matches('/path/[0-9]+/target_file.html')
如果
user-id
標頭的 Base64 解碼值包含特定值,則以下運算式會與要求相符:has(request.headers['user-id']) && request.headers['user-id'].base64Decode().contains('myValue')
以下運算式會使用預先設定的運算式組合,比對 SQLi 攻擊:
evaluatePreconfiguredWaf('sqli-stable')
管理安全性政策
請參閱以下各節,瞭解如何列出專案中的安全性政策、更新安全性政策、刪除安全性政策,或測試安全性政策。
列出安全性政策
您可以按照這些操作說明,列出目前專案或指定專案中的所有 Google Cloud Armor 安全性政策。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
如要查看特定政策,請在「安全政策」頁面中,按一下政策清單中的名稱。
gcloud
gcloud compute security-policies list
例如:
gcloud compute security-policies list
NAME my-policy
更新安全性政策
請按照這些操作說明更新 Google Cloud Armor 安全性政策。舉例來說,您可以修改政策說明、修改預設規則的行為、變更目標後端服務,或新增規則。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
如要更新特定政策,請前往「安全性政策」頁面,在政策清單中,按一下要更新的政策旁邊的「選單」圖示
。- 如要更新預設規則動作的政策說明,請選取「編輯」,進行變更,然後按一下「更新」。
- 如要新增規則,請選取「新增規則」,然後按照「在安全性政策中新增規則」中的指示操作。
- 如要變更政策的目標後端服務,請依序選取「將政策套用至目標」和「新增目標」,然後選取目標並按一下「新增」。
gcloud
如要更新安全性政策,請使用下列 Google Cloud CLI 指示:
- 如要更新安全性政策中的規則,請參閱「更新安全性政策中的單一規則」。
- 如要為安全性政策新增規則,請參閱「為安全性政策新增規則」。
- 如要從安全性政策中刪除規則,請參閱「從安全性政策中刪除規則」。
- 如要在單一更新中更新多個規則 (原子更新),請參閱「原子更新安全性政策中的多個規則」。
- 如要更新安全性政策中的非規則欄位 (例如說明欄位),請參閱「匯出安全性政策」和「匯入安全性政策」。
刪除安全性政策
按照這些操作說明刪除 Google Cloud Armor 安全性政策。您必須先移除政策中的所有後端服務,才能刪除政策。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,找出要刪除的安全性政策名稱,然後勾選旁邊的核取方塊。
按一下頁面右上角的
「刪除」。
gcloud
使用 gcloud compute security-policies delete NAME
。請將 NAME
替換為安全政策名稱:
gcloud compute security-policies delete NAME
測試安全性政策
建議您在預覽模式中部署所有新規則,然後檢查要求記錄,確認政策和規則的運作情況是否符合預期。
管理安全性政策規則
請參閱以下各節,瞭解如何列出安全性政策規則、新增規則、更新規則或刪除規則。
列出安全性政策中的規則
請按照這些操作說明,列出 Google Cloud Armor 安全性政策中的規則。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面上,按一下安全性政策名稱。系統會顯示「政策詳細資料」頁面,並在頁面中間的「規則」分頁中列出政策規則。
gcloud
請使用下列 gcloud
指令,列出單一安全性政策中的所有規則,以及政策說明:
gcloud compute security-policies describe NAME \
使用下列 gcloud
指令,說明指定安全政策中具有指定優先順序的規則:
gcloud compute security-policies rules describe PRIORITY \ --security-policy POLICY_NAME
舉例來說,下列指令會說明安全性政策 my-policy
中優先順序為 1000 的規則:
gcloud compute security-policies rules describe 1000 \ --security-policy my-policy
輸出:
action: deny(403) description: block traffic from 192.0.2.0/24 and 198.51.100.0/24 kind: compute#securityPolicyRule match: srcIpRanges: - '192.0.2.0/24' - '198.51.100.0/24' preview: false priority: 1000
為安全性政策新增規則
按照這些操作說明,在 Google Cloud Armor 安全性政策中新增規則。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,按一下安全性政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「規則」分頁標籤。
按一下 [新增規則]。
選用步驟:輸入規則說明。
選取模式:
- 基本模式:依據 IP 位址或 IP 範圍允許或拒絕流量。
- 進階模式:根據規則運算式允許或拒絕流量。
在「比對」欄位中,指定規則適用的條件:
基本模式:在規則中輸入一 (1) 到五 (5) 個 IP 位址範圍。您最多可以加入 5 個 IP 位址範圍。如要瞭解限制,請參閱「Google Cloud Armor 配額與限制」。
進階模式:輸入運算式或子運算式,以便針對傳入的請求進行評估。如要瞭解如何編寫運算式及閱讀下列範例,請參閱自訂規則語言參考資料。
下列運算式會比對 IP 位址
1.2.3.4
的請求,並在 user-agent 標頭中包含字串example
:inIpRange(origin.ip, '1.2.3.4/32') && has(request.headers['user-agent']) && request.headers['user-agent'].contains('example')
以下運算式會比對含有特定值 Cookie 的要求:
has(request.headers['cookie']) && request.headers['cookie'].contains('cookie_name=cookie_value')
以下運算式會比對來自
AU
區域的要求:origin.region_code == 'AU'
下列運算式會比對來自
AU
區域且不在指定 IP 範圍內的要求:origin.region_code == "AU" && !inIpRange(origin.ip, '1.2.3.0/24')
如果 URI 符合規則運算式,以下運算式會比對要求:
request.path.matches('/example_path/')
如果
user-id
標頭的 Base64 解碼值包含特定值,則以下運算式會與要求相符:has(request.headers['user-id']) && request.headers['user-id'].base64Decode().contains('myValue')
以下運算式會使用預先設定的運算式集合,比對 SQLi 攻擊:
evaluatePreconfiguredWaf('sqli-stable')
在「動作」中,選取「允許」或「拒絕」。
如果您要設定拒絕規則,請選取「拒絕狀態」訊息。
如要為規則啟用預覽模式,請選取「啟用」核取方塊。
在「Priority」欄位中輸入正整數。
按一下「新增」。
gcloud
使用 gcloud compute security-policies rules create PRIORITY
指令。請將 PRIORITY
替換為政策中規則的優先順序:
gcloud compute security-policies rules create PRIORITY \ --security-policy POLICY_NAME \ --description DESCRIPTION \ --src-ip-ranges IP_RANGES | --expression EXPRESSION \ --action=[ allow | deny-403 | deny-404 | deny-502 ] \ --preview
舉例來說,下列指令會新增規則,封鎖來自 IP 位址範圍 192.0.2.0/24 和 198.51.100.0/24 的流量。此規則的優先順序為 1000,是名為 my-policy
的政策中的規則:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --description "block traffic from 192.0.2.0/24 and 198.51.100.0/24" \ --src-ip-ranges "192.0.2.0/24","198.51.100.0/24" \ --action "deny-403"
使用 --expression
旗標,在自訂規則語言參考資料中指定條件。下列指令會新增規則,允許來自 IP 位址 1.2.3.4
的流量,並在使用者代理程式標頭中包含字串 example
:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "inIpRange(origin.ip, '1.2.3.4/32') && has(request.headers['user-agent']) && request.headers['user-agent'].contains('example')" \ --action allow \ --description "Block User-Agent 'example'"
以下指令會新增規則,在要求的 Cookie 包含特定值時封鎖要求:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "has(request.headers['cookie']) && request.headers['cookie'].contains('80=BLAH')" \ --action deny-403 \ --description "Cookie Block"
下列指令會新增規則,封鎖來自 AU
的請求:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "origin.region_code == 'AU'" \ --action deny-403 \ --description "AU block"
下列指令會新增規則,封鎖來自區域 AU
且不在指定 IP 範圍內的請求:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "origin.region_code == "AU" && !inIpRange(origin.ip, '1.2.3.0/24')" \ --action deny-403 \ --description "country and IP block"
下列指令會新增規則,封鎖 URI 與規則運算式相符的要求:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "request.path.matches('/example_path/')" \ --action deny-502 \ --description "regex block"
下列指令會新增規則,如果 user-id
標頭的 Base64 解碼值包含特定值,就會封鎖要求:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "has(request.headers['user-id']) && request.headers['user-id'].base64Decode().contains('myValue')" \ --action deny-403 \ --description "country and IP block"
下列指令會新增使用預先設定的運算式集來緩解 SQLi 攻擊的規則:
gcloud compute security-policies rules create 1000 \ --security-policy my-policy \ --expression "evaluatePreconfiguredWaf('sqli-stable')" \ --action deny-403
更新安全性政策中的單一規則
請按照這些操作說明更新 Google Cloud Armor 安全性政策中的單一規則。如要以原子方式更新多個規則,請參閱「以原子方式更新安全性政策中的多個規則」。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,按一下安全性政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「規則」分頁標籤。
在要更新的規則旁邊,按一下「編輯」圖示
。系統會顯示「Edit rule」(編輯規則) 頁面。進行變更,然後按一下「更新」。
gcloud
使用這個指令可在指定的安全性政策中,更新優先順序為指定值的規則。您一次只能使用這個指令更新一項安全政策:
gcloud compute security-policies rules update PRIORITY [ \ --security-policy POLICY_NAME \ --description DESCRIPTION \ --src-ip-ranges IP_RANGES | --expression EXPRESSION \ --action=[ allow | deny-403 | deny-404 | deny-502 ] \ --preview ]
舉例來說,下列指令會更新優先順序為 1111 的規則,允許來自 IP 位址範圍 192.0.2.0/24 的流量:
gcloud compute security-policies rules update 1111 \ --security-policy my-policy \ --description "allow traffic from 192.0.2.0/24" \ --src-ip-ranges "192.0.2.0/24" \ --action "allow"
如要進一步瞭解這個指令,請參閱 gcloud compute security-policies rules update
。
如要更新規則的優先順序,您必須使用 REST API。詳情請參閱 securityPolicies.patchRule
。
以原子方式更新安全性政策中的多個規則
原子更新會在單一更新中套用對多項規則的變更。如果您逐一更新規則,舊規則和新規則可能會在短時間內同時運作,因此可能會出現一些非預期的行為。
如要一次性更新多個規則,請將目前的安全性政策匯出至 JSON 或 YAML 檔案,然後加以修改。使用修改過的檔案建立新的安全性政策,然後切換相關後端服務的安全性政策。
gcloud
匯出要更新的政策,如以下範例所示:
gcloud compute security-policies export my-policy \ --file-name my-file \ --file-format yaml
匯出的政策會類似以下範例:
description: my description fingerprint: PWfLGDWQDLY= id: '123' name: my-policy rules: - action: deny(404) description: my-rule-1 match: expr: expression: evaluatePreconfiguredWaf('xss-stable') versionedExpr: SRC_IPS_V1 preview: false priority: 1 - action: allow description: my-rule-2 match: config: srcIpRanges: - '1.2.3.4' versionedExpr: SRC_IPS_V1 preview: false priority: 2 - action: deny description: default rule kind: compute#securityPolicyRule match: config: srcIpRanges: - '*' versionedExpr: SRC_IPS_V1 preview: false priority: 2147483647 selfLink: https://www.googleapis.com/compute/v1/projects/my-project/global/securityPolicies/my-policy
使用任何文字編輯器修改政策。例如,您可以修改現有規則的優先順序,並新增規則:
description: my description fingerprint: PWfLGDWQDLY= id: '123' name: my-policy rules: - action: deny(404) description: my-rule-1 match: expr: expression: evaluatePreconfiguredWaf('xss-stable') versionedExpr: SRC_IPS_V1 preview: false priority: 1 - action: allow description: my-new-rule match: config: srcIpRanges: - '1.2.3.1' versionedExpr: SRC_IPS_V1 preview: false priority: 10 - action: allow description: my-rule-2 match: config: srcIpRanges: - '1.2.3.4' versionedExpr: SRC_IPS_V1 preview: false priority: 11 - action: deny description: default rule kind: compute#securityPolicyRule match: config: srcIpRanges: - '*' versionedExpr: SRC_IPS_V1 preview: false priority: 2147483647 selfLink: https://www.googleapis.com/compute/v1/projects/my-project/global/securityPolicies/my-policy
建立新的 Google Cloud Armor 安全性政策,並指定修改過的檔案名稱和格式,如以下範例所示:
gcloud compute security-policies create new-policy \ --file-name modified-policy \ --file-format yaml
從相關的後端服務中移除舊的安全性政策,如以下範例所示:
gcloud compute backend-services update my-backend \ --security-policy ""
將新的安全性政策新增至後端服務,如以下範例所示:
gcloud compute backend-services update my-backend \ --security-policy new-policy
如果舊政策未使用,請刪除:
gcloud compute security-policies delete my-policy
從安全性政策中刪除規則
請按照這些操作說明,從 Google Cloud Armor 安全性政策中刪除規則。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
按一下安全政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
在頁面中間的「規則」分頁中,選取要刪除的規則旁邊的核取方塊。
按一下
「Delete」(刪除)。
gcloud
使用這個指令,即可從指定的安全性政策中移除優先順序為指定值的規則。您一次只能修改一項安全政策,但可以一次刪除多項規則:
gcloud compute security-policies rules delete PRIORITY [...] [ --security-policy POLICY_NAME \ ]
例如:
gcloud compute security-policies rules delete 1000 \ --security-policy my-policy
附加及移除安全性政策
請參閱以下各節,瞭解如何在後端服務和後端值區中附加及移除安全性政策。
將安全性政策附加至後端服務
請按照這些操作說明,將 Google Cloud Armor 安全性政策附加至後端服務。安全性政策可附加至多個後端服務,但後端服務只能附加一種安全性政策。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,按一下安全性政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「目標」分頁標籤。
按一下「對新目標套用政策」。
點選「新增目標」。
在「目標」清單中選取目標,然後按一下「新增」。
gcloud
將後端安全性政策附加至後端服務時,請使用 gcloud compute backend-services
指令和 --security-policy
標記:
gcloud compute backend-services update my-backend \ --security-policy my-policy
將邊緣安全政策附加至後端服務時,請使用 gcloud compute backend-services
指令和 --edge-security-policy
標記:
gcloud compute backend-services update my-backend \ --edge-security-policy my-policy
從後端服務移除安全性政策
按照這些操作說明,從後端服務中移除 Google Cloud Armor 後端安全性政策或邊緣安全性政策。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,按一下安全性政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「目標」分頁標籤。
選取要移除政策的目標後端服務。
按一下 [移除]。
在「移除指定對象」訊息中,按一下「移除」。
gcloud
移除後端安全政策時,請使用 gcloud compute
backend-services
指令和 --security-policy
標記:
gcloud compute backend-services update my-backend \ --security-policy ""
移除邊緣安全政策時,請使用 gcloud compute
backend-services
指令和 --edge-security-policy
旗標:
gcloud compute backend-services update my-backend \ --edge-security-policy ""
將安全性政策附加至後端值區
按照這些操作說明,將 Google Cloud Armor 邊緣安全性政策附加至後端值區。邊緣安全性政策可附加至多個後端值區。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面上,按一下安全性政策名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「目標」分頁標籤。
按一下「對新目標套用政策」。
點選「新增目標」。
在「目標」清單中選取目標,然後按一下「新增」。
gcloud
將邊緣安全政策附加至後端值區時,請使用 cloud compute backend-buckets
指令和 --edge-security-policy
標記:
gcloud compute backend-services update my-bucket \ --edge-security-policy my-edge-policy
從後端值區移除安全性政策
按照這些操作說明,從後端值區移除 Google Cloud Armor 邊緣安全性政策。
主控台
在 Google Cloud 控制台中,前往「Google Cloud Armor 政策」頁面。
在「安全性政策」頁面中,按一下安全性政策的名稱。系統隨即會顯示「政策詳細資料」頁面。
按一下頁面中間的「目標」分頁標籤。
選取要移除政策的目標後端服務。
按一下 [移除]。
在「移除指定對象」訊息中,按一下「移除」。
gcloud
從後端值區移除邊緣安全性政策時,請使用 cloud compute backend-buckets
指令和 --edge-security-policy
標記:
gcloud compute backend-services update my-bucket \ --edge-security-policy ""
匯入及匯出安全性政策
請參閱下列各節,瞭解如何匯入及匯出安全性政策,並以 YAML 或 JSON 檔案格式儲存。
匯入安全性政策
您可以使用 Google Cloud CLI,從 YAML 或 JSON 檔案匯入 Google Cloud Armor 安全性政策。您無法使用 import
指令更新現有政策的規則。相反地,您必須使用更新安全性政策中的單一規則程序逐一更新規則,或是使用在安全性政策中以原子方式更新多個規則程序一次更新所有規則。
gcloud
如要匯入安全性政策,請使用 gcloud compute security-policies import NAME
指令。將 NAME
替換為您要匯入的安全性政策名稱。如果您未提供檔案格式,系統會根據檔案結構假設正確的格式。如果結構無效,您會看到錯誤訊息。
gcloud compute security-policies import NAME \ --file-name FILE_NAME \ [--file-format FILE_FORMAT]
舉例來說,下列指令會匯入檔案 my-file
,以更新政策 my-policy
。
gcloud compute security-policies import my-policy \ --file-name my-file \ --file-format json
如果政策的指紋在匯入時已過時,Google Cloud Armor 會顯示錯誤。這表示自上次匯出政策後,政策已經過修改。如要修正這個問題,請在政策上使用 describe
指令,取得最新的指紋。合併所述政策與您政策之間的任何差異,然後將過時的指紋取代為最新的指紋。
匯出安全性政策
您可以使用 Google Cloud CLI,將 Google Cloud Armor 安全性政策匯出為 YAML 或 JSON 檔案。匯出政策可讓您擷取副本,以便在來源控管中修改或儲存。
gcloud
在下列指令中,
NAME
是安全政策的名稱。有效的檔案格式為 YAML 和 JSON。如果您未提供檔案格式,Google Cloud Armor 會使用預設的 YAML。gcloud compute security-policies export NAME \ --file-name FILE_NAME \ --file-format FILE_FORMAT
以下範例會將
my-policy
安全性政策以 YAML 格式匯出至my-file
檔案:gcloud compute security-policies export my-policy \ --file-name my-file \ --file-format yaml
以下範例顯示匯出的安全性政策:
description: my description fingerprint: PWfLGDWQDLY= id: '123' name: my-policy rules: - action: allow description: default rule match: config: srcIpRanges: - '*' versionedExpr: SRC_IPS_V1 preview: false priority: 2147483647 selfLink: https://www.googleapis.com/compute/v1/projects/my-project/global/securityPolicies/my-policy
您可以使用任何文字編輯器修改匯出的檔案,然後使用
import
指令將檔案匯入 Google Cloud 。
列出可用的預先設定規則
列出預先設定的規則,以便查看預先定義的應用程式保護規則和簽章,例如 Google Cloud Armor 提供的 OWASP 核心規則集。這些預先設定的規則包含多個內建簽名,Google Cloud Armor 會使用這些簽名來評估傳入的要求。您可以使用自訂規則語言參考資料,將這些預先設定的規則加入新規則或現有規則。
詳情請參閱「預先設定的規則」。
gcloud
執行
gcloud compute security-policies list-preconfigured-expression-sets
指令:gcloud compute security-policies list-preconfigured-expression-sets
以下範例說明指令的輸出格式:
EXPRESSION_SET expression-set-1 RULE_ID SENSITIVITY expression-set-1-id-1 sensitivity-value-1 expression-set-1-id-2 sensitivity-value-2 expression-set-2 alias-1 RULE_ID SENSITIVITY expression-set-2-id-1 sensitivity-value-1 expression-set-2-id-2 sensitivity-value-2
以下範例包含指令實際輸出的範例。請注意,實際輸出內容會包含 調整 Google Cloud Armor 網路應用程式防火牆規則 中列出的所有規則。
gcloud compute security-policies list-preconfigured-expression-sets
EXPRESSION_SET sqli-canary RULE_ID SENSITIVITY owasp-crs-v030001-id942110-sqli 2 owasp-crs-v030001-id942120-sqli 2 … xss-canary RULE_ID SENSITIVITY owasp-crs-v030001-id941110-xss 1 owasp-crs-v030001-id941120-xss 1 … sourceiplist-fastly sourceiplist-cloudflare sourceiplist-imperva