DmarcRua
DmarcRua copied to clipboard
More Error Correction for Poorly Formatted Reports
Add more Error Correction for poorly formatted XML Reports... Dropped Min Counts from 1 to 0 and added blank options for basically all enums
Also Visual Studio Reformatted the XSD and I really can't be bothered unformatting it.
But my tests still all pass and I ran it against the last 160 DMARCs in the queue, and they still worked fine.
Can you add some of the poorly formatted reports to the test project please?
@danielsen - I've made a major update and referenced the new spec docs that includes an XSD now. I've added my real world examples to the Unit Tests as well to ensure that we don't have any regression in the future.
I have Implemented the Pending Changes from Pull Request - https://github.com/danielsen/DmarcRua/pull/5 These are minor changes and don't affect anything else, I also added the Reports to the Sample Reports I included
Sorry, Forgot the V1 conversion... Tested - Cleared my last 1000 DMARC reports in Production.
@Biztactix-Ryan - I tested your code with the 10k reports I have in production now. I get 2 different errors . 1 for v1 reports and 1 for v2 reports. It is 2 errors that I got multiple times, but in the overall picture they are not that many.
Besides that my code broke with your new code - I have a stream with where you could not set Position = 0. I changed that to a MemoryStream and then it worked fine. So this will be a breaking change, unless you implement a MemoryStream inside ReadAggregateReport when stream.CanSeek is false. A breaking change would be fine by me and with the support for dmarc-2.0 a bump in version to 2.0 for this project could also make good sense.
@danielsen - Is there anything we can do to help?
The 2 erros I got:
For dmarc v1 Instance validation error: 'unknown' is not a valid value for SpfResultType
<record>
<auth_results>
<spf>
<domain>sub.domain.tld</domain>
<result>unknown</result>
</spf>
For dmarc v2 Instance validation error: 'helo' is not a valid value for SPFDomainScope
<record>
<auth_results>
<spf>
<domain>sub.domain.tld</domain>
<scope>helo</scope>
<result>pass</result>
<spf>
@michaelTBF $DAYJOB has been keeping me busy but I'm planning to tackle this over the next few days.
@Biztactix-Ryan @michaelTBF
Thanks for all the contributions. Sorry this took me so long to get to. The whole repo needed some cleaning and better testing options so in addition to all the other changes I've folded those in as well.
Rather than have separate classes and xsd files for v1 and v2 of aggregate reports, I opted to extend the existing xsd and class to accommodate v2 while still supporting v1. The xsd was already not strictly validating because reports in the real world contained a number of non-standard formats so I don't feel bad about not strictly validating against the v2 spec.
Incidentally, v2 is up for discussion on Feb. 20, 2025 and may become the official standard. https://datatracker.ietf.org/doc/draft-ietf-dmarc-aggregate-reporting/
I bumped the version to 2.0.0 because there are some breaking changes around the naming of some enums. For example AlignmentType.r became AlignmentType.Relaxed.
Thanks Mate, I'm updating to V2 now, I'll see if any bugs pop out... There was only 12 lines of code were needed to change on my end to make V2 work, so barely a breaking change.