Skip to content

Commit 80c7d86

Browse files
authored
feat: v1.9.0 regression tests (#696)
Add regression tests for BYOB releae. --------- Signed-off-by: laurentsimon <[email protected]>
1 parent 58eede7 commit 80c7d86

File tree

72 files changed

+418
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+418
-9
lines changed

cli/slsa-verifier/main_regression_test.go

+67-9
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func pString(s string) *string {
3636
const TEST_DIR = "./testdata"
3737

3838
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"}
4040
// TODO(https://github.com/slsa-framework/slsa-verifier/issues/485): Merge this with
4141
// GHA_ARTIFACT_PATH_BUILDERS.
4242
GHA_ARTIFACT_CONTAINER_BUILDERS = []string{"gha_container-based"}
@@ -80,6 +80,9 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
8080
t.Parallel()
8181
goBuilder := "https://github.com/slsa-framework/slsa-github-generator/.github/workflows/builder_go_slsa3.yml"
8282
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"
8386

8487
tests := []struct {
8588
name string
@@ -532,9 +535,15 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
532535

533536
for _, v := range checkVersions {
534537
var provenancePath string
538+
var byob bool
535539
if tt.provenancePath == "" {
536540
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+
}
538547
} else {
539548
provenancePath = filepath.Clean(filepath.Join(TEST_DIR, v, tt.provenancePath))
540549
}
@@ -564,14 +573,25 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
564573
builder = goBuilder
565574
case strings.HasSuffix(name, "_generic"):
566575
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
567582
default:
568583
builder = genericBuilder
569584
}
570585

571586
// Default builders to test.
572587
builderIDs := []*string{
573588
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)
575595
}
576596

577597
// We only add the tags to tests for versions >= 1,
@@ -600,6 +620,10 @@ func Test_runVerifyGHAArtifactPath(t *testing.T) {
600620
BuildWorkflowInputs: tt.inputs,
601621
}
602622

623+
// BYOB-based builders ignore the reusable workflow.
624+
if errCmp(tt.err, serrors.ErrorUntrustedReusableWorkflow) && byob {
625+
tt.err = serrors.ErrorMismatchBuilderID
626+
}
603627
// The outBuilderID is the actual builder ID from the provenance.
604628
// This is always long form for the GHA builders.
605629
outBuilderID, err := cmd.Exec(context.Background(), artifacts)
@@ -699,6 +723,10 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
699723
// or testdata from malicious untrusted builders.
700724
// When true, this does not iterate over all builder versions.
701725
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
702730
}{
703731
{
704732
name: "valid main branch default",
@@ -718,7 +746,6 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
718746
source: "github.com/slsa-framework/example-package",
719747
pbranch: pString("main"),
720748
},
721-
722749
{
723750
name: "wrong branch master",
724751
artifact: "container_workflow_dispatch",
@@ -745,19 +772,37 @@ func Test_runVerifyGHAArtifactImage(t *testing.T) {
745772
err: serrors.ErrorMismatchSource,
746773
},
747774
{
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,
753781
},
754782
{
755783
name: "versioned tag no match empty tag workflow_dispatch",
756784
artifact: "container_workflow_dispatch",
757785
source: "github.com/slsa-framework/example-package",
758786
pversiontag: pString("v1"),
787+
maxversion: "v1.8.0",
759788
err: serrors.ErrorInvalidRef,
760789
},
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+
},
761806
}
762807
for _, tt := range tests {
763808
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) {
770815
}
771816

772817
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+
}
773831
image := filepath.Clean(filepath.Join(TEST_DIR, v, tt.artifact))
774832
// TODO(#258): test for tagged builder.
775833
sv := filepath.Base(v)

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v13.0.30

Whitespace-only changes.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v13.0.30.intoto.build.slsa

+1
Large diffs are not rendered by default.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v14

Whitespace-only changes.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v14.2

Whitespace-only changes.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v14.2.intoto.build.slsa

+1
Large diffs are not rendered by default.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-push-v14.intoto.build.slsa

+1
Large diffs are not rendered by default.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-workflow_dispatch

Whitespace-only changes.

cli/slsa-verifier/testdata/gha_container-based/v1.9.0/binary-linux-amd64-workflow_dispatch.intoto.build.slsa

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

cli/slsa-verifier/testdata/gha_delegator/v1.9.0/binary-linux-amd64-push-v13.0.30.build.slsa

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

cli/slsa-verifier/testdata/gha_delegator/v1.9.0/binary-linux-amd64-push-v14.2.build.slsa

+1
Large diffs are not rendered by default.

cli/slsa-verifier/testdata/gha_delegator/v1.9.0/binary-linux-amd64-push-v14.build.slsa

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

cli/slsa-verifier/testdata/gha_delegator/v1.9.0/binary-linux-amd64-workflow_dispatch.build.slsa

+1
Large diffs are not rendered by default.
Binary file not shown.

cli/slsa-verifier/testdata/gha_generic/v1.9.0/binary-linux-amd64-push-v13.0.30.intoto.jsonl

+1
Large diffs are not rendered by default.
Binary file not shown.
Binary file not shown.

cli/slsa-verifier/testdata/gha_generic/v1.9.0/binary-linux-amd64-push-v14.2.intoto.jsonl

+1
Large diffs are not rendered by default.

cli/slsa-verifier/testdata/gha_generic/v1.9.0/binary-linux-amd64-push-v14.intoto.jsonl

+1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)