This commit is contained in:
Iliyan Angelov
2025-12-01 06:50:10 +02:00
parent 91f51bc6fe
commit 62c1fe5951
4682 changed files with 544807 additions and 31208 deletions

View File

@@ -0,0 +1,28 @@
from typing import TYPE_CHECKING
from safety.events.handlers import EventHandler
from safety.events.types import EventBusReadyEvent
from safety.events.utils import emit_firewall_heartbeat
from safety.tool import ToolInspector
if TYPE_CHECKING:
from safety.events.event_bus import EventBus
class HeartbeatInspectionEventHandler(EventHandler[EventBusReadyEvent]):
"""
Inspect the system for installed tools and send an emit
a firewall heartbeat event.
"""
def __init__(self, event_bus: "EventBus") -> None:
super().__init__()
self.event_bus = event_bus
async def handle(self, event: EventBusReadyEvent):
ctx = event.payload.ctx
inspector = ToolInspector(timeout=1.0)
tools = await inspector.inspect_all_tools()
emit_firewall_heartbeat(self.event_bus, ctx, tools=tools)