|
| 1 | +{ |
| 2 | + type => "config", |
| 3 | + comment => "SecRequestBodyLimitAction Reject (JSON, <=NoFilesLimit)", |
| 4 | + conf => qq( |
| 5 | + SecRuleEngine On |
| 6 | + SecDebugLog $ENV{DEBUG_LOG} |
| 7 | + SecDebugLogLevel 9 |
| 8 | + SecRequestBodyAccess On |
| 9 | + SecRequestBodyLimitAction Reject |
| 10 | + SecRequestBodyNoFilesLimit 16384 |
| 11 | + SecRequestBodyLimit 32768 |
| 12 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 13 | + ), |
| 14 | + match_log => { |
| 15 | + -error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ], |
| 16 | + }, |
| 17 | + match_response => { |
| 18 | + status => qr/^200$/, |
| 19 | + }, |
| 20 | + request => new HTTP::Request( |
| 21 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 22 | + [ |
| 23 | + "Content-Type" => "application/json", |
| 24 | + "Content-Length" => "16384", |
| 25 | + ], |
| 26 | + '{"a":"' . "1" x 16376 . '"}', |
| 27 | + ), |
| 28 | +}, |
| 29 | +{ |
| 30 | + type => "config", |
| 31 | + comment => "SecRequestBodyLimitAction Reject (JSON, >NoFilesLimit)", |
| 32 | + conf => qq( |
| 33 | + SecRuleEngine On |
| 34 | + SecDebugLog $ENV{DEBUG_LOG} |
| 35 | + SecDebugLogLevel 9 |
| 36 | + SecRequestBodyAccess On |
| 37 | + SecRequestBodyLimitAction Reject |
| 38 | + SecRequestBodyNoFilesLimit 16384 |
| 39 | + SecRequestBodyLimit 32768 |
| 40 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 41 | + ), |
| 42 | + match_log => { |
| 43 | + error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ], |
| 44 | + }, |
| 45 | + match_response => { |
| 46 | + status => qr/^413$/, |
| 47 | + }, |
| 48 | + request => new HTTP::Request( |
| 49 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 50 | + [ |
| 51 | + "Content-Type" => "application/json", |
| 52 | + "Content-Length" => "16385", |
| 53 | + ], |
| 54 | + '{"a":"' . "1" x 16377 . '"}', |
| 55 | + ), |
| 56 | +}, |
| 57 | +{ |
| 58 | + type => "config", |
| 59 | + comment => "SecRequestBodyLimitAction Reject (JSON, >Limit, <=NoFilesLimit)", |
| 60 | + conf => qq( |
| 61 | + SecRuleEngine On |
| 62 | + SecDebugLog $ENV{DEBUG_LOG} |
| 63 | + SecDebugLogLevel 9 |
| 64 | + SecRequestBodyAccess On |
| 65 | + SecRequestBodyLimitAction Reject |
| 66 | + SecRequestBodyNoFilesLimit 32768 |
| 67 | + SecRequestBodyLimit 16384 |
| 68 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 69 | + ), |
| 70 | + match_log => { |
| 71 | + error => [ qr/Request body \(Content-Length\) is larger than the configured limit \(16384\)\./, 1 ], |
| 72 | + }, |
| 73 | + match_response => { |
| 74 | + status => qr/^413$/, |
| 75 | + }, |
| 76 | + request => new HTTP::Request( |
| 77 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 78 | + [ |
| 79 | + "Content-Type" => "application/json", |
| 80 | + "Content-Length" => "16385", |
| 81 | + ], |
| 82 | + '{"a":"' . "1" x 16377 . '"}', |
| 83 | + ), |
| 84 | +}, |
| 85 | +{ |
| 86 | + type => "config", |
| 87 | + comment => "SecRequestBodyLimitAction Reject (JSON, >Limit, >NoFilesLimit)", |
| 88 | + conf => qq( |
| 89 | + SecRuleEngine On |
| 90 | + SecDebugLog $ENV{DEBUG_LOG} |
| 91 | + SecDebugLogLevel 9 |
| 92 | + SecRequestBodyAccess On |
| 93 | + SecRequestBodyLimitAction Reject |
| 94 | + SecRequestBodyNoFilesLimit 16384 |
| 95 | + SecRequestBodyLimit 32768 |
| 96 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 97 | + ), |
| 98 | + match_log => { |
| 99 | + error => [ qr/Request body \(Content-Length\) is larger than the configured limit \(32768\)\./, 1 ], |
| 100 | + }, |
| 101 | + match_response => { |
| 102 | + status => qr/^413$/, |
| 103 | + }, |
| 104 | + request => new HTTP::Request( |
| 105 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 106 | + [ |
| 107 | + "Content-Type" => "application/json", |
| 108 | + "Content-Length" => "32769", |
| 109 | + ], |
| 110 | + '{"a":"' . "1" x 32761 . '"}', |
| 111 | + ), |
| 112 | +}, |
| 113 | +{ |
| 114 | + type => "config", |
| 115 | + comment => "SecRequestBodyLimitAction ProcessPartial (JSON, >NoFilesLimit)", |
| 116 | + conf => qq( |
| 117 | + SecRuleEngine On |
| 118 | + SecDebugLog $ENV{DEBUG_LOG} |
| 119 | + SecDebugLogLevel 9 |
| 120 | + SecRequestBodyAccess On |
| 121 | + SecRequestBodyLimitAction ProcessPartial |
| 122 | + SecRequestBodyNoFilesLimit 16384 |
| 123 | + SecRequestBodyLimit 32768 |
| 124 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 125 | + ), |
| 126 | + match_log => { |
| 127 | + error => [ qr/Request body no files data length is larger than the configured limit \(16384\)\./, 1 ], |
| 128 | + }, |
| 129 | + match_response => { |
| 130 | + status => qr/^200$/, |
| 131 | + }, |
| 132 | + request => new HTTP::Request( |
| 133 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 134 | + [ |
| 135 | + "Content-Type" => "application/json", |
| 136 | + "Content-Length" => "16385", |
| 137 | + ], |
| 138 | + '{"a":"' . "1" x 16377 . '"}', |
| 139 | + ), |
| 140 | +}, |
| 141 | +{ |
| 142 | + type => "config", |
| 143 | + comment => "SecRequestBodyLimitAction ProcessPartial (JSON, >Limit, <=NoFilesLimit)", |
| 144 | + conf => qq( |
| 145 | + SecRuleEngine On |
| 146 | + SecDebugLog $ENV{DEBUG_LOG} |
| 147 | + SecDebugLogLevel 9 |
| 148 | + SecRequestBodyAccess On |
| 149 | + SecRequestBodyLimitAction ProcessPartial |
| 150 | + SecRequestBodyNoFilesLimit 32768 |
| 151 | + SecRequestBodyLimit 16384 |
| 152 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 153 | + ), |
| 154 | + match_log => { |
| 155 | + error => [ qr/Request body \(Content-Length\) is larger than the configured limit \(16384\)\./, 1 ], |
| 156 | + }, |
| 157 | + match_response => { |
| 158 | + status => qr/^200$/, |
| 159 | + }, |
| 160 | + request => new HTTP::Request( |
| 161 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 162 | + [ |
| 163 | + "Content-Type" => "application/json", |
| 164 | + "Content-Length" => "16385", |
| 165 | + ], |
| 166 | + '{"a":"' . "1" x 16377 . '"}', |
| 167 | + ), |
| 168 | +}, |
| 169 | +{ |
| 170 | + type => "config", |
| 171 | + comment => "SecRequestBodyLimitAction ProcessPartial (JSON, >Limit, >NoFilesLimit)", |
| 172 | + conf => qq( |
| 173 | + SecRuleEngine On |
| 174 | + SecDebugLog $ENV{DEBUG_LOG} |
| 175 | + SecDebugLogLevel 9 |
| 176 | + SecRequestBodyAccess On |
| 177 | + SecRequestBodyLimitAction ProcessPartial |
| 178 | + SecRequestBodyNoFilesLimit 16384 |
| 179 | + SecRequestBodyLimit 32768 |
| 180 | + SecRule REQUEST_HEADERS:Content-Type "application/json" "id:'200000',phase:1,t:none,t:lowercase,pass,nolog,ctl:requestBodyProcessor=JSON" |
| 181 | + ), |
| 182 | + match_log => { |
| 183 | + error => [ qr/Request body \(Content-Length\) is larger than the configured limit \(32768\)\./, 1 ], |
| 184 | + }, |
| 185 | + match_response => { |
| 186 | + status => qr/^200$/, |
| 187 | + }, |
| 188 | + request => new HTTP::Request( |
| 189 | + POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt", |
| 190 | + [ |
| 191 | + "Content-Type" => "application/json", |
| 192 | + "Content-Length" => "32769", |
| 193 | + ], |
| 194 | + '{"a":"' . "1" x 32761 . '"}', |
| 195 | + ), |
| 196 | +}, |
0 commit comments