Skip to content

Commit d875738

Browse files
committed
Add PCRE error tests for rx operator
1 parent 6f1bd27 commit d875738

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

test/test-cases/regression/operator-rx.json

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,95 @@
127127
"SecRuleEngine On",
128128
"SecRule REQUEST_HEADERS:Content-Type \"@rx a(b\" \"id:1,phase:2,pass,t:trim,block\""
129129
]
130+
},
131+
{
132+
"enabled":1,
133+
"version_min":300000,
134+
"title":"Testing Operator :: @rx with PCRE error",
135+
"client":{
136+
"ip":"200.249.12.31",
137+
"port":123
138+
},
139+
"server":{
140+
"ip":"200.249.12.31",
141+
"port":80
142+
},
143+
"request":{
144+
"headers":{
145+
"Host":"localhost",
146+
"User-Agent":"curl/7.38.0",
147+
"Accept":"*/*",
148+
"Content-Length": "27",
149+
"Content-Type": "application/x-www-form-urlencoded"
150+
},
151+
"uri":"/?rxtest=wwwwwwwwwwwwwwwwwwwwwowwwwwwwwwww",
152+
"method":"HEAD",
153+
"body": [ ]
154+
},
155+
"response":{
156+
"headers":{
157+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
158+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
159+
"Content-Type":"text/html"
160+
},
161+
"body":[
162+
"no need."
163+
]
164+
},
165+
"expected":{
166+
"debug_log":"rx: regex error 'MATCH_LIMIT' for pattern",
167+
"error_log":"Matched \"Operator `StrEq' with parameter `1' against variable `MSC_PCRE_ERROR'"
168+
},
169+
"rules":[
170+
"SecRuleEngine On",
171+
"SecPcreMatchLimit 2",
172+
"SecRule ARGS:rxtest \"@rx (w+)+$\" \"id:1,phase:1,pass,t:trim,block\"",
173+
"SecRule MSC_PCRE_ERROR \"@streq 1\" \"id:2,phase:1,pass,t:trim,block\""
174+
]
175+
},
176+
{
177+
"enabled":1,
178+
"version_min":300000,
179+
"title":"Testing Operator :: @rx with PCRE match limits exceeded",
180+
"client":{
181+
"ip":"200.249.12.31",
182+
"port":123
183+
},
184+
"server":{
185+
"ip":"200.249.12.31",
186+
"port":80
187+
},
188+
"request":{
189+
"headers":{
190+
"Host":"localhost",
191+
"User-Agent":"curl/7.38.0",
192+
"Accept":"*/*",
193+
"Content-Length": "27",
194+
"Content-Type": "application/x-www-form-urlencoded"
195+
},
196+
"uri":"/?rxtest=wwwwwwwwwwwwwwwwwwwwwowwwwwwwwwww",
197+
"method":"HEAD",
198+
"body": [ ]
199+
},
200+
"response":{
201+
"headers":{
202+
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
203+
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
204+
"Content-Type":"text/html"
205+
},
206+
"body":[
207+
"no need."
208+
]
209+
},
210+
"expected":{
211+
"debug_log":"rx: regex error 'MATCH_LIMIT' for pattern",
212+
"error_log":"Matched \"Operator `StrEq' with parameter `1' against variable `MSC_PCRE_LIMITS_EXCEEDED'"
213+
},
214+
"rules":[
215+
"SecRuleEngine On",
216+
"SecPcreMatchLimit 2",
217+
"SecRule ARGS:rxtest \"@rx (w+)+$\" \"id:1,phase:1,pass,t:trim,block\"",
218+
"SecRule MSC_PCRE_LIMITS_EXCEEDED \"@streq 1\" \"id:2,phase:1,pass,t:trim,block\""
219+
]
130220
}
131221
]

0 commit comments

Comments
 (0)