From 40e4bdc22e9db5a416b9cf1b03f5ba83016514cb Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Thu, 9 Jun 2016 21:35:22 +0200 Subject: [PATCH] (ids) add option to drop/reset suricata log file (eve.json*), closes https://github.com/opnsense/core/issues/997 --- .../OPNsense/IDS/Api/ServiceController.php | 20 ++++++++ .../mvc/app/views/OPNsense/IDS/index.volt | 33 ++++++++++++- src/opnsense/scripts/suricata/dropAlertLog.py | 48 +++++++++++++++++++ .../service/conf/actions.d/actions_ids.conf | 6 +++ 4 files changed, 105 insertions(+), 2 deletions(-) create mode 100755 src/opnsense/scripts/suricata/dropAlertLog.py diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php index c6ec78b56..7f5cf3b37 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/ServiceController.php @@ -311,4 +311,24 @@ class ServiceController extends ApiControllerBase return array(); } } + + /** + * drop alert log + * @return array status + */ + public function dropAlertLogAction() + { + if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); + $backend = new Backend(); + $filename = $this->request->getPost('filename', 'string', null); + if ($filename != null) { + $filename = basename($filename); + $backend->configdpRun("ids drop alertlog", array($filename)); + return array("status" => "ok"); + } + } + return array("status" => "failed"); + } } diff --git a/src/opnsense/mvc/app/views/OPNsense/IDS/index.volt b/src/opnsense/mvc/app/views/OPNsense/IDS/index.volt index 5fc7dd4b2..f6e455db9 100644 --- a/src/opnsense/mvc/app/views/OPNsense/IDS/index.volt +++ b/src/opnsense/mvc/app/views/OPNsense/IDS/index.volt @@ -69,9 +69,9 @@ POSSIBILITY OF SUCH DAMAGE. $('#alert-logfile').html(""); $.each(data, function(key, value) { if (value['sequence'] == undefined) { - $('#alert-logfile').append($("").attr("value",'none').text(value['modified'])); + $('#alert-logfile').append($("").attr("value",value['sequence']).text(value['modified'])); + $('#alert-logfile').append($("