From d5e94c7239f85cd11e3003fa6294e640526ae457 Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 May 2019 10:46:22 +0200 Subject: [PATCH] security/clamav: add custom signatures (#1337) --- security/clamav/Makefile | 3 +- security/clamav/pkg-descr | 5 ++ .../OPNsense/ClamAV/Api/UrlController.php | 64 +++++++++++++++++++ .../OPNsense/ClamAV/GeneralController.php | 3 +- .../ClamAV/forms/dialogEditClamavUrl.xml | 20 ++++++ .../OPNsense/ClamAV/forms/general.xml | 2 +- .../mvc/app/models/OPNsense/ClamAV/Url.php | 31 +++++++++ .../mvc/app/models/OPNsense/ClamAV/Url.xml | 23 +++++++ .../app/views/OPNsense/ClamAV/general.volt | 52 ++++++++++++++- .../templates/OPNsense/ClamAV/freshclam.conf | 7 ++ 10 files changed, 205 insertions(+), 5 deletions(-) create mode 100644 security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/Api/UrlController.php create mode 100644 security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/dialogEditClamavUrl.xml create mode 100644 security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.php create mode 100644 security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.xml diff --git a/security/clamav/Makefile b/security/clamav/Makefile index cd23e4045..0010bcb43 100644 --- a/security/clamav/Makefile +++ b/security/clamav/Makefile @@ -1,6 +1,5 @@ PLUGIN_NAME= clamav -PLUGIN_VERSION= 1.6 -PLUGIN_REVISION= 2 +PLUGIN_VERSION= 1.7 PLUGIN_COMMENT= Antivirus engine for detecting malicious threats PLUGIN_DEPENDS= clamav PLUGIN_MAINTAINER= m.muenz@gmail.com diff --git a/security/clamav/pkg-descr b/security/clamav/pkg-descr index 795490977..e5066efc4 100644 --- a/security/clamav/pkg-descr +++ b/security/clamav/pkg-descr @@ -9,6 +9,11 @@ database updates. Plugin Changelog ================ +1.7 + +* Allow addition of external signatures +* Fix label for JURLBLA signature + 1.6 * Add optional signature sources diff --git a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/Api/UrlController.php b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/Api/UrlController.php new file mode 100644 index 000000000..f1b5356b3 --- /dev/null +++ b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/Api/UrlController.php @@ -0,0 +1,64 @@ + + * + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + */ + +namespace OPNsense\ClamAV\Api; + +use \OPNsense\Base\ApiMutableModelControllerBase; + +class UrlController extends ApiMutableModelControllerBase +{ + protected static $internalModelName = 'list'; + protected static $internalModelClass = '\OPNsense\ClamAV\Url'; + + public function searchUrlAction() + { + return $this->searchBase('lists.list', array("enabled", "name", "link")); + } + public function getUrlAction($uuid = null) + { + $this->sessionClose(); + return $this->getBase('list', 'lists.list', $uuid); + } + public function addUrlAction() + { + return $this->addBase('list', 'lists.list'); + } + public function delUrlAction($uuid) + { + return $this->delBase('lists.list', $uuid); + } + public function setUrlAction($uuid) + { + return $this->setBase('list', 'lists.list', $uuid); + } + public function toggleUrlAction($uuid) + { + return $this->toggleBase('lists.list', $uuid); + } +} diff --git a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/GeneralController.php b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/GeneralController.php index 0304aeaa9..674620d52 100644 --- a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/GeneralController.php +++ b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/GeneralController.php @@ -1,7 +1,7 @@ + Copyright (C) 2017-2019 Michael Muenz All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,6 +33,7 @@ class GeneralController extends \OPNsense\Base\IndexController public function indexAction() { $this->view->generalForm = $this->getForm("general"); + $this->view->formDialogEditClamavUrl = $this->getForm("dialogEditClamavUrl"); $this->view->versionForm = $this->getForm("version"); $this->view->pick('OPNsense/ClamAV/general'); } diff --git a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/dialogEditClamavUrl.xml b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/dialogEditClamavUrl.xml new file mode 100644 index 000000000..9ed1f8dcd --- /dev/null +++ b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/dialogEditClamavUrl.xml @@ -0,0 +1,20 @@ +
+ + list.enabled + + checkbox + This will enable or disable the list. + + + list.name + + text + Set the name for this signatures. + + + list.link + + text + URL of the signature database. + +
diff --git a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/general.xml b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/general.xml index ddef7eb11..8f40db9bd 100644 --- a/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/general.xml +++ b/security/clamav/src/opnsense/mvc/app/controllers/OPNsense/ClamAV/forms/general.xml @@ -191,7 +191,7 @@ general.fc_jurlbla - + checkbox Activate third party signatures from Sanesecurtiy JURLBLA. Use at your own risk. diff --git a/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.php b/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.php new file mode 100644 index 000000000..666449102 --- /dev/null +++ b/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.php @@ -0,0 +1,31 @@ + + All rights reserved. + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +namespace OPNsense\ClamAV; + +use OPNsense\Base\BaseModel; + +class Url extends BaseModel +{ +} diff --git a/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.xml b/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.xml new file mode 100644 index 000000000..84447c3b9 --- /dev/null +++ b/security/clamav/src/opnsense/mvc/app/models/OPNsense/ClamAV/Url.xml @@ -0,0 +1,23 @@ + + //OPNsense/clamav/url + ClamAV List configuration + 0.0.1 + + + + + 1 + Y + + + Y + + + Y + /^https?:\/\/.*$/i + URL has to start with http:// or https:// + + + + + diff --git a/security/clamav/src/opnsense/mvc/app/views/OPNsense/ClamAV/general.volt b/security/clamav/src/opnsense/mvc/app/views/OPNsense/ClamAV/general.volt index ddba12213..c0765170e 100644 --- a/security/clamav/src/opnsense/mvc/app/views/OPNsense/ClamAV/general.volt +++ b/security/clamav/src/opnsense/mvc/app/views/OPNsense/ClamAV/general.volt @@ -1,7 +1,7 @@ {# OPNsense® is Copyright © 2014 – 2017 by Deciso B.V. -This file is Copyright © 2017 by Michael Muenz +This file is Copyright © 2017 – 2019 by Michael Muenz All rights reserved. Redistribution and use in source and binary forms, with or without modification, @@ -34,6 +34,7 @@ POSSIBILITY OF SUCH DAMAGE. @@ -52,8 +53,38 @@ POSSIBILITY OF SUCH DAMAGE. {{ partial("layout_partials/base_form",['fields':versionForm,'id':'frm_version'])}} +
+ + + + + + + + + + + + + + + + + + +
{{ lang._('Enabled') }}{{ lang._('Name') }}{{ lang._('URL') }}{{ lang._('ID') }}{{ lang._('Commands') }}
+ +
+
+
+ +

+
+
+{{ partial("layout_partials/base_dialog",['fields':formDialogEditClamavUrl,'id':'dialogEditClamavUrl','label':lang._('Edit Signature URLs')])}} +