Secure document download and sanitization tool using Dangerzone.
Defuse provides a secure way to download documents from the web and sanitize them using Dangerzone. It supports multiple document formats (PDFs, Word docs, PowerPoint, images, and more) and converts them to safe PDFs while removing potentially malicious content.
- Multi-Format Support: Supports PDFs, Word documents, PowerPoint presentations, images, and other formats supported by Dangerzone
- Secure Downloads: Downloads documents with validation, size limits, and domain filtering
- Automatic Sanitization: Uses Dangerzone to remove JavaScript, macros, forms, and other potentially dangerous content
- Batch Processing: Process multiple URLs from a file
- Cross-Platform: Works on macOS, Linux, and Windows
- Configuration: Customizable settings for domains, output directories, and more
uv tool install defusegit clone https://github.com/codyw912/defuse
cd defuse
uv tool install .Defuse requires Dangerzone to be installed. Defuse will automatically detect Dangerzone in common installation locations on all platforms (PATH, app bundles, package managers, etc.):
# Option 1: Download from website
# https://dangerzone.rocks
# Option 2: Use Homebrew
brew install --cask dangerzone# Use your package manager or download from:
# https://dangerzone.rocksdefuse check-depsdefuse download https://example.com/document.pdf
# Also works with other formats:
defuse download https://example.com/presentation.pptx
defuse download https://example.com/document.docxdefuse sanitize /path/to/document.pdf
# Also works with other formats:
defuse sanitize /path/to/presentation.pptx
defuse sanitize /path/to/document.docx# Create a file with URLs (one per line) - mix of formats supported
echo "https://example.com/doc1.pdf" > urls.txt
echo "https://example.com/presentation.pptx" >> urls.txt
echo "https://example.com/document.docx" >> urls.txt
defuse batch urls.txt# List current settings
defuse config --list
# Set custom output directory
defuse config --output-dir ~/SafeDocuments
# Add allowed domain
defuse config --add-domain example.com
# Set custom Dangerzone path (only needed if auto-detection fails)
defuse config --dangerzone-path /custom/path/to/dangerzone-cli--output-dir, -o: Output directory for sanitized document--output-filename, -f: Custom filename for output--keep-original: Keep the original downloaded file--verbose, -v: Verbose output
--output-dir, -o: Output directory for sanitized document--output-filename, -f: Custom filename for output--verbose, -v: Verbose output
--output-dir, -o: Output directory for sanitized documents--keep-originals: Keep original downloaded files--verbose, -v: Verbose output
- URL Validation: Checks URL format and optional domain restrictions
- File Size Limits: Prevents downloading excessively large files
- Format Detection: Automatically detects document format using magic bytes
- Defense in Depth: Layered security with download isolation + Dangerzone's container-based sanitization
- Adaptive Sandboxing: Automatically selects the best available sandbox backend:
- Linux: Firejail or Bubblewrap (maximum isolation) > Podman > Docker > subprocess fallback
- macOS/Windows: Docker > Podman > subprocess fallback
Defuse stores user configuration in:
- macOS:
~/Library/Application Support/defuse/config.yaml - Linux:
~/.config/defuse/config.yaml - Windows:
%APPDATA%/defuse/config.yaml
Dangerzone converts potentially dangerous documents into safe PDFs by:
- Converting the document into pixel data inside a sandbox (supports PDFs, Word docs, PowerPoint, images, etc.)
- Using OCR to preserve any text content
- Reconstructing a clean PDF outside the sandbox
- Removing all potentially malicious content (JavaScript, macros, forms, embedded files, etc.)
# Clone the repository
git clone https://github.com/codyw912/defuse
cd defuse
# Install development dependencies
uv sync --extra dev
# Run with uv
uv run defuse --help
# Run tests
uv run pytest
# Lint code
uv run ruff checkMIT License - see LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
- Report issues: https://github.com/codyw912/defuse/issues
- Dangerzone documentation: https://dangerzone.rocks