GeneratePredicate creates a Predicate for a validated image/component.
(ctx context.Context)
| 155 | |
| 156 | // GeneratePredicate creates a Predicate for a validated image/component. |
| 157 | func (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 |
| 195 | func (g *Generator) createDetailedSummary() VSASummary { |