Azure/template-analyzer

[BUG] Regex and In operators report incorrectly when inside a "not" expression and evaluated path is missing

JohnathonMohr opened this issue · 0 comments

Describe the bug

If a rule has something like the following:

"anyOf": [
    {
        "not": {
            "path": "notDefinedProperty",
            "in": [1, 2]
        }
    },
    {
        "not": {
            "path": "notDefinedProperty",
            "regex": "someValue"
        }
    }
]

the rule will incorrectly fail for this JSON:

{
    "definedProperty": "anything"
}

Logically, the rule should pass because, even though "notDefinedProperty" is not defined, it still meets the criteria of:

  • does not have a value of 1 or 2
  • does not match the regex of "someValue"

Expected behavior

A path evaluated by "in" and "regex" should pass if they are negated and the path they are evaluating is not defined.

Reproduction Steps

See description.

Environment

No response