Adds support to the FILES_SIZES variable

This commit is contained in:
Felipe Zimmerle 2015-07-17 15:46:54 -03:00
parent ebb16d0439
commit b6cccc798a
2 changed files with 65 additions and 0 deletions

View File

@ -212,6 +212,8 @@ bool Multipart::process(std::string data) {
if (m.filename.empty() == false) {
variables.emplace("FILES:" + m.name, m.filename);
variables.emplace("FILES_NAMES:" + m.name, m.name);
variables.emplace("FILES_SIZES:" + m.name,
std::to_string(m.content.size()));
files_size = files_size + m.content.size();
}
}

View File

@ -0,0 +1,63 @@
[
{
"enabled":1,
"version_min":300000,
"title":"Testing Variables :: FILES_NAMES (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: \"32\" \\(Variable: FILES_SIZES:filedata\\)"
},
"rules":[
"SecRuleEngine On",
"SecDebugLog \/tmp\/modsec_debug.log",
"SecDebugLogLevel 9",
"SecRule FILES_SIZES \"@gt 70.000000\" \"phase:3,pass,t:trim\""
]
}
]