From 951a0f974b5946c0e6c26ddaf7c948b53228c07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Wed, 25 Oct 2017 11:27:59 -0400 Subject: [PATCH] fix: OpenIOC importer --- .../modules/import_mod/openiocimport.py | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/misp_modules/modules/import_mod/openiocimport.py b/misp_modules/modules/import_mod/openiocimport.py index d5e39a0..c237bdc 100755 --- a/misp_modules/modules/import_mod/openiocimport.py +++ b/misp_modules/modules/import_mod/openiocimport.py @@ -4,23 +4,20 @@ import base64 from pymisp.tools import openioc misperrors = {'error': 'Error'} -userConfig = { - 'not save ioc': { - 'type': 'Boolean', - 'message': 'If you check this box, IOC file will not save as an attachment in MISP' - }, - 'default tag': { - 'type': 'String', - 'message': 'Add tags spaced by a comma (tlp:white,misp:threat-level="no-risk")', - 'validation' : '0' - } - } +userConfig = {'not save ioc': {'type': 'Boolean', + 'message': 'If you check this box, IOC file will not save as an attachment in MISP' + }, + 'default tag': { + 'type': 'String', + 'message': 'Add tags spaced by a comma (tlp:white,misp:threat-level="no-risk")', + 'validation': '0'} + } inputSource = ['file'] moduleinfo = {'version': '0.1', 'author': 'Raphaƫl Vinot', - 'description': 'Import OpenIOC package', - 'module-type': ['import']} + 'description': 'Import OpenIOC package', + 'module-type': ['import']} moduleconfig = [] @@ -47,27 +44,23 @@ def handler(q=False): if q.get('config'): if q['config'].get('not save ioc') == "0": - addFile = { - "values": [q.get('filename')], - "types": ['attachment'], - "categories": ['Support Tool'], - "data" : q.get('data'), - } + addFile = {"values": [q.get('filename')], + "types": ['attachment'], + "categories": ['Support Tool'], + "data": q.get('data')} # add tag if q['config'].get('default tag') is not None: addFile["tags"] = q['config']['default tag'].split(",") # add file as attachment r["results"].append(addFile) - # return all attributes for attrib in pkg.attributes: toAppend = { "values": [attrib.value], "types": [attrib.type], "categories": [attrib.category], - "comment":attrib.comment - } + "comment": getattr(attrib, 'comment', '')} # add tag if q.get('config') and q['config'].get('default tag') is not None: toAppend["tags"] = q['config']['default tag'].split(",")