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

Function unmarshallSignatures

acceptance/image/image.go:1280–1295  ·  view source on GitHub ↗

unmarshallSignatures extracts the signatures from the raw attestation

(rawCosignSignature []byte)

Source from the content-addressed store, hash-verified

1278
1279// unmarshallSignatures extracts the signatures from the raw attestation
1280func unmarshallSignatures(rawCosignSignature []byte) (*cosign.Signatures, error) {
1281 var attestationPayload cosign.AttestationPayload
1282 if err := json.Unmarshal(rawCosignSignature, &attestationPayload); err != nil {
1283 return nil, err
1284 }
1285
1286 l := len(attestationPayload.Signatures)
1287 switch {
1288 case l == 0:
1289 return nil, nil
1290 case l > 1:
1291 return nil, fmt.Errorf("received %d signatures, not expecting more than 1", l)
1292 default:
1293 return &attestationPayload.Signatures[0], nil
1294 }
1295}
1296
1297// AttestationSignaturesFrom returns the list of attestation signatures found in the context in
1298// JSON format. If not found, and empty JSON array is returned.

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected