-
Notifications
You must be signed in to change notification settings - Fork 4
ci(release): sign Windows binaries with Azure Artifact Signing #475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
wyattjoh
wants to merge
1
commit into
main
Choose a base branch
from
wyattjoh/issue-474
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+214
−17
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| name: Sign Windows Binaries | ||
|
|
||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| artifact-prefix: | ||
| required: true | ||
| type: string | ||
| description: "Prefix for artifact names (e.g. 'clerk', 'clerk-canary', 'clerk-snapshot')" | ||
| secrets: | ||
| AZURE_TENANT_ID: | ||
| required: true | ||
| AZURE_CLIENT_ID: | ||
| required: true | ||
| AZURE_SUBSCRIPTION_ID: | ||
| required: true | ||
| AZURE_SIGNING_ENDPOINT: | ||
| required: true | ||
| AZURE_SIGNING_ACCOUNT: | ||
| required: true | ||
| AZURE_SIGNING_CERT_PROFILE: | ||
| required: true | ||
|
|
||
| permissions: | ||
| contents: read | ||
| # Azure Artifact Signing authenticates via OIDC federated credentials; the | ||
| # calling job must grant id-token: write or azure/login cannot mint a token. | ||
| id-token: write | ||
|
|
||
| jobs: | ||
| sign: | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| include: | ||
| - target: win32-arm64 | ||
| - target: win32-x64 | ||
| # Azure Artifact Signing ships a Windows-only signing engine (it drives | ||
| # signtool under the hood), so this cannot share the Linux build runner. | ||
| runs-on: windows-latest | ||
| timeout-minutes: 15 | ||
| steps: | ||
| # No checkout: unlike sign-macos.ts there is no local script to run -- | ||
| # the action owns credential handling, batching, and signtool invocation. | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-${{ matrix.target }} | ||
| path: dist/artifacts/${{ matrix.target }} | ||
|
|
||
| - name: Azure login | ||
| uses: azure/login@v3 | ||
| with: | ||
| client-id: ${{ secrets.AZURE_CLIENT_ID }} | ||
| tenant-id: ${{ secrets.AZURE_TENANT_ID }} | ||
| subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | ||
|
|
||
| - name: Sign | ||
| uses: azure/artifact-signing-action@v2 | ||
| with: | ||
| endpoint: ${{ secrets.AZURE_SIGNING_ENDPOINT }} | ||
| signing-account-name: ${{ secrets.AZURE_SIGNING_ACCOUNT }} | ||
| certificate-profile-name: ${{ secrets.AZURE_SIGNING_CERT_PROFILE }} | ||
| files: ${{ github.workspace }}\dist\artifacts\${{ matrix.target }}\clerk.exe | ||
| file-digest: SHA256 | ||
| # Artifact Signing leaf certificates are valid for ~72 hours. The | ||
| # RFC-3161 countersignature is what keeps a released binary trusted | ||
| # after the leaf expires, so an untimestamped signature is a bug. | ||
| timestamp-rfc3161: http://timestamp.acs.microsoft.com | ||
| timestamp-digest: SHA256 | ||
|
|
||
| - name: Verify signature | ||
| shell: pwsh | ||
| run: | | ||
| $path = "dist\artifacts\${{ matrix.target }}\clerk.exe" | ||
| $sig = Get-AuthenticodeSignature -FilePath $path | ||
|
|
||
| Write-Host "Status: $($sig.Status)" | ||
| Write-Host "Signer: $($sig.SignerCertificate.Subject)" | ||
| Write-Host "Timestamp: $($sig.TimeStamperCertificate.Subject)" | ||
|
|
||
| if ($sig.Status -ne 'Valid') { | ||
| throw "Authenticode verification failed ($($sig.Status)): $($sig.StatusMessage)" | ||
| } | ||
| if ($null -eq $sig.TimeStamperCertificate) { | ||
| throw "Signature is not timestamped; it would stop validating once the leaf certificate expires." | ||
| } | ||
|
|
||
| - name: Re-upload signed artifact | ||
| uses: actions/upload-artifact@v7 | ||
| with: | ||
| name: ${{ inputs.artifact-prefix }}-${{ matrix.target }} | ||
| path: dist/artifacts/${{ matrix.target }}/clerk.exe | ||
| overwrite: true | ||
| retention-days: 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟠 Major | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
Repository: clerk/cli
Length of output: 12808
🤖 get_repo_knowledge executed:
get_repo_knowledge clerk/cli /tmp/coderabbit-repo-knowledge/clerk-cli-79f624a6/learnings /tmp/coderabbit-repo-knowledge/clerk-cli-79f624a6/conventionsLength of output: 15823
Pin all release-signing actions to immutable commit SHAs.
The workflow uses mutable tags for
actions/download-artifact,azure/login,azure/artifact-signing-action, andactions/upload-artifact. These actions run with Azure OIDC access and can replace release artifacts. A moved or compromised tag can execute unreviewed code or modify signed binaries. Pin all four actions to reviewed full commit SHAs.🧰 Tools
🪛 zizmor (1.29.0)
[error] 45-45: unpinned action reference (unpinned-uses): action is not pinned to a hash (required by blanket policy)
(unpinned-uses)
📍 Affects 1 file
.github/workflows/sign-windows.yml#L45-L45(this comment).github/workflows/sign-windows.yml#L51-L51.github/workflows/sign-windows.yml#L58-L58.github/workflows/sign-windows.yml#L89-L89🤖 Prompt for AI Agents
Source: Linters/SAST tools