1
- name : " CodeQL Python Security Scan (Top-N + PR Comment) "
1
+ name : " CodeQL Python Security and Quality Scan "
2
2
3
3
on :
4
- pull_request :
5
- branches : [ main, master ]
6
- types : [opened, synchronize, reopened]
7
4
push :
8
5
branches : [ main, master ]
6
+ pull_request :
7
+ branches : [ main, master ]
9
8
10
9
permissions :
11
10
contents : read
@@ -18,37 +17,26 @@ jobs:
18
17
runs-on : ubuntu-latest
19
18
20
19
steps :
20
+ # 1. 检出代码
21
21
- name : Checkout repository
22
22
uses : actions/checkout@v4
23
23
with :
24
24
fetch-depth : 0
25
25
26
+ # 2. 初始化 CodeQL
26
27
- name : Initialize CodeQL
27
28
uses : github/codeql-action/init@v3
28
29
with :
29
30
languages : python
31
+ # 不指定 queries,Action 会默认跑安全 + 质量查询
30
32
33
+ # 3. 自动构建
31
34
- name : Autobuild
32
35
uses : github/codeql-action/autobuild@v3
33
36
37
+ # 4. 执行分析
34
38
- name : Perform CodeQL Analysis
35
39
uses : github/codeql-action/analyze@v3
36
40
with :
37
- upload : true
38
-
39
- - name : Comment CodeQL Alerts on PR
40
- if : github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
41
- uses : marocchino/sticky-pull-request-comment@v2
42
- with :
43
- path : results.sarif
44
- header : " ### :shield: CodeQL Python Security Alerts Summary"
45
- layout : " group-by-file"
46
- format : " markdown-table"
47
- sort-severity : true
48
- highlight : " Critical,High"
49
- collapse : " Medium,Low"
50
- max-items-per-file : 5
51
- show-summary : true
52
- show-file-overview : true
53
- overflow-text : " +{remaining} more alerts in this file"
54
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41
+ # 不指定 queries,Action 会自动跑安全 + 质量规则
42
+ upload : true
0 commit comments