Security Baseline
This document provides context for the Bandit security baseline established on 2025-06-28.
Overview
The Gyrinx codebase uses Bandit for automated security scanning. The baseline captures the current state of security findings to:
Track only new security issues in CI/CD
Document accepted security risks
Plan security improvements over time
Baseline Files
bandit/bandit-baseline.json- Machine-readable baseline for CI comparison (committed to git)bandit/bandit-baseline.txt- Human-readable report with detailed findings (committed to git)
Running Bandit
# Run scan with baseline comparison (as CI does)
bandit -c pyproject.toml -r . --baseline bandit/bandit-baseline.json
# Generate new baseline files
bandit -c pyproject.toml -r . -f json -o bandit/bandit-baseline.json
bandit -c pyproject.toml -r . -f txt -o bandit/bandit-baseline.txtUpdating the Baseline
When security issues are resolved or new acceptable findings are added:
Run Bandit to generate new baseline files
Review the changes carefully
Commit both JSON and TXT files with explanation
Configuration
Bandit is configured in pyproject.toml:
Excluded Directories
.venv,.git,__pycache__- Infrastructure directories*/migrations/*- Django migrations (auto-generated)*/tests/*- Test files (assertions expected)node_modules- Node.js dependencies
Skipped Checks
B101 (
assert_used): Assertions are used in testsB601 (
paramiko_calls): Paramiko is not usedB603 (
subprocess_without_shell_equals_true): Reviewed case-by-case
Additional Security Practices
Input Validation
Use
safe_redirect()helper for all redirect URLs to prevent open redirect vulnerabilitiesValidate user input at form level using Django forms
Sanitise HTML content with appropriate filters
Authentication
Django's built-in authentication system with session management
reCAPTCHA verification for registration (when enabled)
Password validation using Django validators
Pre-commit Hooks
Security checks run automatically on commit via pre-commit:
detect-private-key- Prevents committing private keysbandit- Runs security scan on Python files
Related Documentation
SECURITY.md - Security policy and vulnerability reporting
Last updated