Skip to content

Commit

Permalink
chore(ci): address overly broad permissions scopes (#16996)
Browse files Browse the repository at this point in the history
  • Loading branch information
miketheman authored Oct 31, 2024
1 parent bb78257 commit 7738439
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 8 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
types: [checks_requested]
workflow_dispatch: # generally only for the "combine-prs" workflow
permissions:
id-token: write
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
Expand All @@ -19,9 +18,13 @@ jobs:
runs-on: depot-ubuntu-22.04-arm
outputs:
buildId: ${{ steps.build.outputs.build-id}}
permissions:
id-token: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Set up Depot CLI
uses: depot/setup-action@v1
- name: Build image
Expand Down Expand Up @@ -59,6 +62,8 @@ jobs:
image: registry.depot.dev/rltf7cln5v:${{ needs.build.outputs.buildId }}
env:
BILLING_BACKEND: warehouse.subscriptions.services.MockStripeBillingService api_base=http://stripe:12111 api_version=2020-08-27
permissions:
id-token: write
services:
postgres:
image: ${{ (matrix.name == 'Tests') && 'postgres:16.1' || '' }}
Expand All @@ -81,6 +86,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Cache mypy results
if: ${{ (matrix.name == 'Lint') }}
uses: actions/cache@v4
Expand All @@ -98,6 +105,8 @@ jobs:
continue-on-error: true
container:
image: registry.depot.dev/rltf7cln5v:${{ needs.build.outputs.buildId }}
permissions:
id-token: write
services:
postgres:
image: postgres:16.1
Expand All @@ -112,6 +121,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Dotenv Action
# We need to load the environment variables to run the CLI
id: dotenv
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Set up Python
if: matrix.language == 'python'
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/combine-prs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ on:
required: true
default: 'blocked'

# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions:
contents: write
pull-requests: write
checks: read
actions: write

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "combine-prs"
combine-prs:
# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
permissions:
contents: write
pull-requests: write
checks: read
actions: write
# The type of runner that the job will run on
runs-on: ubuntu-latest

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/dev-env-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- run: make build
- run: docker compose up -d
- run: docker compose ps
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/node-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
persist-credentials: false
- uses: actions/setup-node@v4
with:
node-version: 23.1.0
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/zizmor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# https://github.com/woodruffw/zizmor
name: GitHub Actions Security Analysis with Zizmor

on:
push:
branches: ["main"]
pull_request:
branches: ["*"]

permissions:
contents: read

jobs:
zizmor:
name: Zizmor latest via Cargo
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Get zizmor
run: cargo install zizmor
- name: Run zizmor
run: zizmor --format sarif . > results.sarif
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v3
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
# Optional category for the results
# Used to differentiate multiple results for one commit
category: zizmor

0 comments on commit 7738439

Please sign in to comment.