-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (100 loc) · 3.11 KB
/
codeql.yml
File metadata and controls
116 lines (100 loc) · 3.11 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
name: CodeQL Security Analysis
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
schedule:
# Run every day at 6:00 AM UTC
- cron: '0 6 * * *'
workflow_dispatch:
permissions:
contents: read
security-events: write
actions: read
jobs:
analyze:
name: Analyze Code
runs-on: ubuntu-latest
timeout-minutes: 360
strategy:
fail-fast: false
matrix:
language: ['python']
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
queries: +security-and-quality
config: |
paths-ignore:
- '**/tests/**'
- '**/test_*.py'
- '**/*_test.py'
- '.venv/**'
- 'venv/**'
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version-file: ".python-version"
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
enable-cache: true
- name: Install dependencies
run: |
uv sync --group dev --group test
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{ matrix.language }}"
upload: true
output: sarif-results
add-snippets: true
- name: Upload SARIF results
if: always()
uses: actions/upload-artifact@v4
with:
name: codeql-results-${{ matrix.language }}
path: sarif-results
retention-days: 30
- name: Filter SARIF for PRs
if: github.event_name == 'pull_request'
uses: advanced-security/filter-sarif@v1
with:
patterns: |
-**/tests/**
-**/test_*.py
input: sarif-results/${{ matrix.language }}.sarif
output: sarif-results/${{ matrix.language }}.sarif
summary:
name: Analysis Summary
runs-on: ubuntu-latest
needs: analyze
if: always()
steps:
- name: Generate summary
run: |
echo "## 🔐 CodeQL Analysis Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Language | Status |" >> $GITHUB_STEP_SUMMARY
echo "|----------|--------|" >> $GITHUB_STEP_SUMMARY
echo "| Python | ${{ needs.analyze.result == 'success' && '✅ No issues found' || '⚠️ Issues detected' }} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ needs.analyze.result }}" != "success" ]; then
echo "### 🔍 Action Required" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Security issues were detected during the analysis." >> $GITHUB_STEP_SUMMARY
echo "Please review the Security tab for details." >> $GITHUB_STEP_SUMMARY
else
echo "✅ No security issues detected!" >> $GITHUB_STEP_SUMMARY
fi