Skip to content

Security Audit

Security Audit #10

Workflow file for this run

name: Security Audit
on:
schedule:
- cron: "0 8 * * 1" # every Monday at 08:00 UTC
workflow_dispatch:
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: dtolnay/rust-toolchain@stable
- name: Install cargo-audit
run: cargo install cargo-audit --locked
- name: Run audit
id: audit
run: |
cargo audit --json > audit.json 2>&1 || true
CRITICAL=$(jq '[.vulnerabilities.list[] | select(.advisory.cvss | (. // 0) >= 9.0)] | length' audit.json 2>/dev/null || echo 0)
HIGH=$(jq '[.vulnerabilities.list[] | select(.advisory.cvss | (. // 0) >= 7.0 and . < 9.0)] | length' audit.json 2>/dev/null || echo 0)
TOTAL=$(jq '.vulnerabilities.count' audit.json 2>/dev/null || echo 0)
echo "critical=$CRITICAL" >> $GITHUB_OUTPUT
echo "high=$HIGH" >> $GITHUB_OUTPUT
echo "total=$TOTAL" >> $GITHUB_OUTPUT
- name: Open issue on critical vulnerabilities
if: steps.audit.outputs.critical > 0
uses: actions/github-script@v9
with:
script: |
const critical = ${{ steps.audit.outputs.critical }};
const high = ${{ steps.audit.outputs.high }};
const total = ${{ steps.audit.outputs.total }};
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Security: ${critical} critical vulnerabilit${critical === 1 ? 'y' : 'ies'} found in Cargo dependencies`,
body: `## Security Audit Results\n\n- **Critical:** ${critical}\n- **High:** ${high}\n- **Total:** ${total}\n\nRun \`cargo audit\` locally for full details. Dependabot should open fix PRs shortly.`,
labels: ["security"],
});