Debian Codegraph @

lualib/lua_magic/types.lua

raw
1 --[[
2 Copyright (c) 2022, Vsevolod Stakhov <[email protected]>
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 ]] --
16
17 --[[[
18 -- @module lua_magic/patterns
19 -- This module contains types definitions
20 --]]
21
22 -- This table is indexed by msdos extension for convenience
23
24 local types = {
25 -- exe
26 exe = {
27 ct = 'application/x-ms-application',
28 type = 'executable',
29 },
30 elf = {
31 ct = 'application/x-elf-executable',
32 type = 'executable',
33 },
34 lnk = {
35 ct = 'application/x-ms-application',
36 type = 'executable',
37 },
38 class = {
39 ct = 'application/x-java-applet',
40 type = 'executable',
41 },
42 jar = {
43 ct = 'application/java-archive',
44 type = 'archive',
45 },
46 apk = {
47 ct = 'application/vnd.android.package-archive',
48 type = 'archive',
49 },
50 bat = {
51 ct = 'application/x-bat',
52 type = 'executable',
53 },
54 -- text
55 rtf = {
56 ct = "application/rtf",
57 type = 'binary',
58 },
59 pdf = {
60 ct = 'application/pdf',
61 type = 'binary',
62 },
63 ps = {
64 ct = 'application/postscript',
65 type = 'binary',
66 },
67 chm = {
68 ct = 'application/x-chm',
69 type = 'binary',
70 },
71 djvu = {
72 ct = 'application/x-djvu',
73 type = 'binary',
74 },
75 -- archives
76 arj = {
77 ct = 'application/x-arj',
78 type = 'archive',
79 },
80 cab = {
81 ct = 'application/x-cab',
82 type = 'archive',
83 },
84 ace = {
85 ct = 'application/x-ace',
86 type = 'archive',
87 },
88 tar = {
89 ct = 'application/x-tar',
90 type = 'archive',
91 },
92 bz2 = {
93 ct = 'application/x-bzip',
94 type = 'archive',
95 },
96 xz = {
97 ct = 'application/x-xz',
98 type = 'archive',
99 },
100 lz4 = {
101 ct = 'application/x-lz4',
102 type = 'archive',
103 },
104 zst = {
105 ct = 'application/x-zstandard',
106 type = 'archive',
107 },
108 dmg = {
109 ct = 'application/x-dmg',
110 type = 'archive',
111 },
112 iso = {
113 ct = 'application/x-iso',
114 type = 'archive',
115 },
116 zoo = {
117 ct = 'application/x-zoo',
118 type = 'archive',
119 },
120 egg = {
121 ct = 'application/x-egg',
122 type = 'archive',
123 },
124 alz = {
125 ct = 'application/x-alz',
126 type = 'archive',
127 },
128 xar = {
129 ct = 'application/x-xar',
130 type = 'archive',
131 },
132 epub = {
133 ct = 'application/x-epub',
134 type = 'archive'
135 },
136 szdd = { -- in fact, their MSDOS extension is like FOO.TX_ or FOO.TX$
137 ct = 'application/x-compressed',
138 type = 'archive',
139 },
140 -- images
141 psd = {
142 ct = 'image/psd',
143 type = 'image',
144 av_check = false,
145 },
146 pcx = {
147 ct = 'image/pcx',
148 type = 'image',
149 av_check = false,
150 },
151 pic = {
152 ct = 'image/pic',
153 type = 'image',
154 av_check = false,
155 },
156 tiff = {
157 ct = 'image/tiff',
158 type = 'image',
159 av_check = false,
160 },
161 ico = {
162 ct = 'image/ico',
163 type = 'image',
164 av_check = false,
165 },
166 swf = {
167 ct = 'application/x-shockwave-flash',
168 type = 'image',
169 },
170 -- Ole files
171 ole = {
172 ct = 'application/octet-stream',
173 type = 'office'
174 },
175 doc = {
176 ct = 'application/msword',
177 type = 'office'
178 },
179 xls = {
180 ct = 'application/vnd.ms-excel',
181 type = 'office'
182 },
183 ppt = {
184 ct = 'application/vnd.ms-powerpoint',
185 type = 'office'
186 },
187 vsd = {
188 ct = 'application/vnd.visio',
189 type = 'office'
190 },
191 msi = {
192 ct = 'application/x-msi',
193 type = 'executable'
194 },
195 msg = {
196 ct = 'application/vnd.ms-outlook',
197 type = 'office'
198 },
199 -- newer office (2007+)
200 docx = {
201 ct = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
202 type = 'office'
203 },
204 xlsx = {
205 ct = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
206 type = 'office'
207 },
208 pptx = {
209 ct = 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
210 type = 'office'
211 },
212 -- OpenOffice formats
213 odt = {
214 ct = 'application/vnd.oasis.opendocument.text',
215 type = 'office'
216 },
217 ods = {
218 ct = 'application/vnd.oasis.opendocument.spreadsheet',
219 type = 'office'
220 },
221 odp = {
222 ct = 'application/vnd.oasis.opendocument.presentation',
223 type = 'office'
224 },
225 -- https://en.wikipedia.org/wiki/Associated_Signature_Containers
226 asice = {
227 ct = 'application/vnd.etsi.asic-e+zip',
228 type = 'office'
229 },
230 asics = {
231 ct = 'application/vnd.etsi.asic-s+zip',
232 type = 'office'
233 },
234 -- other
235 pgp = {
236 ct = 'application/encrypted',
237 type = 'encrypted'
238 },
239 uue = {
240 ct = 'application/x-uuencoded',
241 type = 'binary',
242 },
243 -- Types that are detected by Rspamd itself
244 -- Archives
245 zip = {
246 ct = 'application/zip',
247 type = 'archive',
248 },
249 rar = {
250 ct = 'application/x-rar',
251 type = 'archive',
252 },
253 ['7z'] = {
254 ct = 'application/x-7z-compressed',
255 type = 'archive',
256 },
257 gz = {
258 ct = 'application/gzip',
259 type = 'archive',
260 },
261 -- Images
262 png = {
263 ct = 'image/png',
264 type = 'image',
265 av_check = false,
266 },
267 gif = {
268 ct = 'image/gif',
269 type = 'image',
270 av_check = false,
271 },
272 jpg = {
273 ct = 'image/jpeg',
274 type = 'image',
275 av_check = false,
276 },
277 bmp = {
278 type = 'image',
279 ct = 'image/bmp',
280 av_check = false,
281 },
282 heic = {
283 type = 'image',
284 ct = 'image/heic',
285 av_check = false,
286 },
287 webp = {
288 type = 'image',
289 ct = 'image/webp',
290 av_check = false,
291 },
292 svg = {
293 type = 'image',
294 ct = 'image/svg+xml',
295 av_check = false,
296 no_text = true,
297 },
298 dwg = {
299 type = 'image',
300 ct = 'image/vnd.dwg',
301 },
302 -- Text
303 xml = {
304 ct = 'application/xml',
305 type = 'text',
306 no_text = true,
307 },
308 txt = {
309 type = 'text',
310 ct = 'text/plain',
311 av_check = false,
312 },
313 html = {
314 type = 'text',
315 ct = 'text/html',
316 av_check = false,
317 },
318 csv = {
319 type = 'text',
320 ct = 'text/csv',
321 av_check = false,
322 no_text = true,
323 },
324 ics = {
325 type = 'text',
326 ct = 'text/calendar',
327 av_check = false,
328 no_text = true,
329 },
330 vcf = {
331 type = 'text',
332 ct = 'text/vcard',
333 av_check = false,
334 no_text = true,
335 },
336 eml = {
337 type = 'message',
338 ct = 'message/rfc822',
339 av_check = false,
340 },
341 }
342
343 return types