ModSecurity 规则中感叹号的含义

Meaning of exclamation mark in ModSecurity Rules

谁能帮我解释感叹号在像这样的 ModSecurity 规则中的作用:

SecRuleUpdateTargetById 932100 "!ARGS:foo"

在阅读和制定该规则时,人们如何阅读和解释 "!ARGS:foo""ARGS:foo"

在测试差异时,带有感叹号的规则通过在存在该参数时不应用该规则 ID 为我提供了我想要的结果。

我在此处参考了文档 https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#args_names 并尝试从其他示例中收集我能收集到的内容,但可能会使用不同的措辞来分解它。

非常感谢您的帮助!

------编辑------
谢谢你到目前为止的解释。

为什么在BEFORE排除项中写的"equivalent"规则没有"exclamation mark"?

SecRule REQUEST_URI "@streq /my/endpoint" \
    "id:0003, \
    phase:2, \
    pass, \
    nolog, \
    ctl:ruleRemoveTargetById=931130;ARGS:foo"

意思是“不”,在本例中用于排除某些参数。

所以如下:

SecRuleUpdateTargetById 932100 "!ARGS:foo"

更改规则 932100 以查看规则中指定的所有目标,参数 foo 除外。

通常这样做是因为参数 foo 经常导致此规则错误触发。因此,您的选择是完全关闭此规则,或将此参数排除在该规则检查之外。后者通常是更好的选择,因为它意味着规则仍然适用于其他论点,因此仍在证明其大部分保护。

How come the "equivalent" rule written in the BEFORE exclusions [(ctl:ruleRemoveTargetById)] does not have the "exclamation mark"?

那是因为它们并不严格“等价”。 SecRuleUpdateTargetById 通过添加到规则来更新目标,而 ctl:ruleRemoveTargetById 从目标中删除位。如果有 SecRuleRemoveTargetById 那么它们会更等价,但没有。事实上 ModSecurity Reference manual 甚至解决了这个问题:

  1. ruleRemoveTargetById - since this action is used to just remove targets, users don't need to use the char ! before the target list.

为什么他们决定实施 ctl:ruleRemoveTargetById 而不是 ctl:ruleUpdateTargetById,我不能说。