From bc925e01e659031e8550121221290aafd2d18e9a Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 22 Jul 2015 01:57:46 -0300 Subject: [PATCH] Adds support to the REQUEST_LINE variable --- src/assay.cc | 3 ++ .../regression/variable-REQUEST_LINE.json | 45 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 test/test-cases/regression/variable-REQUEST_LINE.json diff --git a/src/assay.cc b/src/assay.cc index 098f27f2..1f5a09b0 100644 --- a/src/assay.cc +++ b/src/assay.cc @@ -219,6 +219,9 @@ int Assay::processURI(const char *uri, const char *protocol, const char *pos = strchr(m_uri_decoded.c_str(), '?'); + store_variable("REQUEST_LINE", std::string(protocol) + " " + + std::string(uri) + " HTTP/" + std::string(http_version)); + std::string path_info; if (pos == NULL) { path_info = std::string(m_uri_decoded, 0); diff --git a/test/test-cases/regression/variable-REQUEST_LINE.json b/test/test-cases/regression/variable-REQUEST_LINE.json new file mode 100644 index 00000000..678f7c58 --- /dev/null +++ b/test/test-cases/regression/variable-REQUEST_LINE.json @@ -0,0 +1,45 @@ +[ + { + "enabled":1, + "version_min":300000, + "title":"Testing Variables :: REQUEST_LINE", + "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":"*/*" + }, + "uri":"/?key=value&key=other_value", + "protocol":"GET", + "http_version":1.1 + }, + "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: \"GET /\\?key=value\\&key=other_value HTTP/1.1\" \\(Variable: REQUEST_LINE\\)" + }, + "rules":[ + "SecRuleEngine On", + "SecDebugLog \/tmp\/modsec_debug.log", + "SecDebugLogLevel 9", + "SecRule REQUEST_LINE \"@contains test \" \"pass,t:trim\"" + ] + } +] +