Skip to content

Commit

Permalink
Adds the missing regression tests for USERID
Browse files Browse the repository at this point in the history
  • Loading branch information
zimmerle committed May 11, 2016
1 parent 758ecb5 commit 3563667
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/test-cases/regression/action-setuid.json
@@ -0,0 +1,37 @@
[
{
"enabled":1,
"version_min":300000,
"title":"Testing setuid action",
"expected":{
"debug_log": "Saving variable: USER:score with value: 5"
},
"client":{
"ip":"200.249.12.31",
"port":123
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*",
"User-Agent":"My sweet little browser",
"Cookie": "PHPSESSID=rAAAAAAA2t5uvjq435r4q7ib3vtdjq120"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"rules":[
"SecRuleEngine On",
"SecDebugLog \/tmp\/modsec_debug.log",
"SecRule REQUEST_HEADERS:User-Agent \"^(.*)$\" \"id:'900018',phase:1,t:none,t:sha1,t:hexEncode,setuid:%{REQUEST_COOKIES:USER}%,nolog,pass\"",
"SecRule REQUEST_HEADERS \".*\" \"id:'900021',phase:1,setvar:USER.score=+10\"",
"SecRule REQUEST_HEADERS:User-Agent \"^(.*)$\" \"id:'900068',phase:1,t:none,t:sha1,t:hexEncode,setsid:%{REQUEST_COOKIES:PHPSESSID}2,nolog,pass\"",
"SecRule REQUEST_HEADERS \".*\" \"id:'900022',phase:1,setvar:USER.score=+5\""
]
}
]
69 changes: 69 additions & 0 deletions test/test-cases/regression/variable-USERID.json
@@ -0,0 +1,69 @@
[
{
"enabled":1,
"version_min":300000,
"title":"Testing USERID variable (1/2)",
"expected":{
"debug_log": "Target value: \"zimmerle2\""
},
"client":{
"ip":"200.249.12.31",
"port":123
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*",
"User-Agent":"My sweet little browser",
"Cookie": "USER=zimmerle"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"rules":[
"SecRuleEngine On",
"SecDebugLog \/tmp\/modsec_debug.log",
"SecRule REQUEST_HEADERS:User-Agent \"^(.*)$\" \"id:'900018',phase:1,t:none,t:sha1,t:hexEncode,setuid:%{REQUEST_COOKIES:USER}%,nolog,pass\"",
"SecRule REQUEST_HEADERS:User-Agent \"^(.*)$\" \"id:'900068',phase:1,t:none,t:sha1,t:hexEncode,setuid:%{REQUEST_COOKIES:USER}2,nolog,pass\"",
"SecRule USERID \".*\" \"id:1239,phase:1,log,pass\""
]
},
{
"enabled":1,
"version_min":300000,
"title":"Testing USERID variable (2/2)",
"expected":{
"debug_log": "Target value: \"whee\""
},
"client":{
"ip":"200.249.12.31",
"port":123
},
"request":{
"headers":{
"Host":"localhost",
"User-Agent":"curl/7.38.0",
"Accept":"*/*",
"User-Agent":"My sweet little browser",
"Cookie": "USER=whee"
},
"uri":"/?key=value&key=other_value",
"method":"GET"
},
"server":{
"ip":"200.249.12.31",
"port":80
},
"rules":[
"SecRuleEngine On",
"SecDebugLog \/tmp\/modsec_debug.log",
"SecRule REQUEST_HEADERS:User-Agent \"^(.*)$\" \"id:'900018',phase:1,t:none,t:sha1,t:hexEncode,setuid:%{REQUEST_COOKIES:USER}%,nolog,pass\"",
"SecRule USERID \".*\" \"id:1239,phase:1,log,pass\""
]
}
]

0 comments on commit 3563667

Please sign in to comment.