1package dmarcrpt
2
3import (
4 "encoding/xml"
5)
6
7// Initially generated by xsdgen, then modified.
8
9// Feedback is the top-level XML field returned.
10type Feedback struct {
11 XMLName xml.Name `xml:"feedback" json:"-"` // todo: removing the json tag triggers bug in sherpadoc, should fix.
12 Version string `xml:"version"`
13 ReportMetadata ReportMetadata `xml:"report_metadata"`
14 PolicyPublished PolicyPublished `xml:"policy_published"`
15 Records []ReportRecord `xml:"record"`
16}
17
18type ReportMetadata struct {
19 OrgName string `xml:"org_name"`
20 Email string `xml:"email"`
21 ExtraContactInfo string `xml:"extra_contact_info,omitempty"`
22 ReportID string `xml:"report_id"`
23 DateRange DateRange `xml:"date_range"`
24 Errors []string `xml:"error,omitempty"`
25}
26
27type DateRange struct {
28 Begin int64 `xml:"begin"`
29 End int64 `xml:"end"`
30}
31
32// PolicyPublished is the policy as found in DNS for the domain.
33type PolicyPublished struct {
34 // Domain is where DMARC record was found, not necessarily message From. Reports we
35 // generate use unicode names, incoming reports may have either ASCII-only or
36 // Unicode domains.
37 Domain string `xml:"domain"`
38 ADKIM Alignment `xml:"adkim,omitempty"`
39 ASPF Alignment `xml:"aspf,omitempty"`
40 Policy Disposition `xml:"p"`
41 SubdomainPolicy Disposition `xml:"sp"`
42 Percentage int `xml:"pct"`
43 ReportingOptions string `xml:"fo"`
44}
45
46// Alignment is the identifier alignment.
47type Alignment string
48
49const (
50 AlignmentAbsent Alignment = ""
51
52 AlignmentRelaxed Alignment = "r" // Subdomains match the DMARC from-domain.
53 AlignmentStrict Alignment = "s" // Only exact from-domain match.
54)
55
56// Disposition is the requested action for a DMARC fail as specified in the
57// DMARC policy in DNS.
58type Disposition string
59
60const (
61 DispositionAbsent Disposition = ""
62
63 DispositionNone Disposition = "none"
64 DispositionQuarantine Disposition = "quarantine"
65 DispositionReject Disposition = "reject"
66)
67
68type ReportRecord struct {
69 Row Row `xml:"row"`
70 Identifiers Identifiers `xml:"identifiers"`
71 AuthResults AuthResults `xml:"auth_results"`
72}
73
74type Row struct {
75 // SourceIP must match the pattern ((1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5]).){3}
76 // (1?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])|
77 // ([A-Fa-f0-9]{1,4}:){7}[A-Fa-f0-9]{1,4}
78 SourceIP string `xml:"source_ip"`
79 Count int `xml:"count"`
80 PolicyEvaluated PolicyEvaluated `xml:"policy_evaluated"`
81}
82
83type PolicyEvaluated struct {
84 Disposition Disposition `xml:"disposition"`
85 DKIM DMARCResult `xml:"dkim"`
86 SPF DMARCResult `xml:"spf"`
87 Reasons []PolicyOverrideReason `xml:"reason,omitempty"`
88}
89
90// DMARCResult is the final validation and alignment verdict for SPF and DKIM.
91type DMARCResult string
92
93const (
94 DMARCAbsent DMARCResult = ""
95
96 DMARCPass DMARCResult = "pass"
97 DMARCFail DMARCResult = "fail"
98)
99
100type PolicyOverrideReason struct {
101 Type PolicyOverride `xml:"type"`
102 Comment string `xml:"comment,omitempty"`
103}
104
105// PolicyOverride is a reason the requested DMARC policy from the DNS record
106// was not applied.
107type PolicyOverride string
108
109const (
110 PolicyOverrideAbsent PolicyOverride = ""
111
112 PolicyOverrideForwarded PolicyOverride = "forwarded"
113 PolicyOverrideSampledOut PolicyOverride = "sampled_out"
114 PolicyOverrideTrustedForwarder PolicyOverride = "trusted_forwarder"
115 PolicyOverrideMailingList PolicyOverride = "mailing_list"
116 PolicyOverrideLocalPolicy PolicyOverride = "local_policy"
117 PolicyOverrideOther PolicyOverride = "other"
118)
119
120type Identifiers struct {
121 EnvelopeTo string `xml:"envelope_to,omitempty"`
122 EnvelopeFrom string `xml:"envelope_from"`
123 HeaderFrom string `xml:"header_from"`
124}
125
126type AuthResults struct {
127 DKIM []DKIMAuthResult `xml:"dkim,omitempty"`
128 SPF []SPFAuthResult `xml:"spf"`
129}
130
131type DKIMAuthResult struct {
132 Domain string `xml:"domain"`
133 Selector string `xml:"selector,omitempty"`
134 Result DKIMResult `xml:"result"`
135 HumanResult string `xml:"human_result,omitempty"`
136}
137
138type DKIMResult string
139
140const (
141 DKIMAbsent DKIMResult = ""
142
143 DKIMNone DKIMResult = "none"
144 DKIMPass DKIMResult = "pass"
145 DKIMFail DKIMResult = "fail"
146 DKIMPolicy DKIMResult = "policy"
147 DKIMNeutral DKIMResult = "neutral"
148 DKIMTemperror DKIMResult = "temperror"
149 DKIMPermerror DKIMResult = "permerror"
150)
151
152type SPFAuthResult struct {
153 Domain string `xml:"domain"`
154 Scope SPFDomainScope `xml:"scope"`
155 Result SPFResult `xml:"result"`
156}
157
158type SPFDomainScope string
159
160const (
161 SPFDomainScopeAbsent SPFDomainScope = ""
162
163 SPFDomainScopeHelo SPFDomainScope = "helo" // SMTP EHLO
164 SPFDomainScopeMailFrom SPFDomainScope = "mfrom" // SMTP "MAIL FROM".
165)
166
167type SPFResult string
168
169const (
170 SPFAbsent SPFResult = ""
171
172 SPFNone SPFResult = "none"
173 SPFNeutral SPFResult = "neutral"
174 SPFPass SPFResult = "pass"
175 SPFFail SPFResult = "fail"
176 SPFSoftfail SPFResult = "softfail"
177 SPFTemperror SPFResult = "temperror"
178 SPFPermerror SPFResult = "permerror"
179)
180