MCPcopy Create free account
hub / github.com/conforma/cli / GeneratePredicate

Method GeneratePredicate

internal/validate/vsa/vsa.go:157–192  ·  view source on GitHub ↗

GeneratePredicate creates a Predicate for a validated image/component.

(ctx context.Context)

Source from the content-addressed store, hash-verified

155
156// GeneratePredicate creates a Predicate for a validated image/component.
157func (g *Generator) GeneratePredicate(ctx context.Context) (*Predicate, error) {
158 log.Infof("Generating EC predicate for image: %s", g.Component.ContainerImage)
159
160 // Get all image references including the index and architecture-specific images
161 imageRefs := g.getAllImageRefs()
162
163 // Determine the overall status based on component success
164 status := "failed"
165 if g.Component.Success {
166 status = "passed"
167 }
168
169 // Create detailed summary with architecture breakdown
170 summary := g.createDetailedSummary()
171
172 // Get the public key from the policy
173 publicKey := ""
174 if g.Policy != nil {
175 if publicKeyBytes, err := g.Policy.PublicKeyPEM(); err != nil {
176 log.Warnf("Failed to get public key from policy: %v", err)
177 } else {
178 publicKey = string(publicKeyBytes)
179 }
180 }
181
182 return &Predicate{
183 Policy: g.Report.Policy, // This contains the resolved policy with pinned URLs
184 PolicySource: g.PolicySource, // This contains the original policy location
185 ImageRefs: imageRefs,
186 Timestamp: time.Now().UTC().Format(time.RFC3339),
187 Status: status,
188 Verifier: "conforma",
189 Summary: summary,
190 PublicKey: publicKey,
191 }, nil
192}
193
194// createDetailedSummary creates a detailed summary with architecture breakdown
195func (g *Generator) createDetailedSummary() VSASummary {

Callers 1

TestGeneratePredicateFunction · 0.95

Calls 5

getAllImageRefsMethod · 0.95
createDetailedSummaryMethod · 0.95
InfofMethod · 0.65
PublicKeyPEMMethod · 0.65
WarnfMethod · 0.65

Tested by 1

TestGeneratePredicateFunction · 0.76