Other operators
Let's look at some additional operators that can be used to operate on data. We have already seen the regular expression, simple string comparison and numeral comparison operators earlier, and here we take a look at some additional ones that are available for use.
Set-based pattern matching with @pm and @pmFromFile
We have seen how to write regular expressions that match one of several alternative words. For example, to match red, green
, or blue
we would use the regex (red|green|blue)
. ModSecurity has two "phrase matching" operators that can be used to match a set of words: @pm
and @pmFromFile
.
The @pm
version of our color-matching example would look like this:
SecRule ARGS "@pm red green blue" deny
This will trigger if an argument contains any of the strings red, green
, or blue
. As with the regex operator, a partial match is enough, so a query string of the form ?color=cobaltblue
would trigger a match since the argument value contains the string blue
.
Set-based pattern matching...