mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-08-18 08:27:18 +02:00
fix(agent): reject invalid telemetry injection payloads
This commit is contained in:
@@ -121,6 +121,10 @@ def inject_layer_data(
|
||||
if layer not in _INJECTABLE_LAYERS:
|
||||
return {"ok": False, "detail": f"layer '{layer}' not injectable"}
|
||||
|
||||
mode = str(mode or "").strip().lower()
|
||||
if mode not in {"append", "replace"}:
|
||||
return {"ok": False, "detail": "mode must be 'append' or 'replace'"}
|
||||
|
||||
items = list(items or [])[:200]
|
||||
if not items:
|
||||
return {"ok": False, "detail": "no items provided"}
|
||||
@@ -136,6 +140,9 @@ def inject_layer_data(
|
||||
entry["_injected_at"] = now
|
||||
tagged.append(entry)
|
||||
|
||||
if not tagged:
|
||||
return {"ok": False, "detail": "no valid items provided"}
|
||||
|
||||
with _data_lock:
|
||||
current = latest_data.get(layer)
|
||||
existing = list(current) if isinstance(current, list) else []
|
||||
|
||||
@@ -1362,7 +1362,9 @@ def _dispatch_command(cmd: str, args: dict[str, Any]) -> dict[str, Any]:
|
||||
if not layer or not items:
|
||||
return {"ok": False, "detail": "layer and items required"}
|
||||
from services.ai_intel_store import inject_layer_data
|
||||
result = inject_layer_data(layer, items)
|
||||
result = inject_layer_data(layer, items, mode=args.get("mode", "append"))
|
||||
if not result.get("ok"):
|
||||
return result
|
||||
return {"ok": True, "data": result}
|
||||
|
||||
if cmd == "create_layer":
|
||||
|
||||
Reference in New Issue
Block a user