MCPcopy Create free account
hub / github.com/TheSecuredAnalyst/security-suite / SplunkExporter

Class SplunkExporter

modules/siem/splunk.py:11–181  ·  view source on GitHub ↗

Export events to Splunk via HEC.

Source from the content-addressed store, hash-verified

9
10class SplunkExporter(SIEMExporter):
11 """Export events to Splunk via HEC."""
12
13 def __init__(
14 self,
15 hec_url: str,
16 hec_token: str,
17 index: str = "main",
18 source: str = "security-suite",
19 sourcetype: str = "security:scan",
20 verify_ssl: bool = True,
21 timeout: float = 10.0,
22 ):
23 """Initialize Splunk exporter.
24
25 Args:
26 hec_url: Splunk HEC URL (e.g., https://splunk:8088)
27 hec_token: HEC authentication token
28 index: Splunk index to send events to
29 source: Event source identifier
30 sourcetype: Event sourcetype
31 verify_ssl: Whether to verify SSL certificates
32 timeout: Request timeout in seconds
33 """
34 super().__init__()
35 self.hec_url = hec_url.rstrip("/")
36 self.hec_token = hec_token
37 self.index = index
38 self.source = source
39 self.sourcetype = sourcetype
40 self.verify_ssl = verify_ssl
41 self.timeout = timeout
42
43 async def export(self, event: SIEMEvent) -> bool:
44 """Export event to Splunk HEC.
45
46 Args:
47 event: Event to export
48
49 Returns:
50 True if successful
51 """
52 url = f"{self.hec_url}/services/collector/event"
53
54 # Build HEC event payload
55 payload = {
56 "time": event.timestamp.timestamp(),
57 "host": event.target or "security-suite",
58 "source": self.source,
59 "sourcetype": self.sourcetype,
60 "index": self.index,
61 "event": event.to_dict(),
62 }
63
64 headers = {
65 "Authorization": f"Splunk {self.hec_token}",
66 "Content-Type": "application/json",
67 }
68

Callers 1

runFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected