/
smtp_templates.go
114 lines (101 loc) · 4.76 KB
/
smtp_templates.go
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
113
114
// SPDX-License-Identifier: Apache-2.0
/*
Copyright (C) 2023 The Falco Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package outputs
var plaintextTmpl = `Priority: {{ .Priority }}
Output: {{ .Output }}
Rule: {{ .Rule }}
Source: {{ .Source }}
Hostname: {{ .Hostname }}
Tags: {{ range .Tags }}{{ . }} {{ end }}
Time: {{ .Time }}
--Fields--
{{ range $key, $value := .OutputFields }}{{ $key }}: {{ $value }}
{{ end }}
`
var htmlTmpl = `
{{ $color := "#858585" }}
{{ $prio := printf "%v" .Priority }}
{{ if or (eq $prio "Emergency") (eq $prio "emergency") }}{{ $color = "#e20b0b" }}{{ end }}
{{ if or (eq $prio "Alert") (eq $prio "Alert") }}{{ $color = "#ff5400" }}{{ end }}
{{ if or (eq $prio "Critical") (eq $prio "critical") }}{{ $color = "#ff9000" }}{{ end }}
{{ if or (eq $prio "Error") (eq $prio "error") }}{{ $color = "#ffc700" }}{{ end }}
{{ if or (eq $prio "Warning") (eq $prio "warning") }}{{ $color = "#ffff00" }}{{ end }}
{{ if or (eq $prio "Notice") (eq $prio "notice") }}{{ $color = "#5bffb5" }}{{ end }}
{{ if or (eq $prio "Informational") (eq $prio "informational") }}{{ $color = "#68c2ff" }}{{ end }}
{{ if or (eq $prio "Debug") (eq $prio "debug") }}{{ $color = "#ccfff2" }}{{ end }}
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css">
td{font-family:arial,helvetica,sans-serif;}
</style>
<table cellpadding="3" cellspacing="0" style="font-family:arial,helvetica,sans-serif; height:2px; width:700px;">
<tbody>
<tr>
<td><img src="https://raw.githubusercontent.com/cncf/artwork/master/projects/falco/horizontal/color/falco-horizontal-color.png" width="117px" height="47"></td>
<td></td>
</tr>
</tbody>
</table>
<br>
<table cellpadding="3" cellspacing="0" style="font-family:arial,helvetica,sans-serif; height:2px; width:700px;">
<tbody>
<tr>
<td style="background-color:{{ $color }}; width:700px; text-align:center;"><span style="font-size:12px; color:#fff;"><strong>{{ .Priority }}</strong></span></td>
</tr>
</tbody>
</table>
<table cellpadding="5" cellspacing="0" style="font-family:arial,helvetica,sans-serif; width:700px; font-size:13px">
<tbody>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Output</strong></span></td>
<td style="background-color:#d1d6da">{{ .Output }}</td>
</tr>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Rule</strong></span></td>
<td style="background-color:#d1d6da">{{ .Rule }}</td>
</tr>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Source</strong></span></td>
<td style="background-color:#d1d6da">{{ .Source }}</td>
</tr>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Hostname</strong></span></td>
<td style="background-color:#d1d6da">{{ .Hostname }}</td>
</tr>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Tags</strong></span></td>
<td style="background-color:#d1d6da">{{ range .Tags }}{{ . }} {{ end }}</td>
</tr>
<tr>
<td style="background-color:#858585"><span style="font-size:14px;color:#fff;"><strong>Time</strong></span></td>
<td style="background-color:#d1d6da">{{ .Time }}</td>
</tr>
</tbody>
</table>
<br>
<table cellpadding="3" cellspacing="0" style="font-family:arial,helvetica,sans-serif; height:2px; width:700px; font-size:13px">
<tbody>
<tr>
<td style="background-color: #858585; width:700px; text-align:center;"><span style="font-size:12px; color:#fff;"><strong>Fields</strong></span></td>
</tr>
</tbody>
</table>
<table cellpadding="3" cellspacing="0" style="font-family:arial,helvetica,sans-serif; height:2px; width:700px; font-size:13px">
<tbody>{{ range $key, $value := .OutputFields }}
<tr>
<td width="1" style="background-color:#858585"><span style="font-size:14px; color:#fff;"><strong>{{ $key }}</strong></span></td>
<td style="background-color:#d1d6da">{{ $value }}</td>
</tr>
{{ end }}</tbody>
</table>
--4t74weu9byeSdJTM--`