first tests for the GoAML export module

pull/163/head
chrisr3d 2018-01-31 18:09:45 +01:00
parent 90ca0cc3a9
commit 48869335ee
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
import json
import pymisp
import base64
misperrors = {'error': 'Error'}
moduleinfo = {'version': '1', 'author': 'Christian Studer',
'description': '',
'module-type': ['export']}
moduleconfig = []
mispattributes = {}
objects_to_parse = ['bank-account', 'person']
class GoAmlGeneration():
def __init__(self):
self.document = {}
def from_event(self, event):
self.misp_event = pymisp.MISPEvent()
self.misp_event.load(event)
def parse_objects(self):
for obj in self.misp_event.objects:
if obj.name in objects_to_parse:
obj_dict = {}
for attribute in obj.attributes:
obj_dict[attribute.object_relation] = attribute.value
self.document[obj.name] = obj_dict
def handler(q=False):
if q is False:
return False
request = json.loads(q)
if 'data' not in request:
return False
exp_doc = GoAmlGeneration()
exp_doc.from_event(request['data'][0])
exp_doc.parse_objects()
return {'response': {}, 'data': exp_doc.document}
#return {'response': [], 'data': str(base64.b64encode(bytes(exp_doc.document, 'utf-8')), 'utf-8')}
def introspection():
return
def version():
moduleinfo['config'] = moduleconfig
return moduleinfo