TestSignerWorkflowSANMatching drives the pattern built by validateSignerWorkflow through the sigstore-go matcher that consumes it, because that matcher applies the pattern with regexp.MatchString and so does not anchor it on the caller's behalf.
(t *testing.T)
| 341 | // through the sigstore-go matcher that consumes it, because that matcher applies the |
| 342 | // pattern with regexp.MatchString and so does not anchor it on the caller's behalf. |
| 343 | func TestSignerWorkflowSANMatching(t *testing.T) { |
| 344 | const pinnedWorkflow = "owner/builder/.github/workflows/release.yml" |
| 345 | const workflowDir = "https://github.com/owner/builder/.github/workflows/" |
| 346 | |
| 347 | testcases := []struct { |
| 348 | name string |
| 349 | san string |
| 350 | expectMatch bool |
| 351 | }{ |
| 352 | { |
| 353 | name: "pinned workflow at a branch ref", |
| 354 | san: workflowDir + "release.yml@refs/heads/main", |
| 355 | expectMatch: true, |
| 356 | }, |
| 357 | { |
| 358 | name: "pinned workflow at a commit SHA", |
| 359 | san: workflowDir + "release.yml@09b495c3f12c7881b3cc17209a327792065c1a1d", |
| 360 | expectMatch: true, |
| 361 | }, |
| 362 | { |
| 363 | name: "pinned workflow at a tag containing @", |
| 364 | san: workflowDir + "release.yml@refs/tags/pkg@1.2.3", |
| 365 | expectMatch: true, |
| 366 | }, |
| 367 | { |
| 368 | name: "pinned workflow at a branch containing @", |
| 369 | san: workflowDir + "release.yml@refs/heads/feature@v2", |
| 370 | expectMatch: true, |
| 371 | }, |
| 372 | { |
| 373 | name: "pinned workflow with no ref", |
| 374 | san: workflowDir + "release.yml", |
| 375 | expectMatch: true, |
| 376 | }, |
| 377 | { |
| 378 | name: "workflow whose file name extends the pinned name", |
| 379 | san: workflowDir + "release.yml.attacker.yml@refs/heads/attacker", |
| 380 | expectMatch: false, |
| 381 | }, |
| 382 | { |
| 383 | name: "workflow whose file name contains the ref separator", |
| 384 | san: workflowDir + "release.yml@attacker.yml@refs/heads/attacker", |
| 385 | expectMatch: false, |
| 386 | }, |
| 387 | { |
| 388 | name: "different workflow in the pinned repository", |
| 389 | san: workflowDir + "other.yml@refs/heads/main", |
| 390 | expectMatch: false, |
| 391 | }, |
| 392 | { |
| 393 | name: "pinned workflow in a lookalike repository", |
| 394 | san: "https://github.com/owner/builder-attacker/.github/workflows/release.yml@refs/heads/main", |
| 395 | expectMatch: false, |
| 396 | }, |
| 397 | } |
| 398 | |
| 399 | sanRegex, err := validateSignerWorkflow("github.com", pinnedWorkflow) |
| 400 | require.NoError(t, err) |
nothing calls this directly
no test coverage detected