mirror of https://github.com/MISP/mail_to_misp
Merge pull request #42 from TheMysteriousX/master
multipart messages can be nested within each otherpull/44/head
commit
7ab2b432df
|
@ -95,7 +95,12 @@ class Mail2MISP():
|
|||
def _find_attached_forward(self):
|
||||
forwarded_emails = []
|
||||
for attachment in self.original_mail.iter_attachments():
|
||||
attachment_content = attachment.get_content()
|
||||
try:
|
||||
attachment_content = attachment.get_content()
|
||||
except KeyError:
|
||||
# Attachment type has no handler
|
||||
continue
|
||||
|
||||
# Search for email forwarded as attachment
|
||||
# I could have more than one, attaching everything.
|
||||
if isinstance(attachment_content, message.EmailMessage):
|
||||
|
|
|
@ -82,6 +82,14 @@ class TestMailToMISP(unittest.TestCase):
|
|||
self.assertEqual(self.mail2misp.misp_event.analysis, '0')
|
||||
self.mail2misp.add_event()
|
||||
|
||||
def test_nested_mime(self):
|
||||
config = importlib.import_module('tests.config_forward')
|
||||
self.mail2misp = Mail2MISP('', '', '', config=config, offline=True)
|
||||
with open('tests/mails/test_nested_mime.eml', 'rb') as f:
|
||||
self.mail2misp.load_email(BytesIO(f.read()))
|
||||
self.mail2misp.process_email_body()
|
||||
self.assertEqual(self.mail2misp.clean_email_body, 'example.org\r\nwww.example.org\r\n')
|
||||
|
||||
def test_attached_emails(self):
|
||||
config = importlib.import_module('tests.config_carrier')
|
||||
self.mail2misp = Mail2MISP('', '', '', config=config, offline=True)
|
||||
|
@ -89,5 +97,6 @@ class TestMailToMISP(unittest.TestCase):
|
|||
attached_emails = self.mail2misp.get_attached_emails(BytesIO(f.read()))
|
||||
self.assertEqual(len(attached_emails), 7)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue