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

Function uploadToTransparencyLog

acceptance/image/image.go:305–341  ·  view source on GitHub ↗

uploadToTransparencyLog uploads a signature to the transparency log and returns the bundle along with the raw tlog entry (needed for creating protobuf bundles).

(ctx context.Context, payload []byte, rawSignature []byte, signer signature.SignerVerifier)

Source from the content-addressed store, hash-verified

303// uploadToTransparencyLog uploads a signature to the transparency log and returns the bundle
304// along with the raw tlog entry (needed for creating protobuf bundles).
305func uploadToTransparencyLog(ctx context.Context, payload []byte, rawSignature []byte, signer signature.SignerVerifier) (*bundle.RekorBundle, *models.LogEntryAnon, error) {
306 // Get public key or cert for transparency log upload
307 pkoc, err := getPublicKeyOrCert(signer)
308 if err != nil {
309 return nil, nil, fmt.Errorf("failed to get public key or cert: %w", err)
310 }
311
312 // Get Rekor URL
313 rekorURL, err := rekor.StubRekor(ctx)
314 if err != nil {
315 return nil, nil, fmt.Errorf("failed to get stub rekor URL: %w", err)
316 }
317
318 rekorClient, err := rc.GetRekorClient(rekorURL)
319 if err != nil {
320 return nil, nil, fmt.Errorf("failed to get rekor client: %w", err)
321 }
322
323 // Compute payload checksum
324 checksum := sha256.New()
325 if _, err := checksum.Write(payload); err != nil {
326 return nil, nil, fmt.Errorf("error checksuming payload: %w", err)
327 }
328
329 tlogEntry, err := cosign.TLogUpload(ctx, rekorClient, rawSignature, checksum, pkoc)
330 if err != nil {
331 return nil, nil, fmt.Errorf("failed to upload to transparency log: %w", err)
332 }
333
334 // Create bundle from the actual transparency log entry
335 rekorBundle := bundle.EntryToBundle(tlogEntry)
336 if rekorBundle == nil {
337 return nil, nil, fmt.Errorf("rekorBundle is nil after EntryToBundle")
338 }
339
340 return rekorBundle, tlogEntry, nil
341}
342
343// getImageDigestAndRef returns the image, its digest, and digest reference for signing
344func getImageDigestAndRef(ctx context.Context, imageName string) (v1.Image, v1.Hash, name.Digest, error) {

Calls 4

StubRekorFunction · 0.92
getPublicKeyOrCertFunction · 0.85
ErrorfMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected