mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-29 19:05:27 +00:00
Fix regression in wildcard matches in In/AnyIn operators (#3686)
Signed-off-by: Sambhav Kothari <skothari44@bloomberg.net> Co-authored-by: Vyankatesh Kudtarkar <vyankateshkd@gmail.com>
This commit is contained in:
parent
8c930134ef
commit
25badfe4fb
4 changed files with 24 additions and 2 deletions
pkg/engine/variables/operator
test/cli/test/context-entries
|
@ -63,7 +63,7 @@ func anyKeyExistsInArray(key string, value interface{}, log logr.Logger) (invali
|
|||
|
||||
case []interface{}:
|
||||
for _, val := range valuesAvailable {
|
||||
if wildcard.Match(fmt.Sprint(val), key) {
|
||||
if wildcard.Match(fmt.Sprint(val), key) || wildcard.Match(key, fmt.Sprint(val)) {
|
||||
return false, true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ func keyExistsInArray(key string, value interface{}, log logr.Logger) (invalidTy
|
|||
|
||||
case []interface{}:
|
||||
for _, val := range valuesAvailable {
|
||||
if wildcard.Match(fmt.Sprint(val), key) {
|
||||
if wildcard.Match(fmt.Sprint(val), key) || wildcard.Match(key, fmt.Sprint(val)) {
|
||||
return false, true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,3 +44,8 @@ results:
|
|||
resource: example
|
||||
kind: Pod
|
||||
result: pass
|
||||
- policy: example
|
||||
rule: wildcard-match
|
||||
resource: example
|
||||
kind: Pod
|
||||
result: pass
|
||||
|
|
|
@ -146,3 +146,20 @@ spec:
|
|||
- key: "{{ to_string(obj.notName) }}"
|
||||
operator: NotEquals
|
||||
value: 'null'
|
||||
- name: wildcard-match
|
||||
context:
|
||||
- name: obj
|
||||
variable:
|
||||
value:
|
||||
- A=ATest
|
||||
- B=BTest
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- Pod
|
||||
validate:
|
||||
deny:
|
||||
conditions:
|
||||
- key: "A=*"
|
||||
operator: AnyNotIn
|
||||
value: "{{ obj }}"
|
||||
|
|
Loading…
Add table
Reference in a new issue