mirror of https://github.com/MISP/mail_to_misp
fix: Allow passing 0 to distribution, threat_level and analysis
parent
145930d55d
commit
757f2cb4bf
|
@ -149,11 +149,11 @@ class Mail2MISP():
|
|||
html.unescape(self.original_mail.get_body(preferencelist=('html', 'plain')).get_payload(decode=True).decode('utf8', 'surrogateescape')), flags=re.MULTILINE)
|
||||
# Check if autopublish key is present and valid
|
||||
if self.config_from_email_body.get('m2mkey') == self.config.m2m_key:
|
||||
if self.config_from_email_body.get('distribution'):
|
||||
if self.config_from_email_body.get('distribution') is not None:
|
||||
self.misp_event.distribution = self.config_from_email_body.get('distribution')
|
||||
if self.config_from_email_body.get('threat_level'):
|
||||
if self.config_from_email_body.get('threat_level') is not None:
|
||||
self.misp_event.threat_level_id = self.config_from_email_body.get('threat_level')
|
||||
if self.config_from_email_body.get('analysis'):
|
||||
if self.config_from_email_body.get('analysis') is not None:
|
||||
self.misp_event.analysis = self.config_from_email_body.get('analysis')
|
||||
if self.config_from_email_body.get('publish'):
|
||||
self.misp_event.publish()
|
||||
|
|
|
@ -69,6 +69,17 @@ class TestMailToMISP(unittest.TestCase):
|
|||
self.mail2misp.load_email(BytesIO(f.read()))
|
||||
self.mail2misp.process_email_body()
|
||||
|
||||
def test_meta_event(self):
|
||||
config = importlib.import_module('tests.config_forward')
|
||||
self.mail2misp = Mail2MISP('', '', '', config=config, offline=True)
|
||||
with open('tests/mails/test_meta.eml', 'rb') as f:
|
||||
self.mail2misp.load_email(BytesIO(f.read()))
|
||||
self.mail2misp.process_email_body()
|
||||
self.mail2misp.process_body_iocs()
|
||||
self.assertTrue(self.mail2misp.misp_event.publish)
|
||||
self.assertEqual(self.mail2misp.misp_event.distribution, 3)
|
||||
self.assertEqual(self.mail2misp.misp_event.threat_level_id, 2)
|
||||
self.assertEqual(self.mail2misp.misp_event.analysis, 0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue