abandon auditor

This commit is contained in:
2026-11-10 19:44:13 -05:00
parent f5e0470cd5
commit 1f7126dca5
4 changed files with 63 additions and 234 deletions

View File

@@ -0,0 +1,64 @@
# Project Idea: Django Security Configuration Auditor
From the security audit, this was the first recommended project:
> **Django Security Configuration Auditor** - Scans Django settings for production readiness (DEBUG, SECRET_KEY, security headers, password validators, token expiry, etc.)
## How this fits the project rules
**✅ Real task** - This is a genuine security tool that Django projects need. The NearBeach audit itself revealed exactly the kinds of issues this tool would catch (hardcoded SECRET_KEY, DEBUG=True, missing security headers, non-expiring tokens).
**✅ Checkable** - Clear completion criteria:
- Run against a test Django project with known issues → tool reports them
- Run against a hardened Django project → tool reports clean
- CLI with exit codes for CI/CD integration
**✅ Big enough** - Multiple components:
- Settings parser (handles `settings.py`, `local_settings.py`, environment-based configs)
- Rule engine (50+ security checks across categories)
- CLI with multiple output formats (JSON, SARIF, human-readable)
- CI/CD integration (GitHub Actions, GitLab CI)
- Extensible rule system for custom checks
**✅ Not already solved** - Existing tools like `django-check-secrets` or `bandit` don't do Django-specific settings analysis comprehensively.
**✅ Safe** - No credentials, no external API calls, pure static analysis.
---
## Suggested Task Breakdown (for 8-15 turns)
| Turn | Focus |
|------|-------|
| 1-2 | Project scaffold: CLI entry point, settings discovery/loading |
| 3-4 | Core rule engine + first 10 rules (SECRET_KEY, DEBUG, ALLOWED_HOSTS, security headers) |
| 5-6 | More rules: password validators, token settings, CORS, CSP, file upload settings |
| 7-8 | Output formats (JSON, SARIF, table), exit codes |
| 9-10 | CI/CD integration examples, GitHub Action |
| 11+ | Extensibility: custom rules, config file, ignore patterns |
---
## Why this is a strong choice for this project
1. **You're the target user** - You just did a manual audit of NearBeach. This tool would automate what you did.
2. **Leverages the repo** - NearBeach's own `local/settings.py` is the perfect test case (has the CRITICAL issues).
3. **Clear "Other notes for reviewer"** - You can explain: "I built this because I manually audited NearBeach and found 17 issues. This tool would have caught them all automatically."
4. **Measurable completion** - Run it on NearBeach zip → shows 17 findings. Fix settings → shows 0.
---
## Questions before we start
1. **Scope**: Just Django settings, or also scan `requirements.txt` / `pyproject.toml` for vulnerable dependencies?
2. **Language**: Python (obviously), but any preference on CLI framework (Click, Typer, argparse)?
3. **Test strategy**: Use NearBeach as the primary test fixture, or create a separate minimal Django project with injected issues?
---
## Next Steps
If proceeding with this as the task:
1. Draft the **Task brief** (description, completion criteria, other notes) for LiveCompare
2. Mount the NearBeach zip
3. Begin the session

View File

@@ -0,0 +1,63 @@
### 1. Task Description
Build a Django Security Configuration Auditor — a CLI tool that scans Django settings files for production readiness issues. The tool parses Django settings (including `settings.py`, `local_settings.py`, and environment-based configurations) and runs 50+ security checks across categories: DEBUG/SECRET_KEY exposure, security headers (CSP, HSTS, X-Frame-Options), password validators, token/session expiry, CORS, file upload limits, SSL/HTTPS settings, and more. Output formats include human-readable table, JSON, and SARIF for CI/CD integration with exit codes for pipeline gating.
This is a genuine security tool that Django projects need. The NearBeach audit itself revealed exactly the kinds of issues this tool would catch (hardcoded SECRET_KEY, DEBUG=True, missing security headers, non-expiring tokens). Existing tools like `django-check-secrets` or `bandit` don't do Django-specific settings analysis comprehensively.
---
### 2. How to Judge Completion
**Primary check (NearBeach test case):**
1. Mount the NearBeach zip and run the auditor against its `local/settings.py`:
```bash
python -m djangosecauditor /path/to/nearbeach/local/settings.py --format table
```
2. The tool should report **17+ findings** including at minimum:
- CRITICAL: `DEBUG = True`
- CRITICAL: Hardcoded `SECRET_KEY`
- HIGH: Missing `SECURE_SSL_REDIRECT`, `SECURE_HSTS_SECONDS`, `SECURE_CONTENT_TYPE_NOSNIFF`
- HIGH: Missing `X_FRAME_OPTIONS` or set to `SAMEORIGIN` instead of `DENY`
- HIGH: Missing CSP headers (`CONTENT_SECURITY_POLICY`)
- MEDIUM: Weak/absent password validators
- MEDIUM: Missing/short token expiry (`REST_FRAMEWORK` token settings, `SIMPLE_JWT` settings)
- MEDIUM: `ALLOWED_HOSTS` too permissive or `['*']`
- MEDIUM: Missing `SECURE_REFERRER_POLICY`, `SECURE_CROSS_ORIGIN_OPENER_POLICY`
**Hardened settings check:**
3. Create a minimal hardened Django settings file (or fix NearBeach's settings) and run again:
```bash
python -m djangosecauditor /path/to/hardened/settings.py --format json
```
Should report **0 findings** (exit code 0).
**CI/CD integration check:**
4. Run with SARIF output and verify valid SARIF 2.1.0:
```bash
python -m djangosecauditor /path/to/settings.py --format sarif --output results.sarif
```
Validate with `jq` or a SARIF viewer — each finding should have `ruleId`, `level`, `message`, `locations`.
**Test suite:**
5. Run the project's test suite:
```bash
python -m pytest tests/ -v
```
Should pass with 50+ test cases covering rule logic, settings parsing (various formats), output formats, and edge cases.
**Exit codes:**
6. Verify exit codes: `0` = clean, `1` = findings present, `2` = error (invalid settings, parse failure).
---
### 3. Other Notes for Reviewer
This tool automates the manual Django security audit I just performed on NearBeach, which uncovered 17 production-readiness issues. The problem it solves: Django projects ship with insecure defaults, and developers often miss settings that must be explicitly hardened for production. Existing tools (`bandit`, `django-check-secrets`, `safety`) focus on code vulnerabilities or dependency scanning, not Django-specific configuration analysis.
**Why this matters:** A single misconfigured setting (e.g., `DEBUG=True`, weak `SECRET_KEY`, missing HSTS) can lead to full compromise. This tool makes "secure by default" enforceable in CI/CD.
**Architecture:** Pure static analysis — no Django runtime, no database, no network calls. Parses settings as Python AST with env-branch modeling to handle `os.environ.get()`, `django-environ`, `python-decouple`, and conditional blocks (`if "KEY" in os.environ:`) without booting the project. Rule engine is extensible: each check is a class with `check(settings_dict) -> List[Finding]`.
**Scope:** Django settings only. Not scanning `requirements.txt`/`pyproject.toml` for vulnerable dependencies (that's a separate tool's job).
**Safety:** No credentials, no external API calls, no code execution beyond AST parsing. Safe to share and run on any codebase.