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

Function DSSEEnvelopeFromBundleBytes

pkg/attestation/attestations.go:105–114  ·  view source on GitHub ↗

DSSEEnvelopeFromBundleBytes extracts a DSSE envelope from the protojson-encoded bytes of a Sigstore bundle. It validates that the bundle carries a DSSE envelope with at least one signature, since callers (and DSSEEnvelopeFromBundle) assume that invariant.

(bundle []byte)

Source from the content-addressed store, hash-verified

103// It validates that the bundle carries a DSSE envelope with at least one signature, since callers
104// (and DSSEEnvelopeFromBundle) assume that invariant.
105func DSSEEnvelopeFromBundleBytes(bundle []byte) (*dsse.Envelope, error) {
106 var attBundle protobundle.Bundle
107 if err := protojson.Unmarshal(bundle, &attBundle); err != nil {
108 return nil, fmt.Errorf("unmarshalling bundle: %w", err)
109 }
110 if len(attBundle.GetDsseEnvelope().GetSignatures()) == 0 {
111 return nil, fmt.Errorf("invalid attestation bundle: missing DSSE signature")
112 }
113 return DSSEEnvelopeFromBundle(&attBundle), nil
114}
115
116// FixSignatureInBundle removes any additional base64 encoding from the signature in the bundle.
117// Kept for backward compatibility with attestations stored before the fix for

Callers 2

SaveAttestationMethod · 0.92
storeAttestationMethod · 0.92

Calls 1

DSSEEnvelopeFromBundleFunction · 0.85

Tested by

no test coverage detected