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