Rego code - Help Needed!!! #288
Answered
by
srenatus
sbalakrishn
asked this question in
OPA and Rego
-
Hi Can someone help solve this for me Playground : Please check this link below I need to evaluate the JSON
|
Beta Was this translation helpful? Give feedback.
Answered by
srenatus
Oct 19, 2022
Replies: 1 comment 8 replies
-
👉 https://play.openpolicyagent.org/p/0W4YtEmda0 I gave it a go here: package example
import future.keywords.every
import future.keywords.if
import future.keywords.in
default allow_update_cname := false
allow_update_cname if some resource in resources("CNAME")
default allow_update_a := false
allow_update_a if some resource in resources("A")
default allow_update_ns := false
allow_update_ns if some resource in resources("NS")
default allow_update_caa := false
allow_update_caa if some resource in resources("CAA")
resources(type) := {r | some r in input[""]; r.type == type}
deny[msg] {
some resource in resources("MX")
msg := sprintf("dns_record '%v' Our policy recommends no changes to MX records", [resource])
} The policy there evaluates to {
"allow_update_a": true,
"allow_update_caa": true,
"allow_update_cname": false,
"allow_update_ns": true,
"deny": [
"dns_record '{\"type\": \"MX\", \"values\": [{\"exchange\": \"aspmx.l.google.com.\", \"preference\": 1}, {\"exchange\": \"alt1.aspmx.l.google.com.\", \"preference\": 5}, {\"exchange\": \"alt2.aspmx.l.google.com.\", \"preference\": 5}, {\"exchange\": \"alt3.aspmx.l.google.com.\", \"preference\": 10}, {\"exchange\": \"alt4.aspmx.l.google.com.\", \"preference\": 10}]}' Our policy recommends no changes to MX records"
]
}
|
Beta Was this translation helpful? Give feedback.
8 replies
Answer selected by
srenatus
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👉 https://play.openpolicyagent.org/p/0W4YtEmda0 I gave it a go here: