A nested json rule question

Brian Chou via mod-security-users <[email protected]> Wed, 6 Jan 2021 18:26:46 +0800
Newsgroups gmane.comp.apache.mod-security.user
Message-ID <CAFVUFcAxc_H9Yv47vJRYXjxqEZvS2ZaU8UmBPNkVZ6_HpUN2Lg@mail.gmail.com>
Hi all,
I'm using mod_security 3.x.
I have a post request which the body contains nested json like below,

*{*
*  "field1": 111,*
*  "field2": [*
*    {*
*      "ff1": 1111*
*    },*
*    {*
*      "ff2": {*
*        "fff1": 11111*
*      }*
*    }*
*  ]*
*}*

I want to check the field exist so that I can make sure the post request is
legal.

So I wrote the rule below:
*SecRule ARGS_NAMES:json.field2.ff2.fff1 "fff1" "id:'200444',phase:3,log"*

Is this correct? Or should I change pattens to *"**json.field2.ff2.fff1"*?

As mentioned above, if I modified the rule to
*SecRule ARGS_NAMES "json.field2.ff2.fff1**"(or "fff1")
"id:'200444',phase:3,log"*

I should get the same result, right?


Best Regards,
Brian

_______________________________________________
mod-security-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mod-security-users
Commercial ModSecurity Rules and Support from Trustwave's SpiderLabs:
http://www.modsecurity.org/projects/commercial/rules/
http://www.modsecurity.org/projects/commercial/support/