Skip to content

Commit 5a0cd92

Browse files
author
Felipe Zimmerle
committed
Refactoring on the SecRules load schema
Among of other things, this refactoring will allow: - Load of the configuration in the order that they are stated in the configuration file. - Better configuration hierarchy, allowing SecRules to be specified inside locations of locations. - Accepts global configurations. 12.patch
1 parent 42be273 commit 5a0cd92

8 files changed

+210
-215
lines changed

src/ngx_http_modsecurity_body_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
3939
ngx_chain_t *chain = in;
4040
ngx_http_modsecurity_ctx_t *ctx = NULL;
4141
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
42-
ngx_http_modsecurity_loc_conf_t *loc_cf = NULL;
42+
ngx_http_modsecurity_conf_t *loc_cf = NULL;
4343
ngx_list_part_t *part = &r->headers_out.headers.part;
4444
ngx_table_elt_t *data = part->elts;
4545
ngx_uint_t i = 0;

src/ngx_http_modsecurity_common.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,23 +56,13 @@ typedef struct {
5656

5757

5858
typedef struct {
59-
ngx_str_t rules;
60-
ngx_str_t rules_file;
61-
ngx_str_t rules_remote_server;
62-
ngx_str_t rules_remote_key;
59+
ModSecurity *modsec;
6360

6461
ngx_flag_t enable;
6562
ngx_flag_t sanity_checks_enabled;
66-
ngx_int_t id;
6763

6864
Rules *rules_set;
69-
} ngx_http_modsecurity_loc_conf_t;
70-
71-
72-
typedef struct {
73-
ModSecurity *modsec;
74-
75-
} ngx_http_modsecurity_main_conf_t;
65+
} ngx_http_modsecurity_conf_t;
7666

7767

7868
typedef ngx_int_t (*ngx_http_modsecurity_resolv_header_pt)(ngx_http_request_t *r, ngx_str_t name, off_t offset);

src/ngx_http_modsecurity_header_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ ngx_http_modescurity_store_ctx_header(ngx_http_request_t *r, ngx_str_t *name, ng
105105
{
106106
ngx_http_modsecurity_ctx_t *ctx = NULL;
107107
ngx_http_modsecurity_header_t *hdr = NULL;
108-
ngx_http_modsecurity_loc_conf_t *loc_cf = NULL;
108+
ngx_http_modsecurity_conf_t *loc_cf = NULL;
109109

110110
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity_module);
111111
if (ctx == NULL || ctx->sanity_headers_out == NULL) {

src/ngx_http_modsecurity_log.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ ngx_int_t
3838
ngx_http_modsecurity_log_handler(ngx_http_request_t *r)
3939
{
4040
ngx_http_modsecurity_ctx_t *ctx = NULL;
41-
ngx_http_modsecurity_loc_conf_t *cf;
41+
ngx_http_modsecurity_conf_t *cf;
4242
ngx_pool_t *old_pool;
4343

4444
dd("catching a new _log_ phase handler");

0 commit comments

Comments
 (0)