DmarcRua
is a simple .NET serializer for DMARC aggregate reports. Given
aggregate report XML, DmarcRua
serializes the report into an object and
provides some convenience functions for identifying and exploring DMARC
failures. DmarcRua
supports both v1 and v2 aggregate reports.
- Serialize DMARC aggregate report XML into .NET types and objects.
- Discover reported DMARC failures.
- Summarize or itemize DMARC failures by IP address.
- Summarize or itemize DMARC failures by From header.
Current Version: 2.0.0
Target Framework: netstandard2.0
- None.
AggregateReport
objects can be constructed with a stream of the report XML
or the report can be serialized later.
For example:
using (var stream = File.OpenRead("\path\to\report.xml"))
{
var aggregateReport = new AggregateReport(stream);
}
Or:
var aggregateReport = new AggregateReport();
using (var stream = File.OpenRead("\path\to\report.xml"))
{
aggregateReport.ReadAggregateReport(stream);
}
AggregateReport.GetFailureRecords()
- An enumeration of all report records that failed DMARC.
AggregateReport.GetFailureCount()
- Count of all report records that failed DMARC
AggregateReport.SummarizeFailuresByIpAddress()
- All report records that failed DMARC summarized by IP address.
AggregateReport.SummarizeFailuresByHeaderFrom()
- All report records that failed DMARC summarized by From header.
AggregateReport.GetFailedRecordsByIpAddress(IPAddress ipAddress)
- Itemized DMARC fail report records for a single IP address.
AggregateReport.GetFailedRecordsByFromHeader(string fromHeader)
- Itemized DMARC fail report records for a single From header.
Specifications on the DMARC aggregate report format were taken from https://tools.ietf.org/html/rfc7489#appendix-C the specifications for version 2 come from https://datatracker.ietf.org/doc/draft-ietf-dmarc-aggregate-reporting/.
Issues can be reported on the Issues page of the GitHub repo. If reporting an issue related to a report that won't parse, please attach an anonymized copy of the report.
Remove any references to your domain(s). These will appear in <domain></domain>
and <header_from></header_from>
elements throughout the report. They can be replaced with
any dummy domain, e.g. phony-domain.com.
Remove any references to your IP(s). These will appear in the <source_ip></source_ip>
elements
of the report. They should be replaced with a parseable IPv4 or IPv6 address, e.g. 127.0.0.1. Do not
use localhost
.
Contributions are always welcome.
- Begin by forking and cloning the repository.
- Go to the DmarcRua repository and click the "Fork" button.
- Clone the repository
git clone [email protected]:USERNAME/DmarcRua.git DmarcRua
- Checkout the develop branch
git checkout develop
- Update the develop branch with the latest upstream changes.
git pull upstream develop
- Create a new branch
git checkout -b fix-parse-for-xyz
- Make your changes
- If your changes involve parsing of a report, put an anonymized sample report in the /dev/testing/resources/dmarc/aggregate/ directory and make sure to run the ResourceTests in the DmarcRua.Tests project. Refer to the Anonymizing Reports section above for anonymization details.
- Add and commit your changes
git add . git commit -m "Fixed enum value observed in report from xyz.com"
- Push your local changes to the remote branch.
git push origin fix-parse-for-xyz
- Go to the repo and open a pull request. Please make sure to write a detailed explanation of your changes.
Project tests are in DmarcRua.Tests
. When running the ResourceTests
make sure to set the environment variable
AGGREGATE_REPORTS
to the path of the sample reports.
$ export AGGREGATE_REPORTS=/home/alice/projects/DmarcRua/dev/testing/resources/dmarc/aggregate/ $ dotnet test src/DmarcRua.Tests/DmarcRua.Tests.csproj