Skip to content

Commit 9ec25cb

Browse files
author
Ali Razmjoo
authored
Merge pull request #335 from OWASP/development
Development
2 parents 7f60ca9 + 1e03547 commit 9ec25cb

5 files changed

Lines changed: 517 additions & 556 deletions

File tree

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
setuptools==57.4.0
2-
elasticsearch==7.13.4
2+
elasticsearch==7.14.0
33
netaddr==0.8.0
44
flask==2.0.1
55
terminable-thread==0.7.1 # library_name=terminable_thread

tests/test_connector.py

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ def test_push_event_queues_to_db(self):
6262
body=filter_by_fields('13.14.15.16', ['ip_dest'])
6363
)['hits']['hits']
6464

65-
self.assertEqual(len(honeypot_records), 1)
66-
self.assertEqual(len(network_records), 1)
6765
# Find the records in the DB
6866
honeypot_record = honeypot_records[0]['_source']
6967
network_record = network_records[0]['_source']
7068

69+
self.assertGreater(len(honeypot_records), 0)
70+
self.assertGreater(len(network_records), 0)
71+
7172
# Compare the record found in the DB with the one pushed
7273
self.assertEqual(honeypot_record["ip_src"], honeypot_event.ip_src)
7374
self.assertEqual(honeypot_record["ip_dest"], honeypot_event.ip_dest)
@@ -76,13 +77,13 @@ def test_push_event_queues_to_db(self):
7677
self.assertEqual(network_record["ip_dest"], network_event.ip_dest)
7778

7879
# Delete test events from the database
79-
connector.elasticsearch_events.delete_by_query(
80+
connector.elasticsearch_events.delete(
8081
index='honeypot_events',
81-
body=filter_by_fields('11.22.33.44', ['ip_dest'])
82+
id=honeypot_records[0]["_id"]
8283
)
83-
connector.elasticsearch_events.delete_by_query(
84+
connector.elasticsearch_events.delete(
8485
index='network_events',
85-
body=filter_by_fields('13.14.15.16', ['ip_dest'])
86+
id=network_records[0]["_id"]
8687
)
8788

8889
def test_insert_to_credential_events(self):
@@ -106,9 +107,10 @@ def test_insert_to_credential_events(self):
106107
index='credential_events',
107108
body=filter_by_fields('88.99.11.22', ['ip_src'])
108109
)['hits']['hits']
109-
self.assertEqual(len(credential_events), 1)
110110
credential_record = credential_events[0]['_source']
111111

112+
self.assertGreater(len(credential_events), 0)
113+
112114
# Compare the record found in the DB with the one pushed
113115
self.assertEqual(
114116
credential_record["ip_src"],
@@ -126,9 +128,9 @@ def test_insert_to_credential_events(self):
126128
)
127129

128130
# Delete test events from the database
129-
connector.elasticsearch_events.delete_by_query(
131+
connector.elasticsearch_events.delete(
130132
index='credential_events',
131-
body=filter_by_fields('88.99.11.22', ['ip_src'])
133+
id=credential_events[0]["_id"]
132134
)
133135

134136
def test_insert_events_data(self):
@@ -146,23 +148,24 @@ def test_insert_events_data(self):
146148
# wait for insert
147149
time.sleep(1)
148150

149-
records = connector.elasticsearch_events.search(
151+
# Find the records in the DB
152+
event_records = connector.elasticsearch_events.search(
150153
index='data_events',
151154
body=filter_by_fields('55.66.77.88', ['ip_src'])
152155
)['hits']['hits']
153-
# Compare number of records present
154-
self.assertEqual(len(records), 1)
155-
# Find the record in the DB
156-
event_record_data = records[0]['_source']
156+
157+
self.assertGreater(len(event_records), 0)
158+
159+
event_record_data = event_records[0]['_source']
157160
# Compare the record found in the DB with the one pushed
158161
self.assertEqual(event_record_data["ip_src"], event_data.ip_src)
159162
self.assertEqual(
160163
event_record_data["data"],
161164
event_data.data
162165
)
163-
connector.elasticsearch_events.delete_by_query(
166+
connector.elasticsearch_events.delete(
164167
index='data_events',
165-
body=filter_by_fields('55.66.77.88', ['ip_src'])
168+
id=event_records[0]["_id"]
166169
)
167170

168171

web/static/index.html

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@
185185

186186
<script>
187187
const translations = {{ encoded_data | safe}};
188-
const param = new URLSearchParams(window.location.search).get("lang");
189-
const menu = document.getElementById("language-menu")
190-
for (let i = 0; i < menu.length; i++) {
191-
if (menu.options[i].value === param) {
192-
menu.value = param
193-
}
194-
}
195188
</script>
196189
<!-- main.js used as general js file for index.html -->
197190
<script src="/js/main.js"></script>

0 commit comments

Comments
 (0)