ModSecurity/test/test-cases/regression/variable-MATCHED_VARS.json
Felipe Zimmerle eec1f00bea Using a custom VariableMatch* implementation
Delay the variable name resolution till last minute.

Fix one of the issues raised in #2376
2020-12-22 22:14:46 -03:00

173 lines
4.3 KiB
JSON

[
{
"enabled":1,
"version_min":300000,
"title":"Testing Variables :: MATCHED_VARS (1/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: \"value\" \\(Variable: MATCHED_VARS:ARGS:keyI\\)"
},
"rules":[
"SecRuleEngine On",
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,pass\"",
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
"SecRule MATCHED_VARS \"@contains asdf\" \"\""
]
},
{
"enabled":1,
"version_min":300000,
"title":"Testing Variables :: MATCHED_VARS (2/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: \"value\" \\(Variable: MATCHED_VARS:ARGS:keyI\\)"
},
"rules":[
"SecRuleEngine On",
"SecRule ARGS:keyI \"@contains value\" \"chain,id:28,pass\"",
"SecRule ARGS:keyII \"@contains other_value\" \"chain\"",
"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'\""
]
}
]