Commit 2d5ea554 authored by Ad Schellevis's avatar Ad Schellevis

(ids) work in progress suricata IDS component (frontend/middleware)

parent 775ffffb
...@@ -96,7 +96,6 @@ class SettingsController extends ApiControllerBase ...@@ -96,7 +96,6 @@ class SettingsController extends ApiControllerBase
$searchPhrase .= "classtype/".$this->request->getPost("classtype", "string", '').' '; $searchPhrase .= "classtype/".$this->request->getPost("classtype", "string", '').' ';
} }
// request list of installed rules // request list of installed rules
$backend = new Backend(); $backend = new Backend();
$response = $backend->configdpRun("ids list installedrules", array($itemsPerPage, $response = $backend->configdpRun("ids list installedrules", array($itemsPerPage,
...@@ -138,7 +137,42 @@ class SettingsController extends ApiControllerBase ...@@ -138,7 +137,42 @@ class SettingsController extends ApiControllerBase
if ($data != null && array_key_exists("rows", $data) && count($data['rows'])>0) { if ($data != null && array_key_exists("rows", $data) && count($data['rows'])>0) {
$row = $data['rows'][0]; $row = $data['rows'][0];
// set current enable status (default + registered offset)
$row['enabled'] = $this->getModel()->getRuleStatus($row['sid'], $row['enabled']); $row['enabled'] = $this->getModel()->getRuleStatus($row['sid'], $row['enabled']);
if (isset($row['reference']) && $row['reference'] != '') {
// browser friendly reference data
$row['reference_html'] = '';
foreach (explode("\n", $row['reference']) as $ref) {
$ref = trim($ref);
$item_html = '<small><a href="%url%" target="_blank">%ref%</a></small>';
if (substr($ref, 0, 4) == 'url,') {
$item_html = str_replace("%url%", 'http://'.substr($ref, 4), $item_html);
$item_html = str_replace("%ref%", substr($ref, 4), $item_html);
} elseif (substr($ref, 0, 7) == "system,") {
$item_html = str_replace("%url%", substr($ref, 7), $item_html);
$item_html = str_replace("%ref%", substr($ref, 7), $item_html);
} elseif (substr($ref, 0, 8) == "bugtraq,") {
$item_html = str_replace("%url%", "http://www.securityfocus.com/bid/".
substr($ref, 8), $item_html);
$item_html = str_replace("%ref%", "bugtraq ".substr($ref, 8), $item_html);
} elseif (substr($ref, 0, 4) == "cve,") {
$item_html = str_replace("%url%", "http://cve.mitre.org/cgi-bin/cvename.cgi?name=".
substr($ref, 4), $item_html);
$item_html = str_replace("%ref%", substr($ref, 4), $item_html);
} elseif (substr($ref, 0, 7) == "nessus,") {
$item_html = str_replace("%url%", "http://cgi.nessus.org/plugins/dump.php3?id=".
substr($ref, 7), $item_html);
$item_html = str_replace("%ref%", 'nessus '.substr($ref, 7), $item_html);
} elseif (substr($ref, 0, 7) == "mcafee,") {
$item_html = str_replace("%url%", "http://vil.nai.com/vil/dispVirus.asp?virus_k=".
substr($ref, 7), $item_html);
$item_html = str_replace("%ref%", 'macafee '.substr($ref, 7), $item_html);
} else {
continue;
}
$row['reference_html'] .= $item_html.'<br/>';
}
}
return $row; return $row;
} else { } else {
return array(); return array();
......
...@@ -37,6 +37,8 @@ class IndexController extends \OPNsense\Base\IndexController ...@@ -37,6 +37,8 @@ class IndexController extends \OPNsense\Base\IndexController
public function indexAction() public function indexAction()
{ {
$this->view->title = "IDS"; $this->view->title = "IDS";
// link dialog
$this->view->formDialogRule = $this->getForm("dialogRule");
// choose template // choose template
$this->view->pick('OPNsense/IDS/index'); $this->view->pick('OPNsense/IDS/index');
} }
......
<form>
<field>
<id>sid</id>
<label>sid</label>
<type>info</type>
</field>
<field>
<id>gid</id>
<label>gid</label>
<type>info</type>
</field>
<field>
<id>classtype</id>
<label>classtype</label>
<type>info</type>
</field>
<field>
<id>msg</id>
<label>alert message</label>
<type>info</type>
</field>
<field>
<id>reference_html</id>
<label>reference</label>
<type>info</type>
</field>
</form>
\ No newline at end of file
...@@ -39,23 +39,31 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -39,23 +39,31 @@ POSSIBILITY OF SUCH DAMAGE.
} }
$("#grid-installedrules").UIBootgrid( $("#grid-installedrules").UIBootgrid(
{ 'search':'/api/ids/settings/searchinstalledrules', { search:'/api/ids/settings/searchinstalledrules',
'options':{ get:'/api/ids/settings/getRuleInfo/',
'requestHandler':addFilters, set:'/api/ids/settings/setRuleInfo/',
'formatters':{ options:{
"rowtoggle": function (column, row) { multiSelect:false,
selection:false,
requestHandler:addFilters,
formatters:{
rowtoggle: function (column, row) {
if (parseInt(row[column.id], 2) == 1) { if (parseInt(row[column.id], 2) == 1) {
return "<span class=\"fa fa-check-square-o command-toggle\" data-value=\"1\" data-row-id=\"" + row.sid + "\"></span>"; var toggle = "<span style=\"cursor: pointer;\" class=\"fa fa-check-square-o command-toggle\" data-value=\"1\" data-row-id=\"" + row.sid + "\"></span>";
} else { } else {
return "<span class=\"fa fa-square-o command-toggle\" data-value=\"0\" data-row-id=\"" + row.sid + "\"></span>"; var toggle = "<span style=\"cursor: pointer;\" class=\"fa fa-square-o command-toggle\" data-value=\"0\" data-row-id=\"" + row.sid + "\"></span>";
} }
toggle += " &nbsp; <button type=\"button\" class=\"btn btn-xs btn-default command-edit\" data-row-id=\"" + row.sid + "\"><span class=\"fa fa-info-circle\"></span></button> ";
return toggle;
} }
} }
}, },
'toggle':'/api/ids/settings/toggleRule/' toggle:'/api/ids/settings/toggleRule/'
} }
); );
// list all known classtypes and add to selection box // list all known classtypes and add to selection box
ajaxGet(url="/api/ids/settings/listRuleClasstypes",sendData={}, callback=function(data, status) { ajaxGet(url="/api/ids/settings/listRuleClasstypes",sendData={}, callback=function(data, status) {
if (status == "success") { if (status == "success") {
...@@ -77,12 +85,12 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -77,12 +85,12 @@ POSSIBILITY OF SUCH DAMAGE.
</script> </script>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs"> <ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#item1">{{ lang._('Item1') }}</a></li> <li class="active"><a data-toggle="tab" href="#rules">{{ lang._('Rules') }}</a></li>
<li><a data-toggle="tab" href="#item2">{{ lang._('Item2') }}</a></li> <li><a data-toggle="tab" href="#item2">{{ lang._('Item2') }}</a></li>
<li><a data-toggle="tab" href="#item3">{{ lang._('Item3') }}</a></li> <li><a data-toggle="tab" href="#item3">{{ lang._('Item3') }}</a></li>
</ul> </ul>
<div class="tab-content content-box tab-content"> <div class="tab-content content-box tab-content">
<div id="item1" class="tab-pane fade in active"> <div id="rules" class="tab-pane fade in active">
<div class="bootgrid-header container-fluid"> <div class="bootgrid-header container-fluid">
<div class="row"> <div class="row">
<div class="col-sm-12 actionBar"> <div class="col-sm-12 actionBar">
...@@ -93,27 +101,18 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -93,27 +101,18 @@ POSSIBILITY OF SUCH DAMAGE.
</div> </div>
<!-- tab page "installed rules" --> <!-- tab page "installed rules" -->
<table id="grid-installedrules" class="table table-condensed table-hover table-striped table-responsive"> <table id="grid-installedrules" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogRule">
<thead> <thead>
<tr> <tr>
<th data-column-id="sid" data-type="number" data-visible="true" data-identifier="true" >sid</th> <th data-column-id="sid" data-type="number" data-visible="true" data-identifier="true" >sid</th>
<th data-column-id="source" data-type="string">Source</th> <th data-column-id="source" data-type="string">Source</th>
<th data-column-id="classtype" data-type="string">ClassType</th> <th data-column-id="classtype" data-type="string">ClassType</th>
<th data-column-id="msg" data-type="string">Message</th> <th data-column-id="msg" data-type="string">Message</th>
<th data-column-id="enabled" data-formatter="rowtoggle" data-sortable="false">enabled</th> <th data-column-id="enabled" data-formatter="rowtoggle" data-sortable="false">enabled / info</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
</tbody> </tbody>
<tfoot>
<tr>
<td></td>
<td>
<button data-action="add" type="button" class="btn btn-xs btn-default"><span class="fa fa-plus"></span></button>
<button data-action="deleteSelected" type="button" class="btn btn-xs btn-default"><span class="fa fa-trash-o"></span></button>
</td>
</tr>
</tfoot>
</table> </table>
</div> </div>
<div id="item2" class="tab-pane fade in"> <div id="item2" class="tab-pane fade in">
...@@ -127,3 +126,5 @@ POSSIBILITY OF SUCH DAMAGE. ...@@ -127,3 +126,5 @@ POSSIBILITY OF SUCH DAMAGE.
<button class="btn btn-primary" id="reconfigureAct" type="button"><b>Apply</b><i id="reconfigureAct_progress" class=""></i></button> <button class="btn btn-primary" id="reconfigureAct" type="button"><b>Apply</b><i id="reconfigureAct_progress" class=""></i></button>
</div> </div>
</div> </div>
{{ partial("layout_partials/base_dialog",['fields':formDialogRule,'id':'DialogRule','label':'Rule details','hasSaveBtn':'false','msgzone_width':1])}}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment