]> git.rmz.io Git - dotfiles.git/blob - mutt/dmarc.xsl
nvim: use ruff for python lsp
[dotfiles.git] / mutt / dmarc.xsl
1 <xsl:stylesheet version="1.0"
2 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:date="http://exslt.org/dates-and-times"
4 xmlns="http://www.w3.org/1999/xhtml">
5 <xsl:output
6 omit-xml-declaration = "yes"
7 doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
8 doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" />
9 <xsl:param name="source_ip_href">
10 <!-- customize this -->
11 <!-- <xsl:text>http://www.tana.it/lookup.php?host=</xsl:text> -->
12 <!-- <xsl:text>http://network-tools.com/default.asp?prog=lookup&#38;amp;host=</xsl:text> -->
13 <!-- <xsl:text>https://dnschecker.org/ip-whois-lookup.php?query=</xsl:text> -->
14 <xsl:text>https://ipalyzer.com/</xsl:text>
15 <!-- alternative examples:
16 <xsl:text>http://www.ip-adress.com/reverse_ip/</xsl:text>
17 -->
18 </xsl:param>
19 <xsl:template match="feedback">
20 <html xmlns="http://www.w3.org/1999/xhtml">
21 <xsl:variable name="title">
22 Feedback from
23 <xsl:value-of select="report_metadata/org_name"/>
24 </xsl:variable>
25 <head>
26 <title>
27 <xsl:value-of select="$title"/>
28 </title>
29 <style type="text/css" id="internal-style">
30 body {
31 font-family: Arial, Helvetica, sans-serif;
32 color: #003300;
33 background-color: #ffcc66;
34 }
35 table, p {
36 margin: 1em;
37 padding: 4pt;
38 background-color: #ffeeaa;
39 border: 3pt solid #776633;
40 }
41 table.report_metadata th {
42 text-align: right;
43 }
44 td, th {
45 margin: 2pt;
46 padding: 2pt;
47 border: 1pt solid #776633;
48 }
49 .pass {
50 background-color: #11bb00;
51 }
52 .fail {
53 background-color: #cc0000;
54 }
55 .dkimpolicy {
56 background-color: #ffff66;
57 }
58 .error {
59 background-color: #bbaaaa;
60 font-weight: bold;
61 }
62 .softfail {
63 background-color: #ff8866;
64 }
65 .reject {
66 background-color: #cc0000;
67 }
68 .quarantine {
69 background-color: #ff8866;
70 }
71 .normal {
72 }
73 .field {
74 font-weight: bold;
75 }
76 </style>
77 </head>
78 <body>
79 <h1>
80 <xsl:value-of select="$title"/>
81 </h1>
82 <p>
83 <table>
84 <xsl:apply-templates select="report_metadata"/>
85 <xsl:apply-templates select="policy_published"/>
86 </table>
87 </p>
88 <table>
89 <tr>
90 <th>
91 Relaying IP
92 </th>
93 <th>
94 msg count
95 </th>
96 <th>
97 reason/dispo
98 </th>
99 <th>
100 From: hdr
101 </th>
102 <th>
103 SPF
104 </th>
105 <xsl:variable name="signatures">
106 <xsl:for-each select="record/auth_results">
107 <xsl:sort select="count(dkim)"
108 data-type="number" order="descending"/>
109 <xsl:if test="position()=1">
110 <xsl:value-of select="count(dkim)"/>
111 </xsl:if>
112 </xsl:for-each>
113 </xsl:variable>
114 <xsl:if test="$signatures > 0">
115 <th>
116 DKIM
117 </th>
118 <xsl:if test="$signatures > 1">
119 <th>
120 2nd DKIM
121 </th>
122 <xsl:if test="$signatures > 2">
123 <th>
124 3rd DKIM
125 </th>
126 </xsl:if>
127 </xsl:if>
128 </xsl:if>
129 </tr>
130 <xsl:text>
131 </xsl:text>
132 <xsl:apply-templates select="record"/>
133 </table>
134 <p>
135 <b><u>Legend</u><br/>
136 disposition: </b>
137 <span class="quarantine">quarantine</span>,
138 <span class="reject">reject</span>.<br/>
139 <b>spf: </b>
140 <span class="pass">pass</span>,
141 <span class="fail">fail</span>,
142 <span class="softfail">softfail</span>,
143 <span class="error">temperror or permerror</span>.<br/>
144 <b>dkim: </b>
145 <span class="pass">pass</span>,
146 <span class="fail">fail</span>,
147 <span class="dkimpolicy">policy</span>.
148 </p>
149 </body>
150 </html>
151 </xsl:template>
152 <xsl:template match="policy_published">
153 <tr>
154 <th align="right">
155 <span class="field">Domain: </span>
156 </th>
157 <td>
158 <xsl:value-of select="domain"/>
159 </td>
160 </tr>
161 <tr>
162 <th align="right">
163 <span class="field">DKIM: </span>
164 </th>
165 <td>
166 <xsl:apply-templates select="adkim"/>
167 </td>
168 </tr>
169 <tr>
170 <th align="right">
171 <span class="field">SPF: </span>
172 </th>
173 <td>
174 <xsl:apply-templates select="aspf"/>
175 </td>
176 </tr>
177 <tr>
178 <th align="right">
179 <span class="field">policy published: </span>
180 </th>
181 <td>
182 <xsl:value-of select="p"/>
183 <xsl:text> </xsl:text>
184 <xsl:value-of select="sp"/>
185 <xsl:text> </xsl:text>
186 <xsl:value-of select="pct"/>
187 </td>
188 </tr>
189 </xsl:template>
190 <xsl:template match="adkim|aspf">
191 <xsl:variable name="alignment">
192 <xsl:value-of select="."/>
193 </xsl:variable>
194 <xsl:choose>
195 <xsl:when test="$alignment='r'">
196 <xsl:text>relaxed</xsl:text>
197 </xsl:when>
198 <xsl:when test="$alignment='s'">
199 <xsl:text>strict</xsl:text>
200 </xsl:when>
201 <xsl:otherwise>
202 <xsl:text>{$alignment}</xsl:text>
203 </xsl:otherwise>
204 </xsl:choose>
205 </xsl:template>
206 <xsl:template match="report_metadata">
207 <tr>
208 <th align="right">Id:</th>
209 <td>
210 <xsl:value-of select="report_id"/>
211 </td>
212 </tr>
213 <tr>
214 <th align="right">begin:</th>
215 <td>
216 <xsl:call-template name="date-range">
217 <xsl:with-param name="utime" select="date_range/begin"/>
218 </xsl:call-template>
219 </td>
220 </tr>
221 <tr>
222 <th align="right">end:</th>
223 <td>
224 <xsl:call-template name="date-range">
225 <xsl:with-param name="utime" select="date_range/end"/>
226 </xsl:call-template>
227 </td>
228 </tr>
229 <xsl:for-each select="error">
230 <xsl:if test="position()=1">
231 <br/>
232 <span class="field">Error: </span>
233 </xsl:if>
234 <span class="error">
235 <xsl:value-of select="."/>
236 </span>
237 <xsl:if test="not(position()=last())">
238 <br/>
239 </xsl:if>
240 </xsl:for-each>
241 </xsl:template>
242 <xsl:template name="date-range">
243 <xsl:param name="utime" select="0"/>
244 <xsl:choose>
245 <xsl:when test="function-available('date:add')">
246 <xsl:value-of
247 select="date:add('1970-01-01T00:00:00', date:duration($utime))"/>
248 </xsl:when>
249 <xsl:otherwise>
250 <xsl:value-of select="$utime"/>
251 </xsl:otherwise>
252 </xsl:choose>
253 </xsl:template>
254 <xsl:template match="record">
255 <tr>
256 <xsl:apply-templates select="row"/>
257 <xsl:apply-templates select="identifiers|identities"/>
258 <xsl:apply-templates select="auth_results"/>
259 </tr>
260 <xsl:text>
261 </xsl:text>
262 </xsl:template>
263 <xsl:template match="row">
264 <td>
265 <a>
266 <xsl:attribute name="href">
267 <xsl:value-of select="$source_ip_href"/>
268 <xsl:value-of select="source_ip"/>
269 </xsl:attribute>
270 <xsl:value-of select="source_ip"/>
271 </a>
272 </td>
273 <td align="right">
274 <xsl:value-of select="count"/>
275 </td>
276 <td>
277 <xsl:attribute name="class">
278 <xsl:variable name="disposition">
279 <xsl:value-of select="policy_evaluated/disposition"/>
280 </xsl:variable>
281 <xsl:choose>
282 <xsl:when test="$disposition='reject'">
283 <xsl:text>reject</xsl:text>
284 </xsl:when>
285 <xsl:when test="$disposition='quarantine'">
286 <xsl:text>quarantine</xsl:text>
287 </xsl:when>
288 <xsl:otherwise>
289 <xsl:text>normal</xsl:text>
290 </xsl:otherwise>
291 </xsl:choose>
292 </xsl:attribute>
293 <xsl:value-of select="policy_evaluated/disposition"/> <br />
294 dkim: <xsl:value-of select="policy_evaluated/dkim"/> <br />
295 spf : <xsl:value-of select="policy_evaluated/spf"/> <br />
296
297 <xsl:for-each select="policy_evaluated/reason">
298 <xsl:value-of select="type"/>
299 <xsl:text> </xsl:text>
300 <xsl:value-of select="comment"/>
301 <br/>
302 </xsl:for-each>
303 </td>
304 </xsl:template>
305 <xsl:template match="identifiers|identities">
306 <td>
307 <xsl:value-of select="header_from"/>
308 <xsl:if test="count(envelope_to) &gt; 0">
309 <br/>
310 <xsl:value-of select="envelope_to"/>
311 </xsl:if>
312 </td>
313 </xsl:template>
314 <xsl:template match="auth_results">
315 <xsl:apply-templates select="spf"/><!-- one -->
316 <xsl:apply-templates select="dkim"/><!-- zero or more -->
317 </xsl:template>
318 <xsl:template name="class_attribute">
319 <xsl:attribute name="class">
320 <xsl:variable name="result">
321 <xsl:value-of select="result"/>
322 </xsl:variable>
323 <xsl:choose>
324 <xsl:when test="$result='pass'">
325 <xsl:text>pass</xsl:text>
326 </xsl:when>
327 <xsl:when test="$result='fail' or $result='hardfail'">
328 <xsl:text>fail</xsl:text>
329 </xsl:when>
330 <xsl:when test="$result='temperror' or $result='permerror'">
331 <xsl:text>error</xsl:text>
332 </xsl:when>
333 <xsl:when test="$result='policy'">
334 <xsl:text>dkimpolicy</xsl:text>
335 </xsl:when>
336 <xsl:when test="$result='softfail'">
337 <xsl:text>softfail</xsl:text>
338 </xsl:when>
339 <xsl:otherwise>
340 <xsl:text>normal</xsl:text>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:attribute>
344 </xsl:template>
345 <xsl:template match="spf">
346 <td>
347 <xsl:call-template name="class_attribute" />
348 <xsl:value-of select="result"/>
349 <br/>
350 <xsl:value-of select="domain"/>
351 <br/>
352 <xsl:value-of select="scope"/>
353 <br/>
354 <xsl:value-of select="human_result"/>
355 </td>
356 </xsl:template>
357 <xsl:template match="dkim">
358 <td>
359 <xsl:call-template name="class_attribute" />
360 <xsl:value-of select="result"/>
361 <br/>
362 <xsl:value-of select="domain"/>
363 <br/>
364 <xsl:value-of select="selector"/>
365 <br/>
366 <xsl:value-of select="human_result"/>
367 </td>
368 </xsl:template>
369 </xsl:stylesheet>
370