Skip to content

ci: make ruff, bandit and pip-audit blocking (#114) - #206

Open
Labu1 wants to merge 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-114
Open

Labu1 wants to merge 1 commit into
secfoo-com:mainfrom
Labu1:repodestek/issue-114

Conversation

@Labu1

@Labu1 Labu1 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

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 the dev extra but nothing ran them. This makes all three blocking.

  • ruff: || true removed. 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 the dev extra so the result is reproducible; bump it on purpose.
  • bandit: new Security (bandit, pip-audit) job runs bandit -r src/secfoo -c .bandit -ll (medium and above), blocking.
  • pip-audit: the same job runs pip-audit --skip-editable on 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 --check is 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 raises ValueError, because asserts are stripped under python -O. Covered by tests/test_runner_target_workdir.py.

Bandit findings: annotated as false positives (# nosec with reason)

  • storage/repository.py cost_summary (B608): group_sql comes from a fixed dict lookup.
  • storage/repository.py runs-table migration (B608): column names come from PRAGMA table_info(runs), not user input.
  • cli.py SECRET = "secret-scanning" (B105): a skill id, not a password.
  • web/security.py WILDCARD_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.py urllib.request.Request(...) (B310): the matching urlopen lines were already annotated; these are the user-configured portal/memory URL and the hardcoded OSV.dev URL.
  • sensor/probe.py two except 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 pytest in a clean Linux container: the 4 remaining failure(s) also occur on the base branch without this change; no new failures are introduced.

  • pytest tests passes
  • ruff check . passes
  • Added/updated tests for the behavior change

This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

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.
@Labu1
Labu1 requested a review from vsn411 as a code owner November 27, 2026 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make lint and security scanning blocking in CI: ruff has 133 errors behind || true, bandit findings are unreviewed, pip-audit never runs

1 participant