Skip to content

Commit 5e39b52

Browse files
Merge pull request #232057 from Miskatonic-Electronic/patch-39
Update create-custom-waf-rules.md
2 parents 41b1e22 + e7dc0a1 commit 5e39b52

File tree

1 file changed

+35
-17
lines changed

1 file changed

+35
-17
lines changed

articles/web-application-firewall/ag/create-custom-waf-rules.md

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ services: web-application-firewall
66
ms.topic: article
77
author: vhorne
88
ms.service: web-application-firewall
9-
ms.date: 08/22/2022
9+
ms.date: 04/06/2023
1010
ms.author: victorh
1111
ms.custom: devx-track-azurepowershell
1212
---
@@ -26,7 +26,7 @@ The JSON snippets shown in this article are derived from a [ApplicationGatewayWe
2626

2727
## Example 1
2828

29-
You know there's a bot named *evilbot* that you want to block from crawling your website. In this case, you’ll block on the User-Agent *evilbot* in the request headers.
29+
You know there's a bot named *evilbot* that you want to block from crawling your website. In this case, you block on the User-Agent *evilbot* in the request headers.
3030

3131
Logic: p
3232

@@ -47,10 +47,11 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
4747
-Priority 2 `
4848
-RuleType MatchRule `
4949
-MatchCondition $condition `
50-
-Action Block
50+
-Action Block `
51+
-State Enabled
5152
```
5253

53-
And here is the corresponding JSON:
54+
And here's the corresponding JSON:
5455

5556
```json
5657
{
@@ -60,6 +61,7 @@ And here is the corresponding JSON:
6061
"priority": 2,
6162
"ruleType": "MatchRule",
6263
"action": "Block",
64+
"state": "Enabled",
6365
"matchConditions": [
6466
{
6567
"matchVariables": [
@@ -106,7 +108,8 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
106108
-Priority 2 `
107109
-RuleType MatchRule `
108110
-MatchCondition $condition `
109-
-Action Block
111+
-Action Block `
112+
-State Enabled
110113
```
111114

112115
And the corresponding JSON:
@@ -119,6 +122,7 @@ And the corresponding JSON:
119122
"priority": 2,
120123
"ruleType": "MatchRule",
121124
"action": "Block",
125+
"state": "Enabled",
122126
"matchConditions": [
123127
{
124128
"matchVariables": [
@@ -144,7 +148,7 @@ And the corresponding JSON:
144148

145149
## Example 2
146150

147-
You want to allow traffic only from the US using the GeoMatch operator and still have the managed rules apply:
151+
You want to allow traffic only from the United States using the GeoMatch operator and still have the managed rules apply:
148152

149153
```azurepowershell
150154
$variable = New-AzApplicationGatewayFirewallMatchVariable `
@@ -162,7 +166,8 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
162166
-Priority 2 `
163167
-RuleType MatchRule `
164168
-MatchCondition $condition `
165-
-Action Block
169+
-Action Block `
170+
-State Enabled
166171
```
167172

168173
And the corresponding JSON:
@@ -175,6 +180,7 @@ And the corresponding JSON:
175180
"priority": 2,
176181
"ruleType": "MatchRule",
177182
"action": "Block",
183+
"state": "Enabled",
178184
"matchConditions": [
179185
{
180186
"matchVariables": [
@@ -201,7 +207,7 @@ And the corresponding JSON:
201207

202208
You want to block all requests from IP addresses in the range 198.168.5.0/24.
203209

204-
In this example, you'll block all traffic that comes from an IP addresses range. The name of the rule is *myrule1* and the priority is set to 10.
210+
In this example, you block all traffic that comes from an IP addresses range. The name of the rule is *myrule1* and the priority is set to 10.
205211

206212
Logic: p
207213

@@ -220,7 +226,8 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
220226
-Priority 10 `
221227
-RuleType MatchRule `
222228
-MatchCondition $condition1 `
223-
-Action Block
229+
-Action Block `
230+
-State Enabled
224231
```
225232

226233
Here's the corresponding JSON:
@@ -233,6 +240,7 @@ Here's the corresponding JSON:
233240
"priority": 10,
234241
"ruleType": "MatchRule",
235242
"action": "Block",
243+
"state": "Enabled",
236244
"matchConditions": [
237245
{
238246
"matchVariables": [
@@ -258,7 +266,7 @@ Corresponding CRS rule:
258266

259267
## Example 4
260268

261-
For this example, you want to block User-Agent *evilbot*, and traffic in the range 192.168.5.0/24. To accomplish this, you can create two separate match conditions, and put them both in the same rule. This ensures that if both *evilbot* in the User-Agent header **and** IP addresses from the range 192.168.5.0/24 are matched, then the request is blocked.
269+
For this example, you want to block User-Agent *evilbot*, and traffic in the range 192.168.5.0/24. To accomplish this action, you can create two separate match conditions, and put them both in the same rule. This configuration ensures that if both *evilbot* in the User-Agent header **and** IP addresses from the range 192.168.5.0/24 are matched, then the request is blocked.
262270

263271
Logic: p **and** q
264272

@@ -288,7 +296,8 @@ $condition2 = New-AzApplicationGatewayFirewallCondition `
288296
-Priority 10 `
289297
-RuleType MatchRule `
290298
-MatchCondition $condition1, $condition2 `
291-
-Action Block
299+
-Action Block `
300+
-State Enabled
292301
```
293302

294303
Here's the corresponding JSON:
@@ -301,6 +310,7 @@ Here's the corresponding JSON:
301310
"priority": 10,
302311
"ruleType": "MatchRule",
303312
"action": "Block",
313+
"state": "Enabled",
304314
"matchConditions": [
305315
{
306316
"matchVariables": [
@@ -369,14 +379,16 @@ $rule1 = New-AzApplicationGatewayFirewallCustomRule `
369379
-Priority 10 `
370380
-RuleType MatchRule `
371381
-MatchCondition $condition1 `
372-
-Action Block
382+
-Action Block `
383+
-State Enabled
373384
374385
$rule2 = New-AzApplicationGatewayFirewallCustomRule `
375386
-Name myrule2 `
376387
-Priority 20 `
377388
-RuleType MatchRule `
378389
-MatchCondition $condition2 `
379-
-Action Block
390+
-Action Block `
391+
-State Enabled
380392
```
381393

382394
And the corresponding JSON:
@@ -389,6 +401,7 @@ And the corresponding JSON:
389401
"priority": 10,
390402
"ruleType": "MatchRule",
391403
"action": "Block",
404+
"state": "Enabled",
392405
"matchConditions": [
393406
{
394407
"matchVariables": [
@@ -410,6 +423,7 @@ And the corresponding JSON:
410423
"priority": 20,
411424
"ruleType": "MatchRule",
412425
"action": "Block",
426+
"state": "Enabled",
413427
"matchConditions": [
414428
{
415429
"matchVariables": [
@@ -456,7 +470,8 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
456470
-Priority 2 `
457471
-RuleType MatchRule `
458472
-MatchCondition $condition `
459-
-Action Block
473+
-Action Block `
474+
-State Enabled
460475
```
461476

462477
Corresponding JSON:
@@ -469,6 +484,7 @@ Corresponding JSON:
469484
"priority": 2,
470485
"ruleType": "MatchRule",
471486
"action": "Block",
487+
"state": "Enabled",
472488
"matchConditions": [
473489
{
474490
"matchVariables": [
@@ -493,7 +509,7 @@ Corresponding JSON:
493509

494510
## Example 7
495511

496-
It is not uncommon to see Azure Front Door deployed in front of Application Gateway. In order to make sure the traffic received by Application Gateway comes from the Front Door deployment, the best practice is to check if the `X-Azure-FDID` header contains the expected unique value. For more information on this, please see [How to lock down the access to my backend to only Azure Front Door](../../frontdoor/front-door-faq.yml#how-do-i-lock-down-the-access-to-my-backend-to-only-azure-front-door-)
512+
It isn't uncommon to see Azure Front Door deployed in front of Application Gateway. In order to make sure the traffic received by Application Gateway comes from the Front Door deployment, the best practice is to check if the `X-Azure-FDID` header contains the expected unique value. For more information on securing access to your application using Azure Front Door, see [How to lock down the access to my backend to only Azure Front Door](../../frontdoor/front-door-faq.yml#how-do-i-lock-down-the-access-to-my-backend-to-only-azure-front-door-)
497513

498514
Logic: **not** p
499515

@@ -515,10 +531,11 @@ $rule = New-AzApplicationGatewayFirewallCustomRule `
515531
-Priority 2 `
516532
-RuleType MatchRule `
517533
-MatchCondition $condition `
518-
-Action Block
534+
-Action Block `
535+
-State Enabled
519536
```
520537

521-
And here is the corresponding JSON:
538+
And here's the corresponding JSON:
522539

523540
```json
524541
{
@@ -528,6 +545,7 @@ And here is the corresponding JSON:
528545
"priority": 2,
529546
"ruleType": "MatchRule",
530547
"action": "Block",
548+
"state": "Enabled",
531549
"matchConditions": [
532550
{
533551
"matchVariables": [

0 commit comments

Comments
 (0)