mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 19:24:29 +03:00
Added cleanup handler for finalize request
This commit is contained in:
@@ -75,6 +75,8 @@ 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);
|
static int ngx_http_modsecurity_drop_action(request_rec *r);
|
||||||
|
|
||||||
|
static void ngx_http_modsecurity_cleanup(void *data);
|
||||||
|
|
||||||
/* command handled by the module */
|
/* command handled by the module */
|
||||||
static ngx_command_t ngx_http_modsecurity_commands[] = {
|
static ngx_command_t ngx_http_modsecurity_commands[] = {
|
||||||
{ ngx_string("ModSecurityConfig"),
|
{ ngx_string("ModSecurityConfig"),
|
||||||
@@ -451,6 +453,7 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
|
|||||||
ngx_uint_t i;
|
ngx_uint_t i;
|
||||||
ngx_int_t rc;
|
ngx_int_t rc;
|
||||||
void **loc_conf;
|
void **loc_conf;
|
||||||
|
ngx_pool_cleanup_t *cln;
|
||||||
|
|
||||||
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "modSecurity: handler");
|
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "modSecurity: handler");
|
||||||
|
|
||||||
@@ -538,6 +541,14 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
|
|||||||
apr_table_setn(ctx->req->subprocess_env, "UNIQUE_ID", "12345");
|
apr_table_setn(ctx->req->subprocess_env, "UNIQUE_ID", "12345");
|
||||||
/* actually, we need ctx only for POST request body handling - don't like this part */
|
/* actually, we need ctx only for POST request body handling - don't like this part */
|
||||||
apr_table_setn(ctx->req->notes, NOTE_NGINX_REQUEST_CTX, (const char *) ctx);
|
apr_table_setn(ctx->req->notes, NOTE_NGINX_REQUEST_CTX, (const char *) ctx);
|
||||||
|
|
||||||
|
/* add cleanup */
|
||||||
|
cln = ngx_pool_cleanup_add(r->pool, 0);
|
||||||
|
if (cln == NULL) {
|
||||||
|
return NGX_ERROR;
|
||||||
|
}
|
||||||
|
cln->data = ctx;
|
||||||
|
cln->handler = ngx_http_modsecurity_cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
// r->keepalive = 0;
|
// r->keepalive = 0;
|
||||||
@@ -600,6 +611,16 @@ ngx_http_modsecurity_handler(ngx_http_request_t *r)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
ngx_http_modsecurity_cleanup(void *data)
|
||||||
|
{
|
||||||
|
ngx_http_modsecurity_ctx_t *ctx = data;
|
||||||
|
|
||||||
|
if (ctx->req != NULL) {
|
||||||
|
(void) modsecFinishRequest(ctx->req);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ngx_http_modsecurity_request_body_handler(ngx_http_request_t *r)
|
ngx_http_modsecurity_request_body_handler(ngx_http_request_t *r)
|
||||||
|
Reference in New Issue
Block a user