Azure / Azure/template-analyzer

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

Open
#252 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
C#
Stars
143
Forks
47
PR merge metrics
No merged PRs in 30d

Description

### Describe the bug

If a rule has something like the following:
```js
"anyOf": [
{
"not": {
"path": "notDefinedProperty",
"in": [1, 2]
}
},
{
"not": {
"path": "notDefinedProperty",
"regex": "someValue"
}
}
]
```
the rule will incorrectly fail for this JSON:
```js
{
"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_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.