Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: --strict flag when using conftest verify #866

Merged

Conversation

samcrang
Copy link
Contributor

Without this conftest verify --strict does not fail in situations where running conftest test --strict would.

I think this was probably an oversight with #798 and it was expected that conftest verify --strict should behave the same as conftest test --strict.

Without this change the behaviour is:

$ go run . verify --policy examples/strict-rules/policy --strict

0 tests, 0 passed, 0 warnings, 0 failures, 0 exceptions, 0 skipped

With this change the behaviour is:

$ go run . verify --policy examples/strict-rules/policy --strict
Error: running verification: load: loading policies: get compiler: 4 errors occurred:
examples/strict-rules/policy/lenient.rego:6: rego_compile_error: assigned var b unused
examples/strict-rules/policy/lenient.rego:7: rego_compile_error: assigned var x unused
examples/strict-rules/policy/lenient.rego:11: rego_compile_error: assigned var c unused
examples/strict-rules/policy/lenient.rego:14: rego_compile_error: unused argument y. (hint: use _ (wildcard variable) instead)
exit status 1

Without this `conftest verify --strict` does not fail in situations
where running `conftest test --strict` would.

I think this was probably an oversight with open-policy-agent#798 and it was expected
that `conftest verify --strict` should behave the same as `conftest test
--strict`.

Without this change the behaviour is:

```
$ go run . verify --policy examples/strict-rules/policy --strict

0 tests, 0 passed, 0 warnings, 0 failures, 0 exceptions, 0 skipped
```

With this change the behaviour is:

```
$ go run . verify --policy examples/strict-rules/policy --strict
Error: running verification: load: loading policies: get compiler: 4 errors occurred:
examples/strict-rules/policy/lenient.rego:6: rego_compile_error: assigned var b unused
examples/strict-rules/policy/lenient.rego:7: rego_compile_error: assigned var x unused
examples/strict-rules/policy/lenient.rego:11: rego_compile_error: assigned var c unused
examples/strict-rules/policy/lenient.rego:14: rego_compile_error: unused argument y. (hint: use _ (wildcard variable) instead)
exit status 1
```

Signed-off-by: Sam Crang <sam.crang@gmail.com>
Copy link
Member

@boranx boranx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sam,

Nice catch! And thanks for fixing it as well 👍

@boranx boranx merged commit 1d387bc into open-policy-agent:master Sep 14, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants