Skip to content

Commit 1634a2a

Browse files
committed
Add more XML tests, leaf or no-leaf, ARGS
1 parent ad94186 commit 1634a2a

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

tests/regression/config/10-reqbody-limit-action-xml.t

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,95 @@
201201
'<root><a>' . '1' x 16355 . 'bad_value</a></root>',
202202
),
203203
},
204+
{
205+
type => "config",
206+
comment => "SecRequestBodyLimitAction ProcessPartial (XML, non-leaf, <=NoFilesLimit, deny)",
207+
conf => qq(
208+
SecRuleEngine On
209+
SecDebugLog $ENV{DEBUG_LOG}
210+
SecDebugLogLevel 9
211+
SecRequestBodyAccess On
212+
SecRequestBodyLimitAction ProcessPartial
213+
SecRequestBodyNoFilesLimit 16384
214+
SecRequestBodyLimit 32768
215+
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\\+|/)|text/)xml" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
216+
SecRule XML:/* "bad_value" "id:'200002',phase:2,t:none,deny"
217+
),
218+
match_log => {
219+
-error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ],
220+
},
221+
match_response => {
222+
status => qr/^403$/,
223+
},
224+
request => new HTTP::Request(
225+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
226+
[
227+
"Content-Type" => "application/xml",
228+
"Content-Length" => "16384",
229+
],
230+
'<root><a>' . '1' x 16351 . 'bad_value<b/></a></root>',
231+
),
232+
},
233+
{
234+
type => "config",
235+
comment => "SecRequestBodyLimitAction ProcessPartial (XML, ARGS, non-leaf, <=NoFilesLimit, pass)",
236+
conf => qq(
237+
SecRuleEngine On
238+
SecDebugLog $ENV{DEBUG_LOG}
239+
SecDebugLogLevel 9
240+
SecRequestBodyAccess On
241+
SecParseXmlIntoArgs On
242+
SecRequestBodyLimitAction ProcessPartial
243+
SecRequestBodyNoFilesLimit 16384
244+
SecRequestBodyLimit 32768
245+
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\\+|/)|text/)xml" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
246+
SecRule ARGS "bad_value" "id:'200002',phase:2,t:none,deny"
247+
),
248+
match_log => {
249+
-error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ],
250+
},
251+
match_response => {
252+
status => qr/^200$/,
253+
},
254+
request => new HTTP::Request(
255+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
256+
[
257+
"Content-Type" => "application/xml",
258+
"Content-Length" => "16384",
259+
],
260+
'<root><a>' . '1' x 16351 . 'bad_value<b/></a></root>',
261+
),
262+
},
263+
{
264+
type => "config",
265+
comment => "SecRequestBodyLimitAction ProcessPartial (XML, ARGS, leaf, <=NoFilesLimit, deny)",
266+
conf => qq(
267+
SecRuleEngine On
268+
SecDebugLog $ENV{DEBUG_LOG}
269+
SecDebugLogLevel 9
270+
SecRequestBodyAccess On
271+
SecParseXmlIntoArgs On
272+
SecRequestBodyLimitAction ProcessPartial
273+
SecRequestBodyNoFilesLimit 16384
274+
SecRequestBodyLimit 32768
275+
SecRule REQUEST_HEADERS:Content-Type "(?:application(?:/soap\\+|/)|text/)xml" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=XML"
276+
SecRule ARGS "bad_value" "id:'200002',phase:2,t:none,deny"
277+
),
278+
match_log => {
279+
-error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ],
280+
},
281+
match_response => {
282+
status => qr/^403$/,
283+
},
284+
request => new HTTP::Request(
285+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
286+
[
287+
"Content-Type" => "application/xml",
288+
"Content-Length" => "16384",
289+
],
290+
'<root><a>' . '1' x 16355 . 'bad_value</a></root>',
291+
),
292+
},
204293
{
205294
type => "config",
206295
comment => "SecRequestBodyLimitAction ProcessPartial (XML, >NoFilesLimit, no bad)",

0 commit comments

Comments
 (0)