Skip to content

Commit 2ba78b2

Browse files
committed
security: harden release app credential handling
1 parent 859053f commit 2ba78b2

3 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
timeout-minutes: 10
2121
permissions:
2222
contents: write
23-
issues: write
24-
pull-requests: write
2523
outputs:
2624
publish: ${{ steps.target.outputs.publish }}
2725
tag: ${{ steps.target.outputs.tag }}
@@ -31,13 +29,13 @@ jobs:
3129
if: github.event_name == 'push'
3230
shell: bash
3331
env:
34-
RELEASE_APP_CLIENT_ID: ${{ vars.RELEASE_APP_CLIENT_ID }}
35-
RELEASE_APP_PRIVATE_KEY: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
32+
RELEASE_APP_CLIENT_ID_CONFIGURED: ${{ vars.RELEASE_APP_CLIENT_ID != '' }}
33+
RELEASE_APP_PRIVATE_KEY_CONFIGURED: ${{ secrets.RELEASE_APP_PRIVATE_KEY != '' }}
3634
run: |
3735
set -euo pipefail
3836
missing=()
39-
[[ -n "$RELEASE_APP_CLIENT_ID" ]] || missing+=(RELEASE_APP_CLIENT_ID)
40-
[[ -n "$RELEASE_APP_PRIVATE_KEY" ]] || missing+=(RELEASE_APP_PRIVATE_KEY)
37+
[[ "$RELEASE_APP_CLIENT_ID_CONFIGURED" == "true" ]] || missing+=(RELEASE_APP_CLIENT_ID)
38+
[[ "$RELEASE_APP_PRIVATE_KEY_CONFIGURED" == "true" ]] || missing+=(RELEASE_APP_PRIVATE_KEY)
4139
if (( ${#missing[@]} > 0 )); then
4240
{
4341
echo "## Release automation is not configured"
@@ -57,6 +55,8 @@ jobs:
5755
with:
5856
client-id: ${{ vars.RELEASE_APP_CLIENT_ID }}
5957
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
58+
owner: ${{ github.repository_owner }}
59+
repositories: ${{ github.event.repository.name }}
6060
permission-contents: write
6161
permission-issues: write
6262
permission-pull-requests: write

‎.gitignore‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,17 @@ __pycache__/
77
.ruff_cache/
88
.venv/
99
.uv-cache/
10+
.env
11+
.env.*
12+
!.env.example
13+
*.key
14+
*.p12
15+
*.pem
16+
*.pfx
1017
build/
1118
dist/
1219
htmlcov/
1320
github-backup.toml
1421
backups/
22+
github-backup-release-app.json
23+
github-backup-app-manifest/

‎docs/RELEASING.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ In the repository or organization settings, create a GitHub App named for releas
2424
7. Add the complete PEM private key as the Actions secret `RELEASE_APP_PRIVATE_KEY`.
2525
8. Delete the downloaded private-key file after storing it in the secret manager.
2626

27-
The workflow requests only the three permissions above when minting its short-lived installation
28-
token. Rotate the App key according to organizational policy.
27+
The workflow explicitly binds the short-lived installation token to this repository and requests
28+
only the three permissions above. Its normal `GITHUB_TOKEN` does not receive the App's issue or
29+
pull-request write permissions. Rotate the App key according to organizational policy.
2930

3031
### 2. Configure Actions and package permissions
3132

0 commit comments

Comments
 (0)