mirror of https://github.com/MISP/MISP
Further work on the filter UI
parent
94963852e2
commit
fdcac8b72c
|
@ -59,6 +59,16 @@ class ServersController extends AppController {
|
|||
$this->paginate['conditions'] = array('Server.org_id LIKE' => $this->Auth->user('org_id'));
|
||||
}
|
||||
$this->set('servers', $this->paginate());
|
||||
$collection = array();
|
||||
$collection['orgs'] = $this->Server->Organisation->find('list', array(
|
||||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$this->loadModel('Tag');
|
||||
$collection['tags'] = $this->Tag->find('list', array(
|
||||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$this->set('collection', $collection);
|
||||
|
||||
}
|
||||
|
||||
public function previewIndex($id) {
|
||||
|
@ -215,25 +225,28 @@ class ServersController extends AppController {
|
|||
}
|
||||
$organisationOptions = array(0 => 'Local organisation', 1 => 'External organisation', 2 => 'New external organisation');
|
||||
$temp = $this->Server->Organisation->find('all', array(
|
||||
'conditions' => array('local' => true),
|
||||
'fields' => array('id', 'name'),
|
||||
'conditions' => array('local' => true),
|
||||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$localOrganisations = array();
|
||||
foreach ($temp as $o) $localOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs = array();
|
||||
foreach ($temp as $o) {
|
||||
$localOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs[] = array('id' => $o['Organisation']['id'], 'name' => $o['Organisation']['name']);
|
||||
}
|
||||
$temp = $this->Server->Organisation->find('all', array(
|
||||
'conditions' => array('local' => false),
|
||||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$externalOrganisations = array();
|
||||
foreach ($temp as $o) $externalOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
foreach ($temp as $o) {
|
||||
$externalOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs[] = array('id' => $o['Organisation']['id'], 'name' => $o['Organisation']['name']);
|
||||
}
|
||||
|
||||
$this->set('organisationOptions', $organisationOptions);
|
||||
$this->set('localOrganisations', $localOrganisations);
|
||||
$this->set('externalOrganisations', $externalOrganisations);
|
||||
|
||||
// list all orgs for the rule picker
|
||||
$temp = $localOrganisations + $externalOrganisations;
|
||||
$allOrgs = array();
|
||||
foreach ($temp as $k => $v) $allOrgs[] = array('id' => $k, 'name' => $v);
|
||||
$this->set('allOrganisations', $allOrgs);
|
||||
|
||||
// list all tags for the rule picker
|
||||
|
@ -326,14 +339,21 @@ class ServersController extends AppController {
|
|||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$localOrganisations = array();
|
||||
foreach ($temp as $o) $localOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs = array();
|
||||
foreach ($temp as $o) {
|
||||
$localOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs[] = array('id' => $o['Organisation']['id'], 'name' => $o['Organisation']['name']);
|
||||
}
|
||||
$temp = $this->Server->Organisation->find('all', array(
|
||||
'conditions' => array('local' => false),
|
||||
'fields' => array('id', 'name'),
|
||||
));
|
||||
$externalOrganisations = array();
|
||||
foreach ($temp as $o) $externalOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
|
||||
foreach ($temp as $o) {
|
||||
$externalOrganisations[$o['Organisation']['id']] = $o['Organisation']['name'];
|
||||
$allOrgs[] = array('id' => $o['Organisation']['id'], 'name' => $o['Organisation']['name']);
|
||||
}
|
||||
|
||||
$oldRemoteSetting = 0;
|
||||
if (!$this->Server->data['RemoteOrg']['local']) $oldRemoteSetting = 1;
|
||||
|
||||
|
@ -343,11 +363,6 @@ class ServersController extends AppController {
|
|||
$this->set('organisationOptions', $organisationOptions);
|
||||
$this->set('localOrganisations', $localOrganisations);
|
||||
$this->set('externalOrganisations', $externalOrganisations);
|
||||
|
||||
// list all orgs for the rule picker
|
||||
$temp = $localOrganisations + $externalOrganisations;
|
||||
$allOrgs = array();
|
||||
foreach ($temp as $k => $v) $allOrgs[] = array('id' => $k, 'name' => $v);
|
||||
$this->set('allOrganisations', $allOrgs);
|
||||
|
||||
// list all tags for the rule picker
|
||||
|
|
|
@ -66,16 +66,16 @@
|
|||
));
|
||||
?>
|
||||
<br /><b>Push rules:</b><br />
|
||||
<span id="push_tags_allowed" style="display:none;">Events with the following tags allowed: <span id="push_tags_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_tags_blocked" style="display:none;">Events with the following tags blocked: <span id="push_tags_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_orgs_allowed" style="display:none;">Events with the following organisations allowed: <span id="push_orgs_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_orgs_blocked" style="display:none;">Events with the following organisations blocked: <span id="push_orgs_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_tags_OR" style="display:none;">Events with the following tags allowed: <span id="push_tags_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_tags_NOT" style="display:none;">Events with the following tags blocked: <span id="push_tags_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_orgs_OR" style="display:none;">Events with the following organisations allowed: <span id="push_orgs_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_orgs_NOT" style="display:none;">Events with the following organisations blocked: <span id="push_orgs_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_modify" class="btn btn-inverse" style="line-height:10px; padding: 4px 4px;">Modify</span><br /><br />
|
||||
<b>Pull rules:</b><br />
|
||||
<span id="pull_tags_allowed" style="display:none;">Events with the following tags allowed: <span id="pull_tags_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_tags_blocked" style="display:none;">Events with the following tags blocked: <span id="pull_tags_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_orgs_allowed" style="display:none;">Events with the following organisations allowed: <span id="pull_orgs_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_orgs_blocked" style="display:none;">Events with the following organisations blocked: <span id="pull_orgs_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_tags_OR" style="display:none;">Events with the following tags allowed: <span id="pull_tags_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_tags_NOT" style="display:none;">Events with the following tags blocked: <span id="pull_tags_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_orgs_OR" style="display:none;">Events with the following organisations allowed: <span id="pull_orgs_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_orgs_NOT" style="display:none;">Events with the following organisations blocked: <span id="pull_orgs_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_modify" class="btn btn-inverse" style="line-height:10px; padding: 4px 4px;">Modify</span><br /><br />
|
||||
<?php
|
||||
echo $this->Form->input('push_rules', array('style' => 'display:none;', 'label' => false, 'div' => false));
|
||||
|
@ -110,7 +110,7 @@ var formInfoValues = {
|
|||
};
|
||||
|
||||
|
||||
var rules = {"push": {"tags": {"allowed":[], "blocked":[]}, "orgs": {"allowed":[], "blocked":[]}}, "pull": {"tags": {"allowed":[], "blocked":[]}, "orgs": {"allowed":[], "blocked":[]}}};
|
||||
var rules = {"push": {"tags": {"OR":[], "NOT":[]}, "orgs": {"OR":[], "NOT":[]}}, "pull": {"tags": {"OR":[], "NOT":[]}, "orgs": {"OR":[], "NOT":[]}}};
|
||||
var validOptions = ['pull', 'push'];
|
||||
var validFields = ['tags', 'orgs'];
|
||||
var tags = <?php echo json_encode($allTags); ?>;
|
||||
|
|
|
@ -75,16 +75,16 @@
|
|||
));
|
||||
?>
|
||||
<br /><b>Push rules:</b><br />
|
||||
<span id="push_tags_allowed" style="display:none;">Events with the following tags allowed: <span id="push_tags_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_tags_blocked" style="display:none;">Events with the following tags blocked: <span id="push_tags_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_orgs_allowed" style="display:none;">Events with the following organisations allowed: <span id="push_orgs_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_orgs_blocked" style="display:none;">Events with the following organisations blocked: <span id="push_orgs_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_tags_OR" style="display:none;">Events with the following tags allowed: <span id="push_tags_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_tags_NOT" style="display:none;">Events with the following tags blocked: <span id="push_tags_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_orgs_OR" style="display:none;">Events with the following organisations allowed: <span id="push_orgs_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="push_orgs_NOT" style="display:none;">Events with the following organisations blocked: <span id="push_orgs_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="push_modify" class="btn btn-inverse" style="line-height:10px; padding: 4px 4px;">Modify</span><br /><br />
|
||||
<b>Pull rules:</b><br />
|
||||
<span id="pull_tags_allowed" style="display:none;">Events with the following tags allowed: <span id="pull_tags_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_tags_blocked" style="display:none;">Events with the following tags blocked: <span id="pull_tags_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_orgs_allowed" style="display:none;">Events with the following organisations allowed: <span id="pull_orgs_allowed_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_orgs_blocked" style="display:none;">Events with the following organisations blocked: <span id="pull_orgs_blocked_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_tags_OR" style="display:none;">Events with the following tags allowed: <span id="pull_tags_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_tags_NOT" style="display:none;">Events with the following tags blocked: <span id="pull_tags_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_orgs_OR" style="display:none;">Events with the following organisations allowed: <span id="pull_orgs_OR_text" style="color:green;"></span><br /></span>
|
||||
<span id="pull_orgs_NOT" style="display:none;">Events with the following organisations blocked: <span id="pull_orgs_NOT_text" style="color:red;"></span><br /></span>
|
||||
<span id="pull_modify" class="btn btn-inverse" style="line-height:10px; padding: 4px 4px;">Modify</span><br /><br />
|
||||
<?php
|
||||
echo $this->Form->input('push_rules', array('style' => 'display:none;', 'label' => false, 'div' => false));
|
||||
|
@ -119,7 +119,7 @@ var formInfoValues = {
|
|||
'ServerSelfSigned' : "Click this, if you would like to allow a connection despite the other instance using a self-signed certificate (not recommended)."
|
||||
};
|
||||
|
||||
var rules = {"push": {"tags": {"allowed":[], "blocked":[]}, "orgs": {"allowed":[], "blocked":[]}}, "pull": {"tags": {"allowed":[], "blocked":[]}, "orgs": {"allowed":[], "blocked":[]}}};
|
||||
var rules = {"push": {"tags": {"OR":[], "NOT":[]}, "orgs": {"OR":[], "NOT":[]}}, "pull": {"tags": {"OR":[], "NOT":[]}, "orgs": {"OR":[], "NOT":[]}}};
|
||||
var validOptions = ['pull', 'push'];
|
||||
var validFields = ['tags', 'orgs'];
|
||||
var tags = <?php echo json_encode($allTags); ?>;
|
||||
|
|
|
@ -32,7 +32,30 @@
|
|||
<th class="actions">Actions</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ($servers as $server): ?>
|
||||
foreach ($servers as $server):
|
||||
$rules = array();
|
||||
$rules['push'] = json_decode($server['Server']['push_rules'], true);
|
||||
$rules['pull'] = json_decode($server['Server']['pull_rules'], true);
|
||||
$syncOptions = array('pull', 'push');
|
||||
$fieldOptions = array('tags', 'orgs');
|
||||
$typeOptions = array('OR' => array('colour' => 'green', 'text' => 'allowed'), 'NOT' => array('colour' => 'red', 'text' => 'blocked'));
|
||||
$ruleDescription = array('pull' => '', 'push' => '');
|
||||
foreach ($syncOptions as $syncOption) {
|
||||
foreach ($fieldOptions as $fieldOption) {
|
||||
foreach ($typeOptions as $typeOption => $typeData) {
|
||||
if (isset($rules[$syncOption][$fieldOption][$typeOption]) && !empty($rules[$syncOption][$fieldOption][$typeOption])) {
|
||||
$ruleDescription[$syncOption] .= '<span class=\'bold\'>' . ucfirst($fieldOption) . ' ' . $typeData['text'] . '</span>: <span class=\'' . $typeData['colour'] . '\'>';
|
||||
foreach ($rules[$syncOption][$fieldOption][$typeOption] as $k => $temp) {
|
||||
if ($k != 0) $ruleDescription[$syncOption] .= ', ';
|
||||
if ($syncOption === 'push') $temp = $collection[$fieldOption][$temp];
|
||||
$ruleDescription[$syncOption] .= h($temp);
|
||||
}
|
||||
$ruleDescription[$syncOption] .= '</span><br />';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php
|
||||
|
@ -41,8 +64,9 @@ foreach ($servers as $server): ?>
|
|||
?>
|
||||
</td>
|
||||
<td id="connection_test_<?php echo $server['Server']['id'];?>"><span class="btn btn-primary" style="line-height:10px; padding: 4px 4px;" onClick="testConnection('<?php echo $server['Server']['id'];?>');">Run</span></td>
|
||||
<td class="short"><span class="<?php echo ($server['Server']['push']? 'icon-ok' : 'icon-remove'); ?>"></span></td>
|
||||
<td class="short"><span class="<?php echo ($server['Server']['pull']? 'icon-ok' : 'icon-remove'); ?>"></span></td>
|
||||
|
||||
<td><span class="<?php echo ($server['Server']['push']? 'icon-ok' : 'icon-remove'); ?>"></span><span class="short <?php if (!$server['Server']['push'] || empty($ruleDescription['push'])) echo "hidden"; ?>" data-toggle="popover" title="Distribution List" data-content="<?php echo $ruleDescription['push']; ?>"> (Rules)</span></td>
|
||||
<td><span class="<?php echo ($server['Server']['pull']? 'icon-ok' : 'icon-remove'); ?>"></span><span class="short <?php if (!$server['Server']['pull'] || empty($ruleDescription['pull'])) echo "hidden"; ?>" data-toggle="popover" title="Distribution List" data-content="<?php echo $ruleDescription['pull']; ?>"> (Rules)</span>
|
||||
<td><?php echo h($server['Server']['url']); ?> </td>
|
||||
<td><a href="/organisations/view/<?php echo h($server['RemoteOrg']['id']); ?>"><?php echo h($server['RemoteOrg']['name']); ?></a></td>
|
||||
<td class="short"><?php echo h($server['Server']['cert_file']); ?> </td>
|
||||
|
@ -89,6 +113,11 @@ endforeach; ?>
|
|||
</div>
|
||||
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
popoverStartup();
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
echo $this->element('side_menu', array('menuList' => 'sync', 'menuItem' => 'index'));
|
||||
?>
|
||||
|
|
|
@ -42,14 +42,14 @@ foreach ($sharingGroups as $k => $sharingGroup):
|
|||
$combined .= "Organisations:";
|
||||
if (count($sharingGroup['SharingGroupOrg']) == 0) $combined .= "<br />N/A";
|
||||
foreach ($sharingGroup['SharingGroupOrg'] as $k2 => $sge) {
|
||||
$combined .= "<br /><a href='/Organisation/view/" . $sge['Organisation']['id'] . "'>" . h($sge['Organisation']['name']) . "</a>";
|
||||
$combined .= "<br /><a href='/Organisation/view/" . h($sge['Organisation']['id']) . "'>" . h($sge['Organisation']['name']) . "</a>";
|
||||
if ($sge['extend']) $combined .= (' (can extend)');
|
||||
}
|
||||
$combined .= "<hr style='margin:5px 0;'><br />Instances:";
|
||||
if (count($sharingGroup['SharingGroupServer']) == 0) $combined .= "<br />N/A";
|
||||
foreach ($sharingGroup['SharingGroupServer'] as $k3 => $sgs) {
|
||||
if ($sgs['server_id'] != 0) {
|
||||
$combined .= "<br /><a href='/Server/view/" . $sgs['Server']['id'] . "'>" . h($sgs['Server']['name']) . "</a>";
|
||||
$combined .= "<br /><a href='/Server/view/" . h($sgs['Server']['id']) . "'>" . h($sgs['Server']['name']) . "</a>";
|
||||
} else {
|
||||
$combined .= "<br />This instance";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue