Skip to content

Commit 69b8b69

Browse files
committed
Chore: Suppress unqualified CodeQL admonitions
GitHub's CodeQL flags [1] those spots with "Unused global variable" [2]. Based on a suggestion [3], this patch attempts to use the `advanced-security/dismiss-alerts` [4] GitHub Action recipe to provide measures to suppress CodeQL flagging by using inline code annotations. [1] https://github.com/crate/crate-python/security/code-scanning [2] https://codeql.github.com/codeql-query-help/python/py-unused-global-variable/ [3] Issue 11427 at https://github.com/github/codeql/issues [4] https://github.com/advanced-security/dismiss-alerts
1 parent a126030 commit 69b8b69

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/codeql.yml

+19
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
languages: ${{ matrix.language }}
5454
config-file: ./.github/codeql.yml
5555
queries: +security-and-quality
56+
# run an 'alert-suppression' query
57+
packs: "codeql/${{ matrix.language }}-queries:AlertSuppression.ql"
5658

5759
#- name: Autobuild
5860
# uses: github/codeql-action/autobuild@v2
@@ -62,4 +64,21 @@ jobs:
6264
uv pip install --system '.[test]'
6365
6466
- name: Perform CodeQL Analysis
67+
id: analyze
6568
uses: github/codeql-action/analyze@v3
69+
with:
70+
category: "/language:${{matrix.language}}"
71+
# define the output folder for SARIF files
72+
output: sarif-results
73+
74+
# Unlock inline mechanism to suppress CodeQL warnings.
75+
# https://github.com/github/codeql/issues/11427#issuecomment-1721059096
76+
- name: Dismiss alerts
77+
# if: github.ref == 'refs/heads/main'
78+
uses: advanced-security/dismiss-alerts@v1
79+
with:
80+
# specify a 'sarif-id' and 'sarif-file'
81+
sarif-id: ${{ steps.analyze.outputs.sarif-id }}
82+
sarif-file: sarif-results/${{ matrix.language }}.sarif
83+
env:
84+
GITHUB_TOKEN: ${{ github.token }}

src/crate/client/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
# regex!
3232
__version__ = "1.0.0"
3333

34+
# codeql[py/unused-global-variable]
3435
apilevel = "2.0"
3536
threadsafety = 1
3637
paramstyle = "qmark"

0 commit comments

Comments
 (0)