Skip to content

Commit 77896dd

Browse files
committed
Added fixes for shuffle tools and email app
1 parent 3d65589 commit 77896dd

File tree

3 files changed

+51
-44
lines changed

3 files changed

+51
-44
lines changed

email/1.2.0/src/app.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def merge(d1, d2):
336336
output_dict["email_uid"] = email_id[0]
337337

338338
if upload_attachments_shuffle:
339-
self.logger.info(f"eml: {parsed_eml}")
339+
self.logger.info("Uploading email ATTACHMENTS to shuffle")
340340
try:
341341
atts_up = [{
342342
"filename": x["filename"],
@@ -348,6 +348,10 @@ def merge(d1, d2):
348348
atts_ids = self.set_files(atts_up)
349349
output_dict["attachments_uids"] = atts_ids
350350

351+
# Don't need this raw.
352+
for x in parsed_eml["attachment"]:
353+
x["raw"] = "Removed and saved in the uploaded file"
354+
351355
except Exception as e:
352356
self.logger.info(f"Major issue with EML attachment - are there attachments: {e}")
353357
else:
@@ -366,7 +370,7 @@ def merge(d1, d2):
366370
"success": True,
367371
"messages": json.loads(json.dumps(emails, default=default)),
368372
}
369-
self.logger.info(f"Emails: {to_return}")
373+
370374
return to_return
371375
except:
372376
return {

shuffle-tools/1.1.0/src/app.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ def parse(data):
238238

239239
# https://github.com/fhightower/ioc-finder
240240
def parse_ioc(self, input_string, input_type="all"):
241+
input_string = str(input_string)
241242
if input_type == "":
242243
input_type = "all"
243244
else:
@@ -1312,13 +1313,6 @@ def merge_lists(self, list_one, list_two, set_field="", sort_key_list_one="", so
13121313
if len(list_one) != len(list_two):
13131314
return {"success": False, "message": "Lists length must be the same. %d vs %d" % (len(list_one), len(list_two))}
13141315

1315-
if len(list_one) > 0:
1316-
if isinstance(list_one[0], int):
1317-
return {
1318-
"success": False,
1319-
"message": "Items in list_one must be valid objects (JSON), not numbers.",
1320-
}
1321-
13221316
if len(sort_key_list_one) > 0:
13231317
self.logger.info("Sort 1 %s by key: %s" % (list_one, sort_key_list_one))
13241318
try:
@@ -1338,20 +1332,28 @@ def merge_lists(self, list_one, list_two, set_field="", sort_key_list_one="", so
13381332
# Loops for each item in sub array and merges items together
13391333
# List one is being overwritten
13401334
base_key = "shuffle_auto_merge"
1341-
for i in range(len(list_one)):
1342-
#self.logger.info(list_two[i])
1343-
if isinstance(list_two[i], dict):
1344-
for key, value in list_two[i].items():
1345-
list_one[i][key] = value
1346-
elif isinstance(list_two[i], str) and list_two[i] == "":
1347-
continue
1348-
elif isinstance(list_two[i], str) or isinstance(list_two[i], int) or isinstance(list_two[i], bool):
1349-
self.logger.info("IN SETTER FOR %s" % list_two[i])
1350-
if len(set_field) == 0:
1351-
self.logger.info("Define a JSON key to set for List two (Set Field)")
1352-
list_one[i][base_key] = list_two[i]
1353-
else:
1354-
list_one[i][set_field] = list_two[i]
1335+
try:
1336+
for i in range(len(list_one)):
1337+
#self.logger.info(list_two[i])
1338+
if isinstance(list_two[i], dict):
1339+
for key, value in list_two[i].items():
1340+
list_one[i][key] = value
1341+
elif isinstance(list_two[i], str) and list_two[i] == "":
1342+
continue
1343+
elif isinstance(list_two[i], str) or isinstance(list_two[i], int) or isinstance(list_two[i], bool):
1344+
self.logger.info("IN SETTER FOR %s" % list_two[i])
1345+
if len(set_field) == 0:
1346+
self.logger.info("Define a JSON key to set for List two (Set Field)")
1347+
list_one[i][base_key] = list_two[i]
1348+
else:
1349+
list_one[i][set_field] = list_two[i]
1350+
except Exception as e:
1351+
return {
1352+
"success": False,
1353+
"reason": "An error occurred while merging the lists. PS: List one can NOT be a list of integers. If this persists, contact us at [email protected]",
1354+
"exception": f"{e}",
1355+
}
1356+
13551357

13561358
return list_one
13571359

shuffle-tools/1.2.0/src/app.py

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ def parse(data):
231231

232232
# https://github.com/fhightower/ioc-finder
233233
def parse_ioc(self, input_string, input_type="all"):
234+
input_string = str(input_string)
234235
if input_type == "":
235236
input_type = "all"
236237
else:
@@ -1371,13 +1372,6 @@ def merge_lists(self, list_one, list_two, set_field="", sort_key_list_one="", so
13711372
if len(list_one) != len(list_two):
13721373
return {"success": False, "message": "Lists length must be the same. %d vs %d" % (len(list_one), len(list_two))}
13731374

1374-
if len(list_one) > 0:
1375-
if isinstance(list_one[0], int):
1376-
return {
1377-
"success": False,
1378-
"message": "Items in list_one must be valid objects (JSON), not numbers.",
1379-
}
1380-
13811375
if len(sort_key_list_one) > 0:
13821376
self.logger.info("Sort 1 %s by key: %s" % (list_one, sort_key_list_one))
13831377
try:
@@ -1397,20 +1391,27 @@ def merge_lists(self, list_one, list_two, set_field="", sort_key_list_one="", so
13971391
# Loops for each item in sub array and merges items together
13981392
# List one is being overwritten
13991393
base_key = "shuffle_auto_merge"
1400-
for i in range(len(list_one)):
1401-
#self.logger.info(list_two[i])
1402-
if isinstance(list_two[i], dict):
1403-
for key, value in list_two[i].items():
1404-
list_one[i][key] = value
1405-
elif isinstance(list_two[i], str) and list_two[i] == "":
1406-
continue
1407-
elif isinstance(list_two[i], str) or isinstance(list_two[i], int) or isinstance(list_two[i], bool):
1408-
self.logger.info("IN SETTER FOR %s" % list_two[i])
1409-
if len(set_field) == 0:
1410-
self.logger.info("Define a JSON key to set for List two (Set Field)")
1411-
list_one[i][base_key] = list_two[i]
1412-
else:
1413-
list_one[i][set_field] = list_two[i]
1394+
try:
1395+
for i in range(len(list_one)):
1396+
#self.logger.info(list_two[i])
1397+
if isinstance(list_two[i], dict):
1398+
for key, value in list_two[i].items():
1399+
list_one[i][key] = value
1400+
elif isinstance(list_two[i], str) and list_two[i] == "":
1401+
continue
1402+
elif isinstance(list_two[i], str) or isinstance(list_two[i], int) or isinstance(list_two[i], bool):
1403+
self.logger.info("IN SETTER FOR %s" % list_two[i])
1404+
if len(set_field) == 0:
1405+
self.logger.info("Define a JSON key to set for List two (Set Field)")
1406+
list_one[i][base_key] = list_two[i]
1407+
else:
1408+
list_one[i][set_field] = list_two[i]
1409+
except Exception as e:
1410+
return {
1411+
"success": False,
1412+
"reason": "An error occurred while merging the lists. PS: List one can NOT be a list of integers. If this persists, contact us at [email protected]",
1413+
"exception": f"{e}",
1414+
}
14141415

14151416
return list_one
14161417

0 commit comments

Comments
 (0)