@@ -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
0 commit comments