Skip to content
This repository has been archived by the owner on Nov 8, 2023. It is now read-only.

Commit

Permalink
Fixed issue #457 (#482)
Browse files Browse the repository at this point in the history
* Setup json scanning to allow for arrays as the parent type

* rather than assuming an object, just validate any json value

* keep as close to the original as possible

* Since all the validation comes within val we don't need to increment off. Initial tests seemed to work

* Fix formatting issue
  • Loading branch information
squedgy authored Feb 12, 2020
1 parent e9c3dd7 commit 15e58c3
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions naxsi_src/naxsi_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,17 +305,10 @@ ngx_http_dummy_json_parse(ngx_http_request_ctx_t *ctx,
js->loc_cf = ngx_http_get_module_loc_conf(r, ngx_http_naxsi_module);
js->main_cf = ngx_http_get_module_main_conf(r, ngx_http_naxsi_module);

if (ngx_http_nx_json_seek(js, '{')) {
ngx_http_apply_rulematch_v_n(&nx_int__invalid_json, ctx, r, NULL, NULL, BODY, 1, 0);
return ;
}
if (ngx_http_nx_json_obj(js) != NGX_OK) {
ngx_http_apply_rulematch_v_n(&nx_int__invalid_json, ctx, r, NULL, NULL, BODY, 1, 0);
NX_DEBUG(_debug_json, NGX_LOG_DEBUG_HTTP, js->r->connection->log, 0, "nx_json_obj returned error, apply invalid_json.");

if (ngx_http_nx_json_val(js) != NGX_OK) {
ngx_http_apply_rulematch_v_n(&nx_int__invalid_json, ctx, r, NULL, NULL, BODY, 1, 0);
NX_DEBUG(_debug_json, NGX_LOG_DEBUG_HTTP, js->r->connection->log, 0, "nx_json_val returned error, apply invalid_json.");
}
/* we are now on closing bracket, check for garbage. */
js->off++;
ngx_http_nx_json_forward(js);
if (js->off != js->len)
ngx_http_apply_rulematch_v_n(&nx_int__invalid_json, ctx, r, NULL, NULL, BODY, 1, 0);
Expand Down

0 comments on commit 15e58c3

Please sign in to comment.