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

feat: Rego engine QoL improvements #960

Merged
merged 19 commits into from
Sep 27, 2022
Merged

feat: Rego engine QoL improvements #960

merged 19 commits into from
Sep 27, 2022

Conversation

liamg
Copy link
Contributor

@liamg liamg commented Sep 27, 2022

Resolves #951

@liamg liamg requested a review from owenrumney as a code owner September 27, 2022 08:26
@liamg liamg merged commit 418759b into master Sep 27, 2022
@liamg liamg deleted the liamg-rego-engine-fun branch September 27, 2022 13:00
Comment on lines -1 to -15
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", ""),
}
}
Copy link
Member

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

Copy link
Contributor Author

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.

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.

feat: Core rego engine rework and QoL improvements
3 participants