George Haraksin 2020-06-16 01:13:11 -07:00
commit 8ec9fc18c5
1 changed files with 8 additions and 2 deletions

View File

@ -113,8 +113,12 @@ def post_stix(manager, content_block, collection_ids, service_id):
block = content_block.content block = content_block.content
if isinstance(block, bytes): if isinstance(block, bytes):
block = block.decode() block = block.decode()
package = pymisp.tools.stix.load_stix(StringIO(block)) try:
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!