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
4
4
SecDataDir /var/cache/modsecurity
5
5
Include /etc/apache2/modsecurity.conf
6
6
</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:
45
45
sudo cp unicode.mapping /etc/apache2/
46
46
sudo mkdir -p /var/cache/modsecurity
47
47
sudo chown -R www-data:www-data /var/cache/modsecurity
48
+ - name : first check config (to get syntax errors)
49
+ run : sudo apachectl configtest
48
50
- name : start apache with module
51
+ run : sudo systemctl restart apache2.service
52
+ - name : Search for errors/warnings in error log
49
53
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
52
60
- name : Check error.log
53
61
run : |
54
62
# Send requests & check log format
60
68
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
61
69
# grep -v succeeded => found some lines with invalid format
62
70
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