1
0

clamav.lua 6.6 KB

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