mirror of
https://github.com/microsoft/regorus.git
synced 2026-08-05 02:16:11 +00:00
Agent-Logs-Url: https://github.com/microsoft/regorus/sessions/992f5462-7cc4-4e4f-bd7f-799308063765 Co-authored-by: anakrish <35780660+anakrish@users.noreply.github.com>
242 lines
4.4 KiB
YAML
242 lines
4.4 KiB
YAML
# Copyright (c) Microsoft Corporation.
|
|
# Licensed under the MIT License.
|
|
|
|
cases:
|
|
- note: partial_object_iteration_some_in_object_v1
|
|
data: {}
|
|
input:
|
|
x:
|
|
FOO: 1
|
|
BAR: 2
|
|
BAZ: 3
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] if {
|
|
some k, _ in input.x
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: partial_object_iteration_some_in_array_v1
|
|
data: {}
|
|
input:
|
|
arr: ["FOO", "BAR", "BAZ"]
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[v] if {
|
|
some _, v in input.arr
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: partial_object_iteration_with_filter_v1
|
|
data: {}
|
|
input:
|
|
x:
|
|
FOO: 1
|
|
BAR: 2
|
|
BAZ: 3
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] if {
|
|
some k, _ in input.x
|
|
k != "BAR"
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: partial_object_iteration_input_lookup_future_keywords
|
|
data: {}
|
|
input:
|
|
x:
|
|
FOO: 1
|
|
BAR: 2
|
|
BAZ: 3
|
|
modules:
|
|
- |
|
|
package test
|
|
import future.keywords.if
|
|
|
|
violations[k] if {
|
|
input.x[k]
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: partial_object_multiple_bodies_collect_all_keys_v1
|
|
data: {}
|
|
input:
|
|
primary:
|
|
FOO: 1
|
|
BAR: 2
|
|
secondary:
|
|
BAZ: 3
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] if {
|
|
some k, _ in input.primary
|
|
}
|
|
|
|
violations[k] if {
|
|
some k, _ in input.secondary
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: constant_key_implicit_true_rule_is_complete_v1
|
|
data: {}
|
|
input:
|
|
enabled: true
|
|
other: false
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
p["x"] if {
|
|
input.enabled
|
|
}
|
|
|
|
p["x"] if {
|
|
input.other
|
|
}
|
|
query: data.test.p.x
|
|
want_result: true
|
|
|
|
- note: partial_object_duplicate_keys_same_value_are_ok_v1
|
|
data: {}
|
|
input:
|
|
arr: ["FOO", "FOO", "BAR"]
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[v] if {
|
|
some _, v in input.arr
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
FOO: true
|
|
|
|
- note: partial_object_duplicate_keys_different_values_error_v1
|
|
data: {}
|
|
input:
|
|
entries:
|
|
- k: "FOO"
|
|
v: 1
|
|
- k: "FOO"
|
|
v: 2
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] := v if {
|
|
some entry in input.entries
|
|
k := entry.k
|
|
v := entry.v
|
|
}
|
|
query: data.test.violations
|
|
want_error: "multiple outputs"
|
|
|
|
- note: partial_object_and_partial_set_iteration_coexist_v1
|
|
data: {}
|
|
input:
|
|
x:
|
|
FOO: 1
|
|
BAR: 2
|
|
BAZ: 3
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] if {
|
|
some k, _ in input.x
|
|
}
|
|
|
|
seen contains k if {
|
|
some k, _ in input.x
|
|
}
|
|
|
|
main := {
|
|
"seen": seen,
|
|
"violations": violations,
|
|
}
|
|
query: data.test.main
|
|
want_result:
|
|
seen:
|
|
set!: ["BAR", "BAZ", "FOO"]
|
|
violations:
|
|
BAR: true
|
|
BAZ: true
|
|
FOO: true
|
|
|
|
- note: partial_object_key_bound_in_outer_scope_v1
|
|
data: {}
|
|
input:
|
|
outer:
|
|
FOO: [1, 2]
|
|
BAR: [3]
|
|
BAZ: []
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
violations[k] if {
|
|
some k, arr in input.outer
|
|
some _ in arr
|
|
}
|
|
query: data.test.violations
|
|
want_result:
|
|
BAR: true
|
|
FOO: true
|
|
|
|
- note: complete_rule_same_value_definitions_still_work_v1
|
|
data: {}
|
|
input:
|
|
role: "superuser"
|
|
modules:
|
|
- |
|
|
package test
|
|
import rego.v1
|
|
|
|
allowed if {
|
|
input.role == "admin"
|
|
}
|
|
|
|
allowed if {
|
|
input.role == "superuser"
|
|
}
|
|
query: data.test.allowed
|
|
want_result: true
|