Skip to content

Commit 8ce5232

Browse files
committed
Add more static checkers (bandit, codespell, vulture)
1 parent c0b209f commit 8ce5232

4 files changed

Lines changed: 62 additions & 2 deletions

File tree

.github/workflows/linting.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,33 @@ jobs:
2424
run: |
2525
uv sync
2626
uv run --package master ty check master/master.cfg master/custom_steps.py
27+
28+
bandit:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- name: Run bandit
34+
run: |
35+
pip install bandit
36+
bandit -c pyproject.toml -r master/master.cfg master/custom_steps.py master/buildbot.tac worker/buildbot.tac
37+
38+
codespell:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Run codespell
44+
run: |
45+
pip install codespell
46+
codespell
47+
48+
vulture:
49+
runs-on: ubuntu-latest
50+
steps:
51+
- uses: actions/checkout@v4
52+
53+
- name: Run vulture
54+
run: |
55+
pip install vulture
56+
vulture master/master.cfg master/custom_steps.py master/buildbot.tac worker/buildbot.tac

.pre-commit-config.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,23 @@ repos:
1010
- id: ruff-check
1111
args: [--fix]
1212
- id: ruff-format
13+
- repo: https://github.com/PyCQA/bandit
14+
rev: 1.9.3
15+
hooks:
16+
- id: bandit
17+
args: ["-c", "pyproject.toml"]
18+
19+
- repo: https://github.com/codespell-project/codespell
20+
rev: v2.4.1
21+
hooks:
22+
- id: codespell
23+
24+
- repo: https://github.com/jendrikseipp/vulture
25+
rev: v2.14
26+
hooks:
27+
- id: vulture
28+
pass_filenames: false
29+
1330
- repo: local
1431
hooks:
1532
- id: ty-check

master/custom_steps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import xml.etree.ElementTree as Xml
1+
import xml.etree.ElementTree as Xml # nosec B405 -- XML comes from trusted CTest output
22

33
from buildbot.process.buildstep import BuildStepFailed, BuildStep, ShellMixin
44
from buildbot.steps.worker import CompositeStepMixin
@@ -68,7 +68,7 @@ def run(self):
6868
ctest_log = yield self.getFileContentFromWorker(xml_results[0], abandonOnFailure=True)
6969

7070
# Parse the result, collecting test failures into more convenient logs.
71-
root = Xml.fromstring(ctest_log)
71+
root = Xml.fromstring(ctest_log) # nosec B314 -- XML comes from trusted CTest output
7272

7373
for test in root.findall(".//Test[@Status='failed']"):
7474
log = yield self.addLog(test.findtext("Name", "unknown"))

pyproject.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,18 @@ include = ["master/custom_steps.py"]
3030
# BuilderConfig gets a dynamic `builder_type` attribute attached
3131
unresolved-attribute = "warn"
3232

33+
[tool.bandit]
34+
targets = ["master/master.cfg", "master/custom_steps.py", "master/buildbot.tac", "worker/buildbot.tac"]
35+
skips = [
36+
"B101", # assert_used: asserts are intentional for config validation
37+
]
38+
39+
[tool.vulture]
40+
paths = ["master/master.cfg", "master/custom_steps.py", "master/buildbot.tac", "worker/buildbot.tac"]
41+
min_confidence = 80
42+
43+
[tool.codespell]
44+
skip = ".venv,*.pyc,__pycache__"
45+
3346
[tool.uv.workspace]
3447
members = ["master", "worker"]

0 commit comments

Comments
 (0)