CtrlK
BlogDocsLog inGet started
Tessl Logo

nicholasjackson/opa-rego-language

Rego is the declarative policy language used by Open Policy Agent (OPA). This tile covers writing and testing Rego policies for Kubernetes admission control, Terraform and infrastructure-as-code plan validation, Docker container authorization, HTTP API authorization, RBAC and role-based access control, data filtering, metadata annotations with opa inspect, and OPA policy testing with opa test.

99

1.19x

Quality

Pending

Does it follow best practices?

Impact

99%

1.19x

Average score across 31 eval scenarios

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

task.mdevals/scenario-11/

Metadata: Runtime Annotation Access

Write a Rego policy for Kubernetes pod admission that reads its own rule metadata at runtime and includes the severity level from annotations in the violation output.

The violation output must be a structured object (not a plain string) containing both the severity from the rule's custom.severity annotation and a message field.

Input

{
  "request": {
    "kind": {"kind": "Pod"},
    "object": {
      "metadata": {"name": "my-pod"},
      "spec": {
        "containers": [
          {"name": "app", "securityContext": {"privileged": true}}
        ]
      }
    }
  }
}

Expected behaviour

  • Deny privileged containers
  • The violation must be a structured object: {"severity": "HIGH", "message": "..."}
  • The severity value comes from the rule's own # METADATA annotation (custom.severity: HIGH), accessed via rego.metadata.rule() at runtime — not hardcoded

Also write a _test.rego file that tests the policy with both a passing case and a failing case.

README.md

rules.md

tile.json