From 97c0d561f6ba18a96604c3fe3953f58d9864c92a Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 22 Jul 2015 01:33:46 -0300 Subject: [PATCH] Adds suppor to the REQUEST_FILENAME variable --- src/assay.cc | 1 + .../regression/variable-REQUEST_FILENAME.json | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/test-cases/regression/variable-REQUEST_FILENAME.json diff --git a/src/assay.cc b/src/assay.cc index d26f5f99..8b89d84b 100644 --- a/src/assay.cc +++ b/src/assay.cc @@ -220,6 +220,7 @@ int Assay::processURI(const char *uri, const char *protocol, store_variable("QUERY_STRING", std::string(strchr(m_uri, '?'))); } store_variable("PATH_INFO", path_info); + store_variable("REQUEST_FILENAME", path_info); size_t offset = path_info.find_last_of("/\\"); if (offset != std::string::npos) { diff --git a/test/test-cases/regression/variable-REQUEST_FILENAME.json b/test/test-cases/regression/variable-REQUEST_FILENAME.json new file mode 100644 index 00000000..6644b381 --- /dev/null +++ b/test/test-cases/regression/variable-REQUEST_FILENAME.json @@ -0,0 +1,45 @@ +[ + { + "enabled":1, + "version_min":300000, + "title":"Testing Variables :: REQUEST_FILENAME", + "client":{ + "ip":"200.249.12.31", + "port":123 + }, + "server":{ + "ip":"200.249.12.11", + "port":80 + }, + "request":{ + "headers":{ + "Host":"localhost", + "User-Agent":"curl/7.38.0", + "Accept":"*/*", + "Content-Length":"27", + "Content-Type":"application/x-www-form-urlencoded" + }, + "uri":"/one/two/login.php?key1=value1&key2=v%20a%20l%20u%20e%202", + "protocol":"GET" + }, + "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: \"/one/two/login.php\" \\(Variable: REQUEST_FILENAME\\)" + }, + "rules":[ + "SecRuleEngine On", + "SecDebugLog \/tmp\/modsec_debug.log", + "SecDebugLogLevel 9", + "SecRule REQUEST_FILENAME \"@contains test \" \"phase:3,pass,t:trim\"" + ] + } +] \ No newline at end of file