Skip to content

Commit cb95a24

Browse files
committed
Modify tests for multipart with ProcessPartial
1 parent 0b599ad commit cb95a24

File tree

1 file changed

+60
-21
lines changed

1 file changed

+60
-21
lines changed

tests/regression/config/10-request-directives.t

Lines changed: 60 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@
997997
},
998998
{
999999
type => "config",
1000-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part across limit #2)",
1000+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #1)",
10011001
conf => qq(
10021002
SecRuleEngine On
10031003
SecDebugLog $ENV{DEBUG_LOG}
@@ -1012,7 +1012,7 @@
10121012
debug => [ qr/Input filter: Bucket type HEAP contains 116 bytes./, 1],
10131013
},
10141014
match_response => {
1015-
status => qr/^200$/,
1015+
status => qr/^403$/,
10161016
},
10171017
request => new HTTP::Request(
10181018
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1032,7 +1032,7 @@
10321032
},
10331033
{
10341034
type => "config",
1035-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/parital/bad-header in part across limit #3)",
1035+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/parital/bad-header in part before limit #2)",
10361036
conf => qq(
10371037
SecRuleEngine On
10381038
SecDebugLog $ENV{DEBUG_LOG}
@@ -1047,7 +1047,7 @@
10471047
debug => [ qr/Input filter: Bucket type HEAP contains 117 bytes./, 1],
10481048
},
10491049
match_response => {
1050-
status => qr/^200$/,
1050+
status => qr/^403$/,
10511051
},
10521052
request => new HTTP::Request(
10531053
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1067,7 +1067,7 @@
10671067
},
10681068
{
10691069
type => "config",
1070-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #1)",
1070+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #3)",
10711071
conf => qq(
10721072
SecRuleEngine On
10731073
SecDebugLog $ENV{DEBUG_LOG}
@@ -1103,7 +1103,7 @@
11031103
},
11041104
{
11051105
type => "config",
1106-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #2)",
1106+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #4)",
11071107
conf => qq(
11081108
SecRuleEngine On
11091109
SecDebugLog $ENV{DEBUG_LOG}
@@ -1139,7 +1139,7 @@
11391139
},
11401140
{
11411141
type => "config",
1142-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #3)",
1142+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/bad-header in part before limit #5)",
11431143
conf => qq(
11441144
SecRuleEngine On
11451145
SecDebugLog $ENV{DEBUG_LOG}
@@ -1190,7 +1190,7 @@
11901190
debug => [ qr/Input filter: Bucket type HEAP contains 117 bytes./, 1],
11911191
},
11921192
match_response => {
1193-
status => qr/^200$/,
1193+
status => qr/^403$/,
11941194
},
11951195
request => new HTTP::Request(
11961196
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1260,7 +1260,7 @@
12601260
debug => [ qr/Input filter: Bucket type HEAP contains 206 bytes./, 1],
12611261
},
12621262
match_response => {
1263-
status => qr/^200$/,
1263+
status => qr/^403$/,
12641264
},
12651265
request => new HTTP::Request(
12661266
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1325,7 +1325,7 @@
13251325
},
13261326
{
13271327
type => "config",
1328-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/invalid final boundary before limit #1)",
1328+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/invalid boundary before limit #1)",
13291329
conf => qq(
13301330
SecRuleEngine On
13311331
SecDebugLog $ENV{DEBUG_LOG}
@@ -1337,6 +1337,7 @@
13371337
),
13381338
match_log => {
13391339
debug => [ qr/Input filter: Bucket type HEAP contains 119 bytes./, 1],
1340+
error => [ qr/Multipart parsing error: Multipart: Invalid boundary./, 1],
13401341
},
13411342
match_response => {
13421343
status => qr/^400$/,
@@ -1353,13 +1354,13 @@
13531354
Content-Type: text/plain
13541355
13551356
value
1356-
--0000!),
1357+
--0000!)
13571358
) . "X",
13581359
),
13591360
},
13601361
{
13611362
type => "config",
1362-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/invalid final boundary before limit #2)",
1363+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/invalid boundary before limit #2)",
13631364
conf => qq(
13641365
SecRuleEngine On
13651366
SecDebugLog $ENV{DEBUG_LOG}
@@ -1371,6 +1372,42 @@
13711372
),
13721373
match_log => {
13731374
debug => [ qr/Input filter: Bucket type HEAP contains 120 bytes./, 1],
1375+
error => [ qr/Multipart parsing error: Multipart: Invalid boundary./, 1],
1376+
},
1377+
match_response => {
1378+
status => qr/^400$/,
1379+
},
1380+
request => new HTTP::Request(
1381+
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
1382+
[
1383+
"Content-Type" => "multipart/form-data; boundary=0000",
1384+
],
1385+
normalize_raw_request_data(
1386+
q(
1387+
--0000
1388+
Content-Disposition: form-data; name="name1"; filename="name1.txt"
1389+
Content-Type: text/plain
1390+
1391+
value
1392+
--0000)
1393+
) . "\r!" . "X",
1394+
),
1395+
},
1396+
{
1397+
type => "config",
1398+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/CRLF/partial/invalid final boundary before limit #1)",
1399+
conf => qq(
1400+
SecRuleEngine On
1401+
SecDebugLog $ENV{DEBUG_LOG}
1402+
SecDebugLogLevel 9
1403+
SecRequestBodyAccess On
1404+
SecRequestBodyLimitAction ProcessPartial
1405+
SecRequestBodyLimit 119
1406+
SecRule REQBODY_ERROR "!\@eq 0" "id:'200001', phase:2,t:none,log,deny,status:400,msg:'Failed to parse request body.',logdata:'%{reqbody_error_msg}',severity:2"
1407+
),
1408+
match_log => {
1409+
debug => [ qr/Input filter: Bucket type HEAP contains 120 bytes./, 1],
1410+
error => [ qr/Multipart parsing error: Multipart: Invalid final boundary./, 1],
13741411
},
13751412
match_response => {
13761413
status => qr/^400$/,
@@ -1427,7 +1464,7 @@
14271464
},
14281465
{
14291466
type => "config",
1430-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/bad-header in part across limit #2)",
1467+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/bad-header in part before limit #1)",
14311468
conf => qq(
14321469
SecRuleEngine On
14331470
SecDebugLog $ENV{DEBUG_LOG}
@@ -1442,7 +1479,7 @@
14421479
debug => [ qr/Input filter: Bucket type HEAP contains 111 bytes./, 1],
14431480
},
14441481
match_response => {
1445-
status => qr/^200$/,
1482+
status => qr/^403$/,
14461483
},
14471484
request => new HTTP::Request(
14481485
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1461,7 +1498,7 @@
14611498
},
14621499
{
14631500
type => "config",
1464-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #1)",
1501+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #2)",
14651502
conf => qq(
14661503
SecRuleEngine On
14671504
SecDebugLog $ENV{DEBUG_LOG}
@@ -1495,7 +1532,7 @@
14951532
},
14961533
{
14971534
type => "config",
1498-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #2)",
1535+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #3)",
14991536
conf => qq(
15001537
SecRuleEngine On
15011538
SecDebugLog $ENV{DEBUG_LOG}
@@ -1530,7 +1567,7 @@
15301567
},
15311568
{
15321569
type => "config",
1533-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #3)",
1570+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/parital/bad-header in part before limit #4)",
15341571
conf => qq(
15351572
SecRuleEngine On
15361573
SecDebugLog $ENV{DEBUG_LOG}
@@ -1580,7 +1617,7 @@
15801617
debug => [ qr/Input filter: Bucket type HEAP contains 112 bytes./, 1],
15811618
},
15821619
match_response => {
1583-
status => qr/^200$/,
1620+
status => qr/^403$/,
15841621
},
15851622
request => new HTTP::Request(
15861623
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1648,7 +1685,7 @@
16481685
debug => [ qr/Input filter: Bucket type HEAP contains 196 bytes./, 1],
16491686
},
16501687
match_response => {
1651-
status => qr/^200$/,
1688+
status => qr/^403$/,
16521689
},
16531690
request => new HTTP::Request(
16541691
POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
@@ -1711,7 +1748,7 @@
17111748
},
17121749
{
17131750
type => "config",
1714-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/invalid final boundary before limit #1)",
1751+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/invalid boundary before limit #1)",
17151752
conf => qq(
17161753
SecRuleEngine On
17171754
SecDebugLog $ENV{DEBUG_LOG}
@@ -1723,6 +1760,7 @@
17231760
),
17241761
match_log => {
17251762
debug => [ qr/Input filter: Bucket type HEAP contains 114 bytes./, 1],
1763+
error => [ qr/Multipart parsing error: Multipart: Invalid boundary./, 1],
17261764
},
17271765
match_response => {
17281766
status => qr/^400$/,
@@ -1744,7 +1782,7 @@
17441782
},
17451783
{
17461784
type => "config",
1747-
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/invalid final boundary before limit #2)",
1785+
comment => "SecRequestBodyLimitAction ProcessPartial (multipart/LF/partial/invalid final boundary before limit #1)",
17481786
conf => qq(
17491787
SecRuleEngine On
17501788
SecDebugLog $ENV{DEBUG_LOG}
@@ -1756,6 +1794,7 @@
17561794
),
17571795
match_log => {
17581796
debug => [ qr/Input filter: Bucket type HEAP contains 115 bytes./, 1],
1797+
error => [ qr/Multipart parsing error: Multipart: Invalid final boundary./, 1],
17591798
},
17601799
match_response => {
17611800
status => qr/^400$/,

0 commit comments

Comments
 (0)