Skip to content

Commit 1a76139

Browse files
committed
web interface: fix erasing the db when connected
1 parent f96cb00 commit 1a76139

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

config/slips.yaml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,13 @@ parameters:
8181
# zeek breaks the connection into smaller connections
8282
tcp_inactivity_timeout : 60
8383

84-
# Should we delete the previously stored data in the DB when we start??
84+
# Should we delete the previously stored data in the DB when we start?
8585
# By default False. Meaning we don't DELETE the DB by default.
8686
deletePrevdb : True
87+
8788
# You can remember the data in all the previous runs of the DB if you put False.
88-
# Redis will remember as long as the redis server is not down. The persistance is
89-
# on the memory, not disk.
89+
# Redis will remember as long as the redis server is not down. The persistence is
90+
# in memory, not disk.
9091
# deletePrevdb : False
9192

9293
# Set the label for all the flows that are being read.

slips_files/common/parsers/config_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ def mac_db_update_period(self):
514514
update_period = 1209600 # 2 weeks
515515
return update_period
516516

517-
def deletePrevdb(self):
517+
def delete_prev_db(self):
518518
return self.read_configuration("parameters", "deletePrevdb", True)
519519

520520
def rotation_period(self):

slips_files/core/database/database_manager.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def __init__(
3838
self.logger, redis_port, start_redis_server, **kwargs
3939
)
4040

41-
# in some rare cases we don't wanna start sqlite,
42-
# like when using -S
43-
# we just want to connect to redis to get the PIDs
41+
# in some rare cases we don't wanna create the sqlite db from scratch,
42+
# like when using -S to stop the daemon, we just wanna connect to
43+
# the existing one
4444
self.sqlite = None
4545
if start_sqlite:
4646
self.sqlite = self.create_sqlite_db(output_dir)

slips_files/core/database/redis_db/database.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def _set_redis_options(cls):
184184
@classmethod
185185
def _read_configuration(cls):
186186
conf = ConfigParser()
187-
cls.deletePrevdb: bool = conf.deletePrevdb()
187+
cls.deletePrevdb: bool = conf.delete_prev_db()
188188
cls.disabled_detections: List[str] = conf.disabled_detections()
189189
cls.width = conf.get_tw_width_as_float()
190190
cls.client_ips: List[str] = conf.client_ips()

slips_files/core/database/sqlite_db/database.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@
1515

1616

1717
class SQLiteDB:
18-
"""Stores all the flows slips reads and handles labeling them"""
18+
"""
19+
Stores all the flows slips reads and handles labeling them
20+
Creates a new db and connects to it if there's none in the given output_dir
21+
"""
1922

2023
name = "SQLiteDB"
2124
# used to lock each call to commit()

webinterface/database/database.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ 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,
55+
start_sqlite=True,
56+
flush_db=False,
5657
)
5758
except RuntimeError:
5859
return

0 commit comments

Comments
 (0)