From a264fc11c8bf634ece766e64502c7392ebdc5040 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Fri, 17 Jul 2015 15:50:49 -0300 Subject: [PATCH] Adds support to the FILES_TMP_CONTENT variable --- src/request_body_processor/multipart.cc | 1 + .../variable-FILES_TMP_CONTENT.json | 63 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 test/test-cases/regression/variable-FILES_TMP_CONTENT.json diff --git a/src/request_body_processor/multipart.cc b/src/request_body_processor/multipart.cc index 22268d66..4865531b 100644 --- a/src/request_body_processor/multipart.cc +++ b/src/request_body_processor/multipart.cc @@ -214,6 +214,7 @@ bool Multipart::process(std::string data) { variables.emplace("FILES_NAMES:" + m.name, m.name); variables.emplace("FILES_SIZES:" + m.name, std::to_string(m.content.size())); + variables.emplace("FILES_TMP_CONTENT:" + m.name, m.content); files_size = files_size + m.content.size(); } } diff --git a/test/test-cases/regression/variable-FILES_TMP_CONTENT.json b/test/test-cases/regression/variable-FILES_TMP_CONTENT.json new file mode 100644 index 00000000..9ad0d3d0 --- /dev/null +++ b/test/test-cases/regression/variable-FILES_TMP_CONTENT.json @@ -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":"trim: \"This is another very small test file.." + }, + "rules":[ + "SecRuleEngine On", + "SecDebugLog \/tmp\/modsec_debug.log", + "SecDebugLogLevel 9", + "SecRule FILES_TMP_CONTENT \"@contains small_text_file.txt\" \"phase:3,pass,t:trim\"" + ] + } +] \ No newline at end of file