Skip to content

Commit ddf5e45

Browse files
authored
feat: Sign sentry-prevent-cli binaries with Cosign (#86)
This PR adds Cosign signing for prevent-cli binaries. We decided to go with Cosign over PGP like we have for the codecov CLI to avoid the headaches of key management and overall I'm pretty happy with how easy this is for both signer and verifier! Closes CCMRG-452
1 parent d23b84b commit ddf5e45

4 files changed

Lines changed: 46 additions & 6 deletions

File tree

.craft.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ github:
55
changelogPolicy: auto
66

77
targets:
8-
# For direct binary downloads + shasum + shasum.sig
8+
# For direct binary downloads + cosign bundles
99
- name: github
1010
tagPrefix: v
1111
checksums:

.github/workflows/build.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,26 @@ jobs:
165165
name: Package assets for Craft
166166
runs-on: ubuntu-latest
167167
needs: [build_for_pypi, build_assets, build_linux_assets]
168+
permissions:
169+
id-token: write # needed for signing binaries with OIDC token via Cosign
168170
steps:
169171
- name: Download artifacts
170172
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
171173
with:
172174
pattern: "{sentry-prevent-,codecov-,codecov}cli*"
173175

176+
- name: Install Cosign
177+
uses: sigstore/cosign-installer@d58896d6a1865668819e1d91763c7751a165e159 # v3.9.2
178+
179+
- name: Sign sentry-prevent-cli binaries
180+
run: |
181+
# Glob matches all prevent-cli binaries, not python wheel nor anything else.
182+
for file in sentry-prevent-cli_*/sentry-prevent-cli_*; do
183+
cosign sign-blob $file --bundle "$file.bundle" --yes;
184+
# Test verification because why not
185+
cosign verify-blob $file --bundle "$file.bundle" --certificate-identity-regexp="^https://github\.com/getsentry/prevent-cli/\.github/workflows/build\.yml@refs/heads/release/[0-9]+\.[0-9]+\.[0-9]+" --certificate-oidc-issuer=https://token.actions.githubusercontent.com
186+
done
187+
174188
- name: Upload release artifact
175189
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
176190
with:
@@ -180,3 +194,4 @@ jobs:
180194
sentry-prevent-cli_wheel/*
181195
codecovcli*
182196
codecov-cli_wheel/*
197+
*.bundle

README.md

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,35 @@ The Sentry Prevent CLI is responsible for uploading code coverage and test resul
1414

1515
# Installing
1616

17-
As of today, you are not able to install the Sentry Prevent CLI. We are planning to release it on the PyPI and for direct download in the near future.
18-
19-
If you're determined, you can build the CLI yourself from source by running `uv build` in the `prevent-cli` directory.
17+
### PyPI
18+
19+
```
20+
pip install sentry-prevent-cli
21+
```
22+
23+
### Binary
24+
25+
We build and publish binaries for Linux, MacOS, and Windows. See our GitHub Releases for the full list of OS/architecture combinations we build for. We'll use our macos binary for demonstration purposes here:
26+
```
27+
curl -o sentry-prevent-cli -L "https://github.com/getsentry/prevent-cli/releases/latest/download/sentry-prevent-cli_macos"
28+
chmod +x sentry-prevent-cli
29+
```
30+
31+
#### Verifying the binary
32+
If you'd like, you may use Sigstore's Cosign to verify the integrity of your download against our provided Cosign bundles and identity details. For more information on Cosign along with installation instructions, see their [documentation](https://docs.sigstore.dev/cosign/system_config/installation).
33+
34+
First get the appropriate Cosign bundle from our GitHub Release assets. Appending `.bundle` to the binary URL will get you the right file.
35+
```
36+
curl -O -L "https://github.com/getsentry/prevent-cli/releases/latest/download/sentry-prevent-cli_macos.bundle"
37+
```
38+
Then, use `cosign` to verify the binary:
39+
```
40+
cosign verify-blob sentry-prevent-cli \
41+
--bundle sentry-prevent-cli_macos.bundle \
42+
--certificate-identity-regexp="^https://github\.com/getsentry/prevent-cli/\.github/workflows/build\.yml@refs/heads/release/[0-9]+\.[0-9]+\.[0-9]+" \
43+
--certificate-oidc-issuer=https://token.actions.githubusercontent.com
44+
```
45+
The OIDC identity here is associated with the specific workflow run that signs the binary. If the verification succeeds, you can trust you've recieved the same binary we built in our GitHub Actions workflow.
2046

2147
# Usage
2248

scripts/build_linux.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ cd ../codecov-cli
1414
uv run pyinstaller -F codecov_cli/main.py
1515
mv ./dist/main ./dist/codecovcli_$1
1616

17-
# linux binary should be just codecovcli_linux
17+
# codecov linux binary should be just codecovcli_linux
1818
if [ $1 = "linux_x86_64" ]; then
1919
cd ..
20-
mv ./prevent-cli/dist/sentry-prevent-cli_$1 ./prevent-cli/dist/sentry-prevent-cli_linux
2120
mv ./codecov-cli/dist/codecovcli_$1 ./codecov-cli/dist/codecovcli_linux
2221
fi

0 commit comments

Comments
 (0)