Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / t / regression / rule / 00-script.t
1 ### Test for SecRuleScript
2
3 # Lua
4 {
5         type => "rule",
6         comment => "SecRuleScript (lua absolute nomatch)",
7         conf => qq(
8                 SecRuleEngine On
9                 SecDebugLog $ENV{DEBUG_LOG}
10                 SecDebugLogLevel 1
11                 SecRuleScript "$ENV{CONF_DIR}/test.lua" "phase:2,deny"
12         ),
13         match_log => {
14                 -error => [ qr/Lua script matched\./, 1 ],
15                 debug => [ qr/Test message\./, 1 ],
16         },
17         match_response => {
18                 status => qr/^200$/,
19         },
20         request => new HTTP::Request(
21                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
22         ),
23 },
24 {
25         type => "rule",
26         comment => "SecRuleScript (lua relative nomatch)",
27         conf => qq(
28                 SecRuleEngine On
29                 SecDebugLog $ENV{DEBUG_LOG}
30                 SecDebugLogLevel 1
31                 SecRuleScript "test.lua" "phase:2,deny"
32         ),
33         match_log => {
34                 -error => [ qr/Lua script matched\./, 1 ],
35                 debug => [ qr/Test message\./, 1 ],
36         },
37         match_response => {
38                 status => qr/^200$/,
39         },
40         request => new HTTP::Request(
41                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
42         ),
43 },
44 {
45         type => "rule",
46         comment => "SecRuleScript (lua relative match)",
47         conf => qq(
48                 SecRuleEngine On
49                 SecDebugLog $ENV{DEBUG_LOG}
50                 SecDebugLogLevel 1
51                 SecRuleScript "match.lua" "phase:2,deny"
52         ),
53         match_log => {
54                 error => [ qr/ModSecurity: Access denied with code 403 \(phase 2\)\. Lua script matched\./, 1 ],
55                 debug => [ qr/Test message\./, 1 ],
56         },
57         match_response => {
58                 status => qr/^403$/,
59         },
60         request => new HTTP::Request(
61                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
62         ),
63 },