You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

drf-protector

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drf-protector

Obfuscate and package Django/DRF apps securely with PyArmor + Docker

0.1.1
pipPyPI
Maintainers
1

DRF Protector

Secure your Django REST Framework (DRF) projects with PyArmor and Docker. This tool lets you obfuscate your source code, add licensing with PyArmor, and package everything into a Docker container for deployment.

🧩 Django Web + DRF Support

This tool is designed to work with both Django REST Framework (DRF) APIs and traditional Django web applications. Whether your project includes APIs, templates, or both — you can use drf-protector to obfuscate your backend logic, protect source code, and deploy it securely using Docker.

Just ensure the drf_protector.json is correctly configured for your app structure.

  • ✅ Works with urls.py, views.py, models, and API views
  • ✅ Compatible with Django templates, static files, and DRF serializers
  • ✅ Obfuscation targets Python code only — static and templates are preserved as-is

Features

  • 🔐 Obfuscate Python code using PyArmor
  • 🧾 License-based execution control
  • 🐳 Generate secure Docker containers
  • 🛠️ Easy CLI for local development and deployment

Usage

drf-protector init        # Generate drf_protector.json config
drf-protector obfuscate   # Obfuscate code
drf-protector dockerize   # Build secure docker image

⚠️ Handling Django Migrations with PyArmor

When obfuscating your Django app, it's important to handle migrations/ correctly to avoid runtime issues.

✅ Best Practices:

  • Exclude migrations/ from PyArmor obfuscation:

    • These files must remain in readable Python as Django loads them dynamically.
    • Already handled in drf_protector.json default: "exclude": ["migrations", "__pycache__"]
  • Include migrations/ in your Docker build:

    • Make sure to copy migration folders into the Docker image for proper deployment.
  • Run makemigrations before obfuscating:

    • Prepare all database changes before protecting the code.
  • Run migrate at container runtime:

    • Once deployed, run python manage.py migrate to apply changes.

❌ Don't Obfuscate:

Avoid obfuscating files in migrations/ as it can break introspection, RunPython, or ORM model detection.

License

MIT

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts