Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
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]>
  • Loading branch information
thevilledev authored Mar 1, 2025
commit d62aa8d90c9c023bedc76151cb44dcbe4f6e7a79
16 changes: 15 additions & 1 deletion internal/commands/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ The policy location defaults to the policy directory in the local folder.
The location can be overridden with the '--policy' flag, e.g.:

$ conftest pull --policy <my-directory> <oci-url>

When using absolute paths, you can enable the '--absolute-paths' flag to preserve them:

$ conftest pull --absolute-paths --policy /absolute/path/to/policies <oci-url>
`

// NewPullCommand creates a new pull command to allow users
Expand All @@ -57,6 +61,9 @@ func NewPullCommand(ctx context.Context) *cobra.Command {
if err := viper.BindPFlag("tls", cmd.Flags().Lookup("tls")); err != nil {
return fmt.Errorf("bind flag: %w", err)
}
if err := viper.BindPFlag("absolute-paths", cmd.Flags().Lookup("absolute-paths")); err != nil {
return fmt.Errorf("bind flag: %w", err)
}

return nil
},
Expand All @@ -66,7 +73,13 @@ func NewPullCommand(ctx context.Context) *cobra.Command {
return fmt.Errorf("missing required arguments")
}

policyDir := filepath.Join(".", viper.GetString("policy"))
policyPath := viper.GetString("policy")
var policyDir string
if viper.GetBool("absolute-paths") && filepath.IsAbs(policyPath) {
policyDir = policyPath
} else {
policyDir = filepath.Join(".", policyPath)
}

if err := downloader.Download(ctx, policyDir, args); err != nil {
return fmt.Errorf("download policies: %w", err)
Expand All @@ -78,6 +91,7 @@ func NewPullCommand(ctx context.Context) *cobra.Command {

cmd.Flags().StringP("policy", "p", "policy", "Path to download the policies to")
cmd.Flags().BoolP("tls", "s", true, "Use TLS to access the registry")
cmd.Flags().Bool("absolute-paths", false, "Preserve absolute paths in policy flag")

return &cmd
}
39 changes: 39 additions & 0 deletions tests/pull-absolute-paths/test.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bats

setup() {
# Create temporary directories for testing
export TEMP_DIR=$(mktemp -d)
export REL_TEMP_DIR="examples/tmp-conftest-test-$$"
export ABS_POLICY_DIR="${TEMP_DIR}/conftest-policies"
mkdir -p "${ABS_POLICY_DIR}"
mkdir -p "${REL_TEMP_DIR}"
}

teardown() {
# Clean up temporary directories
rm -rf "${TEMP_DIR}"
rm -rf "${REL_TEMP_DIR}"
}

@test "Pull command works with relative paths (default behavior)" {
run $CONFTEST pull --policy $REL_TEMP_DIR https://raw.githubusercontent.com/open-policy-agent/conftest/master/examples/compose/policy/deny.rego
[ "$status" -eq 0 ]
[ -d "$REL_TEMP_DIR" ]
[ -f "$REL_TEMP_DIR/deny.rego" ]
}

@test "Pull command uses absolute paths as relative when --absolute-paths is not set" {
run $CONFTEST pull --policy "${ABS_POLICY_DIR}" https://raw.githubusercontent.com/open-policy-agent/conftest/master/examples/compose/policy/deny.rego
[ "$status" -eq 0 ]
# The policy should be downloaded to ./ABS_POLICY_DIR instead of the absolute path
[ ! -d "${ABS_POLICY_DIR}/deny.rego" ]
[ -f "./${ABS_POLICY_DIR}/deny.rego" ]
}

@test "Pull command works with absolute path when --absolute-paths is set" {
run $CONFTEST pull --absolute-paths --policy "${ABS_POLICY_DIR}" https://raw.githubusercontent.com/open-policy-agent/conftest/master/examples/compose/policy/deny.rego
[ "$status" -eq 0 ]
# The policy should be downloaded to the absolute path
[ ! -f "./${ABS_POLICY_DIR#/}/deny.rego" ]
[ -f "${ABS_POLICY_DIR}/deny.rego" ]
}