@@ -21,7 +21,7 @@ use Test::Nginx;
21
21
select STDERR ; $| = 1;
22
22
select STDOUT ; $| = 1;
23
23
24
- my $t = Test::Nginx-> new()-> plan(3 )-> write_file_expand(' nginx.conf' , <<'EOF' );
24
+ my $t = Test::Nginx-> new()-> plan(5 )-> write_file_expand(' nginx.conf' , <<'EOF' );
25
25
26
26
%%TEST_GLOBALS%%
27
27
@@ -76,6 +76,33 @@ http {
76
76
SecRule ARGS "@streq block403" "id:4,phase:1,status:403,block"
77
77
';
78
78
}
79
+
80
+ location /debuglog {
81
+ modsecurity on;
82
+ modsecurity_transaction_id "tid-DEBUG-$request_id";
83
+ modsecurity_rules '
84
+ SecRuleEngine On
85
+ SecDebugLog %%TESTDIR%%/modsec_debug.log
86
+ SecDebugLogLevel 4
87
+ SecDefaultAction "phase:1,log,deny,status:403"
88
+ SecRule ARGS "@streq block403" "id:4,phase:1,status:403,block"
89
+ ';
90
+ }
91
+
92
+ location /auditlog {
93
+ modsecurity on;
94
+ modsecurity_transaction_id "tid-AUDIT-$request_id";
95
+ modsecurity_rules '
96
+ SecRuleEngine On
97
+ SecDefaultAction "phase:1,log,deny,status:403"
98
+ SecAuditEngine On
99
+ SecAuditLogParts A
100
+ SecAuditLog %%TESTDIR%%/modsec_audit.log
101
+ SecAuditLogType Serial
102
+ SecAuditLogStorageDir %%TESTDIR%%/
103
+ SecRule ARGS "@streq block403" "id:4,phase:1,status:403,block"
104
+ ';
105
+ }
79
106
}
80
107
}
81
108
EOF
@@ -92,23 +119,39 @@ Host: server1
92
119
93
120
EOF
94
121
95
- is (lines($t , ' e_s1l1.log' , ' unique_id "tid-HTTP-DEFAULT-' ), 2 , ' http default' );
122
+ isnt (lines($t , ' e_s1l1.log' , ' unique_id "tid-HTTP-DEFAULT-' ), 0 , ' http default' );
96
123
97
124
http(<<EOF );
98
125
GET /?what=block403 HTTP/1.0
99
126
Host: server2
100
127
101
128
EOF
102
129
103
- is (lines($t , ' e_s2l1.log' , ' unique_id "tid-SERVER-DEFAULT-' ), 2 , ' server default' );
130
+ isnt (lines($t , ' e_s2l1.log' , ' unique_id "tid-SERVER-DEFAULT-' ), 0 , ' server default' );
104
131
105
132
http(<<EOF );
106
133
GET /specific/?what=block403 HTTP/1.0
107
134
Host: server2
108
135
109
136
EOF
110
137
111
- is(lines($t , ' e_s2l2.log' , ' unique_id "tid-LOCATION-SPECIFIC-' ), 2, ' location specific' );
138
+ isnt(lines($t , ' e_s2l2.log' , ' unique_id "tid-LOCATION-SPECIFIC-' ), 0, ' location specific' );
139
+
140
+ http(<<EOF );
141
+ GET /debuglog/?what=block403 HTTP/1.0
142
+ Host: server2
143
+
144
+ EOF
145
+
146
+ isnt(lines($t , ' modsec_debug.log' , ' tid-DEBUG-' ), 0, ' libmodsecurity debug log' );
147
+
148
+ http(<<EOF );
149
+ GET /auditlog/?what=block403 HTTP/1.0
150
+ Host: server2
151
+
152
+ EOF
153
+
154
+ isnt(lines($t , ' modsec_audit.log' , ' tid-AUDIT-' ), 0, ' libmodsecurity audit log' );
112
155
113
156
# ##############################################################################
114
157
0 commit comments