Debian Codegraph @

lualib/lua_scanners/init.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_scanners
19 -- This module contains external scanners functions
20 --]]
21
22 local fun = require "fun"
23
24 local exports = {
25 }
26
27 local function require_scanner(name)
28 local sc = require("lua_scanners/" .. name)
29
30 exports[sc.name or name] = sc
31 end
32
33 -- Antiviruses
34 require_scanner('clamav')
35 require_scanner('fprot')
36 require_scanner('kaspersky_av')
37 require_scanner('kaspersky_se')
38 require_scanner('savapi')
39 require_scanner('sophos')
40 require_scanner('virustotal')
41 require_scanner('metadefender')
42 require_scanner('avast')
43
44 -- Other scanners
45 require_scanner('dcc')
46 require_scanner('oletools')
47 require_scanner('icap')
48 require_scanner('vadesecure')
49 require_scanner('spamassassin')
50 require_scanner('p0f')
51 require_scanner('razor')
52 require_scanner('pyzor')
53 require_scanner('cloudmark')
54
55 exports.add_scanner = function(name, t, conf_func, check_func)
56 assert(type(conf_func) == 'function' and type(check_func) == 'function',
57 'bad arguments')
58 exports[name] = {
59 type = t,
60 configure = conf_func,
61 check = check_func,
62 }
63 end
64
65 exports.filter = function(t)
66 return fun.tomap(fun.filter(function(_, elt)
67 return type(elt) == 'table' and elt.type and (
68 (type(elt.type) == 'string' and elt.type == t) or
69 (type(elt.type) == 'table' and fun.any(function(tt)
70 return tt == t
71 end, elt.type))
72 )
73 end, exports))
74 end
75
76 return exports