Skip to content

Commit 70ca14c

Browse files
janmooijdependabot[bot]thevilledevanderseknertxNok
authored
chore(conftest): merge upstream v0.60.0 (#3)
* build(deps): bump github.com/moby/buildkit from 0.18.0 to 0.18.1 (open-policy-agent#1024) * build(deps): bump golang from 1.23.3-alpine to 1.23.4-alpine (open-policy-agent#1025) * build(deps): bump alpine from 3.20.3 to 3.21.0 (open-policy-agent#1026) * build(deps): bump github.com/magiconair/properties from 1.8.7 to 1.8.9 (open-policy-agent#1027) Bumps [github.com/magiconair/properties](https://github.com/magiconair/properties) from 1.8.7 to 1.8.9. - [Release notes](https://github.com/magiconair/properties/releases) - [Commits](magiconair/properties@v1.8.7...v1.8.9) --- updated-dependencies: - dependency-name: github.com/magiconair/properties dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/CycloneDX/cyclonedx-go from 0.9.1 to 0.9.2 (open-policy-agent#1028) Bumps [github.com/CycloneDX/cyclonedx-go](https://github.com/CycloneDX/cyclonedx-go) from 0.9.1 to 0.9.2. - [Release notes](https://github.com/CycloneDX/cyclonedx-go/releases) - [Changelog](https://github.com/CycloneDX/cyclonedx-go/blob/master/.goreleaser.yml) - [Commits](CycloneDX/cyclonedx-go@v0.9.1...v0.9.2) --- updated-dependencies: - dependency-name: github.com/CycloneDX/cyclonedx-go dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * fix: set jsonnet VM stack limits and add test coverage - Set MaxStack to 500 frames to prevent deep recursion - Set MaxStackTraceSize to 20 for cleaner errors - Add test for stack overflow prevention - Improve test structure with table-driven pattern Signed-off-by: Ville Vesilehto <[email protected]> * fix: improve handling for YAML version directives The YAML parser was incorrectly splitting documents with version directives (e.g. '%YAML 1.1') by treating the first '---' marker as a document separator. This caused the version directive to be separated from its document, resulting in parsing errors. Fixed document separation logic to keep version directive with its document. Added test cases for various YAML scenarios and improved test coverage. Signed-off-by: Ville Vesilehto <[email protected]> * fix: add output and tests for GitHub and Azure DevOps Added missing test cases for GitHub and AzureDevOps output formats in output_test.go. Also added OutputAzureDevOps to the list of available output formats in Outputs(). Signed-off-by: Ville Vesilehto <[email protected]> * fix: remove redundant error check in push command Remove an unnecessary error check for configDesc creation in the push command. The NewDescriptorFromBytes function does not return an error, so checking for one was redundant and could never be triggered. Signed-off-by: Ville Vesilehto <[email protected]> * build(deps): bump golang from 1.23.4-alpine to 1.23.5-alpine Bumps golang from 1.23.4-alpine to 1.23.5-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * fix: prevent policy file overwrite on downloads (open-policy-agent#1039) File existence check before downloading policies. Errors out and no overwrites. Maintains data integrity by preventing accidental policy overwrites. Added a test which verified the behaviour. Signed-off-by: Ville Vesilehto <[email protected]> * fix: max stack size already set by jsonnet.MakeVM() Signed-off-by: Ville Vesilehto <[email protected]> * build(deps): bump cuelang.org/go from 0.11.0 to 0.12.0 Bumps cuelang.org/go from 0.11.0 to 0.12.0. --- updated-dependencies: - dependency-name: cuelang.org/go dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/moby/buildkit from 0.18.1 to 0.19.0 Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.18.1 to 0.19.0. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.18.1...v0.19.0) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump alpine from 3.21.0 to 3.21.2 Bumps alpine from 3.21.0 to 3.21.2. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * build(deps): bump github.com/hashicorp/go-getter from 1.7.6 to 1.7.8 Bumps [github.com/hashicorp/go-getter](https://github.com/hashicorp/go-getter) from 1.7.6 to 1.7.8. - [Release notes](https://github.com/hashicorp/go-getter/releases) - [Changelog](https://github.com/hashicorp/go-getter/blob/main/.goreleaser.yml) - [Commits](hashicorp/go-getter@v1.7.6...v1.7.8) --- updated-dependencies: - dependency-name: github.com/hashicorp/go-getter dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * chore: optimize yaml document separator handling Based on PR feedback: - use byte slices instead of string concat - set common byte sequences as vars Signed-off-by: Ville Vesilehto <[email protected]> * feat: enable relative jsonnet imports by setting a path-aware importer - Introduce a new `PathAwareParser` interface that extends `Parser` with `SetPath(path string)`. - Update `parseConfigurations` to detect if a parser implements `PathAwareParser`, and call `SetPath(path)`. - Implement `SetPath` in the Jsonnet parser, setting the JPath to the file’s directory. - Add tests to ensure that relative imports in Jsonnet now work as expected. Signed-off-by: Ville Vesilehto <[email protected]> * fix: correct linters-settings in .golangci.yaml to enable misspell * Fix typo in `.golangci.yaml` to enable linter settings * Fix marshal/unmarshal spelling across codebase Signed-off-by: Ville Vesilehto <[email protected]> * chore: add nilness check to govet linter * Add nilness check to govet linter configuration See open-policy-agent#1041 for an example Signed-off-by: Ville Vesilehto <[email protected]> * test(registry): add test for credentials store init failure Add a test case that verifies SetupClient returns an error when the Docker config file is not readable due to permissions. This ensures the credentials store initialization failure is properly handled. Signed-off-by: Ville Vesilehto <[email protected]> * feature: Documentation command (open-policy-agent#1009) * feat: parse the annotations Signed-off-by: Alexandre Couedelo <[email protected]> refactor: change the way we access annotations I am testing different way to generate the doc. Having the compiler object is much easier than the annotation set only Signed-off-by: Alexandre Couedelo <[email protected]> * feat: generate section that can be used to generate documentations Signed-off-by: Alexandre Couedelo <[email protected]> * feat: generate the documentation file Signed-off-by: Alexandre Couedelo <[email protected]> * feat: add the command doc to conftest Signed-off-by: Alexandre Couedelo <[email protected]> fix: make title coherent in submodules documentation Signed-off-by: Alexandre Couedelo <[email protected]> * chore: improve test case Signed-off-by: Alexandre Couedelo <[email protected]> chore: ignore golden files in git Signed-off-by: Alexandre Couedelo <[email protected]> chore: document and test the custom template feature Signed-off-by: Alexandre Couedelo <[email protected]> chore: linting Signed-off-by: Alexandre Couedelo <[email protected]> * build(deps): bump github.com/open-policy-agent/opa from 0.68.0 to 0.69.0 (open-policy-agent#1010) Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.68.0 to 0.69.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v0.68.0...v0.69.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Alexandre Couedelo <[email protected]> * chore: Fixed changes requested by @boranx build(deps): bump github.com/open-policy-agent/opa from 0.68.0 to 0.69.0 (open-policy-agent#1010) Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.68.0 to 0.69.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v0.68.0...v0.69.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Signed-off-by: Alexandre Couedelo <[email protected]> chore: go mod tidy * test: refactor to use Document instead of []Section Signed-off-by: Alexandre Couedelo <[email protected]> * chore: improve doc string in code Signed-off-by: Alexandre Couedelo <[email protected]> * chore: address changes requested by @ jalseth Signed-off-by: Alexandre Couedelo <[email protected]> * chore: remove error handling on file close Signed-off-by: Alexandre Couedelo <[email protected]> * fix: revert bad renaming Signed-off-by: Alexandre Couedelo <[email protected]> * fix: go mod tidy Signed-off-by: Alexandre Couedelo <[email protected]> * fix: update template in acceptance test the name of the variable has changed to be more meaningful Signed-off-by: Alexandre Couedelo <[email protected]> --------- Signed-off-by: Alexandre Couedelo <[email protected]> Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * test(policy): improve engine test coverage (open-policy-agent#1055) * test(policy): improve engine test coverage Add TestLoadWithData and TestNamespaces to increase test coverage for the policy engine. Tests a few edge cases such as duplicate namespaces. Signed-off-by: Ville Vesilehto <[email protected]> * refactor(policy): replace memfs with testing/fstest Migrate tests to use Go's standard library fstest.MapFS instead of custom memfs implementation. - Update TestProblematicIf and TestNamespaces to use fstest.MapFS - Remove memfs import and dependency - Convert test file content handling to use MapFile structs - Maintain existing test functionality while using official FS impl Signed-off-by: Ville Vesilehto <[email protected]> * docs: explain fstest.MapFS conversion in tests The type conversion from map[string]*fstest.MapFile to fstest.MapFS triggers an 'unnecessary conversion' linter warning. Add explanatory comment to document why this conversion is required - it ensures proper fs.FS interface implementation needed by loader.WithFS. Signed-off-by: Ville Vesilehto <[email protected]> --------- Signed-off-by: Ville Vesilehto <[email protected]> * build(deps): bump github.com/open-policy-agent/opa from 0.70.0 to 1.1.0 (open-policy-agent#1050) * build(deps): bump github.com/open-policy-agent/opa from 0.70.0 to 1.1.0 Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 0.70.0 to 1.1.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v0.70.0...v1.1.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * ci: Disable deprecated code check for golangci-lint This is currently blocking the upgrade to the OPA v1 package, and as a general rule I don't think hard blocking updates and releases on use of deprecated but still working code is good. Signed-off-by: James Alseth <[email protected]> * document: Use V1 AST The V0 path is currently missing the BuildAnnotationSet function which breaks the build. This will be fixed, but the V0 path is an alias to the V1 path, so this is effectively the same. This does not have an impact on the required Rego for conftest users. Signed-off-by: James Alseth <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: James Alseth <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Alseth <[email protected]> * build(deps): bump golang from 1.23.5-alpine to 1.23.6-alpine (open-policy-agent#1062) Bumps golang from 1.23.5-alpine to 1.23.6-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feat(engine): add query metadata to evaluation results (open-policy-agent#1061) * feat(engine): add query metadata to evaluation results Add query information to result metadata to enable output formatters to utilize the originating query in their output. This helps track which policy rule triggered each result. The change: - Adds query metadata to both string and map return types - Ensures metadata map is properly initialized - Adds comprehensive tests covering single and multiple results Signed-off-by: Ville Vesilehto <[email protected]> * test: split checks in TestQueryMetadata Check msg and meta in separate blocks, with separate err Signed-off-by: Ville Vesilehto <[email protected]> --------- Signed-off-by: Ville Vesilehto <[email protected]> * engine: Refactor to allow for Rego version to be specified (open-policy-agent#1059) Signed-off-by: James Alseth <[email protected]> * feat(parser): handle UTF-8 BOM in JSON input (open-policy-agent#1065) Strip UTF-8 BOM (byte order mark) from JSON input before parsing, allowing users to directly use files containing BOM with conftest. Matches OPA's implementation. Signed-off-by: Ville Vesilehto <[email protected]> * test(plugin): add comprehensive plugin package tests (open-policy-agent#1056) * test(plugin): add comprehensive plugin package tests Add tests for Load, FindAll and plugin Exec functionality. Includes test coverage for plugin loading, discovery and command execution. Signed-off-by: Ville Vesilehto <[email protected]> * fix: proper file paths for plugin tests CacheDirectory() will resolve to current working directory if pre-defined directory structure is missing. Signed-off-by: Ville Vesilehto <[email protected]> --------- Signed-off-by: Ville Vesilehto <[email protected]> * feat: Implement SARIF output (open-policy-agent#1042) * feat: add SARIF output format support Add Static Analysis Results Interchange Format (SARIF) v2.1.0 output support to conftest. SARIF is a standard JSON format for static analysis tools. - SARIF v2.1.0 schema compliance - Includes file locations and rule metadata - Tracks execution timing and status - Test coverage - Documentation Signed-off-by: Ville Vesilehto <[email protected]> * feat(output): implement SARIF output using go-sarif library Add Static Analysis Results Interchange Format (SARIF) v2.1.0 output support using the go-sarif library. This provides a standard JSON format for static analysis results with proper schema compliance. Key changes: - Use go-sarif/v2 library instead of custom implementation - Support all result types (failures, warnings, exceptions, successes) - Add comprehensive test coverage with JSON comparison - Document new output format in options.md The SARIF output includes: - File locations and rule metadata - Proper result levels (error/warning/note/none) - Execution status and exit codes - Rule properties from result metadata Signed-off-by: Ville Vesilehto <[email protected]> * refactor: address pr comments - refactor: remove getRuleIndex Use direct map lookups instead - refactor: succinct map lookups Map lookup with a fallback - refactor: move result type logic to addResult func Cleaner code, while not really idiomatic due to go-sarif library design. - fix: treat exceptions as success A file with only exceptions will be treated as a success. Exceptions will still be logged (with level "note") for visibility. The exit code will be 0 (success) when there are only exceptions. - refactor: simplify hasFailures and hasWarnings Risk of typo is too high - refactor: treat exceptions as successes in SARIF output Exceptions are now treated as successes in the SARIF output, removing the separate exception handling. - test: type safe test input for SARIF Probably helps writing further test cases, instead of bare JSON - refactor: use google/go-cmp for json diff Based on PR comment Signed-off-by: Ville Vesilehto <[email protected]> --------- Signed-off-by: Ville Vesilehto <[email protected]> * chore: Change empty interface{} to any throughout the codebase (open-policy-agent#1057) The any type is a clearer intent than an empty interface. Signed-off-by: James Alseth <[email protected]> * chore: Update all examples to OPA V1 syntax (open-policy-agent#1058) Signed-off-by: James Alseth <[email protected]> * refactor(output): Add CheckResults type and helpers (open-policy-agent#1063) Adding a new type for a slice of CheckResult to add helper methods for checking if there were failures, warnings, or exceptions. Signed-off-by: James Alseth <[email protected]> * feat(test): Enable inter-query cache (open-policy-agent#1073) This improves performance for some Rego policies, such as those that use the http.send builtin. This is only enabled for the "conftest test" comamnd to avoid introducing flaky unit tests with "conftest verify" due to the caching. Signed-off-by: James Alseth <[email protected]> * build(deps): bump github.com/open-policy-agent/opa from 1.1.0 to 1.2.0 (open-policy-agent#1080) * build(deps): bump github.com/open-policy-agent/opa from 1.1.0 to 1.2.0 Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.1.0 to 1.2.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v1.1.0...v1.2.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build: Run `go mod tidy`. Signed-off-by: James Alseth <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: James Alseth <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Alseth <[email protected]> * build(deps): bump alpine from 3.21.2 to 3.21.3 (open-policy-agent#1072) Bumps alpine from 3.21.2 to 3.21.3. --- updated-dependencies: - dependency-name: alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/moby/buildkit from 0.19.0 to 0.20.0 (open-policy-agent#1076) Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.19.0 to 0.20.0. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.19.0...v0.20.0) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * refactor(ci): replace Makefile-based Docker builds with GitHub Action… (open-policy-agent#1075) * refactor(ci): replace Makefile-based Docker builds with GitHub Actions for easier maintenance Signed-off-by: Jesse Amamgbu <[email protected]> * build(deps): bump golang from 1.23.6-alpine to 1.24.0-alpine (open-policy-agent#1071) * build(deps): bump golang from 1.23.6-alpine to 1.24.0-alpine Bumps golang from 1.23.6-alpine to 1.24.0-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * build: Bump Go to 1.24. Signed-off-by: James Alseth <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: James Alseth <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Alseth <[email protected]> * feat: add --absolute-paths flag to pull command (open-policy-agent#1078) Add a new flag to the pull command that allows preserving absolute paths when downloading policies. By default, absolute paths in the --policy flag are treated as relative paths from the current directory. With the new --absolute-paths flag, users can specify absolute paths to download policies to. Signed-off-by: Ville Vesilehto <[email protected]> * docs: clarify --trace flag behavior with --output flag (open-policy-agent#1060) Improve documentation to make it clear that when both --trace and --output flags are specified, the output format takes priority over tracing. This helps users understand that they cannot combine tracing with custom output formats like JSON or table. Signed-off-by: Ville Vesilehto <[email protected]> * fix: Conftest can now successfully load files using a file URL (e.g., `file:///C:/path/to/data.yaml`) on windows (open-policy-agent#999) * fix: Conftest encounters errors on Windows when loading file paths that include drive letters (e.g., `C:/path/to/data.yaml`). Even when using a file URL (e.g., `file:///C:/path/to/data.yaml`), we still face issues. With these code changes, Conftest can now successfully load files using a file URL (e.g., `file:///C:/path/to/data.yaml`). We opted for file URLs instead of paths with drive letters (e.g., `C:/path/to/data.yaml`) because OPA does not support file paths with drive letters. For more details, see [this issue comment](open-policy-agent/opa#6922 (comment)). Resolves: open-policy-agent#979 Signed-off-by: Punith C K <[email protected]> * fix: Removing WithProcessAnnotation(true) which is not needed for loading data files Signed-off-by: Punith C K <[email protected]> * fix: Conftest can now successfully load files using a file URL (e.g., file:///C:/path/to/data.yaml) on windows Removing duplicate code Signed-off-by: Punith C K <[email protected]> --------- Signed-off-by: Punith C K <[email protected]> Signed-off-by: Punith C K <[email protected]> Co-authored-by: Punith C K <[email protected]> * ci: Revert "replace Makefile-based Docker builds with GitHub Action… (open-policy-agent#1075)" (open-policy-agent#1081) This reverts commit 854183b. Signed-off-by: James Alseth <[email protected]> * build(deps): bump github.com/moby/buildkit from 0.20.0 to 0.20.1 (open-policy-agent#1083) Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.20.0 to 0.20.1. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.20.0...v0.20.1) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: add documentation feature to the navigation bar (open-policy-agent#1087) Signed-off-by: boranx <[email protected]> * feat: add pre-commit hook support (open-policy-agent#1077) * feat: add pre-commit hook support Add pre-commit integration to validate configurations against OPA policies: - Create .pre-commit-hooks.yaml with conftest test/verify hook configs - Add pre-commit hook tests using bats - Install pre-commit in CI workflow Signed-off-by: Ville Vesilehto <[email protected]> * chore: add teardown to pre-commit test Add teardown function so we clean up the test config. Signed-off-by: Ville Vesilehto <[email protected]> * chore: remove verbose from pre-commit test Test checks the return code only Signed-off-by: Ville Vesilehto <[email protected]> * chore: suggestions from the pr Co-authored-by: Boran Seref <[email protected]> Signed-off-by: Ville Vesilehto <[email protected]> * chore: add Makefile step for installing deps Since acceptance tests require pre-commit lets make sure it's available - if not, install with pip. This is bundled with the 'make test-acceptance' step so that local and CI environments behave the same way. Signed-off-by: Ville Vesilehto <[email protected]> * chore: use isolated temp repo for testing pre-commit - Create a temporary Git repository for each test run - Configure Git with test-specific user info and disabled signing - Use absolute paths for pre-commit hook configuration - Clean up test artifacts properly after each run - Remove dependency on main repository state Signed-off-by: Ville Vesilehto <[email protected]> --------- Signed-off-by: Ville Vesilehto <[email protected]> * build(deps): bump golang from 1.24.0-alpine to 1.24.1-alpine (open-policy-agent#1086) Bumps golang from 1.24.0-alpine to 1.24.1-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/BurntSushi/toml from 1.4.0 to 1.5.0 (open-policy-agent#1089) Bumps [github.com/BurntSushi/toml](https://github.com/BurntSushi/toml) from 1.4.0 to 1.5.0. - [Release notes](https://github.com/BurntSushi/toml/releases) - [Commits](BurntSushi/toml@v1.4.0...v1.5.0) --- updated-dependencies: - dependency-name: github.com/BurntSushi/toml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ci: Remove PR workflow access to all permissions from GITHUB_TOKEN (open-policy-agent#1088) Signed-off-by: James Alseth <[email protected]> * build(deps): bump github.com/moby/buildkit from 0.20.1 to 0.20.2 (open-policy-agent#1091) Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.20.1 to 0.20.2. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.20.1...v0.20.2) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/open-policy-agent/opa from 1.2.0 to 1.3.0 (open-policy-agent#1092) Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.2.0 to 1.3.0. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v1.2.0...v1.3.0) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump golang from 1.24.1-alpine to 1.24.2-alpine (open-policy-agent#1096) Bumps golang from 1.24.1-alpine to 1.24.2-alpine. --- updated-dependencies: - dependency-name: golang dependency-version: 1.24.2-alpine dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump cuelang.org/go from 0.12.0 to 0.12.1 (open-policy-agent#1094) Bumps cuelang.org/go from 0.12.0 to 0.12.1. --- updated-dependencies: - dependency-name: cuelang.org/go dependency-version: 0.12.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/magiconair/properties from 1.8.9 to 1.8.10 (open-policy-agent#1097) Bumps [github.com/magiconair/properties](https://github.com/magiconair/properties) from 1.8.9 to 1.8.10. - [Release notes](https://github.com/magiconair/properties/releases) - [Commits](magiconair/properties@v1.8.9...v1.8.10) --- updated-dependencies: - dependency-name: github.com/magiconair/properties dependency-version: 1.8.10 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * deps: Bump hcl2json to v0.6.7 (open-policy-agent#1074) Signed-off-by: James Alseth <[email protected]> * refactor(ci): replace Makefile-based Docker builds with GitHub Action (open-policy-agent#1082) Signed-off-by: Jesse Amamgbu <[email protected]> * docs: update default template link to use absolute URL (open-policy-agent#1099) Change the relative link to the default template to use an absolute URL pointing to the raw GitHub content for better accessibility. Currently the link is broken since the file from the relative path is not deployed to the docs site. Signed-off-by: Ville Vesilehto <[email protected]> * chore: Update Github Actions via Dependabot (open-policy-agent#1100) Signed-off-by: Manuel Rüger <[email protected]> * build(deps): bump golangci/golangci-lint-action from 6 to 7 (open-policy-agent#1103) * build(deps): bump golangci/golangci-lint-action from 6 to 7 Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 6 to 7. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v6...v7) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> * ci: Run "golangci-lint migrate" Signed-off-by: James Alseth <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: James Alseth <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Alseth <[email protected]> * build(deps): bump actions/setup-go from 4 to 5 (open-policy-agent#1102) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](actions/setup-go@v4...v5) --- updated-dependencies: - dependency-name: actions/setup-go dependency-version: '5' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump bats-core/bats-action from 1.5.4 to 3.0.1 (open-policy-agent#1104) Bumps [bats-core/bats-action](https://github.com/bats-core/bats-action) from 1.5.4 to 3.0.1. - [Release notes](https://github.com/bats-core/bats-action/releases) - [Commits](bats-core/bats-action@1.5.4...3.0.1) --- updated-dependencies: - dependency-name: bats-core/bats-action dependency-version: 3.0.1 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * ci: Move docker build to separate job in the PR workflow (open-policy-agent#1105) This step is slow to run and only needs to be tested after everything else. Signed-off-by: James Alseth <[email protected]> * feat(runner): add support for symlinks (open-policy-agent#1098) Signed-off-by: Dieter Bocklandt <[email protected]> * feat(output): redirect trace output to stderr (open-policy-agent#1084) Signed-off-by: Ville Vesilehto <[email protected]> * build(deps): bump github.com/moby/buildkit from 0.20.2 to 0.21.0 (open-policy-agent#1101) Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.20.2 to 0.21.0. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.20.2...v0.21.0) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/moby/buildkit from 0.21.0 to 0.21.1 (open-policy-agent#1111) Bumps [github.com/moby/buildkit](https://github.com/moby/buildkit) from 0.21.0 to 0.21.1. - [Release notes](https://github.com/moby/buildkit/releases) - [Commits](moby/buildkit@v0.21.0...v0.21.1) --- updated-dependencies: - dependency-name: github.com/moby/buildkit dependency-version: 0.21.1 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/open-policy-agent/opa from 1.3.0 to 1.4.1 (open-policy-agent#1113) * build(deps): bump github.com/open-policy-agent/opa from 1.3.0 to 1.4.1 Bumps [github.com/open-policy-agent/opa](https://github.com/open-policy-agent/opa) from 1.3.0 to 1.4.1. - [Release notes](https://github.com/open-policy-agent/opa/releases) - [Changelog](https://github.com/open-policy-agent/opa/blob/main/CHANGELOG.md) - [Commits](open-policy-agent/opa@v1.3.0...v1.4.1) --- updated-dependencies: - dependency-name: github.com/open-policy-agent/opa dependency-version: 1.4.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * chore: go mod tidy Signed-off-by: James Alseth <[email protected]> --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: James Alseth <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: James Alseth <[email protected]> * docs: Make examples in the docs compatible with v1 syntax (open-policy-agent#1115) Signed-off-by: James Alseth <[email protected]> * cli: Make Rego v1 syntax the default (open-policy-agent#1114) Signed-off-by: James Alseth <[email protected]> * build(deps): bump golangci/golangci-lint-action from 7 to 8 (open-policy-agent#1119) Bumps [golangci/golangci-lint-action](https://github.com/golangci/golangci-lint-action) from 7 to 8. - [Release notes](https://github.com/golangci/golangci-lint-action/releases) - [Commits](golangci/golangci-lint-action@v7...v8) --- updated-dependencies: - dependency-name: golangci/golangci-lint-action dependency-version: '8' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * build(deps): bump github.com/google/go-jsonnet from 0.20.0 to 0.21.0 (open-policy-agent#1120) Bumps [github.com/google/go-jsonnet](https://github.com/google/go-jsonnet) from 0.20.0 to 0.21.0. - [Release notes](https://github.com/google/go-jsonnet/releases) - [Changelog](https://github.com/google/go-jsonnet/blob/master/.goreleaser.yml) - [Commits](google/go-jsonnet@v0.20.0...v0.21.0) --- updated-dependencies: - dependency-name: github.com/google/go-jsonnet dependency-version: 0.21.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * docs: Update README.md to make it compatible with v1 syntax (open-policy-agent#1122) Signed-off-by: William Burton <[email protected]> * fix: revert makefile changes --------- Signed-off-by: dependabot[bot] <[email protected]> Signed-off-by: Ville Vesilehto <[email protected]> Signed-off-by: Alexandre Couedelo <[email protected]> Signed-off-by: James Alseth <[email protected]> Signed-off-by: Jesse Amamgbu <[email protected]> Signed-off-by: Punith C K <[email protected]> Signed-off-by: Punith C K <[email protected]> Signed-off-by: boranx <[email protected]> Signed-off-by: Manuel Rüger <[email protected]> Signed-off-by: Dieter Bocklandt <[email protected]> Signed-off-by: William Burton <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Ville Vesilehto <[email protected]> Co-authored-by: Anders Eknert <[email protected]> Co-authored-by: Alexandre Couedelo <[email protected]> Co-authored-by: James Alseth <[email protected]> Co-authored-by: Jesse Amamgbu <[email protected]> Co-authored-by: pckvcode <[email protected]> Co-authored-by: Punith C K <[email protected]> Co-authored-by: Boran Seref <[email protected]> Co-authored-by: Manuel Rüger <[email protected]> Co-authored-by: Dieter Bocklandt <[email protected]> Co-authored-by: William Burton <[email protected]>
1 parent c8fa83f commit 70ca14c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1169
-536
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,8 @@ updates:
3030
directory: "/"
3131
schedule:
3232
interval: "weekly"
33+
34+
- package-ecosystem: "github-actions"
35+
directory: "/"
36+
schedule:
37+
interval: "weekly"

.github/workflows/release.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
env:
8+
IMAGE: openpolicyagent/conftest
9+
PLATFORMS: linux/amd64,linux/arm64
710

811
jobs:
912
release:
@@ -42,14 +45,14 @@ jobs:
4245
# run: make push TAG=$VERSION
4346

4447
- name: setup go
45-
uses: actions/setup-go@v4
48+
uses: actions/setup-go@v5
4649
with:
47-
go-version: "1.23.x"
50+
go-version: "1.24.x"
4851

4952
- name: release
5053
uses: goreleaser/goreleaser-action@v6
5154
with:
5255
args: release --clean
5356
version: "~> v1"
5457
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows_bak/pr.yaml

Lines changed: 37 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,12 @@ name: pr
22

33
on: [pull_request]
44

5-
permissions:
6-
actions: read
7-
checks: none
8-
contents: none
9-
deployments: none
10-
issues: none
11-
packages: none
12-
pull-requests: none
13-
repository-projects: none
14-
security-events: none
15-
statuses: none
5+
6+
permissions: {}
7+
8+
env:
9+
IMAGE: openpolicyagent/conftest
10+
PLATFORMS: linux/amd64,linux/arm64
1611

1712
jobs:
1813
style:
@@ -59,11 +54,11 @@ jobs:
5954
- name: setup go
6055
uses: actions/setup-go@v5
6156
with:
62-
go-version: "1.23.x"
57+
go-version: "1.24.x"
6358
cache: false
6459

6560
- name: golangci-lint
66-
uses: golangci/golangci-lint-action@v6
61+
uses: golangci/golangci-lint-action@v8
6762
with:
6863
args: --timeout=5m --color=always --max-same-issues=0 --max-issues-per-linter=0
6964

@@ -73,8 +68,16 @@ jobs:
7368
- name: unit test
7469
run: make test
7570

71+
# Ensure Actions runner has Python installed
72+
# This is required for pre-commit tests to work
73+
- name: setup python
74+
uses: actions/setup-python@v5
75+
with:
76+
python-version: '3.13'
77+
cache: 'pip'
78+
7679
- name: setup bats
77-
uses: bats-core/bats-action@1.5.4
80+
uses: bats-core/bats-action@3.0.1
7881
with:
7982
# Pin bats version to fix CI issue: https://github.com/bats-core/bats-action/pull/4
8083
bats-version: "1.10.0"
@@ -91,3 +94,23 @@ jobs:
9194

9295
- name: test oci push/pull
9396
run: ./scripts/push-pull-e2e.sh
97+
98+
docker:
99+
runs-on: ubuntu-latest
100+
needs:
101+
- validate
102+
steps:
103+
- name: checkout source
104+
uses: actions/checkout@v4
105+
106+
- name: setup docker buildx
107+
run: docker buildx create --name conftestbuild --use
108+
109+
- name: Build Docker image
110+
uses: docker/build-push-action@v6
111+
with:
112+
context: .
113+
push: false
114+
tags: |
115+
${{ env.IMAGE }}:latest
116+
platforms: ${{ env.PLATFORMS }}

.golangci.yaml

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
1-
linters-settings:
2-
misspell:
3-
locale: US
4-
govet:
5-
enable:
6-
- nilness
7-
staticcheck:
8-
checks:
9-
- "all" # Include all checks except the ones below.
10-
- "-SA1019" # Do not block the build if deprecated functions or packages are used.
11-
1+
version: "2"
122
linters:
13-
disable-all: true
3+
default: none
144
enable:
155
- errcheck
166
- goconst
17-
- gofmt
18-
- goimports
197
- gosec
20-
- gosimple
218
- govet
229
- ineffassign
2310
- makezero
@@ -26,8 +13,40 @@ linters:
2613
- predeclared
2714
- revive
2815
- staticcheck
29-
- typecheck
3016
- unconvert
3117
- unparam
3218
- unused
3319
- wastedassign
20+
settings:
21+
govet:
22+
enable:
23+
- nilness
24+
misspell:
25+
locale: US
26+
staticcheck:
27+
checks:
28+
# These are processed in order. It is important that the inclusion
29+
# comes before the exclusion.
30+
- all
31+
- -SA1019
32+
exclusions:
33+
generated: lax
34+
presets:
35+
- comments
36+
- common-false-positives
37+
- legacy
38+
- std-error-handling
39+
paths:
40+
- third_party$
41+
- builtin$
42+
- examples$
43+
formatters:
44+
enable:
45+
- gofmt
46+
- goimports
47+
exclusions:
48+
generated: lax
49+
paths:
50+
- third_party$
51+
- builtin$
52+
- examples$

.pre-commit-hooks.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
- id: conftest-test
2+
name: Conftest Test Policy Check
3+
description: Validate configuration files against Open Policy Agent policies using Conftest
4+
entry: conftest test
5+
language: golang
6+
pass_filenames: true
7+
require_serial: true
8+
minimum_pre_commit_version: "2.9.0"
9+
stages: [pre-commit, pre-merge-commit, pre-push, manual]
10+
11+
- id: conftest-verify
12+
name: Conftest Verify Policy Tests
13+
description: Run Rego unit tests for Conftest policies
14+
entry: conftest verify
15+
language: golang
16+
pass_filenames: false
17+
require_serial: true
18+
minimum_pre_commit_version: "2.9.0"
19+
stages: [pre-commit, pre-merge-commit, pre-push, manual]

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.23.6-alpine as base
1+
FROM golang:1.24.2-alpine as base
22
ARG TARGETARCH
33
ARG VERSION
44
ARG COMMIT
@@ -52,7 +52,7 @@ RUN go install cuelang.org/go/cmd/cue@latest
5252
WORKDIR /examples
5353

5454
## RELEASE ##
55-
FROM alpine:3.21.2
55+
FROM alpine:3.21.3
5656

5757
# Install git for protocols that depend on it when using conftest pull
5858
RUN apk add --no-cache git

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ test-examples: build ## Runs the tests for the examples.
3939
@bats acceptance.bats
4040

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

47+
.PHONY: install-test-deps
48+
install-test-deps: ## Installs dependencies required for testing.
49+
@command -v pre-commit >/dev/null 2>&1 || python -m pip install -r requirements-dev.txt
50+
4751
.PHONY: test-oci
4852
test-oci: ## Runs the OCI integration test for push and pull.
4953
@./scripts/push-pull-e2e.sh
@@ -75,4 +79,4 @@ help:
7579
# @test -n "$(TAG)" || (echo "TAG parameter not set." && exit 1)
7680
# @$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):$(TAG) --platform $(DOCKER_PLATFORMS)
7781
# @$(DOCKER) buildx build . --push --build-arg VERSION="$(TAG)" -t $(IMAGE):latest --platform $(DOCKER_PLATFORMS)
78-
# @$(DOCKER) buildx build . --push --target examples -t $(IMAGE):examples --platform $(DOCKER_PLATFORMS)
82+
# @$(DOCKER) buildx build . --push --target examples -t $(IMAGE):examples --platform $(DOCKER_PLATFORMS)

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ Here's a quick example. Save the following as `policy/deployment.rego`:
1515
```rego
1616
package main
1717
18-
deny[msg] {
18+
deny contains msg if {
1919
input.kind == "Deployment"
2020
not input.spec.template.spec.securityContext.runAsNonRoot
2121
2222
msg := "Containers must not run as root"
2323
}
2424
25-
deny[msg] {
25+
deny contains msg if {
2626
input.kind == "Deployment"
2727
not input.spec.selector.matchLabels.app
2828

acceptance.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,12 @@ EOF"
521521
[ "$status" -eq 1 ]
522522
[[ "$output" =~ "look up message type" ]]
523523
}
524+
525+
@test "Can parse files from a symlinked directory" {
526+
TMPDIR="$(mktemp -d -u)"
527+
ln -s $(pwd)/examples/hcl2 ${TMPDIR}
528+
run ./conftest test -p examples/hcl2/policy ${TMPDIR}
529+
rm -rf ${TMPDIR}
530+
[ "$status" -eq 1 ]
531+
[[ "$output" =~ "10 tests, 3 passed, 0 warnings, 7 failures, 0 exceptions" ]]
532+
}

docs/debug.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,3 +108,17 @@ TRAC | Exit data.main.deny = _
108108
TRAC Redo data.main.deny = _
109109
TRAC | Redo data.main.deny = _
110110
```
111+
112+
## Using trace with other output formats
113+
114+
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.
115+
116+
For example:
117+
118+
```console
119+
# Output trace to stderr and table format to stdout
120+
$ conftest test --trace --output=table deployment.yaml
121+
122+
# Capture trace output to a file while viewing table output
123+
$ conftest test --trace --output=table deployment.yaml 2>trace.log
124+
```

0 commit comments

Comments
 (0)