-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (97 loc) · 3.32 KB
/
Copy pathcodeql.yml
File metadata and controls
112 lines (97 loc) · 3.32 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
name: "CodeQL Advanced Security Scanning"
on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, synchronize, reopened]
schedule:
# Run every Monday at 06:00 UTC
- cron: '0 6 * * 1'
workflow_dispatch: # Allow manual triggering
# Cancel in-progress runs for the same workflow
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
security-events: write
actions: read
pull-requests: read
jobs:
analyze:
name: CodeQL Analysis
runs-on: blacksmith-4vcpu-ubuntu-2404
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
language: ['python']
steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v4
- name: Set up Python 3.13
uses: actions/setup-python@e797f83bcb11b83ae66e0230d6156d7c80228e7c # v5
with:
python-version: '3.13'
- name: Install uv
run: pip install uv
- name: Cache uv dependencies
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
.venv
~/.cache/uv
key: ${{ runner.os }}-uv-codeql-${{ hashFiles('pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install dependencies
run: make dev
# Initialize CodeQL with custom configuration
- name: Initialize CodeQL
uses: github/codeql-action/init@ab2e54f42aa112ff08704159b88a57517f6f0ebb # v3
with:
languages: ${{ matrix.language }}
config-file: ./.github/codeql/codeql-config.yml
# Use latest CodeQL bundle
tools: latest
# Setup Python dependencies for better analysis
setup-python-dependencies: true
# No explicit build needed for Python (interpreted language)
# CodeQL will automatically discover Python code
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@ab2e54f42aa112ff08704159b88a57517f6f0ebb # v3
with:
category: "/language:${{ matrix.language }}"
# Upload SARIF even if there are findings
upload: true
# Set severity threshold - fail on high/critical
fail-on: error
# Output SARIF file for artifacts
output: codeql-results-${{ matrix.language }}.sarif
- name: Upload CodeQL results as artifact
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v4
if: always()
with:
name: codeql-results-${{ matrix.language }}
path: codeql-results-${{ matrix.language }}.sarif
retention-days: 30
# Summary job to check overall status
codeql-summary:
name: CodeQL Summary
runs-on: blacksmith-4vcpu-ubuntu-2404
needs: analyze
if: always()
steps:
- name: Check CodeQL status
run: |
if [[ "${{ needs.analyze.result }}" == "failure" ]]; then
echo "::error::CodeQL analysis found security issues"
exit 1
elif [[ "${{ needs.analyze.result }}" == "success" ]]; then
echo "✓ CodeQL analysis completed successfully"
else
echo "::warning::CodeQL analysis status: ${{ needs.analyze.result }}"
fi