Skip to content

Commit a975ddb

Browse files
committed
Add cargo-audit.yml prevention workflow
1 parent 63c5c6d commit a975ddb

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

.github/workflows/cargo-audit.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# SPDX-License-Identifier: MPL-2.0
2+
# Prevention workflow - audits Rust dependencies for vulnerabilities
3+
name: Cargo Audit
4+
5+
on:
6+
push:
7+
branches: [main]
8+
paths:
9+
- '**/Cargo.toml'
10+
- '**/Cargo.lock'
11+
pull_request:
12+
paths:
13+
- '**/Cargo.toml'
14+
- '**/Cargo.lock'
15+
schedule:
16+
- cron: '0 6 * * 1' # Weekly on Monday
17+
18+
permissions: read-all
19+
20+
jobs:
21+
audit:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
25+
26+
- name: Install cargo-audit
27+
run: cargo install cargo-audit --locked
28+
29+
- name: Run cargo audit
30+
run: cargo audit --deny warnings
31+
32+
- name: Check for unmaintained crates
33+
run: cargo audit --deny unmaintained
34+
35+
# Optional: Create issues for vulnerabilities
36+
create-issue:
37+
runs-on: ubuntu-latest
38+
needs: audit
39+
if: failure()
40+
permissions:
41+
issues: write
42+
steps:
43+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
44+
45+
- name: Create vulnerability issue
46+
env:
47+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
EXISTING=$(gh issue list --label "security,dependencies" --state open --json number -q '.[0].number')
50+
if [ -z "$EXISTING" ]; then
51+
gh issue create \
52+
--title "Security: Dependency vulnerabilities detected" \
53+
--body "cargo audit found vulnerabilities. Run \`cargo audit\` locally for details." \
54+
--label "security,dependencies"
55+
fi

0 commit comments

Comments
 (0)