File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 8484 Limit : 1000
8585` ` `
8686
87- ### IPSets
87+ ### IP Sets
8888
8989to create static ip white and black lists use the following config:
9090
@@ -115,4 +115,38 @@ rules:
115115 Arn:
116116 # reference the ipset name in your config
117117 Fn::GetAtt: ['Whitelist', 'Arn']
118+ ` ` `
119+
120+ # ## Regex Pattern Sets
121+
122+ create the RegexPatternSet with an optional description specifying a list of regexes
123+
124+ ` ` ` yaml
125+ pattern_sets:
126+ MyPattern:
127+ desc: test pattern
128+ regexes:
129+ - '^[\w\- ]+$'
130+ ` ` `
131+
132+ create a rule using the RegexPatternSet
133+
134+ ` ` ` yaml
135+ rules:
136+ Regex:
137+ priority: 10
138+ action:
139+ Allow: {}
140+ statement:
141+ RegexPatternSetReferenceStatement:
142+ Arn:
143+ # reference the pattern set name in your config
144+ Fn::GetAtt: ['MyPattern', 'Arn']
145+ # set the field amd transform properities acording to
146+ # https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-wafv2-webacl-fieldtomatch.html
147+ FieldToMatch:
148+ AllQueryArguments: {}
149+ TextTransformations:
150+ - Priority: 1
151+ Type: NONE
118152` ` `
Original file line number Diff line number Diff line change @@ -4,10 +4,14 @@ test_metadata:
44 description : IP white and black lists
55
66ipsets :
7- Whitelist :
7+ WhitelistOne :
88 desc : ips to whitelist for my waf
99 addresses :
1010 - 127.0.0.1/32
11+ WhitelistTwo :
12+ desc : ips to whitelist for my waf
13+ addresses :
14+ - 169.168.0.1/32
1115
1216rules :
1317 IPWhitelistRule :
1923 Statements :
2024 - IPSetReferenceStatement :
2125 Arn :
22- Fn::GetAtt : ['Whitelist', 'Arn']
26+ Fn::GetAtt : ['WhitelistOne', 'Arn']
27+ - IPSetReferenceStatement :
28+ Arn :
29+ Fn::GetAtt : ['WhitelistTwo', 'Arn']
Original file line number Diff line number Diff line change 1+ test_metadata :
2+ type : config
3+ name : pattern_sets
4+ description : regular expression pattern set rules
5+
6+ pattern_sets :
7+ MyPattern :
8+ desc : test pattern
9+ regexes :
10+ - ' ^[\w\-]+$'
11+
12+ rules :
13+ Regex :
14+ priority : 10
15+ action :
16+ Allow : {}
17+ statement :
18+ RegexPatternSetReferenceStatement :
19+ Arn :
20+ Fn::GetAtt : ['MyPattern', 'Arn']
21+ FieldToMatch :
22+ AllQueryArguments : {}
23+ TextTransformations :
24+ - Priority : 1
25+ Type : NONE
Original file line number Diff line number Diff line change 66 extra_tags = external_parameters . fetch ( :extra_tags , { } )
77 extra_tags . each { |key , value | tags << { Key : FnSub ( key ) , Value : FnSub ( value ) } }
88
9+ ipsets = external_parameters . fetch ( :ipsets , [ ] )
910 ipsets . each do |name , properties |
1011 WAFv2_IPSet ( name ) {
1112 Name FnSub ( "${EnvironmentName}-#{ name } " )
1718 }
1819 end
1920
21+ pattern_sets = external_parameters . fetch ( :pattern_sets , [ ] )
22+ pattern_sets . each do |name , properties |
23+ WAFv2_RegexPatternSet ( name ) {
24+ Description properties [ 'desc' ] if properties . has_key? ( 'desc' )
25+ Name FnSub ( "${EnvironmentName}-#{ name } " )
26+ RegularExpressionList properties [ 'regexes' ]
27+ Scope Ref ( :Scope )
28+ Tags tags
29+ }
30+ end
31+
2032 waf_rules = [ ]
2133 rules = external_parameters . fetch ( :rules , { } )
2234 # Loop over each rule in the confic and either override the default or add a new rule
You can’t perform that action at this time.
0 commit comments