Skip to content

Commit

Permalink
add debugging prints
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyaGomaa committed Sep 25, 2023
1 parent 90fb511 commit dd83f42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions comparisons/flow_by_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ def get_labels_lists(self, tool: str) -> Tuple[List, List]:
parses the labels from the db and returns actual and predicted labels list for the given tool
:return: a tuple with 2 lists, first is actual, second is predicted labels
"""
print(f"@@@@@@@@@@@@@@@@ get_labels_lists is called for tool {tool}")
actual = []
predicted = []

Expand All @@ -24,6 +25,8 @@ def get_labels_lists(self, tool: str) -> Tuple[List, List]:
# (aid, gt_label, tool_label)
ground_truth_label, tool_label = flow
actual.append(ground_truth_label)
if tool_label == 'malicious':
print(f"@@@@@@@@@@@@@@@@ {self.name} found 1 predicted malicious flow by {tool}")
predicted.append(tool_label)

return actual, predicted
2 changes: 2 additions & 0 deletions database/sqlite_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,13 @@ def get_labels_flow_by_flow(self, by='all'):
returns all ground truth and the given tools' labels from the labels_flow_by_flow table
:param by: do we want the labels for all tools? slips only? or suricata only?
"""
print(f"@@@@@@@@@@@@@@@@ get_labels_flow_by_flow for tool {by}")

if by == 'all':
cols = '*'
else:
label_col = self.labels_map[by]
print(f"@@@@@@@@@@@@@@@@ col name for this tool is {label_col}")
cols = f'ground_truth_label, {label_col}'

return self.select('labels_flow_by_flow', cols)
Expand Down
6 changes: 5 additions & 1 deletion parsers/suricata.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,16 @@ def parse(self):

if self.db.store_flow(flow, 'suricata'):
if 'malicious' in label.lower():
print(f"@@@@@@@@@@@@@@@@ found 1 NON DISCARDED flow with malicious label in suricata! ")

self.malicious_labels += 1
if not self.label_malicious_tw(timestamp, line['src_ip']):
self.warn_about_discarded_alert(timestamp)
else:
self.benign_labels += 1

else:
if 'malicious' in label.lower():
print(f"@@@@@@@@@@@@@@@@ found 1 discarded flow with malcious label in suricata! ")

self.db.store_suricata_flow(flow)
# used for printing the stats in the main.py
Expand Down

0 comments on commit dd83f42

Please sign in to comment.