Write tests against structured configuration data using the Open Policy Agent Rego query language
open sourceApache-2.0self-hostablefree
Conftest tests configuration files against policies written in Rego, the policy language of Open Policy Agent. It isn't specific to Kubernetes: it parses YAML, JSON, HCL and Terraform, Dockerfiles, TOML, INI, XML, CUE, Jsonnet, Jenkins pipelines, .env and ignore files, SPDX and CycloneDX SBOMs and more, and reports deny, warn and violation rules as test results in plain text, JSON, TAP, JUnit, GitHub, Azure DevOps or SARIF format. Policies can be unit-tested with conftest verify and shared by pulling from Git, HTTPS or OCI registries and pushing to OCI registries. Created by Gareth Rushgrove, part of the Open Policy Agent project, Apache-2.0.
Ways to install
Package managers
Problems it solves
- fail the build when a Kubernetes manifest doesn't follow our security rules
- check Terraform code against company policy before it's applied
- write rules for our Dockerfiles, like banning images that run as root
- test any YAML, JSON, TOML or HCL config file against rules I write once
- share the same config policies across many repositories from a registry
- unit test the policy rules themselves before rolling them out
- show config policy failures as annotations in GitHub or Azure DevOps pipelines
- check SBOM files for licences or components we don't allow
Features
- Rego policies from Open Policy Agent
- parsers for YAML, JSON, HCL/HCL2, Dockerfile, TOML, INI, XML, CUE, Jsonnet, EDN, HOCON, .env, .properties, Jenkinsfile, nginx, VCL, ignore files, CODEOWNERS, SPDX and CycloneDX
conftest verifyfor policy unit tests- pull policies from HTTPS, Git or OCI registries
- push policy bundles to OCI registries
- output as plain text, JSON, TAP, table, JUnit, GitHub, Azure DevOps or SARIF
- exceptions
- plugins
- pre-commit hook
- Homebrew, Scoop, mise and Docker installs
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Takes plugins | plan not known |
Alternatives
The same job
These do what Conftest does.
- Checkov Prevent cloud misconfigurations and find vulnerabilities during build-time in infrastructure as code, container images and open source packages
- Kyverno Unified Policy as Code
- KubeLinter Static analysis for Kubernetes YAML files and Helm charts
