Skip to content

Add security scanning CI (CodeQL, pip-audit, Dependabot) and pre-commit#92

Open
ivan-pinatti wants to merge 5 commits intoAlfredoSequeida:mainfrom
ivan-pinatti:main
Open

Add security scanning CI (CodeQL, pip-audit, Dependabot) and pre-commit#92
ivan-pinatti wants to merge 5 commits intoAlfredoSequeida:mainfrom
ivan-pinatti:main

Conversation

@ivan-pinatti
Copy link
Copy Markdown

@ivan-pinatti ivan-pinatti commented Mar 5, 2026

Summary

Implements the security scanning proposal from #91.

Adds free, automated security scanning at two levels:

CI (GitHub Actions)

  • CodeQL — SAST for Python; finds logic bugs, injection flaws, unsafe API usage. Results appear in Security > Code scanning.
  • pip-audit — fully installs the project (including PyGObject) in a clean Ubuntu runner with system libs, then scans all dependencies including transitive ones against the OSV database for known CVEs.
  • Dependabot — opens PRs automatically when pip dependencies or GitHub Actions versions have updates.

Local (pre-commit)

  • bandit — SAST on staged Python files before each commit; immediate local feedback without waiting for CI.
  • pip-audit — scans direct dependencies from requirements.txt against the OSV database before each commit.
    • PyGObject is excluded from requirements.txt: it requires gobject-introspection system headers to build metadata, which are not universally available locally. It is fully covered by pip-audit in CI.
    • Transitive dependency CVEs are covered by pip-audit in CI.

Files added / modified

File Purpose
.github/workflows/security.yml CodeQL + pip-audit CI jobs
.github/dependabot.yml Weekly dependency update checks
.pre-commit-config.yaml bandit SAST + pip-audit hooks (local)
requirements.txt Direct dependencies for local pip-audit (mirrors setup.py install_requires)
README.md Expanded Contributing/Development section with pre-commit setup instructions

Trigger conditions (CI)

  • Push or PR to main
  • Weekly schedule (Mondays 06:00 UTC)
  • Manual via workflow_dispatch

Pre-existing findings

bandit surfaced the following in the existing codebase (not introduced by this PR):

  • shell=True in subprocess calls (hints.py, setup.py, plasmashell.py, others) — CWE-78
  • pickle.loads from a Unix domain socket (mouse.py, mouse_service.py) — CWE-502
  • Hardcoded /tmp socket path (constants.py) — CWE-377

These are reported for the maintainer's awareness. The pre-commit hook runs only on staged files so it won't block existing workflows.

All tooling is free for public repositories — no external accounts or tokens required. All CI jobs have been validated on the fork before this PR.

Adds three free security layers for the public repo:
- CodeQL SAST for Python logic bugs and unsafe API usage
- pip-audit dependency scan against OSV database for CVEs
- Dependabot for automated dependency and Actions version updates

Closes: AlfredoSequeida#91
Adds bandit (SAST) as a pre-commit hook for catching security issues
in Python code locally before push. Runs only on staged files by default.

Existing findings in the codebase (shell=True, pickle.loads, /tmp socket
path) are pre-existing and for the maintainer to review separately.

pip-audit is intentionally CI-only: installing this project requires
system libs (libgirepository, Cairo) unavailable in pre-commit's
isolated environment.
Adds local dependency vulnerability scanning via pip-audit alongside the
existing bandit SAST hook. requirements.txt mirrors setup.py install_requires
and is used by pip-audit with --no-deps to avoid dependency resolution.

PyGObject is excluded from requirements.txt: it requires gobject-introspection
system headers to build metadata, which are not universally available locally.
It is fully covered by pip-audit in CI where system libs are installed.

Transitive dependency CVEs are also covered by CI.
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