7
7
from ...slips import *
8
8
from pathlib import Path
9
9
import shutil
10
+ import uuid
10
11
11
12
alerts_file = 'alerts.log'
12
13
@@ -17,6 +18,9 @@ def connect_to_redis(redis_port):
17
18
__database__ .connect_to_redis_server (redis_port )
18
19
return __database__
19
20
21
+ def setPrefix (database , _prefix :str ):
22
+ database .setPrefix (_prefix )
23
+ return database
20
24
21
25
def is_evidence_present (log_file , expected_evidence ):
22
26
"""Function to read the log file line by line and returns when it finds the expected evidence"""
@@ -78,18 +82,18 @@ def check_for_text(txt, output_dir):
78
82
return False
79
83
80
84
@pytest .mark .parametrize (
81
- 'pcap_path, expected_profiles, output_dir, redis_port ' ,
85
+ 'pcap_path, expected_profiles, output_dir, prefix ' ,
82
86
[
83
87
(
84
88
'dataset/test7-malicious.pcap' ,
85
89
290 ,
86
90
'test_configuration_file/' ,
87
- 6667 ,
91
+ '2f168df6-c2a9-4a0a-935a-b04fe92e43b7' ,
88
92
)
89
93
],
90
94
)
91
95
def test_conf_file (
92
- pcap_path , expected_profiles , output_dir , redis_port
96
+ pcap_path , expected_profiles , output_dir , prefix
93
97
):
94
98
"""
95
99
In this test we're using tests/test.conf
@@ -101,14 +105,16 @@ def test_conf_file(
101
105
f'-f { pcap_path } ' \
102
106
f'-o { output_dir } ' \
103
107
f'-c tests/integration_tests/test.conf ' \
104
- f'-P { redis_port } ' \
108
+ f'-uid { prefix } ' \
105
109
f'> { output_file } 2>&1'
106
110
# this function returns when slips is done
107
111
os .system (command )
108
112
109
113
assert has_errors (output_dir ) is False
110
114
111
- database = connect_to_redis (redis_port )
115
+ database = connect_to_redis (6379 )
116
+
117
+ database = setPrefix (database , prefix )
112
118
profiles = int (database .getProfilesLen ())
113
119
# expected_profiles is more than 50 because we're using direction = all
114
120
assert profiles > expected_profiles
@@ -146,18 +152,18 @@ def test_conf_file(
146
152
147
153
148
154
@pytest .mark .parametrize (
149
- 'pcap_path, expected_profiles, output_dir, redis_port ' ,
155
+ 'pcap_path, expected_profiles, output_dir, prefix ' ,
150
156
[
151
157
(
152
158
'dataset/test8-malicious.pcap' ,
153
159
1 ,
154
160
'pcap_test_conf2/' ,
155
- 6668 ,
161
+ '5eade174-9e34-431b-86c7-4569e55a723d' ,
156
162
)
157
163
],
158
164
)
159
165
def test_conf_file2 (
160
- pcap_path , expected_profiles , output_dir , redis_port
166
+ pcap_path , expected_profiles , output_dir , prefix
161
167
):
162
168
"""
163
169
In this test we're using tests/test2.conf
@@ -170,15 +176,15 @@ def test_conf_file2(
170
176
f'-f { pcap_path } ' \
171
177
f'-o { output_dir } ' \
172
178
f'-c tests/integration_tests/test2.conf ' \
173
- f'-P { redis_port } ' \
179
+ f'-uid { prefix } ' \
174
180
f'> { output_file } 2>&1'
175
181
# this function returns when slips is done
176
182
os .system (command )
177
183
178
184
assert has_errors (output_dir ) is False
179
185
180
- database = connect_to_redis (redis_port )
181
-
186
+ database = connect_to_redis (6379 )
187
+ database = setPrefix ( database , prefix )
182
188
# test 1 homenet ip
183
189
# the only profile we should have is the one in home_network parameter
184
190
profiles = int (database .getProfilesLen ())
0 commit comments