-
Notifications
You must be signed in to change notification settings - Fork 0
/
rua.xml.j2
112 lines (101 loc) · 3.21 KB
/
rua.xml.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
{#
<Name>
rua.xml.j2
<Author>
Lukas Puehringer <luk.puehringer@gmail.com>
<Started>
May, 2018
<Copyright>
See LICENSE for licensing information.
<Purpose>
A stand-alone Jinja2 template to generate a DMARC aggregate report (rua)
that is conformant with the schema found in `rua.xsd`.
The following snippet can be used to create a dmarc aggregate report using
this template:
```
from jinja2 import FileSystemLoader, Environment
# Sample report data
from data import sample_report
# Prepare template loader and environment
loader = FileSystemLoader(".")
env = Environment(loader=loader, trim_blocks=True, lstrip_blocks=True)
# Load the template
template = env.get_template("rua.xml.j2")
# Render passed data in the template
template.render(sample_report)
```
#}
<?xml version="1.0" encoding="UTF-8" ?>
<feedback>
<report_metadata>
<org_name>{{report_metadata.org_name}}</org_name>
<email>{{report_metadata.org_email}}</email>
{% if report_metadata.extra_contact_info %}
<extra_contact_info>{{report_metadata.extra_contact_info}}</extra_contact_info>
{% endif %}
<report_id>{{report_metadata.report_id}}</report_id>
<date_range>
<begin>{{report_metadata.date_range.begin}}</begin>
<end>{{report_metadata.date_range.end}}</end>
</date_range>
{% for error in report_metadata.errors %}
<error>{{error}}</error>
{% endfor %}
</report_metadata>
<policy_published>
<domain>{{policy_published.domain}}</domain>
{% if policy_published.adkim %}
<adkim>{{policy_published.adkim}}</adkim>
{% endif %}
{% if policy_published.aspf %}
<aspf>{{policy_published.aspf}}</aspf>
{% endif %}
<p>{{policy_published.p}}</p>
<sp>{{policy_published.sp}}</sp>
<pct>{{policy_published.pct}}</pct>
</policy_published>
{% for record in records %}
<record>
<row>
<source_ip>{{record.row.source_ip}}</source_ip>
<count>{{record.row.count}}</count>
<policy_evaluated>
<disposition>{{record.row.policy_evaluated.disposition}}</disposition>
<dkim>{{record.row.policy_evaluated.dkim}}</dkim>
<spf>{{record.row.policy_evaluated.spf}}</spf>
{% for reason in record.row.policy_evaluated.reasons %}
<reason>
<type>{{reason.type}}</type>
{% if reason.comment %}
<comment>{{reason.comment}}</comment>
{% endif %}
</reason>
{% endfor %}
</policy_evaluated>
</row>
<identifiers>
{% if record.identifiers.envelope_to %}
<envelope_to>{{record.identifiers.envelope_to}}</envelope_to>
{% endif %}
<header_from>{{record.identifiers.header_from}}</header_from>
</identifiers>
<auth_results>
{% for dkim in record.auth_results.dkim %}
<dkim>
<domain>{{dkim.domain}}</domain>
<result>{{dkim.result}}</result>
{% if dkim.human_result %}
<human_result>{{dkim.human_result}}</human_result>
{% endif %}
</dkim>
{% endfor %}
{% for spf in record.auth_results.spf %}
<spf>
<domain>{{spf.domain}}</domain>
<result>{{spf.result}}</result>
</spf>
{% endfor %}
</auth_results>
</record>
{% endfor %}
</feedback>