| 1 |
############################### |
| 2 |
# test web acl |
| 3 |
############################### |
| 4 |
- name: get web acl |
| 5 |
wafv2_web_acl_info: |
| 6 |
name: "{{ web_acl_name }}" |
| 7 |
scope: REGIONAL |
| 8 |
register: out |
| 9 |
|
| 10 |
- name: verify rules |
| 11 |
assert: |
| 12 |
that: |
| 13 |
- out.rules | count == 3 |
| 14 |
|
| 15 |
- name: change web acl description |
| 16 |
wafv2_web_acl: |
| 17 |
name: "{{ web_acl_name }}" |
| 18 |
state: present |
| 19 |
description: hallo eins drei |
| 20 |
scope: REGIONAL |
| 21 |
default_action: Allow |
| 22 |
sampled_requests: no |
| 23 |
cloudwatch_metrics: yes |
| 24 |
metric_name: blub |
| 25 |
rules: |
| 26 |
- name: zwei |
| 27 |
priority: 2 |
| 28 |
action: |
| 29 |
block: {} |
| 30 |
visibility_config: |
| 31 |
sampled_requests_enabled: yes |
| 32 |
cloud_watch_metrics_enabled: yes |
| 33 |
metric_name: ddos |
| 34 |
statement: |
| 35 |
xss_match_statement: |
| 36 |
field_to_match: |
| 37 |
body: {} |
| 38 |
text_transformations: |
| 39 |
- type: NONE |
| 40 |
priority: 0 |
| 41 |
- name: admin_protect |
| 42 |
priority: 1 |
| 43 |
override_action: |
| 44 |
none: {} |
| 45 |
visibility_config: |
| 46 |
sampled_requests_enabled: yes |
| 47 |
cloud_watch_metrics_enabled: yes |
| 48 |
metric_name: fsd |
| 49 |
statement: |
| 50 |
managed_rule_group_statement: |
| 51 |
vendor_name: AWS |
| 52 |
name: AWSManagedRulesAdminProtectionRuleSet |
| 53 |
tags: |
| 54 |
A: B |
| 55 |
C: D |
| 56 |
register: out |
| 57 |
|
| 58 |
- name: verify change |
| 59 |
assert: |
| 60 |
that: |
| 61 |
- out is changed |
| 62 |
|
| 63 |
|
| 64 |
- name: add 1 rules |
| 65 |
wafv2_web_acl: |
| 66 |
name: "{{ web_acl_name }}" |
| 67 |
state: present |
| 68 |
description: hallo eins drei |
| 69 |
scope: REGIONAL |
| 70 |
default_action: Allow |
| 71 |
sampled_requests: no |
| 72 |
cloudwatch_metrics: yes |
| 73 |
metric_name: blub |
| 74 |
purge_rules: no |
| 75 |
rules: |
| 76 |
- name: bla |
| 77 |
priority: 8 |
| 78 |
override_action: |
| 79 |
none: {} |
| 80 |
visibility_config: |
| 81 |
sampled_requests_enabled: yes |
| 82 |
cloud_watch_metrics_enabled: yes |
| 83 |
metric_name: fsd |
| 84 |
statement: |
| 85 |
managed_rule_group_statement: |
| 86 |
vendor_name: AWS |
| 87 |
name: AWSManagedRulesAdminProtectionRuleSet |
| 88 |
tags: |
| 89 |
A: B |
| 90 |
C: D |
| 91 |
register: out |
| 92 |
|
| 93 |
- name: verify change |
| 94 |
assert: |
| 95 |
that: |
| 96 |
- out is changed |
| 97 |
|
| 98 |
- name: get web acl |
| 99 |
wafv2_web_acl_info: |
| 100 |
name: "{{ web_acl_name }}" |
| 101 |
scope: REGIONAL |
| 102 |
register: out |
| 103 |
|
| 104 |
- name: verify rules |
| 105 |
assert: |
| 106 |
that: |
| 107 |
- out.rules | count == 3 |
| 108 |
|
| 109 |
- name: reduce rules to 1 |
| 110 |
wafv2_web_acl: |
| 111 |
name: "{{ web_acl_name }}" |
| 112 |
state: present |
| 113 |
description: hallo eins drei |
| 114 |
scope: REGIONAL |
| 115 |
default_action: Allow |
| 116 |
sampled_requests: no |
| 117 |
cloudwatch_metrics: yes |
| 118 |
metric_name: blub |
| 119 |
purge_rules: yes |
| 120 |
rules: |
| 121 |
- name: admin_protect |
| 122 |
priority: 1 |
| 123 |
override_action: |
| 124 |
none: {} |
| 125 |
visibility_config: |
| 126 |
sampled_requests_enabled: yes |
| 127 |
cloud_watch_metrics_enabled: yes |
| 128 |
metric_name: admin_protect |
| 129 |
statement: |
| 130 |
managed_rule_group_statement: |
| 131 |
vendor_name: AWS |
| 132 |
name: AWSManagedRulesAdminProtectionRuleSet |
| 133 |
tags: |
| 134 |
A: B |
| 135 |
C: D |
| 136 |
register: out |
| 137 |
|
| 138 |
- name: verify change |
| 139 |
assert: |
| 140 |
that: |
| 141 |
- out is changed |
| 142 |
|
| 143 |
- name: get web acl |
| 144 |
wafv2_web_acl_info: |
| 145 |
name: "{{ web_acl_name }}" |
| 146 |
scope: REGIONAL |
| 147 |
register: out |
| 148 |
|
| 149 |
- name: verify rules |
| 150 |
assert: |
| 151 |
that: |
| 152 |
- out.rules | count == 1 |
| 153 |
|
| 154 |
- name: immutable change web acl |
| 155 |
wafv2_web_acl: |
| 156 |
name: "{{ web_acl_name }}" |
| 157 |
state: present |
| 158 |
description: hallo eins drei |
| 159 |
scope: REGIONAL |
| 160 |
default_action: Allow |
| 161 |
sampled_requests: no |
| 162 |
cloudwatch_metrics: yes |
| 163 |
metric_name: blub |
| 164 |
rules: |
| 165 |
- name: admin_protect |
| 166 |
priority: 1 |
| 167 |
override_action: |
| 168 |
none: {} |
| 169 |
visibility_config: |
| 170 |
sampled_requests_enabled: yes |
| 171 |
cloud_watch_metrics_enabled: yes |
| 172 |
metric_name: admin_protect |
| 173 |
statement: |
| 174 |
managed_rule_group_statement: |
| 175 |
vendor_name: AWS |
| 176 |
name: AWSManagedRulesAdminProtectionRuleSet |
| 177 |
tags: |
| 178 |
A: B |
| 179 |
C: D |
| 180 |
register: out |
| 181 |
|
| 182 |
- name: verify no change |
| 183 |
assert: |
| 184 |
that: |
| 185 |
- out is not changed |
| 186 |
|
| 187 |
- name: test geo match statement |
| 188 |
wafv2_web_acl: |
| 189 |
name: "{{ web_acl_name }}" |
| 190 |
state: present |
| 191 |
description: hallo eins drei |
| 192 |
scope: REGIONAL |
| 193 |
default_action: Allow |
| 194 |
sampled_requests: no |
| 195 |
cloudwatch_metrics: yes |
| 196 |
metric_name: blub |
| 197 |
purge_rules: yes |
| 198 |
rules: |
| 199 |
- name: block-germany |
| 200 |
priority: 1 |
| 201 |
action: |
| 202 |
block: {} |
| 203 |
visibility_config: |
| 204 |
sampled_requests_enabled: yes |
| 205 |
cloud_watch_metrics_enabled: yes |
| 206 |
metric_name: block-germany |
| 207 |
statement: |
| 208 |
geo_match_statement: |
| 209 |
country_codes: |
| 210 |
- DE |
| 211 |
tags: |
| 212 |
A: B |
| 213 |
C: D |
| 214 |
register: out |
| 215 |
|
| 216 |
- name: verify change |
| 217 |
assert: |
| 218 |
that: |
| 219 |
- out is changed |
| 220 |
|
| 221 |
- name: re-read webacl |
| 222 |
wafv2_web_acl_info: |
| 223 |
name: "{{ web_acl_name }}" |
| 224 |
scope: REGIONAL |
| 225 |
register: out |
| 226 |
|
| 227 |
- name: verify geo match statement |
| 228 |
assert: |
| 229 |
that: |
| 230 |
- out.rules[0].statement.geo_match_statement.country_codes[0] == 'DE' |