Imported Upstream version 2.5.11
[libapache-mod-security.git] / apache2 / t / regression / config / 10-debug-directives.t
1 ### SecDebug* directive tests
2 {
3         type => "config",
4         comment => "SecDebugLog (pos)",
5         conf => qq(
6                 SecRuleEngine On
7                 SecDebugLog $ENV{DEBUG_LOG}
8                 SecDebugLogLevel 9
9         ),
10         match_log => {
11                 debug => [ qr/./, 1 ],
12         },
13         match_response => {
14                 status => qr/^200$/,
15         },
16         request => new HTTP::Request(
17                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
18         ),
19 },
20 {
21         type => "config",
22         comment => "SecDebugLog (neg)",
23         conf => qq(
24                 SecRuleEngine On
25         ),
26         match_log => {
27                 -debug => [ qr/./, 1 ],
28         },
29         match_response => {
30                 status => qr/^200$/,
31         },
32         request => new HTTP::Request(
33                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
34         ),
35 },
36 {
37         type => "config",
38         comment => "SecDebugLogLevel 0",
39         conf => qq(
40                 SecRuleEngine On
41                 SecDebugLog $ENV{DEBUG_LOG}
42                 SecDebugLogLevel 0
43                 SecRule REQUEST_URI "." "phase:1,deny"
44         ),
45         match_log => {
46                 -debug => [ qr/./, 1 ],
47         },
48         match_response => {
49                 status => qr/^403$/,
50         },
51         request => new HTTP::Request(
52                 GET => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
53         ),
54 },
55 {
56         type => "config",
57         comment => "SecDebugLogLevel 1",
58         conf => qq(
59                 SecRuleEngine On
60                 SecDebugLog $ENV{DEBUG_LOG}
61                 SecDebugLogLevel 1
62                 SecRuleScript "test.lua" "phase:1"
63                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
64         ),
65         match_log => {
66                 debug => [ qr/\]\[[1]\] /, 1 ],
67                 -debug => [ qr/\]\[[2-9]\] /, 1 ],
68         },
69         match_response => {
70                 status => qr/^403$/,
71         },
72         request => new HTTP::Request(
73                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
74                 [
75                         "Content-Type" => "application/x-www-form-urlencoded",
76                 ],
77                 "a=1&b=2",
78         ),
79 },
80 {
81         type => "config",
82         comment => "SecDebugLogLevel 2",
83         conf => qq(
84                 SecRuleEngine DetectionOnly
85                 SecDebugLog $ENV{DEBUG_LOG}
86                 SecDebugLogLevel 2
87                 SecRuleScript "test.lua" "phase:1"
88                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
89         ),
90         match_log => {
91                 debug => [ qr/\]\[2\] /, 1 ],
92                 -debug => [ qr/\]\[[3-9]\] /, 1 ],
93         },
94         match_response => {
95                 status => qr/^200$/,
96         },
97         request => new HTTP::Request(
98                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
99                 [
100                         "Content-Type" => "application/x-www-form-urlencoded",
101                 ],
102                 "a=1&b=2",
103         ),
104 },
105 {
106         type => "config",
107         comment => "SecDebugLogLevel 3",
108         conf => qq(
109                 SecRuleEngine On
110                 SecDebugLog $ENV{DEBUG_LOG}
111                 SecDebugLogLevel 3
112                 SecRuleScript "test.lua" "phase:1"
113                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
114         ),
115         match_log => {
116                 debug => [ qr/\]\[3\] /, 1 ],
117                 -debug => [ qr/\]\[[4-9]\] /, 1 ],
118         },
119         match_response => {
120                 status => qr/^403$/,
121         },
122         request => new HTTP::Request(
123                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
124                 [
125                         "Content-Type" => "application/x-www-form-urlencoded",
126                 ],
127                 "a=1&b=2",
128         ),
129 },
130 {
131         type => "config",
132         comment => "SecDebugLogLevel 4",
133         conf => qq(
134                 SecRuleEngine On
135                 SecDebugLog $ENV{DEBUG_LOG}
136                 SecDebugLogLevel 4
137                 SecRuleScript "test.lua" "phase:1"
138                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
139         ),
140         match_log => {
141                 debug => [ qr/\]\[4\] /, 1 ],
142                 -debug => [ qr/\]\[[5-9]\] /, 1 ],
143         },
144         match_response => {
145                 status => qr/^403$/,
146         },
147         request => new HTTP::Request(
148                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
149                 [
150                         "Content-Type" => "application/x-www-form-urlencoded",
151                 ],
152                 "a=1&b=2",
153         ),
154 },
155 {
156         type => "config",
157         comment => "SecDebugLogLevel 5",
158         conf => qq(
159                 SecRuleEngine On
160                 SecDebugLog $ENV{DEBUG_LOG}
161                 SecDebugLogLevel 5
162                 SecRuleScript "test.lua" "phase:1"
163                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
164         ),
165         match_log => {
166                 debug => [ qr/\]\[5\] /, 1 ],
167                 -debug => [ qr/\]\[[6-9]\] /, 1 ],
168         },
169         match_response => {
170                 status => qr/^403$/,
171         },
172         request => new HTTP::Request(
173                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
174                 [
175                         "Content-Type" => "application/x-www-form-urlencoded",
176                 ],
177                 "a=1&b=2",
178         ),
179 },
180 {
181         type => "config",
182         comment => "SecDebugLogLevel 6",
183         conf => qq(
184                 SecRuleEngine On
185                 SecDebugLog $ENV{DEBUG_LOG}
186                 SecDebugLogLevel 6
187                 SecRuleScript "test.lua" "phase:1"
188                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
189         ),
190         match_log => {
191                 debug => [ qr/\]\[6\] /, 1 ],
192                 -debug => [ qr/\]\[[7-9]\] /, 1 ],
193         },
194         match_response => {
195                 status => qr/^403$/,
196         },
197         request => new HTTP::Request(
198                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
199                 [
200                         "Content-Type" => "application/x-www-form-urlencoded",
201                 ],
202                 "a=1&b=2",
203         ),
204 },
205 {
206         type => "config",
207         comment => "SecDebugLogLevel 7",
208         conf => qq(
209                 SecRuleEngine On
210                 SecDebugLog $ENV{DEBUG_LOG}
211                 SecDebugLogLevel 7
212                 SecRuleScript "test.lua" "phase:1"
213                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
214         ),
215         match_log => {
216                 debug => [ qr/\]\[7\] /, 1 ],
217                 -debug => [ qr/\]\[[8-9]\] /, 1 ],
218         },
219         match_response => {
220                 status => qr/^403$/,
221         },
222         request => new HTTP::Request(
223                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
224                 [
225                         "Content-Type" => "application/x-www-form-urlencoded",
226                 ],
227                 "a=1&b=2",
228         ),
229 },
230 {
231         type => "config",
232         comment => "SecDebugLogLevel 8",
233         conf => qq(
234                 SecRuleEngine On
235                 SecDebugLog $ENV{DEBUG_LOG}
236                 SecDebugLogLevel 8
237                 SecRuleScript "test.lua" "phase:1"
238                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
239         ),
240         match_log => {
241                 debug => [ qr/\]\[8\] /, 1 ],
242                 -debug => [ qr/\]\[9\] /, 1 ],
243         },
244         match_response => {
245                 status => qr/^403$/,
246         },
247         request => new HTTP::Request(
248                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
249                 [
250                         "Content-Type" => "application/x-www-form-urlencoded",
251                 ],
252                 "a=1&b=2",
253         ),
254 },
255 {
256         type => "config",
257         comment => "SecDebugLogLevel 9",
258         conf => qq(
259                 SecRuleEngine On
260                 SecDebugLog $ENV{DEBUG_LOG}
261                 SecDebugLogLevel 9
262                 SecRuleScript "test.lua" "phase:1"
263                 SecRule REQUEST_URI "(.)" "phase:4,deny,deprecatevar:bogus"
264         ),
265         match_log => {
266                 debug => [ qr/\]\[9\] /, 1 ],
267         },
268         match_response => {
269                 status => qr/^403$/,
270         },
271         request => new HTTP::Request(
272                 POST => "http://$ENV{SERVER_NAME}:$ENV{SERVER_PORT}/test.txt",
273                 [
274                         "Content-Type" => "application/x-www-form-urlencoded",
275                 ],
276                 "a=1&b=2",
277         ),
278 },