mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-08-14 05:45:59 +03:00
nginx: Considering modsec state before apply any rules
For some reason the state of modsec (enable, disable or detecting only) was not being checked under certain circumstances. For instance, while reading the body. This was leading ModSecurity to fail and consequently nginx. This patch added the to standalone implementation mechanism to verify the state that is now verified under the nginx module.
This commit is contained in:
parent
9bf1f6a2b3
commit
fe14d9df4d
@ -1027,6 +1027,10 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
|
||||
return rc;
|
||||
}
|
||||
|
||||
if (modsecContextState(ctx->req) == MODSEC_DISABLED) {
|
||||
return NGX_DECLINED;
|
||||
}
|
||||
|
||||
if (r->method == NGX_HTTP_POST
|
||||
&& modsecIsRequestBodyAccessEnabled(ctx->req) ) {
|
||||
|
||||
|
@ -500,6 +500,16 @@ void modsecSetConfigForIISRequestBody(request_rec *r)
|
||||
msr->txcfg->stream_inbody_inspection = 1;
|
||||
}
|
||||
|
||||
int modsecContextState(request_rec *r)
|
||||
{
|
||||
modsec_rec *msr = retrieve_msr(r);
|
||||
|
||||
if(msr == NULL || msr->txcfg == NULL)
|
||||
return NOT_SET;
|
||||
|
||||
return msr->txcfg->is_enabled;
|
||||
}
|
||||
|
||||
int modsecIsRequestBodyAccessEnabled(request_rec *r)
|
||||
{
|
||||
modsec_rec *msr = retrieve_msr(r);
|
||||
@ -681,3 +691,4 @@ void modsecSetDropAction(int (*func)(request_rec *r)) {
|
||||
const char *modsecIsServerSignatureAvailale(void) {
|
||||
return new_server_signature;
|
||||
}
|
||||
|
||||
|
@ -112,6 +112,8 @@ void modsecSetDropAction(int (*func)(request_rec *r));
|
||||
int modsecIsResponseBodyAccessEnabled(request_rec *r);
|
||||
int modsecIsRequestBodyAccessEnabled(request_rec *r);
|
||||
|
||||
int modsecContextState(request_rec *r);
|
||||
|
||||
void modsecSetConfigForIISRequestBody(request_rec *r);
|
||||
|
||||
const char *modsecIsServerSignatureAvailale(void);
|
||||
|
Loading…
x
Reference in New Issue
Block a user