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

Function DSSEEnvelopeFromBundle

pkg/attestation/attestations.go:47–70  ·  view source on GitHub ↗

DSSEEnvelopeFromBundle Extracts a DSSE envelope from a Sigstore bundle (Sigstore bundles have their own protobuf implementation for DSSE)

(bundle *protobundle.Bundle)

Source from the content-addressed store, hash-verified

45
46// DSSEEnvelopeFromBundle Extracts a DSSE envelope from a Sigstore bundle (Sigstore bundles have their own protobuf implementation for DSSE)
47func DSSEEnvelopeFromBundle(bundle *protobundle.Bundle) *dsse.Envelope {
48 sigstoreEnvelope := bundle.GetDsseEnvelope()
49 sig := sigstoreEnvelope.GetSignatures()[0].GetSig()
50 // See bug: https://github.com/chainloop-dev/chainloop/issues/1832
51 // signature might be encoded twice. Let's try to fix it first.
52 // TODO: remove this once the bug is fixed
53 sigBytes := sig
54 dst := make([]byte, base64.RawURLEncoding.DecodedLen(len(sig)))
55 i, err := base64.StdEncoding.Decode(dst, sig)
56 if err == nil {
57 // it was already encoded, let's use the decoded one
58 sigBytes = dst[:i]
59 }
60 return &dsse.Envelope{
61 PayloadType: sigstoreEnvelope.PayloadType,
62 Payload: base64.StdEncoding.EncodeToString(sigstoreEnvelope.Payload),
63 Signatures: []dsse.Signature{
64 {
65 KeyID: sigstoreEnvelope.GetSignatures()[0].GetKeyid(),
66 Sig: base64.StdEncoding.EncodeToString(sigBytes),
67 },
68 },
69 }
70}
71
72func BundleFromDSSEEnvelope(dsseEnvelope *dsse.Envelope) (*protobundle.Bundle, error) {
73 if len(dsseEnvelope.Signatures) == 0 {

Callers 5

ExtractDSSEEnvelopeFunction · 0.92
verifyCertSignatureFunction · 0.92
TestSaveAttestationMethod · 0.92
applyBundleMethod · 0.92

Calls

no outgoing calls

Tested by 1

TestSaveAttestationMethod · 0.74