|
24 | 24 | ngx_int_t ngx_http_modsecurity_process_connection(ngx_http_request_t *r,
|
25 | 25 | ngx_http_modsecurity_ctx_t *ctx);
|
26 | 26 | ngx_int_t ngx_http_modsecurity_process_url(ngx_http_request_t *r,
|
27 |
| - ngx_http_modsecurity_ctx_t *ctx); |
| 27 | + ngx_http_modsecurity_ctx_t *ctx, |
| 28 | + const char *uri, const char *method, const char *http_version); |
28 | 29 | ngx_int_t ngx_http_modsecurity_process_req_header(ngx_http_request_t *r,
|
29 | 30 | ngx_http_modsecurity_ctx_t *ctx);
|
30 | 31 | ngx_int_t ngx_http_modsecurity_process_empty_req_body(ngx_http_request_t *r,
|
@@ -61,7 +62,7 @@ ngx_http_modsecurity_rewrite_handler(ngx_http_request_t *r)
|
61 | 62 | return rc;
|
62 | 63 | }
|
63 | 64 |
|
64 |
| - rc = ngx_http_modsecurity_process_url(r, ctx); |
| 65 | + rc = ngx_http_modsecurity_process_url(r, ctx, NULL, NULL, NULL); |
65 | 66 | if (rc > 0) {
|
66 | 67 | return rc;
|
67 | 68 | }
|
@@ -137,36 +138,47 @@ ngx_http_modsecurity_process_connection(ngx_http_request_t *r,
|
137 | 138 |
|
138 | 139 | ngx_int_t
|
139 | 140 | ngx_http_modsecurity_process_url(ngx_http_request_t *r,
|
140 |
| - ngx_http_modsecurity_ctx_t *ctx) |
| 141 | + ngx_http_modsecurity_ctx_t *ctx, |
| 142 | + const char *uri, const char *method, const char *http_version) |
141 | 143 | {
|
142 | 144 | ngx_pool_t *old_pool;
|
143 |
| - const char *http_version, *n_uri, *n_method; |
144 |
| - |
145 |
| - switch (r->http_version) { |
146 |
| - case NGX_HTTP_VERSION_9 : |
147 |
| - http_version = "0.9"; |
148 |
| - break; |
149 |
| - case NGX_HTTP_VERSION_10 : |
150 |
| - http_version = "1.0"; |
151 |
| - break; |
152 |
| - case NGX_HTTP_VERSION_11 : |
153 |
| - http_version = "1.1"; |
154 |
| - break; |
155 |
| - case NGX_HTTP_VERSION_20 : |
156 |
| - http_version = "2.0"; |
157 |
| - break; |
158 |
| - default : |
159 |
| - http_version = "1.0"; |
160 |
| - break; |
| 145 | + |
| 146 | + if (http_version == NULL) { |
| 147 | + switch (r->http_version) { |
| 148 | + case NGX_HTTP_VERSION_9 : |
| 149 | + http_version = "0.9"; |
| 150 | + break; |
| 151 | + case NGX_HTTP_VERSION_10 : |
| 152 | + http_version = "1.0"; |
| 153 | + break; |
| 154 | + case NGX_HTTP_VERSION_11 : |
| 155 | + http_version = "1.1"; |
| 156 | + break; |
| 157 | + case NGX_HTTP_VERSION_20 : |
| 158 | + http_version = "2.0"; |
| 159 | + break; |
| 160 | + default : |
| 161 | + http_version = "1.0"; |
| 162 | + break; |
| 163 | + } |
161 | 164 | }
|
162 | 165 |
|
163 |
| - n_uri = ngx_str_to_char(r->unparsed_uri, r->pool); |
164 |
| - n_method = ngx_str_to_char(r->method_name, r->pool); |
165 |
| - if (n_uri == (char*)-1 || n_method == (char*)-1) { |
166 |
| - return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| 166 | + if (uri == NULL) { |
| 167 | + uri = ngx_str_to_char(r->unparsed_uri, r->pool); |
| 168 | + if (uri == NULL) { |
| 169 | + return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| 170 | + } |
167 | 171 | }
|
| 172 | + |
| 173 | + if (method == NULL) { |
| 174 | + method = ngx_str_to_char(r->method_name, r->pool); |
| 175 | + if (method == NULL) { |
| 176 | + return NGX_HTTP_INTERNAL_SERVER_ERROR; |
| 177 | + } |
| 178 | + } |
| 179 | + |
168 | 180 | old_pool = ngx_http_modsecurity_pcre_malloc_init(r->pool);
|
169 |
| - msc_process_uri(ctx->modsec_transaction, n_uri, n_method, http_version); |
| 181 | + msc_process_uri(ctx->modsec_transaction, uri, method, http_version); |
170 | 182 | ngx_http_modsecurity_pcre_malloc_done(old_pool);
|
171 | 183 |
|
172 | 184 | dd("Processing intervention with the transaction information filled in (uri, method and version)");
|
|
0 commit comments