security/clamav: merge version 1.3 from master

This commit is contained in:
Franco Fichtner 2017-11-28 22:02:31 +01:00
parent f3c4d6c82e
commit cb207ff322
9 changed files with 59 additions and 25 deletions

View file

@ -1,5 +1,5 @@
PLUGIN_NAME= clamav
PLUGIN_VERSION= 1.1
PLUGIN_VERSION= 1.3
PLUGIN_COMMENT= Antivirus engine for detecting malicious threats
PLUGIN_DEPENDS= clamav
PLUGIN_MAINTAINER= m.muenz@gmail.com

View file

@ -66,8 +66,11 @@ class ServiceController extends ApiControllerBase
public function startAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("clamav start", true);
$response = $backend->configdRun("clamav start");
return array("response" => $response);
} else {
return array("response" => array());
@ -81,6 +84,9 @@ class ServiceController extends ApiControllerBase
public function stopAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("clamav stop");
return array("response" => $response);
@ -96,6 +102,9 @@ class ServiceController extends ApiControllerBase
public function restartAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("clamav restart");
return array("response" => $response);
@ -129,7 +138,6 @@ class ServiceController extends ApiControllerBase
$status = "unkown";
}
return array("status" => $status);
}
@ -170,25 +178,23 @@ class ServiceController extends ApiControllerBase
public function versionAction()
{
$infos = array(
"clamav" => array("search" => "Version: "),
"main" => array("search" => "main.cvd: "),
"daily" => array("search" => "daily.cld: "),
"bytecode" => array("search" => "bytecode.cld: "),
"signatures" => array("search" => "Total number of signatures: ")
"clamav" => array("Version"),
"main" => array("main.cvd", "main.cld"),
"daily" => array("daily.cvd", "daily.cld"),
"bytecode" => array("bytecode.cvd", "bytecode.cld"),
"signatures" => array("Total number of signatures")
);
$backend = new Backend();
$result = array();
$response = $backend->configdRun("clamav version");
$response = json_decode($backend->configdRun("clamav version"));
if ($response != null) {
foreach (explode("\n", $response) as $str) {
foreach ($infos as $key => $info) {
if (strpos($str, $info["search"]) !== false) {
$version = substr($str, strlen($info["search"]));
if (isset($version)) {
$result[$key] = $version;
}
foreach ($response as $key => $value) {
foreach ($infos as $info_key => $info) {
if (in_array($key, $info)) {
$result[$info_key] = $value;
}
}
}
return array("version" => $result);
}

View file

@ -6,17 +6,17 @@
</field>
<field>
<id>version.main</id>
<label>main.cvd</label>
<label>main</label>
<type>info</type>
</field>
<field>
<id>version.daily</id>
<label>daily.cld</label>
<label>daily</label>
<type>info</type>
</field>
<field>
<id>version.bytecode</id>
<label>bytecode.cld</label>
<label>bytecode</label>
<type>info</type>
</field>
<field>

View file

@ -1,5 +1,8 @@
<menu>
<Services>
<ClamAV cssClass="fa fa-stethoscope" url="/ui/clamav/general/index" />
<ClamAV cssClass="fa fa-stethoscope">
<Configuration order="10" url="/ui/clamav/general/index"/>
<LogFile VisibleName="Log File" order="20" url="/diag_logs_clamav.php"/>
</ClamAV>
</Services>
</menu>

View file

@ -41,9 +41,9 @@ POSSIBILITY OF SUCH DAMAGE.
<div id="general" class="tab-pane fade in active">
<div class="content-box" style="padding-bottom: 1.5em;">
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}}
<hr />
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct_progress" class=""></i></button>
<hr />
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b> <i id="saveAct_progress"></i></button>
</div>
</div>
</div>

View file

@ -26,10 +26,11 @@
# SUCH DAMAGE.
PIDFILE="/var/run/clamav/freshclam-init.pid"
DBFILE="/var/db/clamav/main.cvd"
CVDDBFILE="/var/db/clamav/main.cvd"
CLDDBFILE="/var/db/clamav/main.cld"
COMMAND="${1}"
if [ -f ${DBFILE} ]; then
if [ -f ${CVDDBFILE} -o -f ${CLDDBFILE} ]; then
echo "done"
elif pgrep -qF ${PIDFILE} 2> /dev/null; then
echo "running"

View file

@ -0,0 +1,6 @@
#!/bin/sh
echo -n "{"
clamconf | sed -n '/Database information/,/^$/p' | tail +2 | grep : | while read line ; do key=`echo $line | cut -d':' -f1`; value=`echo $line | cut -d':' -f2-` ; echo "\"$key\": \"$value\""; done | tr "\n", ","
clamconf | sed -n '/Software settings/,/^$/p' | tail +2 | grep : | while read line ; do key=`echo $line | cut -d':' -f1`; value=`echo $line | cut -d':' -f2-` ; echo "\"$key\": \"$value\""; done | tr "\n", "," | sed 's/,$//'
echo "}"

View file

@ -35,7 +35,7 @@ type:script_output
message:Check or install signatures
[version]
command:/usr/local/bin/clamconf | grep "Version:\|main.cvd: version\|.cld: version\|Total number of signatures:"
command:/usr/local/opnsense/scripts/OPNsense/ClamAV/versions.sh
parameters:
type:script_output
message:Get ClamAV and signature versions

View file

@ -0,0 +1,18 @@
<?php
$type = 'clamd';
if (isset($_GET['type']) && ($_GET['type'] === 'clamd' || $_GET['type'] === 'freshclam')) {
$type = $_GET['type'];
}
$logfile = "/var/log/clamav/{$type}.log";
$logclog = false;
$logsplit = 2;
$logpills = array();
$logpills[] = array(gettext('Clamd'), true, '/diag_logs_clamav.php?type=clamd');
$logpills[] = array(gettext('Freshclam'), false, '/diag_logs_clamav.php?type=freshclam');
$service_hook = 'clamav';
require_once 'diag_logs_template.inc';