`attestation verify --signer-workflow` always treated as regex
- Dominant language
- Go
- Stars
- 46.3k
- Forks
- 9k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 89
Description
### Describe the bug
```
gh --version
gh version 2.55.0 (2024-08-20)
https://github.com/cli/cli/releases/tag/v2.55.0
```
Currently the `gh attestation verify --help` for the `--signer-workflow` option does not seem to suggest that the user input is meant to be treated as a regex, since there is also another `--cert-identity-regex` option.
```
--signer-workflow string Workflow that signed attestation in the format [host/]////
```
However I found that if I supplied an incorrect value, the returned error messages suggest the tool will always treat my input as a regex.
And so I've been able to supply regexes to `--signer-workflow`.
### Steps to reproduce the behavior
1. See my [example workflow](https://github.com/ramonpetgrave/github-build-attestations-rw/actions/runs/10503787090) and download the artifacts and attestations.
2. Invoke, supplying the incorrect signer branch name
````
gh attestation verify slsa3_build_artifact/gundam --bundle slsa3_build_attestation/dl.json --repo ramonpetgrave/github-build-attestations-rw --signer-workflow "ramonpetgrave/github-build-attestations-rw/.github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/main"
Loaded digest sha256:5b4167c6bdf2cf66e30ac3af8d63036bda530293e5dd694085f7df9d8d4fa91d for file://slsa3_build_artifact/gundam
Loaded 1 attestation from slsa3_build_attestation/dl.json
✗ Verification failed
Error: verifying with issuer "sigstore.dev": failed to verify certificate identity: no matching CertificateIdentity found, last error: expected SAN value to match regex "^https://github.com/ramonpetgrave/github-build-attestations-rw/.github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/main", got "https://github.com/ramonpetgrave/github-build-attestations-rw/.github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/dev"
````
3. Invoke, supplying a regex that would match multiple different branch names, including the correct branch name.
````
✗ gh attestation verify slsa3_build_artifact/gundam --bundle slsa3_build_attestation/dl.json --repo ramonpetgrave/github-build-attestations-rw --signer-workflow "ramonpetgrave/github-build-attestations-rw/.github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/(main|dev)"
Loaded digest sha256:5b4167c6bdf2cf66e30ac3af8d63036bda530293e5dd694085f7df9d8d4fa91d for file://slsa3_build_artifact/gundam
Loaded 1 attestation from slsa3_build_attestation/dl.json
✓ Verification succeeded!
sha256:5b4167c6bdf2cf66e30ac3af8d63036bda530293e5dd694085f7df9d8d4fa91d was attested by:
REPO PREDICATE_TYPE WORKFLOW
ramonpetgrave/github-build-attestations-rw https://slsa.dev/provenance/v1 .github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/dev
````
4. Invoke, supplying an incomplete signer workflow URI, not including the ref, and also cutting off the last few characters of, the workflow's file name.
```
gh attestation verify slsa3_build_artifact/gundam --bundle slsa3_build_attestation/dl.json --repo ramonpetgrave/github-build-attestations-rw --signer-workflow "ramonpetgrave/github-build-attestations-rw/.github/workflows/att"
Loaded digest sha256:5b4167c6bdf2cf66e30ac3af8d63036bda530293e5dd694085f7df9d8d4fa91d for file://slsa3_build_artifact/gundam
Loaded 1 attestation from slsa3_build_attestation/dl.json
✓ Verification succeeded!
sha256:5b4167c6bdf2cf66e30ac3af8d63036bda530293e5dd694085f7df9d8d4fa91d was attested by:
REPO PREDICATE_TYPE WORKFLOW
ramonpetgrave/github-build-attestations-rw https://slsa.dev/provenance/v1 .github/workflows/attest-build-provenance-slsa3-rw.yml@refs/heads/dev
```
### Expected vs actual behavior
With the wording of the documentation, I would not expect user input for `--signer-workflow` to be treated as a regex, especially since it's possible to supply an incomplete workflow URI: For example: `[host/]///////`.
Instead, it should probably be treated as a full string match, and another future `--signer-workflow-regex` option should handle regexes.
### Logs
_Logs supplied above._
Contributor guide
Assessment
This issue has not been assessed yet.