Skip to content

Security policies ​

Encyclopedia home · Search machine-readable catalog

CF-091 ​

Reject privileged container fixture

Copy to policy/kubernetes/privileged.rego.

rego
package main

import rego.v1

deny contains msg if {
    input.kind == "Deployment"
    some container in input.spec.template.spec.containers
    container.securityContext.privileged == true
    msg := sprintf("Deployment container %s is privileged", [container.name])
}

Verification. Run Conftest with a known-good and known-bad Deployment. Extend coverage to other workload kinds.

Validation untested. Official reference

CF-092 ​

Immutable container references

Copy to policy/kubernetes/digest.rego.

rego
package main

import rego.v1

deny contains msg if {
    input.kind == "Deployment"
    some container in input.spec.template.spec.containers
    not regex.match("@sha256:[a-f0-9]{64}$", container.image)
    msg := sprintf("Expected digest pin for %s", [container.name])
}

Verification. Verify both image tag rejection and digest acceptance before CI enforcement.

Validation untested. Official reference

CF-093 ​

Reviewed dependency allowlist

Copy to policy/packages.json.

json
["fastapi","pydantic","uvicorn"]

Verification. Pair with CICD-372. Normalize names and track approval for transitive dependencies.

Validation syntax-validated. Official reference

CF-094 ​

Exception metadata fixture

Copy to policy/exceptions.json.

json
[{"id":"LAB-1","owner":"platform-team","expires":"2025-01-01","reason":"Intentionally expired test fixture"}]

Verification. CI must reject this expired fixture. Production exceptions need approved ownership and scope.

Validation syntax-validated. Official reference

CF-095 ​

Kubernetes CEL validation core

Copy to manifest-validation fragment.

yaml
validations:
  - expression: "object.spec.replicas <= 10"
    message: "Replica limit is 10 for this lab"

Verification. Place under ValidatingAdmissionPolicy spec with reviewed resource matches and binding; validate missing/defaulted field handling.

Validation syntax-validated. Official reference