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

Change the artifact_signature rule to use constraints evaluation, not deny-by-default #104

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions rule-types/github/artifact_signature.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,25 @@ def:
eval:
type: rego
rego:
type: deny-by-default
type: constraints
def: |
package minder

import future.keywords.every
import future.keywords.if

default allow := false
violations[{"msg": msg}] {
# iterate over the artifacts. We want all artifacts to be checked individually
artifactVersion := input.ingested[_]

allow if {
every artifactVersion in input.ingested {
every key, value in input.profile {
artifactVersion.Verification[key] == value
}
}
# for each artifact, iterate over all the profile keys
keys := object.keys(input.profile)
key := keys[_]
value := input.profile[key]

artifactVersion.Verification[key] != value

msg := sprintf("Verification failed for on key '%s': expected '%v', got '%v'", [key, value, artifactVersion.Verification[key]])
}
# Defines the configuration for alerting on the rule
alert:
Expand Down
Loading