Checking .CLD and .CVD files. (#339)

This commit is contained in:
Alexander Shursha
2017-11-20 04:43:56 +01:00
committed by Franco Fichtner
parent 182315b1a3
commit 4ca0a9f13d
5 changed files with 24 additions and 19 deletions
@@ -170,25 +170,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);
}
@@ -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>
@@ -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"
@@ -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 "}"
@@ -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