@@ -36,7 +36,7 @@ func pString(s string) *string {
36
36
const TEST_DIR = "./testdata"
37
37
38
38
var (
39
- GHA_ARTIFACT_PATH_BUILDERS = []string {"gha_go" , "gha_generic" }
39
+ GHA_ARTIFACT_PATH_BUILDERS = []string {"gha_go" , "gha_generic" , "gha_delegator" , "gha_maven" , "gha_gradle" }
40
40
// TODO(https://github.com/slsa-framework/slsa-verifier/issues/485): Merge this with
41
41
// GHA_ARTIFACT_PATH_BUILDERS.
42
42
GHA_ARTIFACT_CONTAINER_BUILDERS = []string {"gha_container-based" }
@@ -80,6 +80,9 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
80
80
t .Parallel ()
81
81
goBuilder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml"
82
82
genericBuilder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml"
83
+ delegatorBuilder := "https://github.com/slsa-framework/example-trw/.github/workflows/builder_high-perms_slsa3.yml"
84
+ mavenBuilder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_maven_slsa3.yml"
85
+ gradleBuilder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_gradle_slsa3.yml"
83
86
84
87
tests := []struct {
85
88
name string
@@ -532,9 +535,15 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
532
535
533
536
for _ , v := range checkVersions {
534
537
var provenancePath string
538
+ var byob bool
535
539
if tt .provenancePath == "" {
536
540
testPath := filepath .Clean (filepath .Join (TEST_DIR , v , tt .artifacts [0 ]))
537
- provenancePath = fmt .Sprintf ("%s.intoto.jsonl" , testPath )
541
+ if strings .Contains (testPath , "delegator" ) || strings .Contains (testPath , "maven" ) || strings .Contains (testPath , "gradle" ) {
542
+ provenancePath = fmt .Sprintf ("%s.build.slsa" , testPath )
543
+ byob = true
544
+ } else {
545
+ provenancePath = fmt .Sprintf ("%s.intoto.jsonl" , testPath )
546
+ }
538
547
} else {
539
548
provenancePath = filepath .Clean (filepath .Join (TEST_DIR , v , tt .provenancePath ))
540
549
}
@@ -564,14 +573,25 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
564
573
builder = goBuilder
565
574
case strings .HasSuffix (name , "_generic" ):
566
575
builder = genericBuilder
576
+ case strings .HasSuffix (name , "_delegator" ):
577
+ builder = delegatorBuilder
578
+ case strings .HasSuffix (name , "_maven" ):
579
+ builder = mavenBuilder
580
+ case strings .HasSuffix (name , "_gradle" ):
581
+ builder = gradleBuilder
567
582
default :
568
583
builder = genericBuilder
569
584
}
570
585
571
586
// Default builders to test.
572
587
builderIDs := []* string {
573
588
pString (builder ),
574
- nil ,
589
+ }
590
+
591
+ // Do not run without explicit builder ID for the delegator,
592
+ // because it's hosted on a different repo slsa-framework/example-package.
593
+ if builder != delegatorBuilder {
594
+ builderIDs = append (builderIDs , nil )
575
595
}
576
596
577
597
// We only add the tags to tests for versions >= 1,
@@ -600,6 +620,10 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
600
620
BuildWorkflowInputs : tt .inputs ,
601
621
}
602
622
623
+ // BYOB-based builders ignore the reusable workflow.
624
+ if errCmp (tt .err , serrors .ErrorUntrustedReusableWorkflow ) && byob {
625
+ tt .err = serrors .ErrorMismatchBuilderID
626
+ }
603
627
// The outBuilderID is the actual builder ID from the provenance.
604
628
// This is always long form for the GHA builders.
605
629
outBuilderID , err := cmd .Exec (context .Background (), artifacts )
@@ -699,6 +723,10 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
699
723
// or testdata from malicious untrusted builders.
700
724
// When true, this does not iterate over all builder versions.
701
725
noversion bool
726
+ // minversion is a special case to test a newly added feature into a builder.
727
+ minversion string
728
+ // maxversion is a special case to handle incompatible error changes in the builder.
729
+ maxversion string
702
730
}{
703
731
{
704
732
name : "valid main branch default" ,
@@ -718,7 +746,6 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
718
746
source : "github.com/slsa-framework/example-package" ,
719
747
pbranch : pString ("main" ),
720
748
},
721
-
722
749
{
723
750
name : "wrong branch master" ,
724
751
artifact : "container_workflow_dispatch" ,
@@ -745,19 +772,37 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
745
772
err : serrors .ErrorMismatchSource ,
746
773
},
747
774
{
748
- name : "tag no match empty tag workflow_dispatch" ,
749
- artifact : "container_workflow_dispatch" ,
750
- source : "github.com/slsa-framework/example-package" ,
751
- ptag : pString ("v1.2.3" ),
752
- err : serrors .ErrorInvalidRef ,
775
+ name : "tag no match empty tag workflow_dispatch" ,
776
+ artifact : "container_workflow_dispatch" ,
777
+ source : "github.com/slsa-framework/example-package" ,
778
+ ptag : pString ("v1.2.3" ),
779
+ maxversion : "v1.8.0" ,
780
+ err : serrors .ErrorInvalidRef ,
753
781
},
754
782
{
755
783
name : "versioned tag no match empty tag workflow_dispatch" ,
756
784
artifact : "container_workflow_dispatch" ,
757
785
source : "github.com/slsa-framework/example-package" ,
758
786
pversiontag : pString ("v1" ),
787
+ maxversion : "v1.8.0" ,
759
788
err : serrors .ErrorInvalidRef ,
760
789
},
790
+ {
791
+ name : "tag no match empty tag workflow_dispatch > v1.9.0" ,
792
+ artifact : "container_workflow_dispatch" ,
793
+ source : "github.com/slsa-framework/example-package" ,
794
+ ptag : pString ("v1.2.3" ),
795
+ minversion : "v1.9.0" ,
796
+ err : serrors .ErrorMismatchTag ,
797
+ },
798
+ {
799
+ name : "versioned tag no match empty tag workflow_dispatch > v1.9.0" ,
800
+ artifact : "container_workflow_dispatch" ,
801
+ source : "github.com/slsa-framework/example-package" ,
802
+ pversiontag : pString ("v1" ),
803
+ minversion : "v1.9.0" ,
804
+ err : serrors .ErrorMismatchTag ,
805
+ },
761
806
}
762
807
for _ , tt := range tests {
763
808
tt := tt // Re-initializing variable so it is not changed while executing the closure below
@@ -770,6 +815,19 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
770
815
}
771
816
772
817
for _ , v := range checkVersions {
818
+ parts := strings .Split (v , "/" )
819
+ version := ""
820
+ if len (parts ) > 1 {
821
+ version = parts [1 ]
822
+ }
823
+ if version != "" && tt .minversion != "" && semver .Compare (version , tt .minversion ) <= 0 {
824
+ fmt .Println ("skiping due to min:" , version )
825
+ continue
826
+ }
827
+ if version != "" && tt .maxversion != "" && semver .Compare (version , tt .maxversion ) > 0 {
828
+ fmt .Println ("skiping due to max:" , version )
829
+ continue
830
+ }
773
831
image := filepath .Clean (filepath .Join (TEST_DIR , v , tt .artifact ))
774
832
// TODO(#258): test for tagged builder.
775
833
sv := filepath .Base (v )
0 commit comments