@@ -65,7 +65,8 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
65
65
Trigger : "workflow_dispatch" ,
66
66
Issuer : "https://token.actions.githubusercontent.com" ,
67
67
},
68
- source : trustedBuilderRepository ,
68
+ source : trustedBuilderRepository ,
69
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/heads/main" ,
69
70
},
70
71
{
71
72
name : "valid main ref for e2e test" ,
@@ -76,7 +77,8 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
76
77
Trigger : "workflow_dispatch" ,
77
78
Issuer : certOidcIssuer ,
78
79
},
79
- source : e2eTestRepository ,
80
+ source : e2eTestRepository ,
81
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/heads/main" ,
80
82
},
81
83
{
82
84
name : "valid main ref for e2e test - match builderID" ,
@@ -91,6 +93,7 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
91
93
buildOpts : & options.BuilderOpts {
92
94
ExpectedID : asStringPointer ("https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml" ),
93
95
},
96
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/heads/main" ,
94
97
},
95
98
{
96
99
name : "valid main ref for e2e test - mismatch builderID" ,
@@ -116,8 +119,9 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
116
119
Trigger : "workflow_dispatch" ,
117
120
Issuer : certOidcIssuer ,
118
121
},
119
- source : "malicious/source" ,
120
- err : serrors .ErrorMismatchSource ,
122
+ source : "malicious/source" ,
123
+ err : serrors .ErrorMismatchSource ,
124
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/heads/main" ,
121
125
},
122
126
{
123
127
name : "valid main ref for builder" ,
@@ -151,7 +155,8 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
151
155
Trigger : "workflow_dispatch" ,
152
156
Issuer : certOidcIssuer ,
153
157
},
154
- source : "asraa/slsa-on-github-test" ,
158
+ source : "asraa/slsa-on-github-test" ,
159
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/tags/v1.2.3" ,
155
160
},
156
161
{
157
162
name : "valid workflow identity - match builderID" ,
@@ -166,6 +171,7 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
166
171
buildOpts : & options.BuilderOpts {
167
172
ExpectedID : asStringPointer ("https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml" ),
168
173
},
174
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/tags/v1.2.3" ,
169
175
},
170
176
{
171
177
name : "valid workflow identity - mismatch builderID" ,
@@ -191,8 +197,9 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
191
197
Trigger : "workflow_dispatch" ,
192
198
Issuer : certOidcIssuer ,
193
199
},
194
- source : "asraa/slsa-on-github-test" ,
195
- err : serrors .ErrorInvalidRef ,
200
+ source : "asraa/slsa-on-github-test" ,
201
+ err : serrors .ErrorInvalidRef ,
202
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/tags/v1.2.3-alpha" ,
196
203
},
197
204
{
198
205
name : "invalid workflow identity with build" ,
@@ -227,7 +234,8 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
227
234
Trigger : "workflow_dispatch" ,
228
235
Issuer : certOidcIssuer ,
229
236
},
230
- source : "github.com/asraa/slsa-on-github-test" ,
237
+ source : "github.com/asraa/slsa-on-github-test" ,
238
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/tags/v1.2.3" ,
231
239
},
232
240
{
233
241
name : "valid workflow identity with fully qualified source - match builderID" ,
@@ -242,6 +250,7 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
242
250
buildOpts : & options.BuilderOpts {
243
251
ExpectedID : asStringPointer ("https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml" ),
244
252
},
253
+ builderID : "https://github.com/" + trustedBuilderRepository + "/.github/workflows/builder_go_slsa3.yml@refs/tags/v1.2.3" ,
245
254
},
246
255
{
247
256
name : "valid workflow identity with fully qualified source - mismatch builderID" ,
@@ -267,10 +276,16 @@ func Test_VerifyWorkflowIdentity(t *testing.T) {
267
276
if opts == nil {
268
277
opts = & options.BuilderOpts {}
269
278
}
270
- _ , err := VerifyWorkflowIdentity (tt .workflow , opts , tt .source )
279
+ id , err := VerifyWorkflowIdentity (tt .workflow , opts , tt .source )
271
280
if ! errCmp (err , tt .err ) {
272
281
t .Errorf (cmp .Diff (err , tt .err , cmpopts .EquateErrors ()))
273
282
}
283
+ if err != nil {
284
+ return
285
+ }
286
+ if id != tt .builderID {
287
+ t .Errorf (cmp .Diff (id , tt .builderID ))
288
+ }
274
289
})
275
290
}
276
291
}
0 commit comments