@@ -1510,6 +1510,73 @@ func Test_runVerifyGHAContainerBased(t *testing.T) {
1510
1510
}
1511
1511
}
1512
1512
1513
+ func Test_runVerifyBcrModule (t * testing.T ) {
1514
+ t .Parallel ()
1515
+ os .Setenv ("SLSA_VERIFIER_EXPERIMENTAL" , "1" )
1516
+
1517
+ bcrReleaserBuilderID := "https://github.com/bazel-contrib/.github/.github/workflows/release_ruleset.yaml"
1518
+ bcrPublisherBuilderID := "https://github.com/bazel-contrib/publish-to-bcr/.github/workflows/publish.yaml"
1519
+
1520
+ tests := []struct {
1521
+ name string
1522
+ artifact string
1523
+ source string
1524
+ builderID string
1525
+ err error
1526
+ }{
1527
+ {
1528
+ name : "module.bazel using publishing builder" ,
1529
+ artifact : "MODULE.bazel" ,
1530
+ source : "github.com/aspect-build/rules_lint" ,
1531
+ builderID : bcrPublisherBuilderID ,
1532
+ },
1533
+ {
1534
+ name : "source archive using release builder" ,
1535
+ artifact : "rules_lint-v1.3.1.tar.gz" ,
1536
+ source : "github.com/aspect-build/rules_lint" ,
1537
+ builderID : bcrReleaserBuilderID ,
1538
+ },
1539
+ {
1540
+ name : "module.bazel no builder id" ,
1541
+ artifact : "MODULE.bazel" ,
1542
+ source : "github.com/aspect-build/rules_lint" ,
1543
+ err : serrors .ErrorUntrustedReusableWorkflow ,
1544
+ },
1545
+ {
1546
+ name : "source archive no builder id" ,
1547
+ artifact : "rules_lint-v1.3.1.tar.gz" ,
1548
+ source : "github.com/aspect-build/rules_lint" ,
1549
+ err : serrors .ErrorUntrustedReusableWorkflow ,
1550
+ },
1551
+ {
1552
+ name : "invalid bcr (but otherwise valid) artifact" ,
1553
+ artifacts : []string {"binary-linux-amd64-workflow_dispatch" },
1554
+ source : "github.com/slsa-framework/example-package" ,
1555
+ },
1556
+ }
1557
+
1558
+ for _ , tt := range tests {
1559
+ t .Run (tt .name , func (t * testing.T ) {
1560
+ t .Parallel ()
1561
+
1562
+ artifactPath := filepath .Clean (filepath .Join (TEST_DIR , "bcr" , tt .artifact ))
1563
+ // TODO: this only handles the single attestation case in tests, so *.intoto.jsonl is essentially *.json
1564
+ provenancePath := fmt .Sprintf ("%s.intoto.jsonl" , artifactPath )
1565
+ cmd := verify.VerifyBcrModuleCommand {
1566
+ ProvenancePath : provenancePath ,
1567
+ BuilderID : & tt .builderID ,
1568
+ SourceURI : tt .source ,
1569
+ }
1570
+
1571
+ _ , err := cmd .Exec (context .Background (), artifactPath )
1572
+ if diff := cmp .Diff (tt .err , err , cmpopts .EquateErrors ()); diff != "" {
1573
+ t .Fatalf ("unexpected error (-want +got): \n %s" , diff )
1574
+ }
1575
+ })
1576
+ }
1577
+
1578
+ }
1579
+
1513
1580
func Test_runVerifyNpmPackage (t * testing.T ) {
1514
1581
// We cannot use t.Setenv due to parallelized tests.
1515
1582
os .Setenv ("SLSA_VERIFIER_EXPERIMENTAL" , "1" )
0 commit comments