Skip to content

Commit

Permalink
Merge pull request #439 from stratosphereips/alya/refactor_new_tw_cre…
Browse files Browse the repository at this point in the history
…ation

Refactor the functions responsible for new tw creation
  • Loading branch information
AlyaGomaa authored Jan 23, 2024
2 parents a3b9601 + 5d23911 commit 20a4794
Show file tree
Hide file tree
Showing 6 changed files with 240 additions and 178 deletions.
6 changes: 4 additions & 2 deletions managers/process_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,11 @@ def shutdown_gracefully(self):

else:
flows_count: int = self.main.db.get_flows_count()
self.main.print(f"Total flows read (without altflows): {flows_count}", log_to_logfiles_only=True)
self.main.print(f"Total flows read (without altflows): "
f"{flows_count}", log_to_logfiles_only=True)

hitlist: Tuple[List[Process], List[Process]] = self.get_hitlist_in_order()
hitlist: Tuple[List[Process], List[Process]]
hitlist = self.get_hitlist_in_order()
to_kill_first: List[Process] = hitlist[0]
to_kill_last: List[Process] = hitlist[1]
self.termination_event.set()
Expand Down
2 changes: 1 addition & 1 deletion modules/leak_detector/leak_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def set_evidence_yara_match(self, info: dict):
return

# in which tw is this ts?
twid = self.db.getTWofTime(profileid, ts)
twid = self.db.get_tw_of_ts(profileid, ts)
# convert ts to a readable format
ts = utils.convert_format(ts, utils.alerts_format)
if twid:
Expand Down
2 changes: 1 addition & 1 deletion modules/p2ptrust/utils/go_director.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def set_evidence_p2p_report(self, ip, reporter, score, confidence, timestamp, pr
description = f'attacking another peer: {reporter_ip} ({reporter}). threat level: {threat_level} ' \
f'confidence: {confidence} {ip_identification}'
# get the tw of this report time
if twid := self.db.getTWofTime(profileid_of_attacker, timestamp):
if twid := self.db.get_tw_of_ts(profileid_of_attacker, timestamp):
twid = twid[0]
else:
# create a new twid for the attacker profile that has the
Expand Down
16 changes: 8 additions & 8 deletions slips_files/core/database/database_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,17 +652,17 @@ def get_profiles_len(self, *args, **kwargs):
def get_last_twid_of_profile(self, *args, **kwargs):
return self.rdb.get_last_twid_of_profile(*args, **kwargs)

def getFirstTWforProfile(self, *args, **kwargs):
return self.rdb.getFirstTWforProfile(*args, **kwargs)
def get_first_twid_for_profile(self, *args, **kwargs):
return self.rdb.get_first_twid_for_profile(*args, **kwargs)

def getTWofTime(self, *args, **kwargs):
return self.rdb.getTWofTime(*args, **kwargs)
def get_tw_of_ts(self, *args, **kwargs):
return self.rdb.get_tw_of_ts(*args, **kwargs)

def addNewOlderTW(self, *args, **kwargs):
return self.rdb.addNewOlderTW(*args, **kwargs)
def add_new_older_tw(self, *args, **kwargs):
return self.rdb.add_new_older_tw(*args, **kwargs)

def addNewTW(self, *args, **kwargs):
return self.rdb.addNewTW(*args, **kwargs)
def add_new_tw(self, *args, **kwargs):
return self.rdb.add_new_tw(*args, **kwargs)

def getTimeTW(self, *args, **kwargs):
return self.rdb.getTimeTW(*args, **kwargs)
Expand Down
Loading

0 comments on commit 20a4794

Please sign in to comment.