-
Notifications
You must be signed in to change notification settings - Fork 172
79 lines (67 loc) · 2.36 KB
/
Copy pathrust-security.yml
File metadata and controls
79 lines (67 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Rust Security Audit
on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
jobs:
security-audit:
name: Cargo Audit & Clippy
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
- name: Install cargo-audit
run: cargo install cargo-audit
- name: Run cargo-audit (detect vulnerable dependencies)
run: cargo audit --deny warnings
- name: Run cargo-clippy (linting)
run: cargo clippy --all-targets --all-features -- -D warnings
continue-on-error: true
- name: Run cargo-deny (supply chain security)
continue-on-error: true
run: |
cargo install cargo-deny
cargo deny check advisories
- name: Check for unsafe code
run: |
echo "🔍 Scanning for unsafe code blocks..."
if grep -r "unsafe {" contracts/vault/src --include="*.rs" | grep -v "test\|fuzz"; then
echo "⚠️ Unsafe code found in non-test code. Please review:"
grep -r "unsafe {" contracts/vault/src --include="*.rs" | grep -v "test\|fuzz"
echo ""
echo "✓ Verify these unsafe blocks are documented and necessary"
else
echo "✓ No unsafe code found in production code"
fi
- name: Comment PR with Security Results
uses: actions/github-script@v7
if: always() && github.event_name == 'pull_request'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `## 🔒 Rust Security Audit Complete\n\n✓ Cargo audit completed\n✓ Clippy analysis completed\n\nPlease ensure all security recommendations are addressed before merging.`
});
- name: Fail on audit violations
if: failure()
run: |
echo "❌ Security audit detected issues"
exit 1