chg: Modified the mapping dictionary to support misp-objects updates

pull/164/head
chrisr3d 2018-02-22 01:23:08 +01:00
parent 9b34602f73
commit c942013812
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 34 additions and 27 deletions

View File

@ -14,26 +14,33 @@ responseType = "application/xml"
objects_to_parse = ['transaction', 'bank-account', 'person', 'entity', 'geolocation'] objects_to_parse = ['transaction', 'bank-account', 'person', 'entity', 'geolocation']
goAMLmapping = {'bank-account': 't_account', 'institution-code': 'institution_code', 'iban': 'iban', goAMLmapping = {'bank-account': {'bank-account': 't_account', 'institution-name': 'institution_name',
'swift': 'swift', 'branch': 'branch', 'non-banking-institution': 'non_bank_institution', 'institution-code': 'institution_code', 'iban': 'iban', 'swift': 'swift',
'account': 'account', 'currency-code': 'currency_code', 'account-name': 'account_name', 'branch': 'branch', 'non-banking-institution': 'non_bank_institution',
'client-number': 'client_number', 'personal-account-type': 'personal_account_type', 'account': 'account', 'currency-code': 'currency_code',
'opened': 'opened', 'closed': 'closed', 'balance': 'balance', 'status-code': 'status_code', 'account-name': 'account_name', 'client-number': 'client_number',
'beneficiary': 'beneficiary', 'beneficiary-comment': 'beneficiary_comment', 'comments': 'comments', 'personal-account-type': 'personal_account_type', 'opened': 'opened',
'person': 't_person', 'text': 'comments', 'first-name': 'first_name', 'middle-name': 'middle_name', 'closed': 'closed', 'balance': 'balance', 'status-code': 'status_code',
'last-name': 'last_name', 'mothers-name': 'mothers_name', 'title': 'title', 'alias': 'alias', 'beneficiary': 'beneficiary', 'beneficiary-comment': 'beneficiary_comment',
'date-of-birth': 'birthdate', 'place-of-birth': 'birth_place', 'gender': 'gender', 'comments': 'comments'},
'person': {'person': 't_person', 'text': 'comments', 'first-name': 'first_name',
'middle-name': 'middle_name', 'last-name': 'last_name', 'title': 'title',
'mothers-name': 'mothers_name', 'alias': 'alias', 'date-of-birth': 'birthdate',
'place-of-birth': 'birth_place', 'gender': 'gender','nationality': 'nationality1',
'passport-number': 'passport_number', 'passport-country': 'passport_country', 'passport-number': 'passport_number', 'passport-country': 'passport_country',
'social-security-number': 'ssn', 'nationality': 'nationality1', 'identity-card-number': 'id_number', 'social-security-number': 'ssn', 'identity-card-number': 'id_number'},
'geolocation': 'location', 'city': 'city', 'region': 'state', 'country': 'country-code', 'geolocation': {'geolocation': 'location', 'city': 'city', 'region': 'state',
'address': 'address', 'zipcode': 'zip', 'country': 'country-code', 'address': 'address', 'zipcode': 'zip'},
'transaction': 'transaction', 'transaction-number': 'transactionnumber', 'date': 'date_transaction', 'transaction': {'transaction': 'transaction', 'transaction-number': 'transactionnumber',
'location': 'transaction_location', 'transmode-code': 'transmode_code', 'amount': 'amount_local', 'date': 'date_transaction', 'location': 'transaction_location',
'transmode-comment': 'transmode_comment', 'date-posting': 'date_posting', 'teller': 'teller', 'transmode-code': 'transmode_code', 'amount': 'amount_local',
'authorized': 'authorized', 'transmode-comment': 'transmode_comment', 'date-posting': 'date_posting',
'legal-entity': 'entity', 'name': 'name', 'commercial-name': 'commercial_name', 'business': 'business', 'teller': 'teller', 'authorized': 'authorized',
'legal-form': 'incorporation_legal_form', 'registration-number': 'incorporation_number', 'text': 'transaction_description'},
'phone-number': 'phone'} 'legal-enitty': {'legal-entity': 'entity', 'name': 'name', 'business': 'business',
'commercial-name': 'commercial_name', 'phone-number': 'phone',
'legal-form': 'incorporation_legal_form',
'registration-number': 'incorporation_number'}}
referencesMapping = {'bank-account': {'aml_type': '{}_account', 'bracket': 't_{}'}, referencesMapping = {'bank-account': {'aml_type': '{}_account', 'bracket': 't_{}'},
'person': {'transaction': {'aml_type': '{}_person', 'bracket': 't_{}'}, 'bank-account': {'aml_type': 't_person', 'bracket': 'signatory'}}, 'person': {'transaction': {'aml_type': '{}_person', 'bracket': 't_{}'}, 'bank-account': {'aml_type': 't_person', 'bracket': 'signatory'}},
@ -89,7 +96,7 @@ class GoAmlGeneration(object):
obj = self.misp_event.get_object_by_uuid(uuid) obj = self.misp_event.get_object_by_uuid(uuid)
if object_type == 'transaction': if object_type == 'transaction':
self.xml[xml_part] += "<{}>".format(aml_type) self.xml[xml_part] += "<{}>".format(aml_type)
self.fill_xml_transaction(obj.attributes, xml_part) self.fill_xml_transaction(object_type, obj.attributes, xml_part)
self.parsed_uuids[object_type].append(uuid) self.parsed_uuids[object_type].append(uuid)
if obj.ObjectReference: if obj.ObjectReference:
self.parseObjectReferences(object_type, xml_part, obj.ObjectReference) self.parseObjectReferences(object_type, xml_part, obj.ObjectReference)
@ -105,7 +112,7 @@ class GoAmlGeneration(object):
def itterate_normal_case(self, object_type, obj, aml_type, uuid, xml_part): def itterate_normal_case(self, object_type, obj, aml_type, uuid, xml_part):
self.xml[xml_part] += "<{}>".format(aml_type) self.xml[xml_part] += "<{}>".format(aml_type)
self.fill_xml(obj, xml_part) self.fill_xml(object_type, obj, xml_part)
self.parsed_uuids[object_type].append(uuid) self.parsed_uuids[object_type].append(uuid)
if obj.ObjectReference: if obj.ObjectReference:
self.parseObjectReferences(object_type, xml_part, obj.ObjectReference) self.parseObjectReferences(object_type, xml_part, obj.ObjectReference)
@ -118,7 +125,7 @@ class GoAmlGeneration(object):
relationship_type = ref.relationship_type relationship_type = ref.relationship_type
self.parse_references(object_type, next_object_type, next_uuid, relationship_type, xml_part) self.parse_references(object_type, next_object_type, next_uuid, relationship_type, xml_part)
def fill_xml_transaction(self, attributes, xml_part): def fill_xml_transaction(self, object_type, attributes, xml_part):
from_and_to_fields = {'from': {}, 'to': {}} from_and_to_fields = {'from': {}, 'to': {}}
for attribute in attributes: for attribute in attributes:
object_relation = attribute.object_relation object_relation = attribute.object_relation
@ -134,12 +141,12 @@ class GoAmlGeneration(object):
from_and_to_fields[relation_type][field] = attribute_value from_and_to_fields[relation_type][field] = attribute_value
continue continue
try: try:
self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[object_relation], attribute_value) self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[object_type][object_relation], attribute_value)
except KeyError: except KeyError:
pass pass
self.from_and_to_fields = from_and_to_fields self.from_and_to_fields = from_and_to_fields
def fill_xml(self, obj, xml_part): def fill_xml(self, object_type, obj, xml_part):
if obj.name == 'bank-account': if obj.name == 'bank-account':
for attribute in obj.attributes: for attribute in obj.attributes:
if attribute.object_relation in ('personal-account-type', 'status-code'): if attribute.object_relation in ('personal-account-type', 'status-code'):
@ -147,13 +154,13 @@ class GoAmlGeneration(object):
else: else:
attribute_value = attribute.value attribute_value = attribute.value
try: try:
self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[attribute.object_relation], attribute_value) self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[object_type][attribute.object_relation], attribute_value)
except KeyError: except KeyError:
pass pass
else: else:
for attribute in obj.attributes: for attribute in obj.attributes:
try: try:
self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[attribute.object_relation], attribute.value) self.xml[xml_part] += "<{0}>{1}</{0}>".format(goAMLmapping[object_type][attribute.object_relation], attribute.value)
except KeyError: except KeyError:
pass pass