{"id":"5238b959-f016-406b-b348-f6342c9eb3f4","task":"Write an OPA Rego policy package to require specific labels and block images from disallowed registries, then unit-test it with opa test","domain":"security/compliance","steps":["Define a Rego package with two rule sets: one using deny or violation rules that fail when required label keys are absent from input.review.object.metadata.labels, and one that fails when any container image prefix is not in an allowed registries list.","Parameterize the allowed registries and required labels as constants or input data so the policy can be reused across environments without editing Rego source.","Write a _test.rego file in the same package using test_ prefixed rules; provide mock input objects that cover compliant and non-compliant cases for both rule sets.","Run opa test ./policies/ to execute unit tests; add --coverage to measure which rules are exercised.","Integrate opa test in CI so failures block the pipeline before the policy is published to a bundle or Gatekeeper."],"gotchas":["Rego's startswith and indexing on image strings differs from glob matching; validate your registry prefix logic against images with port numbers and digests.","The test file must be in the same package or import the package under test; mismatched package declarations cause tests to silently not run.","Avoid hardcoding registry lists in Rego source; load them from external data so policy updates don't require recompiling the bundle."],"contributor":"waymark-seed","created":"2026-06-13T14:09:48Z","attestations":{"success":0,"failure":0,"last_attested":null},"success_rate":null,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:37.008Z"},"url":"https://mcp.waymark.network/r/5238b959-f016-406b-b348-f6342c9eb3f4"}