Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
8da347b
build(deps): bump github.com/moby/buildkit from 0.18.0 to 0.18.1 (#1024)
dependabot[bot] Dec 16, 2024
1e7d052
build(deps): bump golang from 1.23.3-alpine to 1.23.4-alpine (#1025)
dependabot[bot] Dec 16, 2024
4299ce7
build(deps): bump alpine from 3.20.3 to 3.21.0 (#1026)
dependabot[bot] Dec 16, 2024
642e7cd
build(deps): bump github.com/magiconair/properties from 1.8.7 to 1.8.…
dependabot[bot] Jan 6, 2025
5b3e926
build(deps): bump github.com/CycloneDX/cyclonedx-go from 0.9.1 to 0.9…
dependabot[bot] Jan 6, 2025
7428841
fix: set jsonnet VM stack limits and add test coverage
thevilledev Jan 15, 2025
8e541da
fix: improve handling for YAML version directives
thevilledev Jan 18, 2025
151643b
fix: add output and tests for GitHub and Azure DevOps
thevilledev Jan 18, 2025
8b34fcb
fix: remove redundant error check in push command
thevilledev Jan 18, 2025
c4e656f
build(deps): bump golang from 1.23.4-alpine to 1.23.5-alpine
dependabot[bot] Jan 20, 2025
163bdd8
fix: prevent policy file overwrite on downloads (#1039)
thevilledev Jan 22, 2025
0bbb473
fix: max stack size already set by jsonnet.MakeVM()
thevilledev Jan 23, 2025
4df824c
build(deps): bump cuelang.org/go from 0.11.0 to 0.12.0
dependabot[bot] Jan 30, 2025
ea55b61
Merge pull request #1051 from open-policy-agent/dependabot/go_modules…
anderseknert Jan 31, 2025
1a4a428
build(deps): bump github.com/moby/buildkit from 0.18.1 to 0.19.0
dependabot[bot] Jan 31, 2025
744f867
Merge pull request #1046 from open-policy-agent/dependabot/go_modules…
anderseknert Jan 31, 2025
1a25844
Merge pull request #1043 from open-policy-agent/dependabot/docker/gol…
anderseknert Jan 31, 2025
154c1aa
build(deps): bump alpine from 3.21.0 to 3.21.2
dependabot[bot] Jan 31, 2025
1d47ac3
build(deps): bump github.com/hashicorp/go-getter from 1.7.6 to 1.7.8
dependabot[bot] Jan 31, 2025
d5e8a77
Merge pull request #1036 from open-policy-agent/dependabot/go_modules…
anderseknert Jan 31, 2025
24e9ca8
chore: optimize yaml document separator handling
thevilledev Jan 31, 2025
3096ca7
Merge pull request #1038 from thevilledev/fix/yaml-preamble-multidoc
anderseknert Jan 31, 2025
6b31946
Merge pull request #1040 from thevilledev/fix/missing-outputs
anderseknert Jan 31, 2025
a603656
Merge pull request #1037 from thevilledev/fix/recursive-jsonnet
anderseknert Jan 31, 2025
aa9e3c8
feat: enable relative jsonnet imports by setting a path-aware importer
thevilledev Jan 20, 2025
326a1a4
Merge pull request #1044 from thevilledev/fix/jsonnet-library-imports
anderseknert Jan 31, 2025
5063084
Merge pull request #1041 from thevilledev/fix/impossible-nil
anderseknert Jan 31, 2025
a770d29
fix: correct linters-settings in .golangci.yaml to enable misspell
thevilledev Jan 31, 2025
356ede4
Merge pull request #1035 from open-policy-agent/dependabot/docker/alp…
anderseknert Jan 31, 2025
6c867fc
Merge pull request #1052 from thevilledev/fix/linters-settings
anderseknert Jan 31, 2025
874f0bc
chore: add nilness check to govet linter
thevilledev Jan 31, 2025
f110dde
Merge pull request #1053 from thevilledev/style/enable-nilness-lint
anderseknert Feb 1, 2025
bad47e2
test(registry): add test for credentials store init failure
thevilledev Feb 1, 2025
3f67b78
feature: Documentation command (#1009)
xNok Feb 5, 2025
26b6c24
Merge pull request #1054 from thevilledev/test/registry-store-init
anderseknert Feb 5, 2025
256bf5e
test(policy): improve engine test coverage (#1055)
thevilledev Feb 8, 2025
19c82bc
build(deps): bump github.com/open-policy-agent/opa from 0.70.0 to 1.1…
dependabot[bot] Feb 9, 2025
6da5673
build(deps): bump golang from 1.23.5-alpine to 1.23.6-alpine (#1062)
dependabot[bot] Feb 11, 2025
eacba23
feat(engine): add query metadata to evaluation results (#1061)
thevilledev Feb 11, 2025
8a44613
engine: Refactor to allow for Rego version to be specified (#1059)
jalseth Feb 15, 2025
5decd18
feat(parser): handle UTF-8 BOM in JSON input (#1065)
thevilledev Feb 15, 2025
9efcd87
test(plugin): add comprehensive plugin package tests (#1056)
thevilledev Feb 15, 2025
abad255
feat: Implement SARIF output (#1042)
thevilledev Feb 15, 2025
155cd3c
chore: Change empty interface{} to any throughout the codebase (#1057)
jalseth Feb 19, 2025
278f735
chore: Update all examples to OPA V1 syntax (#1058)
jalseth Feb 19, 2025
cdd65ba
refactor(output): Add CheckResults type and helpers (#1063)
jalseth Feb 25, 2025
4154949
feat(test): Enable inter-query cache (#1073)
jalseth Feb 25, 2025
6424545
build(deps): bump github.com/open-policy-agent/opa from 1.1.0 to 1.2.…
dependabot[bot] Mar 1, 2025
8e0fdf2
build(deps): bump alpine from 3.21.2 to 3.21.3 (#1072)
dependabot[bot] Mar 1, 2025
6cb9d19
build(deps): bump github.com/moby/buildkit from 0.19.0 to 0.20.0 (#1076)
dependabot[bot] Mar 1, 2025
854183b
refactor(ci): replace Makefile-based Docker builds with GitHub Action…
Amamgbu Mar 1, 2025
43264f4
build(deps): bump golang from 1.23.6-alpine to 1.24.0-alpine (#1071)
dependabot[bot] Mar 1, 2025
d62aa8d
feat: add --absolute-paths flag to pull command (#1078)
thevilledev Mar 1, 2025
5ae180f
docs: clarify --trace flag behavior with --output flag (#1060)
thevilledev Mar 1, 2025
4435c65
fix: Conftest can now successfully load files using a file URL (e.g.…
pckvcode Mar 1, 2025
39bd5fc
ci: Revert "replace Makefile-based Docker builds with GitHub Action… …
jalseth Mar 1, 2025
a20159b
build(deps): bump github.com/moby/buildkit from 0.20.0 to 0.20.1 (#1083)
dependabot[bot] Mar 7, 2025
6a9a474
docs: add documentation feature to the navigation bar (#1087)
boranx Mar 14, 2025
21e1163
feat: add pre-commit hook support (#1077)
thevilledev Mar 20, 2025
1b1ce3a
build(deps): bump golang from 1.24.0-alpine to 1.24.1-alpine (#1086)
dependabot[bot] Mar 20, 2025
45bf533
build(deps): bump github.com/BurntSushi/toml from 1.4.0 to 1.5.0 (#1089)
dependabot[bot] Mar 20, 2025
8c8b13f
ci: Remove PR workflow access to all permissions from GITHUB_TOKEN (#…
jalseth Mar 23, 2025
32aac49
build(deps): bump github.com/moby/buildkit from 0.20.1 to 0.20.2 (#1091)
dependabot[bot] Mar 30, 2025
eac6f5e
build(deps): bump github.com/open-policy-agent/opa from 1.2.0 to 1.3.…
dependabot[bot] Mar 30, 2025
cb88a17
build(deps): bump golang from 1.24.1-alpine to 1.24.2-alpine (#1096)
dependabot[bot] Apr 8, 2025
813f329
build(deps): bump cuelang.org/go from 0.12.0 to 0.12.1 (#1094)
dependabot[bot] Apr 8, 2025
19f1eaf
build(deps): bump github.com/magiconair/properties from 1.8.9 to 1.8.…
dependabot[bot] Apr 12, 2025
688c88f
deps: Bump hcl2json to v0.6.7 (#1074)
jalseth Apr 12, 2025
e9612c3
refactor(ci): replace Makefile-based Docker builds with GitHub Action…
Amamgbu Apr 12, 2025
7bec660
docs: update default template link to use absolute URL (#1099)
thevilledev Apr 19, 2025
3ae2e78
chore: Update Github Actions via Dependabot (#1100)
mrueg Apr 19, 2025
b3d0491
build(deps): bump golangci/golangci-lint-action from 6 to 7 (#1103)
dependabot[bot] Apr 20, 2025
67a3c3e
build(deps): bump actions/setup-go from 4 to 5 (#1102)
dependabot[bot] Apr 20, 2025
609490f
build(deps): bump bats-core/bats-action from 1.5.4 to 3.0.1 (#1104)
dependabot[bot] Apr 20, 2025
4c5e5f5
ci: Move docker build to separate job in the PR workflow (#1105)
jalseth Apr 24, 2025
18a0f14
feat(runner): add support for symlinks (#1098)
Apr 26, 2025
06658d4
feat(output): redirect trace output to stderr (#1084)
thevilledev Apr 26, 2025
5ea0446
build(deps): bump github.com/moby/buildkit from 0.20.2 to 0.21.0 (#1101)
dependabot[bot] Apr 26, 2025
21a73eb
build(deps): bump github.com/moby/buildkit from 0.21.0 to 0.21.1 (#1111)
dependabot[bot] May 4, 2025
2797c99
build(deps): bump github.com/open-policy-agent/opa from 1.3.0 to 1.4.…
dependabot[bot] May 4, 2025
c0799c4
docs: Make examples in the docs compatible with v1 syntax (#1115)
jalseth May 7, 2025
3907482
cli: Make Rego v1 syntax the default (#1114)
jalseth May 7, 2025
e894c43
build(deps): bump golangci/golangci-lint-action from 7 to 8 (#1119)
dependabot[bot] May 7, 2025
9e56924
build(deps): bump github.com/google/go-jsonnet from 0.20.0 to 0.21.0 …
dependabot[bot] May 9, 2025
1441245
docs: Update README.md to make it compatible with v1 syntax (#1122)
IshentRas May 10, 2025
1fe40dd
Merge remote-tracking branch 'upstream/master'
janmooij May 16, 2025
03ff170
Merge remote-tracking branch 'upstream/master' into janmooij/v0.60.0
janmooij May 16, 2025
c50d866
fix: revert makefile changes
janmooij May 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ updates:
directory: "/"
schedule:
interval: "weekly"

- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
9 changes: 6 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
push:
tags:
- 'v*'
env:
IMAGE: openpolicyagent/conftest
PLATFORMS: linux/amd64,linux/arm64

jobs:
release:
Expand Down Expand Up @@ -42,14 +45,14 @@ jobs:
# run: make push TAG=$VERSION

- name: setup go
uses: actions/setup-go@v4
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
go-version: "1.24.x"

- name: release
uses: goreleaser/goreleaser-action@v6
with:
args: release --clean
version: "~> v1"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51 changes: 37 additions & 14 deletions .github/workflows_bak/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ name: pr

on: [pull_request]

permissions:
actions: read
checks: none
contents: none
deployments: none
issues: none
packages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none

permissions: {}

env:
IMAGE: openpolicyagent/conftest
PLATFORMS: linux/amd64,linux/arm64

jobs:
style:
Expand Down Expand Up @@ -59,11 +54,11 @@ jobs:
- name: setup go
uses: actions/setup-go@v5
with:
go-version: "1.23.x"
go-version: "1.24.x"
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
uses: golangci/golangci-lint-action@v8
with:
args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0

Expand All @@ -73,8 +68,16 @@ jobs:
- name: unit test
run: make test

# Ensure Actions runner has Python installed
# This is required for pre-commit tests to work
- name: setup python
uses: actions/setup-python@v5
with:
python-version: '3.13'
cache: 'pip'

- name: setup bats
uses: bats-core/bats-action@1.5.4
uses: bats-core/bats-action@3.0.1
with:
# Pin bats version to fix CI issue: https://github.com/bats-core/bats-action/pull/4
bats-version: "1.10.0"
Expand All @@ -91,3 +94,23 @@ jobs:

- name: test oci push/pull
run: ./scripts/push-pull-e2e.sh

docker:
runs-on: ubuntu-latest
needs:
- validate
steps:
- name: checkout source
uses: actions/checkout@v4

- name: setup docker buildx
run: docker buildx create --name conftestbuild --use

- name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
push: false
tags: |
${{ env.IMAGE }}:latest
platforms: ${{ env.PLATFORMS }}
51 changes: 35 additions & 16 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
linters-settings:
misspell:
locale: US
govet:
enable:
- nilness
staticcheck:
checks:
- "all" # Include all checks except the ones below.
- "-SA1019" # Do not block the build if deprecated functions or packages are used.

version: "2"
linters:
disable-all: true
default: none
enable:
- errcheck
- goconst
- gofmt
- goimports
- gosec
- gosimple
- govet
- ineffassign
- makezero
Expand All @@ -26,8 +13,40 @@ linters:
- predeclared
- revive
- staticcheck
- typecheck
- unconvert
- unparam
- unused
- wastedassign
settings:
govet:
enable:
- nilness
misspell:
locale: US
staticcheck:
checks:
# These are processed in order. It is important that the inclusion
# comes before the exclusion.
- all
- -SA1019
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
19 changes: 19 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- id: conftest-test
name: Conftest Test Policy Check
description: Validate configuration files against Open Policy Agent policies using Conftest
entry: conftest test
language: golang
pass_filenames: true
require_serial: true
minimum_pre_commit_version: "2.9.0"
stages: [pre-commit, pre-merge-commit, pre-push, manual]

- id: conftest-verify
name: Conftest Verify Policy Tests
description: Run Rego unit tests for Conftest policies
entry: conftest verify
language: golang
pass_filenames: false
require_serial: true
minimum_pre_commit_version: "2.9.0"
stages: [pre-commit, pre-merge-commit, pre-push, manual]
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23.6-alpine as base
FROM golang:1.24.2-alpine as base
ARG TARGETARCH
ARG VERSION
ARG COMMIT
Expand Down Expand Up @@ -52,7 +52,7 @@ RUN go install cuelang.org/go/cmd/cue@latest
WORKDIR /examples

## RELEASE ##
FROM alpine:3.21.2
FROM alpine:3.21.3

# Install git for protocols that depend on it when using conftest pull
RUN apk add --no-cache git
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@ test-examples: build ## Runs the tests for the examples.
@bats acceptance.bats

.PHONY: test-acceptance
test-acceptance: build ## Runs the tests in the test folder.
test-acceptance: build install-test-deps ## Runs the tests in the test folder.
@for testdir in $(TEST_DIRS) ; do \
cd $(CURDIR)/$$testdir && CONFTEST=$(ROOT_DIR)/$(BIN) bats test.bats || exit 1; \
done

.PHONY: install-test-deps
install-test-deps: ## Installs dependencies required for testing.
@command -v pre-commit >/dev/null 2>&1 || python -m pip install -r requirements-dev.txt

.PHONY: test-oci
test-oci: ## Runs the OCI integration test for push and pull.
@./scripts/push-pull-e2e.sh
Expand Down Expand Up @@ -75,4 +79,4 @@ help:
# @test -n "$(TAG)" || (echo "TAG parameter not set." && exit 1)
# @$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):$(TAG) --platform $(DOCKER_PLATFORMS)
# @$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):latest --platform $(DOCKER_PLATFORMS)
# @$(DOCKER) buildx build . --push --target examples -t $(IMAGE):examples --platform $(DOCKER_PLATFORMS)
# @$(DOCKER) buildx build . --push --target examples -t $(IMAGE):examples --platform $(DOCKER_PLATFORMS)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Here's a quick example. Save the following as `policy/deployment.rego`:
```rego
package main

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

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

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

Expand Down
9 changes: 9 additions & 0 deletions acceptance.bats
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,12 @@ EOF"
[ "$status" -eq 1 ]
[[ "$output" =~ "look up message type" ]]
}

@test "Can parse files from a symlinked directory" {
TMPDIR="$(mktemp -d -u)"
ln -s $(pwd)/examples/hcl2 ${TMPDIR}
run ./conftest test -p examples/hcl2/policy ${TMPDIR}
rm -rf ${TMPDIR}
[ "$status" -eq 1 ]
[[ "$output" =~ "10 tests, 3 passed, 0 warnings, 7 failures, 0 exceptions" ]]
}
14 changes: 14 additions & 0 deletions docs/debug.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,17 @@ TRAC | Exit data.main.deny = _
TRAC Redo data.main.deny = _
TRAC | Redo data.main.deny = _
```

## Using trace with other output formats

You can use the `--trace` flag together with any output format. When using `--trace` with formats like `--output=table` or `--output=json`, the trace information will be written to stderr while the formatted output will be written to stdout. This allows you to capture trace information for debugging while still using your preferred output format.

For example:

```console
# Output trace to stderr and table format to stdout
$ conftest test --trace --output=table deployment.yaml

# Capture trace output to a file while viewing table output
$ conftest test --trace --output=table deployment.yaml 2>trace.log
```
2 changes: 1 addition & 1 deletion docs/documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ conftest doc path/to/policy

## Use your own template

You can override the [default template](../document/resources/document.md) with your own template
You can override the [default template](https://raw.githubusercontent.com/open-policy-agent/conftest/refs/heads/master/document/resources/document.md) with your own template

```aiignore
conftest -t template.md path/tp/policies
Expand Down
8 changes: 4 additions & 4 deletions docs/exceptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ There might be cases where rules might not apply under certain circumstances. Fo
Inputs matched by the `exception` will be exempted from the rules specified in `rules`, prefixed by `deny_` or `violation_`:

```rego
exception[rules] {
exception contains rules if {
# Logic

rules = ["foo","bar"]
rules := ["foo","bar"]
}
```

Expand All @@ -29,14 +29,14 @@ In the below example, a Kubernetes deployment named `can-run-as-root` will be al
```rego
package main

deny_run_as_root[msg] {
deny_run_as_root contains msg if {
input.kind == "Deployment"
not input.spec.template.spec.securityContext.runAsNonRoot

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

exception[rules] {
exception contains rules if {
input.kind == "Deployment"
input.metadata.name == "can-run-as-root"

Expand Down
30 changes: 26 additions & 4 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ For instance, save the following as `policy/deployment.rego`:
```rego
package main

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

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

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

Expand Down Expand Up @@ -84,6 +84,28 @@ As of today Conftest supports:
* XML
* YAML

### Pre-commit Integration

Conftest can be used as a [pre-commit](https://pre-commit.com/) hook to validate your configuration files before committing them.

To use Conftest with pre-commit, add the following to your `.pre-commit-config.yaml`:

```yaml
repos:
- repo: https://github.com/open-policy-agent/conftest
rev: v0.59.0 # Use a specific tag or 'HEAD' for the latest commit
hooks:
- id: conftest-test
args: [--policy, path/to/your/policies] # Specify your policy directory
# Optional: Add the verify hook to run policy unit tests
- id: conftest-verify
args: [--policy, path/to/your/policies]
```

The `conftest-test` hook validates your configuration files against policies, while the `conftest-verify` hook runs unit tests for your policies.

For more information on pre-commit hooks, refer to the [pre-commit documentation](https://pre-commit.com/).

### Testing/Verifying Policies

When authoring policies, it is helpful to test them. Consult the Rego [testing documentation](https://www.openpolicyagent.org/docs/latest/policy-testing)
Expand All @@ -105,7 +127,7 @@ When writing unit tests, it is common to use the `with` keyword to override the
`input` and `data` documents. For example:

```rego
test_foo {
test_foo if {
input := {
"abc": 123,
"foo": ["bar", "baz"],
Expand Down Expand Up @@ -135,7 +157,7 @@ in a unit test.
**deny.rego**

```rego
deny[msg] {
deny contains msg if {
proto := input.resource.aws_alb_listener[lb].protocol
proto == "HTTP"
msg = sprintf("ALB `%v` is using HTTP rather than HTTPS", [lb])
Expand Down
Loading