Skip to content

Commit 5a5a5f0

Browse files
authored
DS-3492 Release issue fix for waf rules (#1046)
# Task Branch Pull Request **<https://nhsd-jira.digital.nhs.uk/browse/DS-3492>** ## Description of Changes Sorting priority order of WAF rules for AWS managed and custom rules. ## Type of change - Security enhancements(Monitoring of SQL injections) ## Development Checklist - [x] I have performed a self-review of my own code - [x] Tests have added that prove my fix is effective or that my feature works (Integration tests) - [x] I have updated Dependabot to include my changes (if applicable) ## Code Reviewer Checklist - [x] I can confirm the changes have been tested or approved by a tester
1 parent 1e65fa9 commit 5a5a5f0

1 file changed

Lines changed: 43 additions & 43 deletions

File tree

  • infrastructure/stacks/shared-resources

infrastructure/stacks/shared-resources/waf.tf

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,39 +61,29 @@ resource "aws_wafv2_web_acl" "di_endpoint_waf" {
6161
}
6262

6363
rule {
64-
name = var.waf_aws_common_rule_name
64+
name = var.waf_custom_sqli_rule_name
6565
priority = 3
6666

67-
override_action {
68-
none {}
67+
action {
68+
count {}
6969
}
70-
statement {
71-
managed_rule_group_statement {
72-
name = "AWSManagedRulesCommonRuleSet"
73-
vendor_name = "AWS"
74-
75-
rule_action_override {
76-
action_to_use {
77-
count {}
78-
}
7970

80-
name = "NoUserAgent_HEADER"
71+
statement {
72+
sqli_match_statement {
73+
field_to_match {
74+
body {}
8175
}
82-
83-
rule_action_override {
84-
action_to_use {
85-
count {}
86-
}
87-
88-
name = "SizeRestrictions_BODY"
76+
sensitivity_level = "HIGH"
77+
text_transformation {
78+
priority = 0
79+
type = "NONE"
8980
}
9081
}
9182
}
92-
9383
visibility_config {
84+
sampled_requests_enabled = true
85+
metric_name = var.waf_custom_sqli_rule_name
9486
cloudwatch_metrics_enabled = true
95-
metric_name = var.waf_aws_common_rule_name
96-
sampled_requests_enabled = true
9787
}
9888
}
9989

@@ -165,50 +155,60 @@ resource "aws_wafv2_web_acl" "di_endpoint_waf" {
165155
}
166156

167157
rule {
168-
name = var.waf_custom_sqli_rule_name
169-
priority = 8
158+
name = var.waf_ip_reputation_list_rule_name
159+
priority = 7
170160

171-
action {
172-
count {}
161+
override_action {
162+
none {}
173163
}
174164

175165
statement {
176-
sqli_match_statement {
177-
field_to_match {
178-
body {}
179-
}
180-
sensitivity_level = "HIGH"
181-
text_transformation {
182-
priority = 0
183-
type = "NONE"
184-
}
166+
managed_rule_group_statement {
167+
name = "AWSManagedRulesAmazonIpReputationList"
168+
vendor_name = "AWS"
185169
}
186170
}
171+
187172
visibility_config {
188-
sampled_requests_enabled = true
189-
metric_name = var.waf_custom_sqli_rule_name
190173
cloudwatch_metrics_enabled = true
174+
metric_name = var.waf_ip_reputation_list_rule_name
175+
sampled_requests_enabled = true
191176
}
192177
}
193178

194179
rule {
195-
name = var.waf_ip_reputation_list_rule_name
196-
priority = 7
180+
name = var.waf_aws_common_rule_name
181+
priority = 8
197182

198183
override_action {
199184
none {}
200185
}
201-
202186
statement {
203187
managed_rule_group_statement {
204-
name = "AWSManagedRulesAmazonIpReputationList"
188+
name = "AWSManagedRulesCommonRuleSet"
205189
vendor_name = "AWS"
190+
191+
rule_action_override {
192+
action_to_use {
193+
count {}
194+
}
195+
196+
name = "NoUserAgent_HEADER"
197+
}
198+
199+
rule_action_override {
200+
action_to_use {
201+
count {}
202+
}
203+
204+
name = "SizeRestrictions_BODY"
205+
}
206206
}
207207
}
208208

209209
visibility_config {
210210
cloudwatch_metrics_enabled = true
211-
metric_name = var.waf_ip_reputation_list_rule_name
211+
metric_name = var.waf_aws_common_rule_name
212212
sampled_requests_enabled = true
213213
}
214214
}

0 commit comments

Comments
 (0)