-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcfWAF.tf
111 lines (98 loc) · 2.77 KB
/
cfWAF.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# OWASP
## Adjusting OWASP package
### Generate data object for package_id variable
data "cloudflare_waf_packages" "owaspPackage" {
zone_id = var.cloudflare_zone_id
filter {
name = "OWASP ModSecurity Core Rule Set"
}
}
resource "cloudflare_waf_package" "owasp" {
package_id = data.cloudflare_waf_packages.owaspPackage.packages.0.id
zone_id = var.cloudflare_zone_id
sensitivity = "medium"
action_mode = "simulate"
}
## Adjusting OWASP rule groups (sets)
### Generating data object for group_id variable
data "cloudflare_waf_groups" "owaspBadRobot" {
zone_id = var.cloudflare_zone_id
filter {
name = "OWASP Bad Robots"
}
}
### Turns OWASP rule group OWASP Bad Robot to On
resource "cloudflare_waf_group" "owaspBadRobot" {
group_id = data.cloudflare_waf_groups.owaspBadRobot.groups.0.id
zone_id = var.cloudflare_zone_id
mode = "on"
}
data "cloudflare_waf_groups" "owaspURIXSS" {
zone_id = var.cloudflare_zone_id
filter {
name = "OWASP Uri XSS Attacks"
}
}
resource "cloudflare_waf_group" "owaspURIXSS" {
group_id = data.cloudflare_waf_groups.owaspURIXSS.groups.0.id
zone_id = var.cloudflare_zone_id
mode = "on"
}
## Adjusting individual rule behavior
resource "cloudflare_waf_rule" "waf_rule_100000356" {
rule_id = "100000356"
zone_id = var.cloudflare_zone_id
mode = "off"
}
resource "cloudflare_waf_rule" "waf_rule_URI-958000" {
rule_id = "URI-958000"
zone_id = var.cloudflare_zone_id
mode = "off"
}
# Cloudflare Managed Rulesets
### Data object for group_id variable
data "cloudflare_waf_groups" "drupal" {
zone_id = var.cloudflare_zone_id
filter {
name = "Cloudflare Drupal"
}
}
### Adjusts Cloudflare Drupal rule group to Off
resource "cloudflare_waf_group" "drupal" {
group_id = data.cloudflare_waf_groups.drupal.groups.0.id
zone_id = var.cloudflare_zone_id
mode = "off"
}
data "cloudflare_waf_groups" "flash" {
zone_id = var.cloudflare_zone_id
filter {
name = "Cloudflare Flash"
}
}
resource "cloudflare_waf_group" "flash" {
group_id = data.cloudflare_waf_groups.flash.groups.0.id
zone_id = var.cloudflare_zone_id
mode = "off"
}
data "cloudflare_waf_groups" "misc" {
zone_id = var.cloudflare_zone_id
filter {
name = "Cloudflare Miscellaneous"
}
}
resource "cloudflare_waf_group" "misc" {
group_id = data.cloudflare_waf_groups.misc.groups.0.id
zone_id = var.cloudflare_zone_id
mode = "on"
}
## Adjusting individual rule behavior
resource "cloudflare_waf_rule" "waf_rule_100000" {
rule_id = "100000"
zone_id = var.cloudflare_zone_id
mode = "simulate"
}
resource "cloudflare_waf_rule" "waf_rule_100015" {
rule_id = "100015"
zone_id = var.cloudflare_zone_id
mode = "challenge"
}