MCPcopy
hub / github.com/open-policy-agent/conftest

github.com/open-policy-agent/conftest @v0.68.2 sqlite

repository ↗ · DeepWiki ↗ · release v0.68.2 ↗
382 symbols 1,359 edges 108 files 193 documented · 51%
README

Conftest

Go Report Card Netlify

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 for writing the assertions. You can read more about Rego in the Policy Language section in the Open Policy Agent documentation.

Here's a quick example. Save the following as policy/deployment.rego:

package main

deny contains msg if {
  input.kind == "Deployment"
  not input.spec.template.spec.securityContext.runAsNonRoot

  msg := "Containers must not run as root"
}

deny contains msg if {
  input.kind == "Deployment"
  not input.spec.selector.matchLabels.app

  msg := "Containers must provide app label for pod selectors"
}

Assuming you have a Kubernetes deployment in deployment.yaml you can run Conftest like so:

$ conftest test deployment.yaml
FAIL - deployment.yaml - Containers must not run as root
FAIL - deployment.yaml - Containers must provide app label for pod selectors

2 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 for installation instructions and more details about the features.

Want to contribute to Conftest?

For discussions and questions join us on the Open Policy Agent Slack in the #opa-conftest channel.

Extension points exported contracts — how you extend this code

Outputter (Interface)
Outputter controls how results of an evaluation will be recorded and reported to the end user. [9 implementers]
output/output.go
Parser (Interface)
Parser defines all of the methods that every parser definition must implement. [21 implementers]
parser/parser.go
RenderDocumentOption (FuncType)
(no doc)
document/template.go
PathAwareParser (Interface)
PathAwareParser is an optional interface that parsers may implement if they need the original file path for relative imp [1 …
parser/parser.go

Core symbols most depended-on inside this repo

Run
called by 55
runner/test.go
String
called by 40
output/result.go
Unmarshal
called by 35
parser/parser.go
Output
called by 11
output/output.go
New
called by 11
parser/parser.go
Directory
called by 10
plugin/plugin.go
ParseConfigurations
called by 8
parser/parser.go
CacheDirectory
called by 6
plugin/plugin.go

Shape

Function 222
Method 99
Struct 52
TypeAlias 5
Interface 3
FuncType 1

Languages

Go100%

Modules by API surface

policy/engine.go28 symbols
output/result.go21 symbols
parser/parser.go15 symbols
policy/engine_test.go13 symbols
output/output.go13 symbols
builtins/parse_config.go11 symbols
plugin/plugin.go10 symbols
plugin/install_test.go9 symbols
output/sarif.go9 symbols
plugin/plugin_test.go8 symbols
output/standard.go8 symbols
output/github.go8 symbols

Dependencies from manifests, versioned

cel.dev/exprv0.25.1 · 1×
cloud.google.com/gov0.123.0 · 1×
cloud.google.com/go/authv0.18.2 · 1×
cloud.google.com/go/auth/oauth2adaptv0.2.8 · 1×
cloud.google.com/go/compute/metadatav0.9.0 · 1×
cloud.google.com/go/monitoringv1.24.3 · 1×
cloud.google.com/go/storagev1.61.3 · 1×
cuelang.org/gov0.16.0 · 1×
github.com/CycloneDX/cyclonedx-gov0.10.0 · 1×
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcpv1.30.0 · 1×

Datastores touched

(mysql)Database · 1 repos

For agents

$ claude mcp add conftest \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact