Skip to content

Cargo Audit

Cargo Audit #25

Workflow file for this run

# SPDX-License-Identifier: MPL-2.0
# Prevention workflow - audits Rust dependencies for vulnerabilities
name: Cargo Audit
on:
push:
branches: [main]
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
pull_request:
paths:
- '**/Cargo.toml'
- '**/Cargo.lock'
schedule:
- cron: '0 6 * * 1' # Weekly on Monday
permissions: read-all
jobs:
audit:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Run cargo audit
run: cargo audit --deny warnings
- name: Check for unmaintained crates
run: cargo audit --deny unmaintained
# Optional: Create issues for vulnerabilities
create-issue:
runs-on: ubuntu-latest
timeout-minutes: 15
needs: audit
# Only file a tracking issue on push/schedule runs. On pull_request events
# GITHUB_TOKEN is forced read-only, so `gh issue create` 403s; guarding here
# keeps PR runs green (the audit job itself still gates the PR).
if: failure() && github.event_name != 'pull_request'
permissions:
issues: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v4
- name: Create vulnerability issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
EXISTING=$(gh issue list --label "security,dependencies" --state open --json number -q '.[0].number')
if [ -z "$EXISTING" ]; then
gh issue create \
--title "Security: Dependency vulnerabilities detected" \
--body "cargo audit found vulnerabilities. Run \`cargo audit\` locally for details." \
--label "security,dependencies"
fi