@@ -25,6 +25,7 @@ import (
25
25
26
26
protobundle "github.com/sigstore/protobuf-specs/gen/pb-go/bundle/v1"
27
27
protocommon "github.com/sigstore/protobuf-specs/gen/pb-go/common/v1"
28
+ protodsse "github.com/sigstore/protobuf-specs/gen/pb-go/dsse"
28
29
rekorv1 "github.com/sigstore/protobuf-specs/gen/pb-go/rekor/v1"
29
30
_ "github.com/sigstore/rekor/pkg/types/hashedrekord"
30
31
"github.com/stretchr/testify/require"
@@ -669,6 +670,53 @@ func TestVerificationContent(t *testing.T) {
669
670
},
670
671
wantErr : true ,
671
672
},
673
+ {
674
+ name : "certificate chain with nil bytes" ,
675
+ pb : Bundle {
676
+ Bundle : & protobundle.Bundle {
677
+ VerificationMaterial : & protobundle.VerificationMaterial {
678
+ Content : & protobundle.VerificationMaterial_X509CertificateChain {
679
+ X509CertificateChain : & protocommon.X509CertificateChain {
680
+ Certificates : []* protocommon.X509Certificate {
681
+ {
682
+ RawBytes : nil ,
683
+ },
684
+ },
685
+ },
686
+ },
687
+ },
688
+ },
689
+ },
690
+ wantErr : true ,
691
+ },
692
+ {
693
+ name : "certificate chain with nil cert" ,
694
+ pb : Bundle {
695
+ Bundle : & protobundle.Bundle {
696
+ VerificationMaterial : & protobundle.VerificationMaterial {
697
+ Content : & protobundle.VerificationMaterial_X509CertificateChain {
698
+ X509CertificateChain : & protocommon.X509CertificateChain {
699
+ Certificates : nil ,
700
+ },
701
+ },
702
+ },
703
+ },
704
+ },
705
+ wantErr : true ,
706
+ },
707
+ {
708
+ name : "certificate chain with nil chain" ,
709
+ pb : Bundle {
710
+ Bundle : & protobundle.Bundle {
711
+ VerificationMaterial : & protobundle.VerificationMaterial {
712
+ Content : & protobundle.VerificationMaterial_X509CertificateChain {
713
+ X509CertificateChain : nil ,
714
+ },
715
+ },
716
+ },
717
+ },
718
+ wantErr : true ,
719
+ },
672
720
{
673
721
name : "certificate" ,
674
722
pb : Bundle {
@@ -699,6 +747,36 @@ func TestVerificationContent(t *testing.T) {
699
747
},
700
748
wantErr : true ,
701
749
},
750
+ {
751
+ name : "certificate with nil bytes" ,
752
+ pb : Bundle {
753
+ Bundle : & protobundle.Bundle {
754
+ VerificationMaterial : & protobundle.VerificationMaterial {
755
+ Content : & protobundle.VerificationMaterial_Certificate {
756
+ Certificate : & protocommon.X509Certificate {
757
+ RawBytes : nil ,
758
+ },
759
+ },
760
+ },
761
+ },
762
+ },
763
+ wantErr : true ,
764
+ },
765
+ {
766
+ name : "empty certificate" ,
767
+ pb : Bundle {
768
+ Bundle : & protobundle.Bundle {
769
+ VerificationMaterial : & protobundle.VerificationMaterial {
770
+ Content : & protobundle.VerificationMaterial_Certificate {
771
+ Certificate : & protocommon.X509Certificate {
772
+ RawBytes : nil ,
773
+ },
774
+ },
775
+ },
776
+ },
777
+ },
778
+ wantErr : true ,
779
+ },
702
780
{
703
781
name : "public key" ,
704
782
pb : Bundle {
@@ -712,6 +790,19 @@ func TestVerificationContent(t *testing.T) {
712
790
},
713
791
wantPublicKey : true ,
714
792
},
793
+ {
794
+ name : "nil public key" ,
795
+ pb : Bundle {
796
+ Bundle : & protobundle.Bundle {
797
+ VerificationMaterial : & protobundle.VerificationMaterial {
798
+ Content : & protobundle.VerificationMaterial_PublicKey {
799
+ PublicKey : nil ,
800
+ },
801
+ },
802
+ },
803
+ },
804
+ wantErr : true ,
805
+ },
715
806
}
716
807
for _ , tt := range tests {
717
808
tt := tt
@@ -742,16 +833,50 @@ func TestSignatureContent(t *testing.T) {
742
833
pb Bundle
743
834
wantEnvelope bool
744
835
wantSignature bool
836
+ wantErr bool
745
837
}{
746
838
{
747
839
name : "dsse envelope" ,
748
840
pb : Bundle {
749
841
Bundle : & protobundle.Bundle {
750
- Content : & protobundle.Bundle_DsseEnvelope {},
842
+ Content : & protobundle.Bundle_DsseEnvelope {
843
+ DsseEnvelope : & protodsse.Envelope {
844
+ Payload : []byte {},
845
+ Signatures : []* protodsse.Signature {{Sig : []byte {}, Keyid : "" }},
846
+ },
847
+ },
751
848
},
752
849
},
753
850
wantEnvelope : true ,
754
851
},
852
+ {
853
+ name : "dsse envelope with nil signature" ,
854
+ pb : Bundle {
855
+ Bundle : & protobundle.Bundle {
856
+ Content : & protobundle.Bundle_DsseEnvelope {
857
+ DsseEnvelope : & protodsse.Envelope {
858
+ Payload : []byte {},
859
+ Signatures : []* protodsse.Signature {nil },
860
+ },
861
+ },
862
+ },
863
+ },
864
+ wantErr : true ,
865
+ },
866
+ {
867
+ name : "dsse envelope with nil payload" ,
868
+ pb : Bundle {
869
+ Bundle : & protobundle.Bundle {
870
+ Content : & protobundle.Bundle_DsseEnvelope {
871
+ DsseEnvelope : & protodsse.Envelope {
872
+ Payload : nil ,
873
+ Signatures : []* protodsse.Signature {{Sig : []byte {}, Keyid : "" }},
874
+ },
875
+ },
876
+ },
877
+ },
878
+ wantErr : true ,
879
+ },
755
880
{
756
881
name : "message signature" ,
757
882
pb : Bundle {
@@ -770,6 +895,10 @@ func TestSignatureContent(t *testing.T) {
770
895
tt := tt
771
896
t .Run (tt .name , func (t * testing.T ) {
772
897
got , gotErr := tt .pb .SignatureContent ()
898
+ if tt .wantErr {
899
+ require .Error (t , gotErr )
900
+ return
901
+ }
773
902
require .NoError (t , gotErr )
774
903
if tt .wantEnvelope {
775
904
require .NotNil (t , got .EnvelopeContent ())
@@ -794,7 +923,12 @@ func TestEnvelope(t *testing.T) {
794
923
name : "dsse envelope" ,
795
924
pb : Bundle {
796
925
Bundle : & protobundle.Bundle {
797
- Content : & protobundle.Bundle_DsseEnvelope {},
926
+ Content : & protobundle.Bundle_DsseEnvelope {
927
+ DsseEnvelope : & protodsse.Envelope {
928
+ Payload : []byte {},
929
+ Signatures : []* protodsse.Signature {{Sig : []byte {}, Keyid : "" }},
930
+ },
931
+ },
798
932
},
799
933
},
800
934
},
0 commit comments