Skip to content

Commit 06b1361

Browse files
committed
fixup! Fix: WAF alarm tripped by BlockedIPs and BlockedUserAgents rules (#7205)
1 parent cea4b9c commit 06b1361

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

src/azul/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,10 @@ def docker_image_gists_path(self) -> Path:
17721772

17731773
blocked_user_agents_custom_regex_term = 'blocked_user_agents_custom'
17741774

1775-
waf_block_rules_not_logged = [
1775+
#: The names of WAF rules whose matching requests will not be logged in the
1776+
#: WAF log group, nor trip the `waf_blocked` Cloudwatch alarm.
1777+
#:
1778+
waf_rules_not_logged = [
17761779
blocked_v4_ips_term,
17771780
blocked_user_agents_regex_term
17781781
]

terraform/api_gateway.tf.json.template.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
158158
for rule in resources['aws_wafv2_web_acl']['api_gateway']['rule']
159159
if (
160160
('block' in rule.get('action', {}) or 'none' in rule.get('override_action', {}))
161-
and rule['name'] not in config.waf_block_rules_not_logged
161+
and rule['name'] not in config.waf_rules_not_logged
162162
)
163163
]
164164
metrics = [
@@ -350,9 +350,10 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
350350
'action': {
351351
action: {}
352352
},
353-
# We add a label to requests blocked by IP
354-
# to prevent these requests from being
355-
# logged or tripping WAF alarms.
353+
# We add a label to these requests to give
354+
# us the option to exclude them from being
355+
# logged in the WAF log group. See
356+
# aws_wafv2_web_acl_logging_configuration
356357
'rule_label': {
357358
'name': name
358359
},
@@ -396,9 +397,10 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
396397
'action': {
397398
'block': {}
398399
},
399-
# We add a label to requests blocked by user
400-
# agent to prevent these requests from being
401-
# logged or tripping WAF alarms.
400+
# We add a label to these requests to give us
401+
# the option to exclude them from being logged
402+
# in the WAF log group. See
403+
# aws_wafv2_web_acl_logging_configuration
402404
'rule_label': {
403405
'name': config.blocked_user_agents_regex_term
404406
},
@@ -666,7 +668,7 @@ def add_waf_blocked_alarm(resources: JSON) -> JSON:
666668
term
667669
)
668670
}
669-
} for term in config.waf_block_rules_not_logged
671+
} for term in config.waf_rules_not_logged
670672
]
671673
]
672674
]

0 commit comments

Comments
 (0)