Skip to content

Commit 8beedfd

Browse files
committed
Add Terraform example for malicious uploads
1 parent fc258a8 commit 8beedfd

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

src/content/docs/terraform/additional-configurations/waf-custom-rules.mdx

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,15 @@ head:
88
content: Configure WAF custom rules with Terraform
99
---
1010

11-
import { Render } from "~/components";
11+
import { Render, GlossaryTooltip } from "~/components";
1212

1313
This page provides examples of creating WAF custom rules in a zone or account using Terraform. The examples cover the following scenarios:
1414

1515
- Zone-level configurations:
16-
1716
- [Add a custom rule to a zone](#add-a-custom-rule-to-a-zone)
1817
- [Add a custom rule challenging requests with leaked credentials](#add-a-custom-rule-challenging-requests-with-leaked-credentials)
19-
18+
- [Add a custom rule blocking malicious uploads](#add-a-custom-rule-blocking-malicious-uploads)
2019
- Account-level configurations:
21-
2220
- [Create and deploy a custom ruleset](#create-and-deploy-a-custom-ruleset)
2321
- [Add a custom rule checking for exposed credentials](#add-a-custom-rule-checking-for-exposed-credentials)
2422

@@ -88,6 +86,33 @@ resource "cloudflare_ruleset" "zone_custom_firewall_leaked_creds" {
8886

8987
For more information on configuring custom detection locations, refer to the [Terraform example](/waf/detections/leaked-credentials/get-started/#4-optional-configure-a-custom-detection-location) in the WAF documentation.
9088

89+
### Add a custom rule blocking malicious uploads
90+
91+
:::note
92+
For more information on enabling malicious uploads detection using Terraform, refer to the [malicious uploads detection](/waf/detections/malicious-uploads/get-started/#1-turn-on-the-detection) documentation.
93+
:::
94+
95+
This example adds a custom rule that blocks requests with one or more <GlossaryTooltip term="content object">content objects</GlossaryTooltip> considered malicious by using one of the [content scanning fields](/waf/detections/malicious-uploads/#content-scanning-fields) in the rule expression.
96+
97+
```tf
98+
resource "cloudflare_ruleset" "zone_custom_firewall_malicious_uploads" {
99+
zone_id = "<ZONE_ID>"
100+
name = "Phase entry point ruleset for custom rules in my zone"
101+
description = ""
102+
kind = "zone"
103+
phase = "http_request_firewall_custom"
104+
105+
rules {
106+
ref = "block_malicious_uploads"
107+
description = "Block requests uploading malicious content objects"
108+
expression = "(cf.waf.content_scan.has_malicious_obj and http.request.uri.path eq \"/upload.php\")"
109+
action = "block"
110+
}
111+
}
112+
```
113+
114+
For more information on configuring custom scan expressions, refer to the [Terraform example](/waf/detections/malicious-uploads/get-started/#4-optional-configure-a-custom-scan-expression) in the WAF documentation.
115+
91116
## Account-level configurations
92117

93118
### Create and deploy a custom ruleset

0 commit comments

Comments
 (0)