-
Notifications
You must be signed in to change notification settings - Fork 172
154 lines (141 loc) Β· 6.13 KB
/
Copy pathslither.yml
File metadata and controls
154 lines (141 loc) Β· 6.13 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Slither Static Analysis
# ============================================================================
# TRIGGER: Runs on every push and pull request to main and develop branches
# ============================================================================
on:
pull_request:
branches:
- main
- develop
push:
branches:
- main
- develop
jobs:
slither:
name: Run Slither Analysis
runs-on: ubuntu-latest
permissions:
contents: read
security-events: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
# ======================================================================
# DEPENDENCY INSTALLATION PHASE
# Ensures Slither can compile and analyze smart contracts
# ======================================================================
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Setup Foundry (for Solidity compilation)
uses: foundry-rs/foundry-toolchain@v1
continue-on-error: true
- name: Install dependencies
run: |
echo "π¦ Installing project dependencies..."
npm install || true
npm run build 2>/dev/null || true
if [ -f "Cargo.toml" ]; then
cargo build 2>/dev/null || true
fi
echo "β Dependencies installed (continuation on error for flexibility)"
# ======================================================================
# STATIC ANALYSIS PHASE
# Run Slither with severity-based failure thresholds
# ======================================================================
- name: Run Slither analysis
uses: crytic/slither-action@latest
id: slither
with:
target: .
sarif: results.sarif
# SEVERITY POLICY:
# - fail-on: medium β Fails build for High AND Medium severity
# - Low and Informational findings are logged but don't block merge
fail-on: medium
slither-config: slither.config.json
continue-on-error: true
# ======================================================================
# GITHUB SECURITY INTEGRATION
# Uploads SARIF report to GitHub Security tab for visibility
# ======================================================================
- name: Upload SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v2
if: always()
with:
sarif_file: results.sarif
wait-for-processing: true
continue-on-error: true
# ======================================================================
# PR COMMENT WITH RESULTS
# Posts a summary comment on the PR with key findings
# ======================================================================
- name: Comment PR with security summary
if: github.event_name == 'pull_request' && always()
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fs = require('fs');
const severity = {
π΄: 'High/Medium (Build Blocking)',
π‘: 'Low (Informational)',
β
: 'No findings'
};
let summary = '## π Slither Static Analysis Results\n\n';
summary += '**Severity Policy:**\n';
summary += '- π΄ High/Medium findings **BLOCK** the build\n';
summary += '- π‘ Low/Informational findings are **LOGGED** (non-blocking)\n\n';
summary += '**See Results:**\n';
summary += '- [GitHub Security Tab](../../security/code-scanning) for full SARIF report\n';
summary += '- [Slither Documentation](https://github.com/crytic/slither) for more details\n\n';
summary += '**To Suppress False Positives:**\n';
summary += '```solidity\n// slither-disable-next-line detector-name\nfunction myFunction() public {\n // Code here won\'t trigger detector-name\n}\n```\n';
summary += 'See [SECURITY_CHECKLIST.md](/docs/SECURITY_CHECKLIST.md) for detailed suppression guidance.\n';
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: summary
});
# ======================================================================
# BUILD STATUS REPORTING
# Explicit failure message for High/Medium findings
# ======================================================================
- name: Report analysis status
if: always()
run: |
echo "π Slither Analysis Summary"
echo "===================================="
echo ""
echo "β Analysis completed"
echo " Severity Policy:"
echo " π΄ High/Medium severity: BUILD FAILS"
echo " π‘ Low/Informational: BUILD PASSES (warnings logged)"
echo ""
echo "π View full results:"
echo " 1. GitHub Security tab (SARIF report)"
echo " 2. PR comment (summary)"
echo " 3. Slither config: slither.config.json"
echo ""
echo "π For false positives:"
echo " See: docs/SECURITY_CHECKLIST.md (Triage & False Positives section)"
echo " Use: //slither-disable-next-line <detector>"
echo ""
- name: Fail if High/Medium findings detected
if: failure() && steps.slither.outcome == 'failure'
run: |
echo "β Build blocked due to High/Medium severity findings"
echo ""
echo "π‘ Next steps:"
echo "1. Review findings in GitHub Security tab"
echo "2. Either fix the vulnerability OR suppress if it's a false positive"
echo "3. For false positives, follow the process in docs/SECURITY_CHECKLIST.md"
echo "4. Leave an inline comment: //slither-disable-next-line <detector>"
exit 1