From 7bf1343bf7edc9f40e025df6c4e95afecd096242 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Sat, 6 Aug 2016 09:25:22 +0200 Subject: [PATCH] IDS / crash reports, closes https://github.com/opnsense/core/issues/1117 --- .../OPNsense/IDS/Api/SettingsController.php | 14 +++++++++----- src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php | 4 ++-- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php index e4c111254..c564caf2c 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/IDS/Api/SettingsController.php @@ -147,15 +147,19 @@ class SettingsController extends ApiControllerBase /** * get rule information - * @param $sid rule identifier + * @param string|null $sid rule identifier * @return array|mixed */ - public function getRuleInfoAction($sid) + public function getRuleInfoAction($sid=null) { // request list of installed rules - $backend = new Backend(); - $response = $backend->configdpRun("ids query rules", array(1, 0,'sid/'.$sid)); - $data = json_decode($response, true); + if (!empty($sid)) { + $backend = new Backend(); + $response = $backend->configdpRun("ids query rules", array(1, 0,'sid/'.$sid)); + $data = json_decode($response, true); + } else { + $data = null; + } if ($data != null && array_key_exists("rows", $data) && count($data['rows'])>0) { $row = $data['rows'][0]; diff --git a/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php b/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php index efef19fd3..dcee0ca51 100644 --- a/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php +++ b/src/opnsense/mvc/app/models/OPNsense/IDS/IDS.php @@ -131,7 +131,7 @@ class IDS extends BaseModel public function getRuleStatus($sid, $default) { $this->updateSIDlist(); - if (array_key_exists($sid, $this->sid_list)) { + if (!empty($sid) && array_key_exists($sid, $this->sid_list)) { return (string)$this->sid_list[$sid]->enabled; } else { return $default; @@ -148,7 +148,7 @@ class IDS extends BaseModel public function getRuleAction($sid, $default, $response_plain = false) { $this->updateSIDlist(); - if (array_key_exists($sid, $this->sid_list)) { + if (!empty($sid) && array_key_exists($sid, $this->sid_list)) { if (!$response_plain) { return $this->sid_list[$sid]->action->getNodeData(); } else {