mirror of
https://github.com/ChuckBuilds/LEDMatrix.git
synced 2026-05-26 05:53:33 +00:00
py/flask-debug (#214): - debug_web_manual.py: read debug mode from LEDMATRIX_FLASK_DEBUG env var instead of hardcoded True py/stack-trace-exposure (#216, #218): - api_v3.py execute_system_action: remove subprocess stdout/stderr from HTTP responses; log via logger instead - api_v3.py get_git_version: validate output matches safe ref format (^[a-zA-Z0-9._-]+$) before including in response - api_v3.py: remove all remaining traceback.format_exc() dead variables and print() debug calls (replaced with logger.debug/warning) py/reflective-xss (#207, #208, #209, #210, #211, #212): - api_v3.py: remove plugin_id from all error/success response messages (uninstall, install, update, health, not-found responses) - pages_v3.py load_partial: return static "Partial not found" message instead of echoing partial_name - pages_v3.py _load_starlark_config_partial: add app_id regex validation, use static error messages instead of f-strings with app_id py/path-injection (#187–#206): - pages_v3.py _load_plugin_config_partial: resolve plugins_base and validate _plugin_dir with relative_to() before all file operations; same for assets metadata directory - pages_v3.py _load_starlark_config_partial: resolve starlark_base and validate schema_file/config_file paths with relative_to() - plugin_loader.py _find_plugin_directory: resolve plugins_dir and validate strategy-2 candidates with relative_to() - plugin_loader.py install_dependencies: resolve plugin_dir first, then construct requirements_file and marker_path from resolved base - plugin_loader.py load_module: resolve plugin_dir with strict=True and validate entry_file with relative_to() before exec_module Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
92 lines
2.7 KiB
Python
92 lines
2.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Web Interface Manual Debug Script
|
|
Run this to diagnose why web_interface/start.py isn't working
|
|
"""
|
|
|
|
import sys
|
|
import os
|
|
import traceback
|
|
from pathlib import Path
|
|
|
|
def main():
|
|
print("🔍 LED Matrix Web Interface Debug Tool")
|
|
print("=" * 50)
|
|
|
|
# Change to project root (where this script is located)
|
|
project_root = Path(__file__).parent.resolve()
|
|
os.chdir(project_root)
|
|
print(f"📁 Working directory: {os.getcwd()}")
|
|
|
|
# Add to Python path
|
|
sys.path.insert(0, str(project_root))
|
|
print(f"🔗 Python path includes: {project_root}")
|
|
|
|
print("\n1. Testing basic imports...")
|
|
try:
|
|
import flask
|
|
print(f" ✅ Flask: {flask.__version__}")
|
|
except ImportError as e:
|
|
print(f" ❌ Flask missing: {e}")
|
|
return False
|
|
|
|
try:
|
|
from src.config_manager import ConfigManager
|
|
print(" ✅ ConfigManager imported")
|
|
except Exception as e:
|
|
print(f" ❌ ConfigManager failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n2. Testing web interface imports...")
|
|
try:
|
|
from web_interface.app import app
|
|
print(" ✅ web_interface.app imported")
|
|
print(f" 📋 App object: {app}")
|
|
except Exception as e:
|
|
print(f" ❌ web_interface.app failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n3. Checking config...")
|
|
try:
|
|
config_manager = ConfigManager()
|
|
config = config_manager.load_config()
|
|
print(" ✅ Config loaded")
|
|
|
|
autostart = config.get('web_display_autostart', False)
|
|
print(f" 🔧 web_display_autostart: {autostart}")
|
|
except Exception as e:
|
|
print(f" ❌ Config check failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
print("\n4. Testing Flask startup...")
|
|
try:
|
|
print(" 🚀 Starting Flask app...")
|
|
print(" 📍 Will run on: http://0.0.0.0:5000")
|
|
print(" ⏹️ Press Ctrl+C to stop")
|
|
|
|
# Run the app (debug mode controlled by env var to satisfy security scanners)
|
|
_debug = os.environ.get('LEDMATRIX_FLASK_DEBUG', '0') == '1'
|
|
app.run(host='0.0.0.0', port=5000, debug=_debug)
|
|
|
|
except KeyboardInterrupt:
|
|
print("\n ⏹️ Server stopped by user")
|
|
return True
|
|
except Exception as e:
|
|
print(f" ❌ Flask startup failed: {e}")
|
|
traceback.print_exc()
|
|
return False
|
|
|
|
if __name__ == "__main__":
|
|
try:
|
|
success = main()
|
|
if success:
|
|
print("\n✅ Debug completed successfully")
|
|
else:
|
|
print("\n❌ Debug found issues - check output above")
|
|
except Exception as e:
|
|
print(f"\n💥 Debug script crashed: {e}")
|
|
traceback.print_exc()
|