feat: (IaC) include evidence field in json output [IAC-3161] #5611
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Submission Checklist
What does this PR do?
IaC custom rules may include evidence to why a certain policy passed for a resource. If that evidence (string) is specified, we display it in the JSON output for the rule.
Note: this applies only for custom IaC rules, since the standard rules are not required to provide this evidence, and were not modified to include it.
There should be no concerns about output size increase, IaC custom rules are used by a small fraction of the customers, and this field should be a one line string in the majority of cases, if at all added.
How should this be manually tested?
This functionality is fully covered by tests, so no need for a manual test, which is a bit complicated.
I write it here nevertheless, just in case.
A custom rule needs to be created and pushed to Snyk using
snyk iac rules init
. See an example here of what the rule could look like.Theresources
Rego rule declares acontext
, which needs to include anevidence
string field.Publish the rule bundle using
snyk iac rules push
.Define a terraform file with a resource designed to pass the custom rule.
Run
snyk iac test
on the Terraform file, and expect to see theevidence
message included in the relevantinfrastructureAsCodeSuccesses
entries.What are the relevant tickets?
https://snyksec.atlassian.net/browse/IAC-3161