Skip to content

Commit c9bb5b6

Browse files
Add Cosign attestation verification
1 parent a03b298 commit c9bb5b6

1 file changed

Lines changed: 99 additions & 10 deletions

File tree

VERIFY_ATTESTATIONS.md

Lines changed: 99 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,30 @@ Download the release artifacts first:
2727

2828
```bash
2929
version="x.y.z"
30-
gh release download "v${version}" --repo integrations/terraform-provider-github -p "*.zip"
30+
gh release download "v${version}" --repo integrations/terraform-provider-github -p "*.zip" --clobber
3131
```
3232

3333
To verify the artifact attestations for this project, you can run the following command:
3434

3535
```bash
36-
gh attestation verify --repo integrations/terraform-provider-github --source-ref "v${version}"\
37-
--signer-workflow integrations/terraform-provider-github/.github/workflows/release.yaml \
36+
gh attestation verify --repo integrations/terraform-provider-github --source-ref "refs/tags/v${version}"\
37+
--signer-workflow integrations/terraform-provider-github/.github/workflows/release.yaml@refs/tags/v${version} \
3838
"terraform-provider-github_${version}_darwin_amd64.zip"
3939
```
4040

41+
### Verifying all artifacts at once
42+
43+
Alternatively, you can verify all downloaded artifacts with a loop that provides individual status reporting:
44+
45+
```bash
46+
for artifact in terraform-provider-github_${version}_*.zip; do
47+
echo "Verifying: $artifact"
48+
gh attestation verify --repo integrations/terraform-provider-github --source-ref "refs/tags/v${version}" \
49+
--signer-workflow integrations/terraform-provider-github/.github/workflows/release.yaml@refs/tags/v${version} \
50+
"$artifact" && echo "✓ Verified" || echo "✗ Failed"
51+
done
52+
```
53+
4154
### Using optional flags
4255

4356
The `gh attestation verify` command supports additional flags for more specific verification:
@@ -54,11 +67,11 @@ If you would like to require an artifact attestation to be signed with a specifi
5467

5568
```bash
5669
gh attestation verify --owner integrations --signer-workflow \
57-
integrations/terraform-provider-github/.github/workflows/release.yaml \
70+
integrations/terraform-provider-github/.github/workflows/release.yaml@refs/tags/v${version} \
5871
terraform-provider-github_${version}_darwin_amd64.zip
5972
```
6073

61-
## Verifying release artifacts with Cosign
74+
## Verifying checksums file signature with Cosign and checking artifact integrity
6275

6376
> [!WARNING]
6477
> Not all the releases may have Cosign signature for the checksum files.
@@ -74,15 +87,12 @@ First, install Cosign if you haven't already. See the [installation instructions
7487

7588
### Verify checksums file
7689

77-
> [!NOTE]
78-
> Make sure to replace X.Y.Z with the actual release tag you want to verify.
79-
8090
Download the checksums file and its signature bundle:
8191

8292
```bash
8393
gh release download v${version} --repo integrations/terraform-provider-github \
8494
-p "terraform-provider-github_${version}_SHA256SUMS" \
85-
-p "terraform-provider-github_${version}_SHA256SUMS.sbom.json.bundle"
95+
-p "terraform-provider-github_${version}_SHA256SUMS.sbom.json.bundle" --clobber
8696
```
8797

8898
Verify the checksums file signature:
@@ -103,7 +113,7 @@ Download the artifact you want to verify:
103113

104114
```bash
105115
gh release download v${version} --repo integrations/terraform-provider-github \
106-
-p "terraform-provider-github_${version}_darwin_amd64.zip"
116+
-p "terraform-provider-github_${version}_darwin_amd64.zip" --clobber
107117
```
108118

109119
Verify the checksum:
@@ -113,3 +123,82 @@ shasum -a 256 -c terraform-provider-github_${version}_SHA256SUMS --ignore-missin
113123
```
114124

115125
This will verify that your downloaded artifact matches the signed checksum, confirming its integrity and authenticity.
126+
127+
## Verifying SLSA Provenance Attestations with Cosign
128+
129+
In addition to using the GitHub CLI, you can verify SLSA provenance attestations using Cosign by downloading the attestation and verifying it against your local artifact.
130+
131+
### Prerequisites
132+
133+
1. Install `cosign` for verifying attestations. See the [installation instructions](https://docs.sigstore.dev/cosign/system_config/installation/).
134+
2. Install `gh` (GitHub CLI) if you haven't already. See the [installation instructions](https://github.com/cli/cli#installation).
135+
136+
### Download and verify attestation
137+
138+
> [!NOTE]
139+
> Make sure to replace x.y.z with the actual release tag you want to verify.
140+
141+
> [!CAUTION]
142+
> The attestations are available only for the releases created since the version `v6.9.0` of this project.
143+
144+
First, download the artifact you want to verify:
145+
146+
```bash
147+
version="x.y.z"
148+
gh release download "v${version}" --repo integrations/terraform-provider-github \
149+
-p "terraform-provider-github_${version}_darwin_amd64.zip" --clobber
150+
```
151+
152+
Then, download the attestation associated with the artifact:
153+
154+
```bash
155+
gh attestation download "terraform-provider-github_${version}_darwin_amd64.zip" \
156+
--repo integrations/terraform-provider-github
157+
```
158+
159+
This will create a file named `sha256:[digest].jsonl` in the current directory.
160+
161+
Verify the attestation using Cosign:
162+
163+
```bash
164+
# Calculate the digest and verify using the specific bundle file
165+
digest=$(shasum -a 256 "terraform-provider-github_${version}_darwin_amd64.zip" | awk '{ print $1 }')
166+
cosign verify-blob-attestation \
167+
--bundle "sha256:${digest}.jsonl" \
168+
--new-bundle-format \
169+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
170+
--certificate-identity "https://github.com/integrations/terraform-provider-github/.github/workflows/release.yaml@refs/tags/v${version}" \
171+
"terraform-provider-github_${version}_darwin_amd64.zip"
172+
```
173+
174+
A successful verification will output `Verified OK`, confirming that the artifact was built by the trusted GitHub Actions workflow and its provenance is securely recorded.
175+
176+
### Verifying all release artifacts
177+
178+
To verify all release artifacts for a specific version:
179+
180+
```bash
181+
version="x.y.z"
182+
183+
# Download all release artifacts
184+
gh release download "v${version}" --repo integrations/terraform-provider-github -p "*.zip" --clobber
185+
186+
# Download attestations for all artifacts
187+
for artifact in terraform-provider-github_${version}_*.zip; do
188+
gh attestation download "$artifact" --repo integrations/terraform-provider-github
189+
done
190+
191+
# Verify all artifacts using specific digest-based bundle files
192+
for artifact in terraform-provider-github_${version}_*.zip; do
193+
echo "Verifying: $artifact"
194+
digest=$(shasum -a 256 "$artifact" | awk '{ print $1 }')
195+
cosign verify-blob-attestation \
196+
--bundle "sha256:${digest}.jsonl" \
197+
--new-bundle-format \
198+
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
199+
--certificate-identity "https://github.com/integrations/terraform-provider-github/.github/workflows/release.yaml@refs/tags/v${version}" \
200+
"$artifact" > /dev/null && echo "✓ Verified" || echo "✗ Failed"
201+
done
202+
```
203+
204+
This approach calculates the digest for each artifact and uses the corresponding specific bundle file, ensuring each artifact is verified against its own attestation.

0 commit comments

Comments
 (0)