Skip to content

Commit 0d58757

Browse files
committed
added modsecurity_disable_error_log test cases
Signed-off-by: Fatih USTA <[email protected]>
1 parent 1494b25 commit 0d58757

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

.github/nginx/nginx.conf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,18 @@ http {
7474
}
7575
}
7676

77+
server {
78+
listen 80;
79+
server_name modsecurity_disable_error_log;
80+
81+
modsecurity on;
82+
modsecurity_disable_error_log on;
83+
modsecurity_rules_file /home/runner/work/ModSecurity-nginx/ModSecurity-nginx/ModSecurity-nginx/.github/nginx/modsecurity.conf;
84+
root /usr/local/nginx/html/;
85+
86+
location / {
87+
try_files $uri /index.html;
88+
}
89+
}
7790
}
7891

.github/workflows/test.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,28 @@ jobs:
140140
echo "FAIL"
141141
exit 1
142142
fi
143+
- name: Check attack log vhost 2 (modsecurity_disable_error_log off(default))
144+
run: |
145+
if ( grep -q "modsectest2" /usr/local/nginx/logs/error.log ); then
146+
echo "OK"
147+
else
148+
echo "FAIL"
149+
exit 1
150+
fi
151+
- name: Check attack log vhost 3 (modsecurity_disable_error_log on)
152+
run: |
153+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsecurity_disable_error_log" "http://localhost/?q=attack")
154+
if [ "${status}" == "403" ]; then
155+
if ( grep -q "modsecurity_disable_error_log" /usr/local/nginx/logs/error.log ); then
156+
echo "FAIL"
157+
exit 1
158+
else
159+
echo "OK"
160+
fi
161+
else
162+
echo "FAIL"
163+
exit 1
164+
fi
143165
- name: Start Nginx with redir
144166
run: |
145167
sudo killall nginx
@@ -320,4 +342,4 @@ jobs:
320342
md temp
321343
set TEMP=temp
322344
set TEST_NGINX_BINARY=..\objs\nginx.exe
323-
prove modsecurity*.t
345+
prove modsecurity*.t

0 commit comments

Comments
 (0)