|
@@ -0,0 +1,178 @@
|
|
1
|
+--[[
|
|
2
|
+
|
|
3
|
+LuCI ClamAV module
|
|
4
|
+
|
|
5
|
+Copyright (C) 2015, Itus Networks, Inc.
|
|
6
|
+
|
|
7
|
+Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+you may not use this file except in compliance with the License.
|
|
9
|
+You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+ http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+Author: Marko Ratkaj <marko.ratkaj@sartura.hr>
|
|
14
|
+ Luka Perkov <luka.perkov@sartura.hr>
|
|
15
|
+
|
|
16
|
+]]--
|
|
17
|
+
|
|
18
|
+local fs = require "nixio.fs"
|
|
19
|
+local sys = require "luci.sys"
|
|
20
|
+require "ubus"
|
|
21
|
+
|
|
22
|
+m = Map("clamav", translate("ClamAV"))
|
|
23
|
+m.on_after_commit = function() luci.sys.call("/etc/init.d/clamav restart") end
|
|
24
|
+
|
|
25
|
+s = m:section(TypedSection, "clamav")
|
|
26
|
+s.anonymous = true
|
|
27
|
+s.addremove = false
|
|
28
|
+
|
|
29
|
+s:tab("tab_advanced", translate("Settings"))
|
|
30
|
+s:tab("tab_logs", translate("Log"))
|
|
31
|
+
|
|
32
|
+--------------- Settings --------------
|
|
33
|
+
|
|
34
|
+LogFileMaxSize = s:taboption("tab_advanced", Value, "LogFileMaxSize", translate("Max size of log file"))
|
|
35
|
+LogFileMaxSize:value("512K", translate("512K"))
|
|
36
|
+LogFileMaxSize:value("1M", translate("1M"))
|
|
37
|
+LogFileMaxSize:value("2M", translate("2M"))
|
|
38
|
+LogFileMaxSize.default = "1M"
|
|
39
|
+
|
|
40
|
+LogTime = s:taboption("tab_advanced", ListValue, "LogTime", translate("Log time with each message"))
|
|
41
|
+LogTime:value("no", translate("No"))
|
|
42
|
+LogTime:value("yes", translate("Yes"))
|
|
43
|
+LogTime.default = "no"
|
|
44
|
+
|
|
45
|
+LogVerbose = s:taboption("tab_advanced", ListValue, "LogVerbose", translate("Enable verbose logging"))
|
|
46
|
+LogVerbose:value("no", translate("No"))
|
|
47
|
+LogVerbose:value("yes", translate("Yes"))
|
|
48
|
+LogVerbose.default = "no"
|
|
49
|
+
|
|
50
|
+ExtendedDetectionInfo = s:taboption("tab_advanced", ListValue, "ExtendedDetectionInfo", translate("Log additional infection info"))
|
|
51
|
+ExtendedDetectionInfo:value("no", translate("No"))
|
|
52
|
+ExtendedDetectionInfo:value("yes", translate("Yes"))
|
|
53
|
+ExtendedDetectionInfo.default = "no"
|
|
54
|
+
|
|
55
|
+dummy3 = s:taboption("tab_advanced", DummyValue, "")
|
|
56
|
+dummy4 = s:taboption("tab_advanced", DummyValue, "")
|
|
57
|
+
|
|
58
|
+MaxDirectoryRecursion = s:taboption("tab_advanced", Value, "MaxDirectoryRecursion", translate("Max directory scan depth"))
|
|
59
|
+MaxDirectoryRecursion:value("15", translate("15"))
|
|
60
|
+MaxDirectoryRecursion:value("20", translate("20"))
|
|
61
|
+MaxDirectoryRecursion.default = "15"
|
|
62
|
+
|
|
63
|
+FollowDirectorySymlink = s:taboption("tab_advanced", ListValue, "FollowDirectorySymlink", translate("Follow directory symlinks"))
|
|
64
|
+FollowDirectorySymlink:value("no", translate("No"))
|
|
65
|
+FollowDirectorySymlink:value("yes", translate("Yes"))
|
|
66
|
+FollowDirectorySymlink.default = "no"
|
|
67
|
+
|
|
68
|
+FollowFileSymlinks = s:taboption("tab_advanced", ListValue, "FollowFileSymlinks", translate("Follow file symlinks"))
|
|
69
|
+FollowFileSymlinks:value("no", translate("No"))
|
|
70
|
+FollowFileSymlinks:value("yes", translate("Yes"))
|
|
71
|
+FollowFileSymlinks.default = "no"
|
|
72
|
+
|
|
73
|
+DetectPUA = s:taboption("tab_advanced", ListValue, "DetectPUA", translate("Detect possibly unwanted apps"))
|
|
74
|
+DetectPUA:value("no", translate("No"))
|
|
75
|
+DetectPUA:value("yes", translate("Yes"))
|
|
76
|
+DetectPUA.default = "no"
|
|
77
|
+
|
|
78
|
+ScanPE = s:taboption("tab_advanced", ListValue, "ScanPE", translate("Scan portable executables"))
|
|
79
|
+ScanPE:value("no", translate("No"))
|
|
80
|
+ScanPE:value("yes", translate("Yes"))
|
|
81
|
+ScanPE.default = "yes"
|
|
82
|
+
|
|
83
|
+ScanELF = s:taboption("tab_advanced", ListValue, "ScanELF", translate("Scan ELF files"))
|
|
84
|
+ScanELF:value("no", translate("No"))
|
|
85
|
+ScanELF:value("yes", translate("Yes"))
|
|
86
|
+ScanELF.default = "yes"
|
|
87
|
+
|
|
88
|
+DetectBrokenExecutables = s:taboption("tab_advanced", ListValue, "DetectBrokenExecutables", translate("Detect broken executables"))
|
|
89
|
+DetectBrokenExecutables:value("no", translate("No"))
|
|
90
|
+DetectBrokenExecutables:value("yes", translate("Yes"))
|
|
91
|
+DetectBrokenExecutables.default = "no"
|
|
92
|
+
|
|
93
|
+ScanOLE2 = s:taboption("tab_advanced", ListValue, "ScanOLE2", translate("Scan MS Office and .msi files"))
|
|
94
|
+ScanOLE2:value("no", translate("No"))
|
|
95
|
+ScanOLE2:value("yes", translate("Yes"))
|
|
96
|
+ScanOLE2.default = "yes"
|
|
97
|
+
|
|
98
|
+ScanPDF = s:taboption("tab_advanced", ListValue, "ScanPDF", translate("Scan pdf files"))
|
|
99
|
+ScanPDF:value("no", translate("No"))
|
|
100
|
+ScanPDF:value("yes", translate("Yes"))
|
|
101
|
+ScanPDF.default = "yes"
|
|
102
|
+
|
|
103
|
+ScanSWF = s:taboption("tab_advanced", ListValue, "ScanSWF", translate("Scan swf files"))
|
|
104
|
+ScanSWF:value("no", translate("No"))
|
|
105
|
+ScanSWF:value("yes", translate("Yes"))
|
|
106
|
+ScanSWF.default = "yes"
|
|
107
|
+
|
|
108
|
+ScanMail = s:taboption("tab_advanced", ListValue, "ScanMail", translate("Scan emails"))
|
|
109
|
+ScanMail:value("no", translate("No"))
|
|
110
|
+ScanMail:value("yes", translate("Yes"))
|
|
111
|
+ScanMail.default = "yes"
|
|
112
|
+
|
|
113
|
+ScanPartialMessages = s:taboption("tab_advanced", ListValue, "ScanPartialMessages", translate("Scan RFC1341 messages split over many emails"))
|
|
114
|
+ScanPartialMessages:value("no", translate("No"))
|
|
115
|
+ScanPartialMessages:value("yes", translate("Yes"))
|
|
116
|
+ScanPartialMessages.default = "no"
|
|
117
|
+
|
|
118
|
+ScanArchive = s:taboption("tab_advanced", ListValue, "ScanArchive", translate("Scan archives"))
|
|
119
|
+ScanArchive:value("no", translate("No"))
|
|
120
|
+ScanArchive:value("yes", translate("Yes"))
|
|
121
|
+ScanArchive.default = "yes"
|
|
122
|
+
|
|
123
|
+ArchiveBlockEncrypted = s:taboption("tab_advanced", ListValue, "ArchiveBlockEncrypted", translate("Block encrypted archives"))
|
|
124
|
+ArchiveBlockEncrypted:value("no", translate("No"))
|
|
125
|
+ArchiveBlockEncrypted:value("yes", translate("Yes"))
|
|
126
|
+ArchiveBlockEncrypted.default = "no"
|
|
127
|
+
|
|
128
|
+dummy5 = s:taboption("tab_advanced", DummyValue, "")
|
|
129
|
+dummy6 = s:taboption("tab_advanced", DummyValue, "")
|
|
130
|
+
|
|
131
|
+StreamMinPort = s:taboption("tab_advanced", Value, "StreamMinPort", translate("Port range, lowest port"))
|
|
132
|
+StreamMinPort.datatype = "portrange"
|
|
133
|
+StreamMinPort:value("1024",translate("1024"))
|
|
134
|
+StreamMinPort.default = "1024"
|
|
135
|
+
|
|
136
|
+StreamMaxPort = s:taboption("tab_advanced", Value, "StreamMaxPort", translate("Port range, highest port"))
|
|
137
|
+StreamMaxPort.datatype = "portrange"
|
|
138
|
+StreamMaxPort:value("2048",translate("2048"))
|
|
139
|
+StreamMaxPort.default = "2048"
|
|
140
|
+
|
|
141
|
+MaxThreads = s:taboption("tab_advanced", Value, "MaxThreads", translate("Max number of threads"))
|
|
142
|
+MaxThreads.datatype = "and(uinteger,min(1))"
|
|
143
|
+MaxThreads:value("10",translate("10"))
|
|
144
|
+MaxThreads:value("20",translate("20"))
|
|
145
|
+MaxThreads.default = "10"
|
|
146
|
+
|
|
147
|
+SelfCheck = s:taboption("tab_advanced", Value, "SelfCheck", translate("Database check every N sec"))
|
|
148
|
+SelfCheck.datatype = "and(uinteger,min(1))"
|
|
149
|
+SelfCheck:value("600",translate("600"))
|
|
150
|
+SelfCheck.default = "600"
|
|
151
|
+
|
|
152
|
+MaxFileSize = s:taboption("tab_advanced", Value, "MaxFileSize", translate("Max size of scanned file"))
|
|
153
|
+MaxFileSize.datatype = "string"
|
|
154
|
+MaxFileSize:value("150M",translate("150M"))
|
|
155
|
+MaxFileSize:value("50M",translate("50M"))
|
|
156
|
+MaxFileSize.default = "150M"
|
|
157
|
+
|
|
158
|
+------------------ Log --------------------
|
|
159
|
+
|
|
160
|
+clamav_logfile = s:taboption("tab_logs", TextValue, "lines", "")
|
|
161
|
+clamav_logfile.wrap = "off"
|
|
162
|
+clamav_logfile.rows = 25
|
|
163
|
+clamav_logfile.rmempty = true
|
|
164
|
+
|
|
165
|
+function clamav_logfile.cfgvalue()
|
|
166
|
+ local uci = require "luci.model.uci".cursor_state()
|
|
167
|
+ local file = "/tmp/clamd.log"
|
|
168
|
+ if file then
|
|
169
|
+ return fs.readfile(file) or ""
|
|
170
|
+ else
|
|
171
|
+ return ""
|
|
172
|
+ end
|
|
173
|
+end
|
|
174
|
+
|
|
175
|
+function clamav_logfile.write()
|
|
176
|
+end
|
|
177
|
+
|
|
178
|
+return m
|