unmarshallSignatures extracts the signatures from the raw attestation
(rawCosignSignature []byte)
| 1278 | |
| 1279 | // unmarshallSignatures extracts the signatures from the raw attestation |
| 1280 | func 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. |
no test coverage detected