Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/open-policy-agent/conftest
Write tests against structured configuration data using the Open Policy Agent Rego query language
https://github.com/open-policy-agent/conftest
kubernetes open-policy-agent openpolicyagent rego testing
Last synced: 2 days ago
JSON representation
Write tests against structured configuration data using the Open Policy Agent Rego query language
- Host: GitHub
- URL: https://github.com/open-policy-agent/conftest
- Owner: open-policy-agent
- License: other
- Created: 2019-03-28T17:12:29.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-12-04T17:20:39.000Z (8 days ago)
- Last Synced: 2024-12-08T21:16:33.249Z (4 days ago)
- Topics: kubernetes, open-policy-agent, openpolicyagent, rego, testing
- Language: Go
- Homepage: https://conftest.dev
- Size: 3.98 MB
- Stars: 2,885
- Watchers: 27
- Forks: 306
- Open Issues: 43
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
- awesome - conftest - Write tests against structured configuration data using the Open Policy Agent Rego query language (Go)
- awesome-repositories - open-policy-agent/conftest - Write tests against structured configuration data using the Open Policy Agent Rego query language (Go)
- awesome-k8s-resources - Conftest - Conftest helps you write tests against structured configuration data. (Tools and Libraries / Testing and Troubleshooting)
- awesome-cloud-sec - conftest - - Write tests against structured configuration data using the Open Policy Agent Rego query language (Other Awesome Lists / Open Policy Agent (OPA))
- awesome-opa - Conftest - Write tests against structured configuration data (Official projects / Repositories)
- awesome-devsecops-russia - Conftest
README
# Conftest
[![Go Report Card](https://goreportcard.com/badge/open-policy-agent/opa)](https://goreportcard.com/report/open-policy-agent/conftest) [![Netlify](https://api.netlify.com/api/v1/badges/2d928746-3380-4123-b0eb-1fd74ba390db/deploy-status)](https://app.netlify.com/sites/vibrant-villani-65041c/deploys)
Conftest helps you write tests against structured configuration data. Using Conftest you can
write tests for your Kubernetes configuration, Tekton pipeline definitions, Terraform code,
Serverless configs or any other config files.Conftest uses the Rego language from [Open Policy Agent](https://www.openpolicyagent.org/) for writing
the assertions. You can read more about Rego in [How do I write policies](https://www.openpolicyagent.org/docs/how-do-i-write-policies.html)
in the Open Policy Agent documentation.Here's a quick example. Save the following as `policy/deployment.rego`:
```rego
package maindeny[msg] {
input.kind == "Deployment"
not input.spec.template.spec.securityContext.runAsNonRootmsg := "Containers must not run as root"
}deny[msg] {
input.kind == "Deployment"
not input.spec.selector.matchLabels.appmsg := "Containers must provide app label for pod selectors"
}
```Assuming you have a Kubernetes deployment in `deployment.yaml` you can run Conftest like so:
```console
$ conftest test deployment.yaml
FAIL - deployment.yaml - Containers must not run as root
FAIL - deployment.yaml - Containers must provide app label for pod selectors2 tests, 0 passed, 0 warnings, 2 failures, 0 exceptions
```Conftest isn't specific to Kubernetes. It will happily let you write tests for any configuration files in a variety of different formats. See the [documentation](https://www.conftest.dev/) for [installation instructions](https://www.conftest.dev/install/) and
more details about the features.## Want to contribute to Conftest?
* See [DEVELOPMENT.md](DEVELOPMENT.md) to build and test Conftest itself.
* See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.For discussions and questions join us on the [Open Policy Agent Slack](https://slack.openpolicyagent.org/)
in the `#opa-conftest` channel.