CtrlK
BlogDocsLog inGet started
Tessl Logo

nitinjain999/platform-skills

Production-grade platform engineering handbook — Kubernetes, Terraform, Flux CD, GitHub Actions, AWS, and more.

67

Quality

84%

Does it follow best practices?

Impact

No eval scenarios have been run

SecuritybySnyk

Passed

No known issues

Overview
Quality
Evals
Security
Files

README.mdexamples/demo/opa-policy-review/

Demo: OPA Policy Review

Status: Stable

An OPA/Rego admission policy with a critical default-allow flaw. Platform-skills catches it and generates a production-safe replacement.

What's wrong with bad.rego

FindingSeverityRisk
default allow = true — allow-by-defaultCriticalAny pod not explicitly denied passes — policy is opt-out, not opt-in
Uses allow = false reassignmentHighRego v0 style; undefined behaviour when multiple rules conflict
Only checks privileged containersHighRoot containers, missing limits, hostNetwork all bypass the policy
No deny set — single booleanMediumCannot return meaningful error messages to the user
No import rego.v1MediumDeprecated syntax; will break in OPA ≥1.0

What changed in fixed.rego

  • default allow := false — deny-by-default; nothing passes unless explicitly permitted
  • deny contains msg set — each violation returns a human-readable message
  • Covers 4 controls: privileged, runAsNonRoot, resource limits, hostNetwork
  • import rego.v1 — explicit Rego v1 syntax, forward-compatible
  • any_violation helper — single allow rule, no conflicting reassignments

Blast radius of bad.rego

  • A pod with runAsNonRoot: false and no memory limit deploys to production unblocked
  • hostNetwork: true workload gets access to node network — lateral movement risk
  • Policy gives a false sense of security — teams think they're protected, they're not

Validation

# Install conftest
brew install conftest

# Test the fixed policy against a violating pod spec
conftest test --policy fixed.rego --namespace kubernetes.admission ./test-pod.yaml

# Lint with Regal
brew install styrainc/packages/regal
regal lint fixed.rego

Try it yourself

Use $platform-skills to review this OPA/Rego admission policy for correctness.
Check: default deny, rule conflicts, coverage gaps, Rego v1 syntax, and unit test coverage.

examples

demo

opa-policy-review

BEFORE_AFTER.md

CHANGELOG.md

CODE_OF_CONDUCT.md

COMMANDS.md

CONTRIBUTING.md

EDITOR_INTEGRATIONS.md

GETTING_STARTED.md

HOW_IT_WORKS.md

install.sh

INSTALLATION.md

LAUNCH.md

PROMPTS.md

QUICKSTART.md

README.md

renovate.json

SECURITY.md

SKILL.md

tessl.json

tile.json