Skip to content

Commit

Permalink
Address zizmor security issues in GitHub Actions setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lopopolo committed Feb 2, 2025
1 parent 740c081 commit 0349bff
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 111 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ name: Audit
- trunk
schedule:
- cron: "0 0 * * TUE"
permissions: {}
jobs:
ruby:
name: Audit Ruby Dependencies
Expand All @@ -17,6 +18,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
persist-credentials: false

- name: Install Ruby toolchain
uses: ruby/setup-ruby@2654679fe7f7c29875c669398a8ec0791b8a64a1 # v1.215.0
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/block-merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ name: Merge
"on":
pull_request:
types: [opened, labeled, unlabeled, synchronize]
permissions: {}
jobs:
labels:
name: Labels
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write

steps:
- uses: mheap/github-action-required-labels@388fd6af37b34cdfe5a23b37060e763217e58b03 # v5.5
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ name: CI
- trunk
schedule:
- cron: "0 0 * * TUE"
permissions: {}
jobs:
test-setup-audit-toolchain:
name: Test setup audit toolchain action
Expand All @@ -18,6 +19,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup stable audit toolchain
uses: ./setup-rust-action/audit
Expand All @@ -34,6 +36,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup nightly build and test toolchain
uses: ./setup-rust-action/build-and-test
Expand Down Expand Up @@ -89,6 +92,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup stable build and test toolchain
uses: ./setup-rust-action/check-minimal-versions
Expand Down Expand Up @@ -134,6 +138,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup stable audit toolchain
uses: ./setup-rust-action/code-coverage
Expand All @@ -150,6 +155,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup stable build and test toolchain
uses: ./setup-rust-action/lint-and-format
Expand Down Expand Up @@ -231,6 +237,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup stable audit toolchain
uses: ./setup-rust-action/miri
Expand All @@ -247,6 +254,7 @@ jobs:
uses: actions/[email protected]
with:
path: setup-rust-action
persist-credentials: false

- name: Setup nightly rustdoc toolchain
uses: ./setup-rust-action/rustdoc
Expand All @@ -261,6 +269,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
persist-credentials: false

- name: Install Ruby toolchain
uses: ruby/setup-ruby@2654679fe7f7c29875c669398a8ec0791b8a64a1 # v1.215.0
Expand All @@ -277,6 +287,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/[email protected]
with:
persist-credentials: false

- name: Lint and check formatting with prettier
run: npx prettier --check '**/*'
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/repo-labels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,18 @@
schedule:
- cron: "0 0 * * TUE"
name: Create Repository Labels
permissions: {}
jobs:
labels:
name: Synchronize repository labels
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- uses: actions/[email protected]
with:
persist-credentials: false

- name: Sync GitHub Issue Labels
uses: crazy-max/ghaction-github-labeler@b54af0c25861143e7c8813d7cbbf46d2c341680c # v5.1.0
Expand Down
42 changes: 30 additions & 12 deletions audit/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,49 @@ inputs:
description: "Rustup toolchain"
required: true
default: "stable"
override-dir:
description: "Directory to set the rustup override for"
required: false
default: "."

