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

fix(attestations): add compatibility with old policy evaluations #1756

Merged
merged 4 commits into from
Jan 24, 2025
Merged
Changes from 1 commit
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
9 changes: 8 additions & 1 deletion pkg/attestation/renderer/chainloop/v02.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ type ProvenancePredicateV02 struct {
Materials []*intoto.ResourceDescriptor `json:"materials,omitempty"`
// Map materials and policies
PolicyEvaluations map[string][]*PolicyEvaluation `json:"policyEvaluations,omitempty"`
// Used to read policy evaluations from old attestations
PolicyEvaluationsFallback map[string][]*PolicyEvaluation `json:"policy_evaluations,omitempty"`

// Whether the attestation has policy violations
PolicyHasViolations bool `json:"policyHasViolations"`
// Whether we want to block the attestation on policy violations
Expand Down Expand Up @@ -374,7 +377,11 @@ func (p *ProvenancePredicateV02) GetMaterials() []*NormalizedMaterial {
}

func (p *ProvenancePredicateV02) GetPolicyEvaluations() map[string][]*PolicyEvaluation {
return p.PolicyEvaluations
evs := p.PolicyEvaluations
if len(evs) == 0 && len(p.PolicyEvaluationsFallback) > 0 {
evs = p.PolicyEvaluationsFallback
}
return evs
}

func (p *ProvenancePredicateV02) HasPolicyViolations() bool {
Expand Down
Loading