datree icon indicating copy to clipboard operation
datree copied to clipboard

Print rule name in CLI output needed for skip rule annotations

Open HariSekhon opened this issue 3 years ago • 4 comments

When you get a policy rule violation output in the CLI or CI/CD, it would be nice if it printed the rule name needed to set an ignore - relates to #726.

This would save having to go to the dashboard, figure out which rule it is, and click the i for information to get the rule name to put into an ignore annotation.

HariSekhon avatar Jul 18 '22 15:07 HariSekhon

@HariSekhon I get your point, though I wonder if presenting this identifier can create more noise than value, since it's relevant mainly for users that have Policy-As-Code mode on, or users that want to skip a rule, therefore it may confuse other users.

I suggest that we add the PAC identifier to the output when using the --verbose flag, that way each user can decide whether to have it or not. WDYT?

adifayer avatar Jul 19 '22 09:07 adifayer

Agreed, this should probably be in the first level of verbose mode.

HariSekhon avatar Jul 19 '22 13:07 HariSekhon

These are the product requirements:

Is your feature request related to a problem? Please describe. Skipping a rule on a specific resource is done by adding an annotation in the manifest. The annotation syntax is the following: datree.skip/[identifier] while the identifier is the unique rule identifier (policy as code identifier). The PAC identifier is available only within the dashboard, which creates an extra step to the process of skipping a rule.

Describe the solution you'd like When passing the --verbose flag within datree test run, display each rule's Policy-as-code. Output example:

❌  Ensure each container image has a pinned (tag) version  [9 occurrences]
      Policy as code identifier: CONTAINERS_MISSING_IMAGE_VALUE_VERSION
      How to fix: https://hub.datree.io/ensure-image-pinned-version
       - metadata.name: N/A (kind: Pod)
💡  Incorrect value for key `image` - specify an image version to avoid unpleasant "version surprises" in the future

adifayer avatar Jul 19 '22 16:07 adifayer

@adifayer @eyarz shall I work on this

Meyazhagan avatar Apr 27 '23 17:04 Meyazhagan