Skip to content

Commit 585dc82

Browse files
committed
directive changed as modsecurity_use_error_log
- tests are changed with new directive name - nginx.conf updated with new directive name - added doc Signed-off-by: Fatih USTA <[email protected]>
1 parent 0d58757 commit 585dc82

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

.github/nginx/nginx.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ http {
7676

7777
server {
7878
listen 80;
79-
server_name modsecurity_disable_error_log;
79+
server_name modsecurity_use_error_log_off;
8080

8181
modsecurity on;
82-
modsecurity_disable_error_log on;
82+
modsecurity_use_error_log off;
8383
modsecurity_rules_file /home/runner/work/ModSecurity-nginx/ModSecurity-nginx/ModSecurity-nginx/.github/nginx/modsecurity.conf;
8484
root /usr/local/nginx/html/;
8585

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,19 +140,19 @@ jobs:
140140
echo "FAIL"
141141
exit 1
142142
fi
143-
- name: Check attack log vhost 2 (modsecurity_disable_error_log off(default))
143+
- name: Check attack log vhost 2 (modsecurity_use_error_log on(default))
144144
run: |
145145
if ( grep -q "modsectest2" /usr/local/nginx/logs/error.log ); then
146146
echo "OK"
147147
else
148148
echo "FAIL"
149149
exit 1
150150
fi
151-
- name: Check attack log vhost 3 (modsecurity_disable_error_log on)
151+
- name: Check attack log vhost 3 (modsecurity_use_error_log off)
152152
run: |
153-
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsecurity_disable_error_log" "http://localhost/?q=attack")
153+
status=$(curl -sSo /dev/null -w %{http_code} -I -X GET -H "Host: modsecurity_use_error_log_off" "http://localhost/?q=attack")
154154
if [ "${status}" == "403" ]; then
155-
if ( grep -q "modsecurity_disable_error_log" /usr/local/nginx/logs/error.log ); then
155+
if ( grep -q "modsecurity_use_error_log_off" /usr/local/nginx/logs/error.log ); then
156156
echo "FAIL"
157157
exit 1
158158
else

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,15 @@ using the same unique identificator.
175175

176176
String can contain variables.
177177

178+
modsecurity_use_error_log
179+
-----------
180+
**syntax:** *modsecurity_use_error_log on | off*
181+
182+
**context:** *http, server, location*
183+
184+
**default:** *on*
185+
186+
Turns on or off ModSecurity error log functionality.
178187

179188
# Contributing
180189

src/ngx_http_modsecurity_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ typedef struct {
118118
void *rules_set;
119119

120120
ngx_flag_t enable;
121-
ngx_flag_t disable_error_log;
121+
ngx_flag_t use_error_log;
122122
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
123123
ngx_flag_t sanity_checks_enabled;
124124
#endif

src/ngx_http_modsecurity_module.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_re
166166
return NGX_HTTP_INTERNAL_SERVER_ERROR;
167167
}
168168

169-
// logging to nginx error log can be disable by setting `modsecurity_disable_error_log` to on
170-
if (!mcf->disable_error_log) {
169+
// logging to nginx error log can be disable by setting `modsecurity_use_error_log` to off
170+
if (mcf->use_error_log) {
171171
log = intervention.log;
172172
if (intervention.log == NULL) {
173173
log = "(no log message was specified)";
@@ -522,11 +522,11 @@ static ngx_command_t ngx_http_modsecurity_commands[] = {
522522
NULL
523523
},
524524
{
525-
ngx_string("modsecurity_disable_error_log"),
525+
ngx_string("modsecurity_use_error_log"),
526526
NGX_HTTP_LOC_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_MAIN_CONF|NGX_CONF_FLAG,
527527
ngx_conf_set_flag_slot,
528528
NGX_HTTP_LOC_CONF_OFFSET,
529-
offsetof(ngx_http_modsecurity_conf_t, disable_error_log),
529+
offsetof(ngx_http_modsecurity_conf_t, use_error_log),
530530
NULL
531531
},
532532
ngx_null_command
@@ -740,7 +740,7 @@ ngx_http_modsecurity_create_conf(ngx_conf_t *cf)
740740
conf->rules_set = msc_create_rules_set();
741741
conf->pool = cf->pool;
742742
conf->transaction_id = NGX_CONF_UNSET_PTR;
743-
conf->disable_error_log = NGX_CONF_UNSET;
743+
conf->use_error_log = NGX_CONF_UNSET;
744744
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
745745
conf->sanity_checks_enabled = NGX_CONF_UNSET;
746746
#endif
@@ -780,7 +780,7 @@ ngx_http_modsecurity_merge_conf(ngx_conf_t *cf, void *parent, void *child)
780780

781781
ngx_conf_merge_value(c->enable, p->enable, 0);
782782
ngx_conf_merge_ptr_value(c->transaction_id, p->transaction_id, NULL);
783-
ngx_conf_merge_value(c->disable_error_log, p->disable_error_log, 0);
783+
ngx_conf_merge_value(c->use_error_log, p->use_error_log, 1);
784784
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
785785
ngx_conf_merge_value(c->sanity_checks_enabled, p->sanity_checks_enabled, 0);
786786
#endif

0 commit comments

Comments
 (0)