Skip to content

Commit 9ea77c1

Browse files
committed
CI: add cargo-audit
1 parent 31135b0 commit 9ea77c1

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

.github/workflows/cargo-audit.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Cargo Audit
2+
3+
on:
4+
push: {}
5+
pull_request: {}
6+
7+
jobs:
8+
audit:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout code
12+
uses: actions/checkout@v4
13+
14+
- name: Install Rust
15+
uses: actions-rs/toolchain@v1
16+
with:
17+
toolchain: stable
18+
override: true
19+
20+
- name: Install cargo-audit
21+
run: cargo install cargo-audit
22+
23+
- name: Run cargo audit
24+
run: cargo audit --json > audit.json || true
25+
26+
- name: Check for critical vulnerabilities
27+
run: |
28+
CRITICAL_COUNT=$(jq '[.vulnerabilities.list[] | select(.advisory.severity == "critical")] | length' audit.json)
29+
echo "Found $CRITICAL_COUNT critical vulnerabilities"
30+
if [ "$CRITICAL_COUNT" -gt 0 ]; then
31+
echo "Critical vulnerabilities detected!"
32+
exit 1
33+
fi
34+
35+
- name: Upload audit report artifact
36+
if: always()
37+
uses: actions/upload-artifact@v4
38+
with:
39+
name: cargo-audit-report
40+
path: audit-results/audit.json

0 commit comments

Comments
 (0)