Analyzes all DMARC reporting .xml files in the current directory and all subdirectories. Prints the result as a formatted Unicode table with ANSI coloring.
The coloring tries to reflect the interpretation. Own IP addresses are printed green, other ones yellow, and the disposition, DKIM and SPF columns are colored red or green depending on whether the code decides the action taken by the server was 'good'. If you don't like this coloring, feel free to adjust the code.
Before running, you need to set up config.yaml
and - if you want to use
IMAP fetching - config.sops.yaml
. The config.sops.yaml
file must be
encrypted with Mozilla SOPS.
The utility fetch.py
allows to fetch DMARC reports from an IMAP account,
and extract.py
allows to batch extract compressed DMARC reports.
config.yaml
can have the following keys:
own_ips
: dictionary mapping an IP address to a dictionary. The inner dictionary can contain fieldsfrom
anduntil
to specify from when until when the address was valid. Omittingfrom
means the IP address has been valid untiluntil
, and omittinguntil
means the IP address is valid fromfrom
on. Omitting both means the IP address is always valid.identify_own_ips_from_dkim_and_spf
: instead of providing an explicit set of IP addresses inown_ips
, you can also setidentify_own_ips_from_dkim_and_spf
totrue
to accept the IP addresses as correct where both DKIM and SPF policies evaluate topass
. Only used byanalysis.py
.imap_server
: the IMAP server address for fetching DMARC reports from. Only used byfetch.py
.imap_folder
: the IMAP folder name for fetching DMARC reports from. Only used byfetch.py
.imap_user
: the IMAP user name for fetching DMARC reports from. Only used byfetch.py
.
config.sops.yaml
can have the following keys:
imap_password
: the IMAP user name for fetching DMARC reports from. Only used byfetch.py
.
After setting up config.yaml
and config.sops.yaml
(optional), you can do the
following:
- (Optional) Run
fetch.py
to fetch DMARC reports from IMAP. The attachments are extracted into the current directory and the mails marked as read. Only unread emails are processed. - Run
extract.py
to extract DMARC reports into the subdirectoryfiles/
. - Run
analysis.py
to print an analysis of the reports. Seeanalysis.py --help
for information on command line options.
The tools are licensed under the MIT license. See LICENSE for details.