Skip to content

Commit 177fbb7

Browse files
author
Martin Belanger
committed
code quality: add CodeQL static analysis
Add a CodeQL workflow to perform static security analysis on the Python codebase. The workflow runs on push/PR to main and weekly on Tuesdays. The Meson build runs before analysis so that all template-configured files are resolved in .build/ prior to scanning. A CodeQL config file constrains analysis to .build/ (excluding .build/subprojects/, which is nvme-cli/libnvme code) and sets PYTHONPATH so that libnvme imports are resolved for accurate taint tracking. Signed-off-by: Martin Belanger <[email protected]>
1 parent 42aeef3 commit 177fbb7

2 files changed

Lines changed: 71 additions & 0 deletions

File tree

.github/codeql/codeql-config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Analyze only the Meson build output (.build/), which contains fully
2+
# configured files (Meson template substitutions resolved). Exclude
3+
# subprojects/ — that is nvme-cli/libnvme code, not nvme-stas.
4+
paths:
5+
- .build
6+
paths-ignore:
7+
- .build/subprojects

.github/workflows/codeql.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CodeQL
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
schedule:
9+
- cron: '15 3 * * 2' # Tuesdays at 3:15 AM UTC
10+
11+
workflow_dispatch:
12+
13+
jobs:
14+
analyze:
15+
name: Analyze (python)
16+
runs-on: ubuntu-24.04
17+
timeout-minutes: 60
18+
permissions:
19+
actions: read
20+
contents: read
21+
security-events: write
22+
23+
steps:
24+
- name: "CHECKOUT: nvme-stas"
25+
uses: actions/checkout@v6
26+
27+
- name: "INSTALL: build packages"
28+
run: |
29+
sudo apt-get update
30+
sudo apt-get install --yes --quiet meson ninja-build cmake
31+
32+
- name: "INSTALL: python packages"
33+
run: |
34+
sudo apt-get install --yes --quiet python3-systemd python3-pyudev python3-dasbus python3-gi python3-lxml python3-tomli
35+
36+
- name: "INSTALL: remaining debian packages"
37+
run: |
38+
sudo apt-get install --yes --quiet libgirepository1.0-dev libsystemd-dev
39+
40+
- name: "INSTALL: libnvme packages (needed to build libnvme)"
41+
run: |
42+
sudo apt-get install --yes --quiet swig libjson-c-dev
43+
44+
- name: "INIT: CodeQL"
45+
uses: github/codeql-action/init@v3
46+
with:
47+
languages: python
48+
config-file: ./.github/codeql/codeql-config.yml
49+
50+
- name: "BUILD: [libnvme, nvme-stas] (generates configured files in .build/)"
51+
uses: BSFishy/[email protected]
52+
with:
53+
action: build
54+
directory: .build
55+
setup-options: --buildtype=release --sysconfdir=/etc --prefix=/usr -Dnvme-cli:buildtype=release -Dnvme-cli:sysconfdir=/etc -Dnvme-cli:prefix=/usr -Dnvme-cli:python=enabled -Dnvme-cli:libdbus=disabled -Dnvme-cli:openssl=disabled -Dnvme-cli:json-c=disabled -Dnvme-cli:keyutils=disabled
56+
57+
- name: "CONFIG: PYTHONPATH"
58+
run: |
59+
echo "PYTHONPATH=.build:.build/subprojects/nvme-cli/libnvme:/usr/lib/python3/dist-packages/" >> $GITHUB_ENV
60+
61+
- name: "ANALYZE: CodeQL"
62+
uses: github/codeql-action/analyze@v3
63+
with:
64+
category: "/language:python"

0 commit comments

Comments
 (0)