From 7fb0f2383264e8ae2f942613e7496072d0cefb8c Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Mon, 5 Mar 2018 22:31:20 +0000 Subject: Code cleanup Some small code cleanup changes --- dmarcpipe.py | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/dmarcpipe.py b/dmarcpipe.py index 139694e..bbcc914 100755 --- a/dmarcpipe.py +++ b/dmarcpipe.py @@ -50,13 +50,13 @@ gzip2xml = lambda data: gz_decompress(data) octet_stream = lambda data: decode(data, magic(data).mime_type) decoders = { - 'application/zip': zip2xml, + 'application/gzip': gzip2xml, 'application/x-gzip': gzip2xml, 'application/octet-stream': octet_stream, 'application/x-zip': zip2xml, 'application/x-zip-compressed': zip2xml, + 'application/zip': zip2xml, 'application/zlib': gzip2xml, - 'application/gzip': gzip2xml, 'text/xml': lambda data: data, } @@ -67,10 +67,6 @@ def decode(data, mime): raise FalseReportException('invalid content type: {}'.format(mime)) def process_message(m): - if m.get_content_maintype() != 'multipart' and \ - m.get_content_type() not in decoders.keys(): - raise FalseReportException('invalid content type: {}'.format(m.get_content_type())) - att = None inv_fn = False @@ -86,9 +82,8 @@ def process_message(m): continue att = part break - - if att is None: - raise FalseReportException('attachment not found{}'.format(inv_fn == True and ' (invalid filename)' or '')) + else: + raise FalseReportException('attachment not found{}'.format(inv_fn and ' (invalid filename)' or '')) xml = decode(att.get_payload(decode=True), att.get_content_type()) dmarc = parse_dmarc(xml) -- cgit v1.2.3-54-g00ecf