File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ LoadModule security2_module /usr/lib/apache2/modules/mod_security2.so
44 SecDataDir /var/cache/modsecurity
55 Include /etc/apache2/modsecurity.conf
66</IfModule>
7+
8+ SecAuditLog /var/log/apache2/modsec_audit.log
Original file line number Diff line number Diff line change @@ -45,10 +45,18 @@ jobs:
4545 sudo cp unicode.mapping /etc/apache2/
4646 sudo mkdir -p /var/cache/modsecurity
4747 sudo chown -R www-data:www-data /var/cache/modsecurity
48+ - name : first check config (to get syntax errors)
49+ run : sudo apachectl configtest
4850 - name : start apache with module
51+ run : sudo systemctl restart apache2.service
52+ - name : Search for errors/warnings in error log
4953 run : |
50- sudo systemctl restart apache2.service
51- sudo cat /var/log/apache2/error.log
54+ # '|| :' handles the case grep doesn't match, otherwise the script exits with 1 (error)
55+ errors=$(grep -E ':(?error|warn)[]]' /var/log/apache2/error.log) || :
56+ if [[ -z "${errors}" ]]; then exit 0; fi
57+ echo "::error:: Found errors/warnings in error.log"
58+ echo "${errors}"
59+ exit 1
5260 - name : Check error.log
5361 run : |
5462 # Send requests & check log format
6068 grep -F ModSecurity < /var/log/apache2/error.log | grep -vP "^\[[^\]]+\] \[security2:[a-z]+\] \[pid [0-9]+:tid [0-9]+\] (?:\[client [0-9.:]+\] )?ModSecurity" || exit 0
6169 # grep -v succeeded => found some lines with invalid format
6270 exit 1
71+ - name : Show httpd error log
72+ if : always()
73+ run : sudo cat /var/log/apache2/error.log
74+ - name : Show mod_security2 audit log
75+ if : always()
76+ run : sudo cat /var/log/apache2/modsec_audit.log
You can’t perform that action at this time.
0 commit comments