Open Policy Agent (OPA) rules and policies for organizational governance.
This repository contains a production-ready OPA framework (v1.7.1) that enforces security, compliance, and best practices across our infrastructure and applications. The framework follows OPA best practices for bundle management, testing, performance optimization, and observability.
.
├── policies/ # OPA policy files organized by domain
│ ├── kubernetes/ # Kubernetes admission control policies
│ ├── terraform/ # Terraform plan validation policies
│ ├── docker/ # Docker image and container policies
│ ├── github/ # GitHub repository and workflow policies
│ └── lib/ # Shared policy libraries and utilities
├── data/ # Static data files (JSON/YAML) for policies
├── examples/ # Example inputs and test cases
├── tests/ # Policy test files (*_test.rego)
├── benchmarks/ # Performance benchmarking configurations
├── bundles/ # Pre-built policy bundles
│ └── .manifest # Bundle manifest with metadata
├── config/ # OPA server configuration files
│ ├── config.yaml # Main OPA configuration
│ └── decision-log.yaml # Decision logging configuration
├── scripts/ # Utility scripts for operations
└── .github/workflows/ # CI/CD workflows for policy validation
- Open Policy Agent (OPA) CLI v1.7.1
- opa-test for testing policies
- Conftest for validating configurations (optional)
jqfor JSON processingmakefor automation
- Install OPA v1.7.1:
# macOS
brew install opa@1.7.1
# Linux (recommended)
curl -L -o opa https://github.com/open-policy-agent/opa/releases/download/v1.7.1/opa_linux_amd64_static
chmod 755 opa
sudo mv opa /usr/local/bin/
# Verify installation
opa version- Clone this repository:
git clone git@github-personal:verlyn13/policy-as-code.git
cd policy-as-codeopa eval -d policies/kubernetes/ -i examples/kubernetes/pod.json "data.kubernetes.admission.deny[x]"opa test policies/ tests/ -vconftest verify --policy policies/terraform/ examples/terraform/plan.json- Pod security standards
- Resource limits and requests
- Network policies
- RBAC validation
- Resource tagging requirements
- Security group rules
- IAM policy restrictions
- Cost optimization rules
- Base image restrictions
- Security scanning requirements
- Label requirements
- User permissions
- Branch protection rules
- Secret scanning
- Dependency management
- Workflow security
- Create a new branch for your policy
- Add policy files in the appropriate directory
- Include test cases in
tests/ - Update documentation as needed
- Submit a pull request
All policies must include comprehensive tests. Run tests locally before submitting:
# Run all tests
opa test policies/ tests/ -v
# Run specific domain tests
opa test policies/kubernetes/ tests/kubernetes/ -vGitHub Actions workflows automatically:
- Validate policy syntax
- Run all policy tests
- Check policy coverage
- Lint Rego files
See docs/INFISICAL.md for Terraform modules, provider setup, and OPA enforcement specific to Infisical org/project configuration.
- Kubernetes admission control: use a fail-closed webhook (see
examples/kubernetes/validatingwebhook-failclosed.yaml). - Staged rollout: promote signed bundles through
dev → stg → prodwith audit-only in dev. - Decision logs, metrics, and alerts: see
docs/OPERATIONS.mdfor setup and examples.
[Add your license here]