mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-16 07:56:12 +03:00
Adds support to FULL_REQUEST_LENGTH variable
This commit is contained in:
parent
e516ded1e7
commit
6e46c5c7f7
@ -489,6 +489,7 @@ int Assay::processRequestBody() {
|
|||||||
fullRequest = fullRequest + "\n\n";
|
fullRequest = fullRequest + "\n\n";
|
||||||
fullRequest = fullRequest + m_requestBody.str();
|
fullRequest = fullRequest + m_requestBody.str();
|
||||||
store_variable("FULL_REQUEST", fullRequest);
|
store_variable("FULL_REQUEST", fullRequest);
|
||||||
|
store_variable("FULL_REQUEST_LENGTH", std::to_string(fullRequest.size()));
|
||||||
|
|
||||||
this->m_rules->evaluate(ModSecurity::RequestBodyPhase, this);
|
this->m_rules->evaluate(ModSecurity::RequestBodyPhase, this);
|
||||||
return 0;
|
return 0;
|
||||||
|
63
test/test-cases/regression/variable-FULL_REQUEST_LENGTH.json
Normal file
63
test/test-cases/regression/variable-FULL_REQUEST_LENGTH.json
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"enabled":1,
|
||||||
|
"version_min":300000,
|
||||||
|
"title":"Testing Variables :: FULL_REQUEST_LENGTH (1/1)",
|
||||||
|
"client":{
|
||||||
|
"ip":"200.249.12.31",
|
||||||
|
"port":123
|
||||||
|
},
|
||||||
|
"server":{
|
||||||
|
"ip":"200.249.12.31",
|
||||||
|
"port":80
|
||||||
|
},
|
||||||
|
"request":{
|
||||||
|
"headers":{
|
||||||
|
"Host":"localhost",
|
||||||
|
"User-Agent":"curl/7.38.0",
|
||||||
|
"Accept":"*/*",
|
||||||
|
"Content-Length":"330",
|
||||||
|
"Content-Type":"multipart/form-data; boundary=--------------------------756b6d74fa1a8ee2",
|
||||||
|
"Expect":"100-continue"
|
||||||
|
},
|
||||||
|
"uri":"/",
|
||||||
|
"protocol":"POST",
|
||||||
|
"body":[
|
||||||
|
"--------------------------756b6d74fa1a8ee2",
|
||||||
|
"Content-Disposition: form-data; name=\"name\"",
|
||||||
|
"",
|
||||||
|
"test",
|
||||||
|
"--------------------------756b6d74fa1a8ee2",
|
||||||
|
"Content-Disposition: form-data; name=\"filedata\"; filename=\"small_text_file.txt\"",
|
||||||
|
"Content-Type: text/plain",
|
||||||
|
"",
|
||||||
|
"This is a very small test file..",
|
||||||
|
"--------------------------756b6d74fa1a8ee2",
|
||||||
|
"Content-Disposition: form-data; name=\"filedata\"; filename=\"small_text_file.txt\"",
|
||||||
|
"Content-Type: text/plain",
|
||||||
|
"",
|
||||||
|
"This is another very small test file..",
|
||||||
|
"--------------------------756b6d74fa1a8ee2--"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"response":{
|
||||||
|
"headers":{
|
||||||
|
"Date":"Mon, 13 Jul 2015 20:02:41 GMT",
|
||||||
|
"Last-Modified":"Sun, 26 Oct 2014 22:33:37 GMT",
|
||||||
|
"Content-Type":"text/html"
|
||||||
|
},
|
||||||
|
"body":[
|
||||||
|
"no need."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"expected":{
|
||||||
|
"debug_log":"Target value: \"690\" \\(Variable: FULL_REQUEST_LENGTH\\)"
|
||||||
|
},
|
||||||
|
"rules":[
|
||||||
|
"SecRuleEngine On",
|
||||||
|
"SecDebugLog \/tmp\/modsec_debug.log",
|
||||||
|
"SecDebugLogLevel 9",
|
||||||
|
"SecRule FULL_REQUEST_LENGTH \"@contains small_text_file.txt\" \"phase:3,pass,t:trim\""
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user