Skip to content

Commit 18672ef

Browse files
committed
web interface: fix displaying profiles
1 parent 651fbf4 commit 18672ef

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

webinterface/analysis/analysis.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,23 @@ def set_profile_tws():
122122
"""
123123
Set profiles and their timewindows into the tree.
124124
Blocked are highligted in red.
125-
:return: (profile, [tw, blocked], blocked)
126125
"""
127-
data = {}
128-
126+
profiles_dict = {}
127+
# Fetch profiles
129128
profiles = db.get_profiles()
130-
blocked_profiles = db.get_malicious_profiles()
131129
for profileid in profiles:
132-
blocked: bool = profileid in blocked_profiles
133-
profile_ip = profileid.split("_")[-1]
134-
data.update({"profile": profile_ip, "blocked": blocked})
130+
profile_word, profile_ip = profileid.split("_")
131+
profiles_dict[profile_ip] = False
132+
133+
if blocked_profiles := db.get_malicious_profiles():
134+
for profile in blocked_profiles:
135+
blocked_ip = profile.split("_")[-1]
136+
profiles_dict[blocked_ip] = True
135137

138+
data = [
139+
{"profile": profile_ip, "blocked": blocked_state}
140+
for profile_ip, blocked_state in profiles_dict.items()
141+
]
136142
return {"data": data}
137143

138144

webinterface/database/database.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ def get_db_manager_obj(self, port: int = False) -> Optional[DBManager]:
5252
output_dir,
5353
port,
5454
start_redis_server=False,
55+
start_sqlite=False,
5556
)
5657
except RuntimeError:
5758
return

webinterface/general/general.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def index():
2222
def set_blocked_profiles_and_tws():
2323
"""
2424
Function to set blocked profiles and tws
25+
blocked here means only blocked through the firewall
2526
"""
2627
blocked_profiles_and_tws = db.get_blocked_profiles_and_timewindows()
2728
data = []

0 commit comments

Comments
 (0)