mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 13:56:01 +03:00
Adds support for transformations inside Lua engine
This commit is contained in:
parent
a676f313c3
commit
7bec78a5a5
2
CHANGES
2
CHANGES
@ -2,6 +2,8 @@
|
|||||||
v3.0.????? - ?
|
v3.0.????? - ?
|
||||||
---------------------------
|
---------------------------
|
||||||
|
|
||||||
|
- Adds support for transformations inside Lua engine
|
||||||
|
[Issue #994 - @zimmerle]
|
||||||
- Adds initial support for Lua engine.
|
- Adds initial support for Lua engine.
|
||||||
[Issue #994 - @zimmerle]
|
[Issue #994 - @zimmerle]
|
||||||
- Adds support for @inspectFile operator.
|
- Adds support for @inspectFile operator.
|
||||||
|
21
test/test-cases/data/match-getvar-multi-transformations.lua
Normal file
21
test/test-cases/data/match-getvar-multi-transformations.lua
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
function main()
|
||||||
|
ret = nil
|
||||||
|
m.log(9, "Lets rock.");
|
||||||
|
|
||||||
|
var = m.getvar("tx.test" , { "lowercase", "uppercase" });
|
||||||
|
if var == nil then
|
||||||
|
m.log(9, "Don't know what to say...");
|
||||||
|
return ret;
|
||||||
|
end
|
||||||
|
|
||||||
|
if var == "FELIPE" then
|
||||||
|
m.log(9, "Whee. Working like a charm. That is what we have: " .. var);
|
||||||
|
elseif var == "felipe" then
|
||||||
|
m.log(9, "Oh boy. Got: " .. var);
|
||||||
|
ret ="ok";
|
||||||
|
else
|
||||||
|
m.log(9, "Really?");
|
||||||
|
end
|
||||||
|
|
||||||
|
return "whee"
|
||||||
|
end
|
@ -1,20 +1,21 @@
|
|||||||
function main()
|
function main()
|
||||||
ret = nil
|
ret = nil
|
||||||
|
m.log(9, "Lets rock.");
|
||||||
|
|
||||||
var = m.getvar("tx.test");
|
var = m.getvar("tx.test" , "lowercase");
|
||||||
if var == nil then
|
if var == nil then
|
||||||
m.log(9, "Don't know what to say...");
|
m.log(9, "Don't know what to say...");
|
||||||
return ret
|
return ret;
|
||||||
end
|
end
|
||||||
|
|
||||||
if var == "FELIPE"
|
if var == "FELIPE" then
|
||||||
m.log(9, "Ops.");
|
m.log(9, "Ops.");
|
||||||
elseif var == "felipe"
|
elseif var == "felipe" then
|
||||||
m.log(9, "Just fine.");
|
m.log(9, "Just fine.");
|
||||||
ret ="ok";
|
ret ="ok";
|
||||||
else
|
else
|
||||||
m.log(9, "Really?");
|
m.log(9, "Really?");
|
||||||
end
|
end
|
||||||
|
|
||||||
return ret
|
return "whee"
|
||||||
end
|
end
|
||||||
|
7
test/test-cases/data/match-getvar-withTnfs.lua
Normal file
7
test/test-cases/data/match-getvar-withTnfs.lua
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function main()
|
||||||
|
ret = nil
|
||||||
|
|
||||||
|
var = m.getvar("tx.test", "lowercase");
|
||||||
|
|
||||||
|
return ret
|
||||||
|
end
|
@ -298,12 +298,90 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"expected":{
|
"expected":{
|
||||||
"debug_log":"Z: \\{ \\[1\\] = \\{ \\[\"value\"\\] = res=whee&z=z&d=e,\\[\"name\"\\] = QUERY_STRING,\\} ,\\}"
|
"debug_log":"Z: \\{ \\[1\\] = \\{ \\[\""
|
||||||
},
|
},
|
||||||
"rules":[
|
"rules":[
|
||||||
"SecRuleEngine On",
|
"SecRuleEngine On",
|
||||||
"SecRule QUERY_STRING \".\" \"id:2,phase:2,setvar:tx.test=2\"",
|
"SecRule QUERY_STRING \".\" \"id:2,phase:2,setvar:tx.test=2\"",
|
||||||
"SecRule ARGS:res \"@inspectFile test-cases/data/match-getvars.lua\" \"id:1,phase:2,pass,t:trim\""
|
"SecRule ARGS:res \"@inspectFile test-cases/data/match-getvars.lua\" \"id:1,phase:2,pass,t:trim\""
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enabled":1,
|
||||||
|
"version_min":300000,
|
||||||
|
"title":"Testing Operator :: @inspectFile - lua (6/?)",
|
||||||
|
"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":"*/*",
|
||||||
|
"Content-Length": "27",
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
"uri":"/whee?res=whee&z=z&d=e",
|
||||||
|
"method":"GET",
|
||||||
|
"body": [ ]
|
||||||
|
},
|
||||||
|
"response":{
|
||||||
|
"headers":{},
|
||||||
|
"body":[
|
||||||
|
"no need."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"expected":{
|
||||||
|
"debug_log":"Just fine."
|
||||||
|
},
|
||||||
|
"rules":[
|
||||||
|
"SecRuleEngine On",
|
||||||
|
"SecRule QUERY_STRING \".\" \"id:2,phase:2,setvar:tx.test=FELIPE\"",
|
||||||
|
"SecRule QUERY_STRING \"@inspectFile test-cases/data/match-getvar-transformation.lua\" \"id:1,phase:2,pass\""
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"enabled":1,
|
||||||
|
"version_min":300000,
|
||||||
|
"title":"Testing Operator :: @inspectFile - lua (7/?)",
|
||||||
|
"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":"*/*",
|
||||||
|
"Content-Length": "27",
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded"
|
||||||
|
},
|
||||||
|
"uri":"/whee?res=whee&z=z&d=e",
|
||||||
|
"method":"GET",
|
||||||
|
"body": [ ]
|
||||||
|
},
|
||||||
|
"response":{
|
||||||
|
"headers":{},
|
||||||
|
"body":[
|
||||||
|
"no need."
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"expected":{
|
||||||
|
"debug_log":"Whee. Working like a charm. That is what we have: FELIPE"
|
||||||
|
},
|
||||||
|
"rules":[
|
||||||
|
"SecRuleEngine On",
|
||||||
|
"SecRule QUERY_STRING \".\" \"id:2,phase:2,setvar:tx.test=FeLiPe\"",
|
||||||
|
"SecRule QUERY_STRING \"@inspectFile test-cases/data/match-getvar-multi-transformations.lua\" \"id:1,phase:2,pass\""
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user