MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / subject

Method subject

pkg/attestation/renderer/chainloop/v02.go:203–248  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

201}
202
203func (r *RendererV02) subject() ([]*intoto.ResourceDescriptor, error) {
204 raw, err := json.Marshal(r.att)
205 if err != nil {
206 return nil, err
207 }
208
209 // We might don't want this and just force the existence of one material with output = true
210 subject := []*intoto.ResourceDescriptor{
211 {
212 Name: v1.CreateAnnotation(fmt.Sprintf("workflow.%s", r.att.GetWorkflow().Name)),
213 Digest: map[string]string{
214 "sha256": fmt.Sprintf("%x", sha256.Sum256(raw)),
215 },
216 },
217 }
218
219 if head := r.att.GetHead(); head != nil {
220 annotations, err := commitAnnotations(head)
221 if err != nil {
222 return nil, fmt.Errorf("error creating annotations: %w", err)
223 }
224
225 subject = append(subject, &intoto.ResourceDescriptor{
226 Name: SubjectGitHead,
227 Digest: map[string]string{"sha1": head.GetHash()},
228 Annotations: annotations,
229 })
230 }
231
232 normalizedMaterials, err := outputMaterials(r.att, true)
233 if err != nil {
234 return nil, fmt.Errorf("error normalizing materials: %w", err)
235 }
236
237 for _, m := range normalizedMaterials {
238 if m.Digest != nil {
239 subject = append(subject, &intoto.ResourceDescriptor{
240 Name: m.Name,
241 Digest: m.Digest,
242 Annotations: m.Annotations,
243 })
244 }
245 }
246
247 return subject, nil
248}
249
250func (r *RendererV02) predicate() (*structpb.Struct, error) {
251 normalizedMaterials, err := outputMaterials(r.att, false)

Callers 1

StatementMethod · 0.95

Calls 5

commitAnnotationsFunction · 0.85
outputMaterialsFunction · 0.85
GetHeadMethod · 0.80
GetWorkflowMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected