mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
Adds support to variables: REQUEST_{METHOD,PROTOCOL,URI,URI_RAW}
This commit is contained in:
parent
bc925e01e6
commit
ec34f676c6
@ -239,6 +239,10 @@ int Assay::processURI(const char *uri, const char *protocol,
|
||||
path_info.length() - offset);
|
||||
store_variable("REQUEST_BASENAME", basename);
|
||||
}
|
||||
store_variable("REQUEST_METHOD", protocol);
|
||||
store_variable("REQUEST_PROTOCOL", "HTTP/" + std::string(http_version));
|
||||
store_variable("REQUEST_URI", uri);
|
||||
store_variable("REQUEST_URI_RAW", uri);
|
||||
|
||||
if (pos != NULL && strlen(pos) > 2) {
|
||||
/**
|
||||
|
45
test/test-cases/regression/variable-REQUEST_METHOD.json
Normal file
45
test/test-cases/regression/variable-REQUEST_METHOD.json
Normal file
@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: REQUEST_METHOD",
|
||||
"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\" \\(Variable: REQUEST_METHOD\\)"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecDebugLog \/tmp\/modsec_debug.log",
|
||||
"SecDebugLogLevel 9",
|
||||
"SecRule REQUEST_METHOD \"@contains test \" \"pass,t:trim\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
45
test/test-cases/regression/variable-REQUEST_PROTOCOL.json
Normal file
45
test/test-cases/regression/variable-REQUEST_PROTOCOL.json
Normal file
@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: REQUEST_PROTOCOL",
|
||||
"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: \"HTTP/1.1\" \\(Variable: REQUEST_PROTOCOL\\)"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecDebugLog \/tmp\/modsec_debug.log",
|
||||
"SecDebugLogLevel 9",
|
||||
"SecRule REQUEST_PROTOCOL \"@contains test \" \"pass,t:trim\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
45
test/test-cases/regression/variable-REQUEST_URI.json
Normal file
45
test/test-cases/regression/variable-REQUEST_URI.json
Normal file
@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: REQUEST_URI",
|
||||
"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: \"/\\?key=value\\&key=other_value\" \\(Variable: REQUEST_URI\\)"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecDebugLog \/tmp\/modsec_debug.log",
|
||||
"SecDebugLogLevel 9",
|
||||
"SecRule REQUEST_URI \"@contains test \" \"pass,t:trim\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
45
test/test-cases/regression/variable-REQUEST_URI_RAW.json
Normal file
45
test/test-cases/regression/variable-REQUEST_URI_RAW.json
Normal file
@ -0,0 +1,45 @@
|
||||
[
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: REQUEST_URI_RAW",
|
||||
"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: \"/\\?key=value\\&key=other_value\" \\(Variable: REQUEST_URI_RAW\\)"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecDebugLog \/tmp\/modsec_debug.log",
|
||||
"SecDebugLogLevel 9",
|
||||
"SecRule REQUEST_URI_RAW \"@contains test \" \"pass,t:trim\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user