diff options
| author | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-05 22:31:20 +0000 | 
|---|---|---|
| committer | Tomasz Kramkowski <tk@the-tk.com> | 2018-03-05 22:31:20 +0000 | 
| commit | 7fb0f2383264e8ae2f942613e7496072d0cefb8c (patch) | |
| tree | 5bc22a0c35f470fe5adbd039c0d412b9ad81c568 | |
| parent | 4c5be848f6562cb1b504a40c28434c87d91b65c5 (diff) | |
| download | dmarcpipe-7fb0f2383264e8ae2f942613e7496072d0cefb8c.tar.gz dmarcpipe-7fb0f2383264e8ae2f942613e7496072d0cefb8c.tar.xz dmarcpipe-7fb0f2383264e8ae2f942613e7496072d0cefb8c.zip  | |
Code cleanup
Some small code cleanup changes
| -rwxr-xr-x | dmarcpipe.py | 13 | 
1 files 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)  | 
