mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-11-16 17:41:52 +03:00
Using a custom VariableMatch* implementation
Delay the variable name resolution till last minute. Fix one of the issues raised in #2376
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS (1/2)",
|
||||
"title":"Testing Variables :: MATCHED_VARS (1/4)",
|
||||
"client":{
|
||||
"ip":"200.249.12.31",
|
||||
"port":123
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS (2/2)",
|
||||
"title":"Testing Variables :: MATCHED_VARS (2/4)",
|
||||
"client":{
|
||||
"ip":"200.249.12.31",
|
||||
"port":123
|
||||
@@ -81,6 +81,92 @@
|
||||
"SecRule MATCHED_VARS \"@contains asdf\" \"\"",
|
||||
"SecRule MATCHED_VARS \"@contains value\" \"id:29\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS (3/4)",
|
||||
"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":"/?keyI=value&keyII=other_value",
|
||||
"method":"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: \"other_value\" \\(Variable: MATCHED_VARS:ARGS:keyII\\)",
|
||||
"http_code": 302,
|
||||
"error_log": "whee MATCHED_VARS:ARGS:keyII test"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,deny,status:302\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VARS:ARGS:keyII \"@contains other_value\" \"msg:'whee %{MATCHED_VARS_NAMES}% test'\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS (4/4)",
|
||||
"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":"/?keyI=value&keyII=other_value",
|
||||
"method":"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: \"other_value\" \\(Variable: MATCHED_VARS:ARGS:keyII\\)",
|
||||
"http_code": 302,
|
||||
"error_log": "whee MATCHED_VARS:ARGS:keyII test"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,deny,status:302\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VARS:/ARGS:.*II/ \"@contains other_value\" \"msg:'whee %{MATCHED_VARS_NAMES}% test'\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (1/2)",
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (1/5)",
|
||||
"client":{
|
||||
"ip":"200.249.12.31",
|
||||
"port":123
|
||||
@@ -43,7 +43,7 @@
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (2/2)",
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (2/5)",
|
||||
"client":{
|
||||
"ip":"200.249.12.31",
|
||||
"port":123
|
||||
@@ -81,6 +81,133 @@
|
||||
"SecRule MATCHED_VARS_NAMES \"@contains asdf\" \"\"",
|
||||
"SecRule MATCHED_VARS_NAMES \"@contains value\" \"id:29\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (3/5)",
|
||||
"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":"/?keyI=value&keyII=other_value",
|
||||
"method":"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: \"ARGS:keyI\" \\(Variable: MATCHED_VARS_NAMES:ARGS:keyI\\)"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,pass\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VARS_NAMES \"@contains asdf\" \"\"",
|
||||
"SecRule MATCHED_VARS_NAMES:ARGS:keyI \"@contains value\" \"id:29\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (4/5)",
|
||||
"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":"/?keyI=value&keyII=other_value",
|
||||
"method":"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: \"ARGS:keyI\" \\(Variable: MATCHED_VARS_NAMES:ARGS:keyI\\)",
|
||||
"http_code": 302
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,deny,status:302\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VARS_NAMES:/^ARGS:.*eyI$/ \"@contains ARGS:keyI\" \"\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"enabled":1,
|
||||
"version_min":300000,
|
||||
"title":"Testing Variables :: MATCHED_VARS_NAMES (5/5)",
|
||||
"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":"/?keyI=value&keyII=other_value",
|
||||
"method":"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: \"ARGS:keyI\" \\(Variable: MATCHED_VARS_NAMES:ARGS:keyI\\)",
|
||||
"http_code": 302,
|
||||
"error_log": "whee MATCHED_VARS_NAMES:ARGS:keyI test"
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,deny,status:302\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VARS_NAMES:/^ARGS:.*eyI$/ \"@contains ARGS:keyI\" \"msg:'whee %{MATCHED_VARS_NAMES}% test'\""
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@
|
||||
},
|
||||
"rules":[
|
||||
"SecRuleEngine On",
|
||||
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,pass\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
|
||||
"SecRule MATCHED_VAR_NAME \"@contains asdf\" \"\""
|
||||
"SecRule ARGS:keyI \"@contains value\" \"id:28,pass\"",
|
||||
"SecRule ARGS:keyII \"@contains other_value\" \"id:29,pass\"",
|
||||
"SecRule MATCHED_VAR_NAME \"@contains asdf\" \"id:30,pass\""
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user