Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update backend/scanners_core.py
Browse files- backend/scanners_core.py +14 -0
backend/scanners_core.py
CHANGED
|
@@ -839,6 +839,20 @@ def launch_scan(app, scan_id: str) -> bool:
|
|
| 839 |
worker_thread.start()
|
| 840 |
_queue_worker_started = True
|
| 841 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 842 |
_scan_queue.put(scan_id)
|
| 843 |
print(f"[Scanner] Scan {scan_id} placed in execution queue (Current queue size: {_scan_queue.qsize()})", flush=True)
|
| 844 |
return True
|
|
|
|
| 839 |
worker_thread.start()
|
| 840 |
_queue_worker_started = True
|
| 841 |
|
| 842 |
+
# ── Seed logs immediately so the /logs endpoint never returns the static fallback ──
|
| 843 |
+
# This ensures the frontend sees real log entries from the very first poll,
|
| 844 |
+
# even if the queue worker hasn't started executing the scan yet.
|
| 845 |
+
try:
|
| 846 |
+
with app.app_context():
|
| 847 |
+
s = Scan.query.get(scan_id)
|
| 848 |
+
if s:
|
| 849 |
+
add_log(scan_id, "INFO", f"LarShield WSS — {s.scan_type.upper()} SCAN QUEUED")
|
| 850 |
+
add_log(scan_id, "INFO", f"Target: {s.target_url}")
|
| 851 |
+
add_log(scan_id, "INFO", f"Scan ID: {scan_id}")
|
| 852 |
+
add_log(scan_id, "INFO", "Waiting for execution slot in the sequential scan queue...")
|
| 853 |
+
except Exception as _seed_err:
|
| 854 |
+
print(f"[Scanner] Log seed warning (non-fatal): {_seed_err}", flush=True)
|
| 855 |
+
|
| 856 |
_scan_queue.put(scan_id)
|
| 857 |
print(f"[Scanner] Scan {scan_id} placed in execution queue (Current queue size: {_scan_queue.qsize()})", flush=True)
|
| 858 |
return True
|