Show ClamAV version and databases versions (#317)

This commit is contained in:
Alexander Shursha
2017-10-10 12:53:12 +02:00
committed by Franco Fichtner
parent 9e0ada3fd3
commit 153029ae76
5 changed files with 91 additions and 0 deletions
@@ -163,4 +163,37 @@ class ServiceController extends ApiControllerBase
return array("status" => "failed");
}
}
/**
* get ClamAV and signature versions
*/
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: ")
);
$backend = new Backend();
$result = array();
$response = $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;
}
}
}
}
return array("version" => $result);
}
else {
return array();
}
}
}
@@ -34,6 +34,7 @@ class GeneralController extends \OPNsense\Base\IndexController
{
$this->view->title = gettext("ClamAV Settings");
$this->view->generalForm = $this->getForm("general");
$this->view->versionForm = $this->getForm("version");
$this->view->pick('OPNsense/ClamAV/general');
}
}
@@ -0,0 +1,27 @@
<form>
<field>
<id>version.clamav</id>
<label>ClamAV engine version</label>
<type>info</type>
</field>
<field>
<id>version.main</id>
<label>main.cvd</label>
<type>info</type>
</field>
<field>
<id>version.daily</id>
<label>daily.cld</label>
<type>info</type>
</field>
<field>
<id>version.bytecode</id>
<label>bytecode.cld</label>
<type>info</type>
</field>
<field>
<id>version.signatures</id>
<label>Total number of signatures</label>
<type>info</type>
</field>
</form>
@@ -32,6 +32,11 @@ POSSIBILITY OF SUCH DAMAGE.
<div style="margin-top: 8px;">{{ lang._('No signature database found, please download before use. The download will take several minutes and this message will disappear when it has been completed.') }}</div>
</div>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
<li><a data-toggle="tab" href="#versions">{{ lang._('Versions') }}</a></li>
</ul>
<div class="tab-content content-box tab-content">
<div id="general" class="tab-pane fade in active">
<div class="content-box" style="padding-bottom: 1.5em;">
@@ -42,6 +47,11 @@ POSSIBILITY OF SUCH DAMAGE.
</div>
</div>
</div>
<div id="versions" class="tab-pane fade in">
<div class="content-box" style="padding-bottom: 1.5em;">
{{ partial("layout_partials/base_form",['fields':versionForm,'id':'frm_version'])}}
</div>
</div>
</div>
<script type="text/javascript">
@@ -64,6 +74,12 @@ $( document ).ready(function() {
$('.selectpicker').selectpicker('refresh');
});
var version_get_map = {'frm_version':"/api/clamav/service/version"};
mapDataToFormUI(version_get_map).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
ajaxCall(url="/api/clamav/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
@@ -98,5 +114,13 @@ $( document ).ready(function() {
setTimeout(timeoutCheck, 2500);
});
});
// update history on tab state and implement navigation
if(window.location.hash != "") {
$('a[href="' + window.location.hash + '"]').click()
}
$('.nav-tabs a').on('shown.bs.tab', function (e) {
history.pushState(null, null, e.target.hash);
});
});
</script>
@@ -33,3 +33,9 @@ command:/usr/local/opnsense/scripts/OPNsense/ClamAV/freshclam.sh
parameters:%s
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:"
parameters:
type:script_output
message:Get ClamAV and signature versions