-
Notifications
You must be signed in to change notification settings - Fork 309
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
conftest test does not output all policy names #490
Comments
@Biswajee could you provide a small example of a Rego policy and the result you would expect to see when it succeeds? Theres been some discussion on this in the past, but the success messages always seemed to be noisy since the only thing we'd be able to report on is the name of the rule that succeeded. For most, the rules are just |
@jpreese Thanks for picking up the request. I would wish to have the name of policy file being returned as success message since we generally have descriptive filenames and policies defined in them. Consider the example policy:
package kubernetes.admission
mandatory_labels = {"dev" , "prod"}
deny [msg] {
input.kind == "Deployment"
not mandatory_labels[input.metadata.labels]
msg := sprintf("Mandatory labels %s are not present", [mandatory_labels])
} I can imagine +---------+-----------------------------------------------------+--------------------------------+
| RESULT | FILE | MESSAGE |
+---------+-----------------------------------------------------+--------------------------------+
| success | resultDir\test\templates\deployment.yaml | enforce-labels.rego |
+---------+-----------------------------------------------------+--------------------------------+ This can help users understand that the policy was evaluated and at the same time provides some positive vibes that some policies succeeded 😄. Incase, you are looking for a longer filename, here's one: |
Thanks for the clarification, @Biswajee! We may need to provide the option to display filename and/or policy name. Showing the filename makes sense in this scenario, but other users may have less files but more verbose rule names. |
Hi @jpreese, I agree with you on having lesser filenames but more verbose rules. But, a flag for displaying filenames will be really cool since we maintain verbose policy filenames and often a single rule per file. I could find examples of naming policy files in the |
Oh sorry if I wasn't clear. I agree that showing the filename is a good thing to have. But we should also provide a way to include the rule name for users who do the opposite (generic policy files with very granular rule names). e.g. Message: enforce-labels.rego // this works great for named files |
I'm interested in this functionality as well. I'm more specifically looking for the successful rules to be enumerated in the JUnit output so my CI engine can report on it. |
Related to this issue as well (specifically my comments about JUnit which echo @jschwanz ) |
I think I'm trying to figure out the same thing as @jcmcken and @jschwanz, but I got a little confused between this issue and #258, and wanted to recap the current state of things for conftest 0.30.0. If I use granular deny_xxx rules, all in the same .rego file and package name, currently conftest output:
That's what other users experience, right? Here's my example. If I use the deny_xxx rule naming feature and create two deny_xxx rules:
Then conftest (version 0.30.0) will show two results for each input file:
The "junit" output is similar to the "table" output - basically MESSAGE is embedded in the name of each of the 6 The failing rule ( If the rule name (deny_escalation_containers vs deny_host_ports_containers) was somehow included in the individual result (in the RESULT, in the MESSAGE, or in some new column, that would improve things for me. Do others agree? Thanks! |
After some more testing, I see how conftest's NAMESPACE column gives you a way to distinguish successful rules, if you're willing to break up your rules into fine-grained Rego packages (and files). If I take what was a single Rego file and package, with a single 7 Rego packages:
conftest 0.30.0 run:
Each input file has exactly 7 results, 1 per Rego package, whether the package's This example is more in keeping with the Rego package organization in the konstraint project's examples, lots of fine-grained Rego packages. Does conftest's current behavior of including the Rego package name in NAMESPACE help the other folks commenting on this issue? Or do the other folks need to avoid fine-grained Rego packages? Like either of these situations:
Are there any downsides (performance etc.) to splitting the Rego code into so many Rego packages? Thanks! |
@jdoylei My impression of the Konstraint repo's organization is that it's only organized that way because of how Gatekeeper is designed. But Gatekeeper's organization is not necessarily a model everyone should follow. For example, Gatekeeper doesn't support the concept of "shared library" code that can be re-used across policies. This necessitates copying and pasting shared library rules across many different constraint templates. And splitting your Rego code across many tiny files. Needless to say, it's quite a pain to work with in practice. |
Hi,
Currently,
conftest test resultDir --output table --all-namespaces
results in:Requesting for a feature that will enable us visualize successful policies as well in the message column.
And, something similar for other
--output
implementations as well.Reference link to discussion: here.
The text was updated successfully, but these errors were encountered: