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-22/

Regal: Boolean Structure — Pod Security Policy

Write a Rego policy in the package kubernetes.security that validates Kubernetes pod specs. The policy should:

  1. Define an allow rule (boolean) that is true only when there are no violations
  2. Collect violations as an incremental set using violations contains msg if { ... } (not a comprehension assigned to a variable)
  3. Add violations for:
    • Any container where securityContext.privileged == true
    • Any container missing resources.limits

Input

{
  "spec": {
    "template": {
      "spec": {
        "containers": [
          {
            "name": "app",
            "securityContext": {"privileged": false},
            "resources": {"limits": {"cpu": "500m", "memory": "128Mi"}}
          }
        ]
      }
    }
  }
}

Expected behaviour

  • Compliant pod (no privileged, has limits) → allow is true, violations is empty
  • Privileged container → violation message containing the container name
  • Container without resource limits → violation message containing the container name

README.md

rules.md

tile.json