Repository navigation
ci: make ruff, bandit and pip-audit blocking (#114) - #206
Conversation
The ruff backlog has been cleared (secfoo-com#194, secfoo-com#196, secfoo-com#198), so drop the `|| true` and pin ruff in the dev extra so a new ruff release can't turn unrelated PRs red. Add a Security job that runs bandit at medium severity and above and pip-audit on the installed environment, both blocking. Replace the assert in runner._target_workdir with a real check (asserts are stripped under -O) and annotate the reviewed bandit false positives with `# nosec` and a reason. Document the three commands as the pre-PR checklist in CONTRIBUTING.md. Fixes secfoo-com#114.
BLE001 already accepts these except blocks (they log with exc_info), so the noqa was unused (RUF100); keep each reason as a plain comment. Sort the cli.py imports (I001). Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, this is exactly what #114 asks for. Each bandit finding is listed as fixed or annotated with its reason. The The Test jobs are red, but your changes didn't cause it.
To get this merged I pushed the fix straight to your branch: a merge of current |
Leaderboard update
Labu1 now has 18 points (rank #4). 7 more to reach Bronze. |
Closes #114
What does this change, and why?
CI ran
ruff check . || true, so lint could never fail a build. bandit and pip-audit were in thedevextra but nothing ran them. This makes all three blocking.|| trueremoved. The backlog from the issue was already cleared by test: resolve ruff lint findings in tests/ #194, fix(lint): resolve the error-handling ruff findings in src #196 and chore(lint): apply ruff's safe autofixes (Optional[X], __all__ order, regex flags) #198. ruff is now pinned (ruff==0.17.6) in thedevextra so the result is reproducible; bump it on purpose.Security (bandit, pip-audit)job runsbandit -r src/secfoo -c .bandit -ll(medium and above), blocking.pip-audit --skip-editableon the installed environment after upgrading pip. It's blocking, and secfoo itself is skipped because the editable install may be ahead of the latest release. No advisories are accepted today; the step's comment shows the--ignore-vuln <ID>format and asks for a date and reason on each entry.ruff format --checkis not added: formatting the whole codebase would be a large unrelated diff, so that should be a follow-up issue.CONTRIBUTING.md: new pre-PR checklist with the three commands and how to handle an intentional exception for each.Bandit findings: fixed
runner.py_target_workdir:assert resolved.path is not None(B101) is now a real check that raisesValueError, because asserts are stripped underpython -O. Covered bytests/test_runner_target_workdir.py.Bandit findings: annotated as false positives (
# nosecwith reason)storage/repository.pycost_summary(B608):group_sqlcomes from a fixed dict lookup.storage/repository.pyruns-table migration (B608): column names come fromPRAGMA table_info(runs), not user input.cli.pySECRET = "secret-scanning"(B105): a skill id, not a password.web/security.pyWILDCARD_BINDS(B104): the set used to detect and guard wildcard binds; nothing binds to it.report/evidence.py'/tmp/evaluator'(B108): replacement text in a path scrubber, never opened as a file.cloud.py,memory.py,osv.pyurllib.request.Request(...)(B310): the matchingurlopenlines were already annotated; these are the user-configured portal/memory URL and the hardcoded OSV.dev URL.sensor/probe.pytwoexcept Exception: pass(B110, Low): these run inside the user's application while it shuts down or disables the probe. The probe must never raise into the app or log through its handlers, so they stay silent on purpose. Runner's other broad excepts already log at debug level.Testing
Ran
pytestin a clean Linux container: the 4 remaining failure(s) also occur on the base branch without this change; no new failures are introduced.pytest testspassesruff check .passesThis PR was prepared with AI assistance (Claude) and reviewed by me before submitting.