Skip to content

Commit

Permalink
suricta: add error handling when extracting suricata flows
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Aug 5, 2024
1 parent 5f51dd1 commit 0b21f04
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion parsers/suricata.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def extract_flow(self, line: str) -> dict:
or icmp type and code from icmp flows from the given line
:param line: suricata line as read from the file
"""
if not "flow" in line:
return {}
proto = line['proto'].lower()
flow = {
'timestamp': line['flow']['start'],
Expand Down Expand Up @@ -101,8 +103,14 @@ def parse(self):
# only read benign flows and alert events
continue


flow: dict = self.extract_flow(line)
if not flow:
self.log("",
f"Problem extracting suricata flow "
f"from line: {line} .. Skipping line.",
error=True)
continue

original_ts = flow['timestamp']
timestamp = self.timestamp_handler.convert_iso_8601_to_unix_timestamp(flow['timestamp'])
flow['timestamp'] = timestamp
Expand Down

0 comments on commit 0b21f04

Please sign in to comment.