mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Handle undefined values correctly in ordered-else. Previously an undefined value in one of the blocks could cause the entire rule to evaluate to undefined. Handle undefined values correctly in generic rule refs to prevent them from propagating to output. Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
committed by
GitHub
parent
fec6f8f8b4
commit
edd0ccca5b
@@ -2,17 +2,34 @@
|
||||
# Licensed under the MIT License.
|
||||
|
||||
cases:
|
||||
- note: else without body
|
||||
# - note: else without body
|
||||
# data: {}
|
||||
# modules:
|
||||
# - |
|
||||
# package test
|
||||
# x = 4 {
|
||||
# false
|
||||
# } else = 5
|
||||
|
||||
# y = 6
|
||||
# query: data.test
|
||||
# want_result:
|
||||
# x: 5
|
||||
# y: 6
|
||||
- note: undefined values being assigned
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
x = 4 {
|
||||
false
|
||||
} else = 5
|
||||
|
||||
y = 6
|
||||
|
||||
import rego.v1
|
||||
|
||||
x := data.y if {
|
||||
true
|
||||
} else := 2 if {
|
||||
true
|
||||
}
|
||||
query: data.test
|
||||
want_result:
|
||||
x: 5
|
||||
y: 6
|
||||
x: 2
|
||||
|
||||
|
||||
26
tests/interpreter/cases/rule/generic.yaml
Normal file
26
tests/interpreter/cases/rule/generic.yaml
Normal file
@@ -0,0 +1,26 @@
|
||||
# Copyright (c) Microsoft Corporation.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
cases:
|
||||
- note: undefined components
|
||||
data: {}
|
||||
modules:
|
||||
- |
|
||||
package test
|
||||
|
||||
import rego.v1
|
||||
|
||||
principal := input.principal
|
||||
action := input.action
|
||||
|
||||
p[principal][action] := 1 if {
|
||||
some a in []
|
||||
}
|
||||
|
||||
q[principal][action] contains 1 if {
|
||||
some a in []
|
||||
}
|
||||
query: data.test
|
||||
want_result:
|
||||
p: {}
|
||||
q: {}
|
||||
Reference in New Issue
Block a user