feat: v1.5.0 Phase 2 - Debug File Management
Implement debug file management system with configuration controls, automatic cleanup, and security improvements per v1.5.0 Phase 2. ## Changes ### Configuration (config.py) - Add DEBUG_SAVE_FAILED_UPLOADS (default: false, production-safe) - Add DEBUG_FILE_MAX_AGE_DAYS (default: 7 days) - Add DEBUG_FILE_MAX_SIZE_MB (default: 100MB) ### Media Validation (media.py) - Check config before saving debug files - Sanitize filenames to prevent path traversal - Pattern: alphanumeric + "._-", truncated to 50 chars - Add cleanup_old_debug_files() function * Age-based cleanup (delete files older than MAX_AGE) * Size-based cleanup (delete oldest if total > MAX_SIZE) ### Application Startup (__init__.py) - Run cleanup_old_debug_files() on startup - Automatic maintenance of debug directory ### Tests (test_debug_file_management.py) - 15 comprehensive tests - Config defaults and overrides - Debug file saving behavior - Filename sanitization security - Cleanup age and size limits - Startup integration ## Security Improvements - Debug saving disabled by default (production-safe) - Filename sanitization prevents path traversal - Automatic cleanup prevents disk exhaustion ## Acceptance Criteria - [x] Configuration options added - [x] Debug saving disabled by default - [x] Filename sanitized before saving - [x] Cleanup runs on startup - [x] Old files deleted based on age - [x] Size limit enforced All tests pass. Ready for architect review. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -97,6 +97,11 @@ def load_config(app, config_override=None):
|
||||
app.config["METRICS_BUFFER_SIZE"] = int(os.getenv("METRICS_BUFFER_SIZE", "1000"))
|
||||
app.config["METRICS_MEMORY_INTERVAL"] = int(os.getenv("METRICS_MEMORY_INTERVAL", "30"))
|
||||
|
||||
# Debug file configuration (v1.5.0 Phase 2)
|
||||
app.config["DEBUG_SAVE_FAILED_UPLOADS"] = os.getenv("DEBUG_SAVE_FAILED_UPLOADS", "false").lower() == "true"
|
||||
app.config["DEBUG_FILE_MAX_AGE_DAYS"] = int(os.getenv("DEBUG_FILE_MAX_AGE_DAYS", "7"))
|
||||
app.config["DEBUG_FILE_MAX_SIZE_MB"] = int(os.getenv("DEBUG_FILE_MAX_SIZE_MB", "100"))
|
||||
|
||||
# Apply overrides if provided
|
||||
if config_override:
|
||||
app.config.update(config_override)
|
||||
|
||||
Reference in New Issue
Block a user