try/except on pymisp loading stix failing

pull/82/head
haraksin 2020-06-16 01:12:23 -07:00
parent e020452a3d
commit 67d08c443f
1 changed files with 8 additions and 2 deletions

View File

@ -114,7 +114,11 @@ def post_stix(manager, content_block, collection_ids, service_id):
if isinstance(block, bytes): if isinstance(block, bytes):
block = block.decode() block = block.decode()
try:
package = pymisp.tools.stix.load_stix(StringIO(block)) package = pymisp.tools.stix.load_stix(StringIO(block))
except:
log.error('Could not load stix into MISP format; exiting.')
return 0
log.info("STIX loaded succesfully.") log.info("STIX loaded succesfully.")
values = [x.value for x in package.attributes] values = [x.value for x in package.attributes]
log.info("Extracted %s", values) log.info("Extracted %s", values)
@ -130,6 +134,8 @@ def post_stix(manager, content_block, collection_ids, service_id):
search = '' search = ''
if MISP: if MISP:
search = MISP.search("attributes", values=str(attrib)) search = MISP.search("attributes", values=str(attrib))
else:
return 0
if 'response' in search: if 'response' in search:
if search["response"]["Attribute"] != []: if search["response"]["Attribute"] != []:
# This means we have it! # This means we have it!