runs:
using: "composite"
env:
TOOLCHAIN: ${{ inputs.toolchain }}
steps:
- name: Install ${{ inputs.toolchain }} toolchain
- name: Install toolchain
shell: bash
run: rustup toolchain install "${{ inputs.toolchain }}" --profile minimal
working-directory: ${{ inputs.override-dir }}
run: |
rustup toolchain install "$TOOLCHAIN" --profile minimal
- name: Update ${{ inputs.toolchain }} toolchain
- name: Update toolchain
shell: bash
run: rustup update "${{ inputs.toolchain }}"
working-directory: ${{ inputs.override-dir }}
run: |
rustup update "$TOOLCHAIN"
- name: Set default toolchain to ${{ inputs.toolchain }}
- name: Set default toolchain override
shell: bash
# https://rust-lang.github.io/rustup/overrides.html
run: echo 'RUSTUP_TOOLCHAIN=${{ inputs.toolchain }}' >> "$GITHUB_ENV"
working-directory: ${{ inputs.override-dir }}
run: |
# https://rust-lang.github.io/rustup/overrides.html
rustup override set "$TOOLCHAIN"
- name: Show rustup version
shell: bash
run: rustup -Vv
working-directory: ${{ inputs.override-dir }}
run: |
rustup -Vv
- name: Show ${{ inputs.toolchain }} rustc version
- name: Show rustc version
shell: bash
run: rustc +${{ inputs.toolchain }} -Vv
working-directory: ${{ inputs.override-dir }}
run: |
rustc +"$TOOLCHAIN" -Vv
- name: Show ${{ inputs.toolchain }} cargo version
- name: Show cargo version
shell: bash
run: cargo +${{ inputs.toolchain }} version --verbose
working-directory: ${{ inputs.override-dir }}
run: |
cargo +"$TOOLCHAIN" version --verbose
52 changes: 37 additions & 15 deletions build-and-test/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,70 @@ inputs:
description: "Target triple"
required: false
default: ""
override-dir:
description: "Directory to set the rustup override for"
required: false
default: "."

runs:
using: "composite"
env:
TOOLCHAIN: ${{ inputs.toolchain }}
TARGET: ${{ inputs.target }}
steps:
- name: Install ${{ inputs.toolchain }} toolchain
- name: Install toolchain
shell: bash
run: rustup toolchain install "${{ inputs.toolchain }}" --profile minimal
working-directory: ${{ inputs.override-dir }}
run: |
rustup toolchain install "$TOOLCHAIN" --profile minimal
- name: Update ${{ inputs.toolchain }} toolchain
- name: Update toolchain
shell: bash
run: rustup update "${{ inputs.toolchain }}"
working-directory: ${{ inputs.override-dir }}
run: |
rustup update "$TOOLCHAIN"
- name: Install additional target
shell: bash
working-directory: ${{ inputs.override-dir }}
if: inputs.target != ''
run: rustup target add --toolchain "${{ inputs.toolchain }}" "${{ inputs.target }}"
run: |
rustup target add --toolchain "$TOOLCHAIN" "$TARGET"
- name: Set default toolchain to ${{ inputs.toolchain }}
- name: Set default toolchain
shell: bash
# https://rust-lang.github.io/rustup/overrides.html
run: echo 'RUSTUP_TOOLCHAIN=${{ inputs.toolchain }}' >> "$GITHUB_ENV"
working-directory: ${{ inputs.override-dir }}
run: |
# https://rust-lang.github.io/rustup/overrides.html
rustup override set "$TOOLCHAIN"
- name: Show rustup version
shell: bash
run: rustup -Vv
working-directory: ${{ inputs.override-dir }}
run: |
rustup -Vv
- name: Show ${{ inputs.toolchain }} rustc version
- name: Show rustc version
shell: bash
run: rustc +${{ inputs.toolchain }} -Vv
working-directory: ${{ inputs.override-dir }}
run: |
rustc +"$TOOLCHAIN" -Vv
- name: Show ${{ inputs.toolchain }} cargo version
- name: Show cargo version
shell: bash
run: cargo +${{ inputs.toolchain }} version --verbose
working-directory: ${{ inputs.override-dir }}
run: |
cargo +"$TOOLCHAIN" version --verbose
- name: Check if Cargo.lock is present
shell: bash
working-directory: ${{ inputs.override-dir }}
id: lockfile
run: |
if [[ -f Cargo.lock ]]; then
echo "present=true" >> $GITHUB_OUTPUT
echo "present=true" >> "$GITHUB_OUTPUT"
else
echo "present=false" >> $GITHUB_OUTPUT
echo "present=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup Rust caching
Expand Down
Loading

0 comments on commit 0349bff

Please sign in to comment.