Skip to main content

Django + DRF security, reliability and performance inspector

Project description

django_security_hunter

Django + DRF Security, Reliability, and Performance Inspector.

django_security_hunter helps backend teams catch risky patterns early: security misconfigurations, authorization gaps, abuse-protection weaknesses, API correctness issues, and performance/reliability smells.

Why django_security_hunter

AI-assisted coding improves speed, but it can also introduce hidden backend risks.
django_security_hunter gives fast, actionable feedback during development and in CI before code reaches production.

Features

  • Static and configuration scanning for Django + DRF projects
  • Runtime profiling mode scaffold for query explosion / N+1 detection
  • Output formats: console, json, sarif
  • CI-friendly exit codes by severity threshold
  • GitHub Security integration through SARIF

Documentation

Installation

From PyPI:

pip install django-security-hunter

Python package / CLI: django_security_hunter.

From source (clone into a folder name that matches the project):

git clone https://github.com/abu-rayhan-alif/djangoGuard.git django-security-hunter
cd django-security-hunter
python -m venv .venv
# Windows PowerShell
.venv\Scripts\Activate.ps1
pip install -e .[dev]

Quick Start

django_security_hunter scan --project . --format console
django_security_hunter scan --project . --format json --output reports/django_security_hunter.json
django_security_hunter scan --project . --format sarif --output reports/django_security_hunter.sarif

Commands

django_security_hunter scan

Runs static/config analysis and emits a report.

django_security_hunter profile

Runs runtime-oriented profiling checks (currently scaffolded in v0.1).

django_security_hunter init

Creates a default django_security_hunter.toml file in the target project.

CLI Options

  • --project Project root path
  • --settings Django settings module (example: config.settings)
  • --format console | json | sarif
  • --output Output file path
  • --threshold INFO | WARN | HIGH | CRITICAL

Configuration

Configuration is loaded in this order:

  1. django_security_hunter.toml (project override)
  2. pyproject.toml -> [tool.django_security_hunter]

Example:

severity_threshold = "WARN"
query_count_threshold = 50
db_time_ms_threshold = 200

Rule Catalog (V1 Target)

Rule ID Severity Description
DJG001 CRITICAL DEBUG=True in production
DJG002 HIGH Suspicious/hardcoded SECRET_KEY
DJG020 HIGH DRF default permissions missing or AllowAny
DJG040 WARN/HIGH Query count per test above threshold
DJG041 HIGH Repeated query signature indicates N+1
DJG070 HIGH Risky XSS usage patterns detected

Full rules and implementation progress can be maintained in docs/rules.md.

Output Formats

Console

Human-readable output for local development.

JSON

Stable schema for automation and custom dashboards.

SARIF

SARIF v2.1.0 output for GitHub PR annotations and Security tab integration.

Exit Codes

  • 0: No findings at or above threshold
  • 2: One or more findings at or above threshold

GitHub Actions Integration

Workflow file: .github/workflows/ci.yml

On every push and pull request:

  • installs dependencies
  • runs tests
  • generates SARIF report
  • uploads SARIF to GitHub Security

Docker

Build and run:

docker build -t django_security_hunter:local .
docker run --rm django_security_hunter:local django_security_hunter scan --project /app --format console

Using Docker Compose:

docker compose run --rm django_security_hunter django_security_hunter scan --project /app --format console

Limitations

  • Some future rules are heuristic and may produce false positives
  • Runtime profiling depends on project test coverage quality
  • Rule precision improves with project-specific tuning and allowlists

Roadmap

  • Django settings hardening rules (DJG001-DJG012)
  • DRF auth/permission/throttle checks (DJG020+)
  • Static code pattern rules (XSS/SSRF/deserialization/secrets)
  • Concurrency and atomicity heuristics (DJG050+)
  • Runtime N+1 and DB-time evidence improvements (DJG040+)
  • Optional dependency vulnerability integrations

Contributing

Contributions are welcome.

Please follow these guidelines:

  1. Open an issue for major changes
  2. Add tests for every new rule
  3. Keep rule IDs stable and documented
  4. Include remediation hints with findings

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_security_hunter-0.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_security_hunter-0.1.0-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file django_security_hunter-0.1.0.tar.gz.

File metadata

  • Download URL: django_security_hunter-0.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for django_security_hunter-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06383ea9265646959247f3e976573553f1db64d2c7c32c3d99ae67864634c2bc
MD5 fe32637c5cfdaf3c5c6e99712643afe1
BLAKE2b-256 41aac70b514d4accceab78b46a1aabd774d6705d6ea03d8fceb4d6190df98bea

See more details on using hashes here.

File details

Details for the file django_security_hunter-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_security_hunter-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a7a75c14f0a450fc3b06d7d8b946c46365dd3f2c9be50f8f223a462f59ebf08
MD5 381cffcae46815063590386d3c8b5b05
BLAKE2b-256 609f9f9f577faa9cc0618442530cb2fd8a91248d1c80bad8778f61222c96101d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page