-
Notifications
You must be signed in to change notification settings - Fork 118
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
feat: Rego engine QoL improvements #960
Conversation
package lib.result | ||
|
||
new(msg, cause) = result { | ||
metadata := object.get(cause, "__defsec_metadata", cause) | ||
result := { | ||
"msg": msg, | ||
"startline": object.get(metadata, "startline", object.get(metadata, "StartLine", 0)), | ||
"endline": object.get(metadata, "endline", object.get(metadata, "EndLine", 0)), | ||
"filepath": object.get(metadata, "filepath", object.get(metadata, "Path", "")), | ||
"explicit": object.get(metadata, "explicit", false), | ||
"managed": object.get(metadata, "managed", true), | ||
"fskey": object.get(metadata, "fskey", ""), | ||
"resource": object.get(metadata, "resource", ""), | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry just stumbled my way here – will this helper live somewhere else? (Maybe it already does and I might have missed it)
Today there are references to this in other policies such as https://github.com/aquasecurity/defsec/blob/master/internal/rules/docker/policies/add_instead_of_copy.rego#L36
We probably also need to update the policies with the correct import of wherever this helper would end up living as today they don't seem to have them.
I ran into this while importing all defsec rules into trivy through the OCI artifact.
docker/policies/add_instead_of_copy.rego:36: rego_type_error: undefined function result.new
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this now works without the import as the function is provided as an extension via the Go library - it is now defined in Go.
Resolves #951