This commit is contained in:
+15
-10
@@ -1364,29 +1364,34 @@ def register_web_routes(app, dependencies):
|
||||
|
||||
@app.get("/api/scan/status")
|
||||
async def api_scan_status():
|
||||
"""Proxy scan status requests to core container"""
|
||||
"""Check scan status by looking at core container logs"""
|
||||
import urllib.request
|
||||
import urllib.error
|
||||
import json
|
||||
import os
|
||||
import socket
|
||||
import time
|
||||
|
||||
# Get core container URL
|
||||
# Get core container URL to check if it's responsive
|
||||
core_host = os.environ.get("CORE_API_HOST", "nfoguard-core")
|
||||
core_port = os.environ.get("CORE_API_PORT", "8080")
|
||||
core_url = f"http://{core_host}:{core_port}/api/scan/status"
|
||||
|
||||
# For now, implement basic status tracking based on recent activity
|
||||
# This is a simple implementation - ideally the core would track this
|
||||
try:
|
||||
# Create request with timeout
|
||||
req = urllib.request.Request(core_url)
|
||||
# Try to reach core container to see if it's active
|
||||
health_url = f"http://{core_host}:{core_port}/health"
|
||||
req = urllib.request.Request(health_url)
|
||||
|
||||
# Make request with timeout
|
||||
with urllib.request.urlopen(req, timeout=10) as response:
|
||||
response_data = response.read().decode('utf-8')
|
||||
return json.loads(response_data)
|
||||
with urllib.request.urlopen(req, timeout=5) as response:
|
||||
# Core is responsive, return basic status
|
||||
# TODO: Core container should implement proper scan status tracking
|
||||
return {
|
||||
"scanning": False,
|
||||
"message": "Scan status tracking not fully implemented - check core container logs"
|
||||
}
|
||||
|
||||
except (urllib.error.URLError, socket.timeout):
|
||||
# If core is unreachable, return default status
|
||||
return {"scanning": False, "message": "Core container unavailable"}
|
||||
except Exception:
|
||||
return {"scanning": False, "message": "Unable to check scan status"}
|
||||
Reference in New Issue
Block a user