Files
intercept/utils/__init__.py
James Smith 1398a5dedd Major security and code quality improvements
Security:
- Add input validation for all API endpoints (frequency, lat/lon, device, gain, ppm)
- Add HTML escaping utility to prevent XSS attacks
- Add path traversal protection for log file configuration
- Add proper HTTP status codes for error responses (400, 409, 503)

Performance:
- Reduce SSE keepalive overhead (30s interval instead of 1s)
- Add centralized SSE stream utility with optimized keepalive
- Add DataStore class for thread-safe data with automatic cleanup

New Features:
- Add data export endpoints (/export/aircraft, /export/wifi, /export/bluetooth)
- Support for both JSON and CSV export formats
- Add process cleanup on application exit (atexit handlers)
- Label Iridium module as demo mode with clear warnings

Code Quality:
- Create utils/validation.py for centralized input validation
- Create utils/sse.py for SSE stream utilities
- Create utils/cleanup.py for memory management
- Add safe_terminate() and register_process() for process management
- Improve error handling with proper logging throughout routes

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-30 19:24:40 +00:00

43 lines
1.0 KiB
Python

# Utility modules for INTERCEPT
from .dependencies import check_tool, check_all_dependencies, TOOL_DEPENDENCIES
from .process import (
cleanup_stale_processes,
is_valid_mac,
is_valid_channel,
detect_devices,
safe_terminate,
register_process,
unregister_process,
cleanup_all_processes,
)
from .logging import (
get_logger,
app_logger,
pager_logger,
sensor_logger,
wifi_logger,
bluetooth_logger,
adsb_logger,
satellite_logger,
iridium_logger,
)
from .validation import (
escape_html,
validate_latitude,
validate_longitude,
validate_frequency,
validate_device_index,
validate_gain,
validate_ppm,
validate_hours,
validate_elevation,
validate_wifi_channel,
validate_mac_address,
validate_positive_int,
sanitize_callsign,
sanitize_ssid,
sanitize_device_name,
)
from .sse import sse_stream, format_sse, clear_queue
from .cleanup import DataStore, CleanupManager, cleanup_manager, cleanup_dict