tierpod / dmarc-report-converter

Convert dmarc reports from xml to human-readable formats
MIT License
241 stars 25 forks source link

Messages with inline MIME headers are not processed #58

Open moorereason opened 6 months ago

moorereason commented 6 months ago

I've received some emails that use inline MIME headers which are silently ignored.

Sample content:

MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/mixed; boundary="17122880850.dd5Fb0.406180"

--17122880850.dd5Fb0.406180
Date: Thu, 4 Apr 2024 23:34:45 -0400
MIME-Version: 1.0
Content-Type: text/plain; charset="US-ASCII"
Content-Disposition: inline

This is a DMARC aggregate report for example.com

8 records.
8 passed.
0 failed.

Submitted by Pobox by Fastmail Pty Ltd
Generated with Mail::DMARC 1.20240313

--17122880850.dd5Fb0.406180
Date: Thu, 4 Apr 2024 23:34:45 -0400
MIME-Version: 1.0
Content-Type: application/gzip;
 name="pobox.com!example.com!1712188800!1712275199!46972001.xml.gz"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="pobox.com!example.com!1712188800!1712275199!46972001.xml.gz"

PUT/YOUR/BASE64/STUFF/HERE==

--17122880850.dd5Fb0.406180--

At the very least, it would help to log a message:

[WARN] extractAttachment: inline MIME headers are not currently supported, skip

The underlying issue is here: https://github.com/tierpod/dmarc-report-converter/blob/abf80ca2ebc98e0437aaa4253fe7b4f4e0ec716f/cmd/dmarc-report-converter/imap.go#L173-L174

An offending message returns headers of type *mail.InlineHeader. The go-message API for inline vs attachment headers is very different. See https://github.com/emersion/go-message/issues/138 for a discussion about the need for feature parity between the two types, but it doesn't appear that any work has been done.

thx1111 commented 3 months ago

I suppose that this is the same issue:

[INFO] files: found 243 input files in /home/james/Maildir/.dmarc/cur/
[ERROR] files: mimetype text/plain; charset=utf-8 not supported in file /home/james/Maildir/.dmarc/cur/..., skip
...
[ERROR] processFiles: reports list is empty

Since that error includes every single dmarc report received, how is dmarc-report-converter useful? Am I missing something? Do each of the dmarc report files need to be manually extracted before processing?

moorereason commented 3 months ago

@thx1111, I think you're problem is unrelated.