From 3d41104d5b7c4916f92d09229959757a267de88d Mon Sep 17 00:00:00 2001 From: chrisr3d Date: Thu, 25 Jul 2019 17:47:08 +0200 Subject: [PATCH] fix: Avoid adding file object twice if a KeyError exception comes for some unexpected reasons --- misp_modules/lib/joe_parser.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/misp_modules/lib/joe_parser.py b/misp_modules/lib/joe_parser.py index 1da9abd..f773c5d 100644 --- a/misp_modules/lib/joe_parser.py +++ b/misp_modules/lib/joe_parser.py @@ -217,10 +217,11 @@ class JoeParser(): for field, mapping in file_object_mapping.items(): attribute_type, object_relation = mapping file_object.add_attribute(object_relation, **{'type': attribute_type, 'value': fileinfo[field]}) - try: - to_call = arch_type_mapping[self.data['generalinfo']['arch']] + arch = self.data['generalinfo']['arch'] + if arch in arch_type_mapping: + to_call = arch_type_mapping[arch] getattr(self, to_call)(fileinfo, file_object) - except KeyError: + else: self.misp_event.add_object(**file_object) def parse_apk(self, fileinfo, file_object):