Skip to content

ci(security): add Python SAST via Ruff bandit rules and CodeQL scanning#5738

Open
leseb wants to merge 4 commits intoogx-ai:mainfrom
leseb:implement-secret-scanning-and-python-sast-in-ogx-p
Open

ci(security): add Python SAST via Ruff bandit rules and CodeQL scanning#5738
leseb wants to merge 4 commits intoogx-ai:mainfrom
leseb:implement-secret-scanning-and-python-sast-in-ogx-p

Conversation

@leseb
Copy link
Copy Markdown
Collaborator

@leseb leseb commented May 6, 2026

Summary

  • Enable Ruff's S (flake8-bandit) security rule set for Python SAST, catching issues like hardcoded passwords, unsafe subprocess calls, and SQL injection patterns at lint time
  • Add Python to the existing CodeQL workflow for deeper semantic security analysis on PRs touching src/
  • Add targeted per-file-ignores to suppress known false positives (test fixtures, CLI subprocess calls, SQL table name interpolation guarded by existing hooks)

Test plan

  • uv run ruff check passes with the new rules enabled
  • CodeQL workflow updated to scan Python in addition to GitHub Actions
  • CI validates both ruff and CodeQL on this PR

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

leseb and others added 3 commits May 6, 2026 17:05
Enable the flake8-bandit rule set ("S") in Ruff to catch security issues
such as hardcoded passwords, SQL injection, unsafe subprocess calls, and
insecure cryptographic usage at lint time.

S101 (assert) is globally ignored since assert is used extensively as an
internal invariant pattern throughout the codebase. Per-file-ignores
suppress known false positives: env var template defaults in provider
configs (S105/S106/S107), legitimate subprocess usage in CLI tools
(S603/S607), and table-name interpolation in storage layers already
covered by the custom SQL injection pre-commit hook (S608).

Test files get broad security rule suppression since test fixtures
legitimately use hardcoded credentials, temp files, and assertions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
Extend the CodeQL workflow to scan Python source code alongside GitHub
Actions. Python is added to the language matrix and the paths trigger is
expanded to include src/ so the workflow runs on Python changes.

The security-extended query suite was already configured and will now
apply to Python as well, covering SQL injection, path traversal, command
injection, and other OWASP categories.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
…ripts

Extend the Ruff security rule suppressions to cover benchmarking mock
servers (S104, S110, S311), client SDK templates (S110, S112, S113), and
codegen scripts (S110, S112, S603, S607) which legitimately use patterns
flagged by bandit rules.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
Signed-off-by: Sébastien Han <seb@redhat.com>
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.

1 participant