mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Added drop action for nginx
This commit is contained in:
@@ -81,6 +81,8 @@ static char *ngx_http_modsecurity_add_handler(ngx_conf_t *cf, ngx_command_t *cmd
|
||||
static char *ngx_http_modsecurity_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
|
||||
static ngx_int_t ngx_http_modsecurity_pass_to_backend(ngx_http_request_t *r);
|
||||
|
||||
static int ngx_http_modsecurity_drop_action(request_rec *r);
|
||||
|
||||
/* command handled by the module */
|
||||
static ngx_command_t ngx_http_modsecurity_commands[] = {
|
||||
{ ngx_string("ModSecurityConfig"),
|
||||
@@ -223,6 +225,8 @@ ngx_http_modsecurity_init_process(ngx_cycle_t *cycle)
|
||||
|
||||
modsecSetLogHook(cycle->log, modsecLog);
|
||||
|
||||
modsecSetDropAction(ngx_http_modsecurity_drop_action);
|
||||
|
||||
modsecInit();
|
||||
/* config was already parsed in master process */
|
||||
// modsecStartConfig();
|
||||
@@ -1094,3 +1098,16 @@ ngx_http_modsecurity_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
|
||||
|
||||
return NGX_CONF_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
ngx_http_modsecurity_drop_action(request_rec *r)
|
||||
{
|
||||
ngx_http_modsecurity_ctx_t *ctx;
|
||||
ctx = (ngx_http_modsecurity_ctx_t *) apr_table_get(r->notes, NOTE_NGINX_REQUEST_CTX);
|
||||
|
||||
if (ctx == NULL) {
|
||||
return -1;
|
||||
}
|
||||
ctx->r->connection->error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user