Skip to content

Commit

Permalink
policy: fixup simple default policy
Browse files Browse the repository at this point in the history
The OPA linter seems to have updated and now complains if we don't use
an if before our blocks.

This is unrelated to the rest of this PR.

Signed-off-by: Tobin Feldman-Fitzthum <[email protected]>
  • Loading branch information
fitzthum committed Dec 20, 2024
1 parent 8ffcff3 commit 89754d0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions attestation-service/src/token/simple_default_policy.rego
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import future.keywords.every

default allow = false

allow {
allow if {
every k, v in input {
# `judge_field`: Traverse each key value pair in the input and make policy judgments on it.
#
Expand All @@ -44,7 +44,7 @@ allow {
}
}

judge_field(input_key, input_value) {
judge_field(input_key, input_value) if {
has_key(data.reference, input_key)
reference_value := data.reference[input_key]

Expand All @@ -57,16 +57,16 @@ judge_field(input_key, input_value) {
match_value(reference_value, input_value)
}

judge_field(input_key, input_value) {
judge_field(input_key, input_value) if {
not has_key(data.reference, input_key)
}

match_value(reference_value, input_value) {
match_value(reference_value, input_value) if {
not is_array(reference_value)
input_value == reference_value
}

match_value(reference_value, input_value) {
match_value(reference_value, input_value) if {
is_array(reference_value)

# `array_include`: judge the input value with the values in the array.
Expand All @@ -78,16 +78,16 @@ match_value(reference_value, input_value) {
array_include(reference_value, input_value)
}

array_include(reference_value_array, input_value) {
array_include(reference_value_array, input_value) if {
reference_value_array == []
}

array_include(reference_value_array, input_value) {
array_include(reference_value_array, input_value) if {
reference_value_array != []
some i
reference_value_array[i] == input_value
}

has_key(m, k) {
has_key(m, k) if {
_ = m[k]
}

0 comments on commit 89754d0

Please sign in to comment.