2012-04-04 20:22:22 +02:00
<div class="servers index">
2018-07-20 09:29:50 +02:00
<h2><?php echo __('Servers');?></h2>
<div class="pagination">
<ul>
<?php
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
?>
</ul>
</div>
<table class="table table-striped table-hover table-condensed">
2021-01-07 18:05:10 +01:00
<tr>
<th><?php echo $this->Paginator->sort('id', __('ID'));?></th>
2018-07-20 09:29:50 +02:00
<th><?php echo $this->Paginator->sort('name');?></th>
2019-09-13 11:49:12 +02:00
<th><?php echo __('Prio');?></th>
2018-07-20 09:29:50 +02:00
<th><?php echo __('Connection test');?></th>
2019-11-13 19:09:37 +01:00
<th><?php echo __('Sync user');?></th>
2019-09-09 13:00:21 +02:00
<th><?php echo __('Reset API key');?></th>
2018-07-20 09:29:50 +02:00
<th><?php echo $this->Paginator->sort('internal');?></th>
<th><?php echo $this->Paginator->sort('push');?></th>
<th><?php echo $this->Paginator->sort('pull');?></th>
2019-11-22 21:53:51 +01:00
<th><?php echo $this->Paginator->sort('push_sightings', 'Push Sightings');?></th>
2020-05-26 15:08:24 +02:00
<th><?php echo $this->Paginator->sort('push_galaxy_clusters', 'Push Clusters');?></th>
2020-06-10 09:36:34 +02:00
<th><?php echo $this->Paginator->sort('pull_galaxy_clusters', 'Pull Clusters');?></th>
2019-01-18 09:06:23 +01:00
<th><?php echo $this->Paginator->sort('caching_enabled', 'Cache');?></th>
2021-01-07 18:05:10 +01:00
<th><?php echo $this->Paginator->sort('unpublish_event');?></th>
<th><?php echo $this->Paginator->sort('publish_without_email');?></th>
<th><?php echo $this->Paginator->sort('url', 'URL');?></th>
2018-07-20 09:29:50 +02:00
<th><?php echo __('Remote Organisation');?></th>
<th><?php echo $this->Paginator->sort('cert_file');?></th>
<th><?php echo $this->Paginator->sort('client_cert_file');?></th>
<th><?php echo $this->Paginator->sort('self_signed');?></th>
<th><?php echo $this->Paginator->sort('skip_proxy');?></th>
<th><?php echo $this->Paginator->sort('org');?></th>
<th class="actions"><?php echo __('Actions');?></th>
2021-01-07 18:05:10 +01:00
</tr>
2018-07-20 09:29:50 +02:00
<?php
2021-01-07 18:05:10 +01:00
foreach ($servers as $server):
2018-07-20 09:29:50 +02:00
$rules = array();
$rules['push'] = json_decode($server['Server']['push_rules'], true);
$rules['pull'] = json_decode($server['Server']['pull_rules'], true);
$syncOptions = array('pull', 'push');
2021-12-10 10:07:37 +01:00
$fieldOptions = array('tags', 'orgs');
if (!empty(Configure::read('MISP.enable_synchronisation_filtering_on_type'))) {
$fieldOptions = array_merge($fieldOptions, ['type_attributes', 'type_objects']);
}
2018-07-20 09:29:50 +02:00
$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] .= ', ';
2021-04-22 16:23:59 +02:00
if ($syncOption === 'push') {
$temp = !empty($collection[$fieldOption][$temp]) ? $collection[$fieldOption][$temp] : $temp;
}
2018-07-20 09:29:50 +02:00
$ruleDescription[$syncOption] .= h($temp);
}
2021-01-07 18:05:10 +01:00
$ruleDescription[$syncOption] .= '</span><br>';
2018-07-20 09:29:50 +02:00
}
}
}
2020-01-23 09:42:16 +01:00
if ($syncOption === 'pull') {
if (!empty($rules['pull']['url_params'])) {
$ruleDescription[$syncOption] .= sprintf(
'%s: %s',
sprintf("<span class='bold'>%s</span>", __('URL params')),
sprintf(
"<pre class='jsonify'>%s</pre>",
h(json_encode(json_decode($rules['pull']['url_params']), JSON_PRETTY_PRINT))
)
);
}
}
2018-07-20 09:29:50 +02:00
}
2019-09-13 11:49:12 +02:00
$arrows = '';
foreach (['up', 'down'] as $direction) {
$arrows .= sprintf(
2021-01-07 18:05:10 +01:00
'<i class="fas fa-arrow-circle-%s rearrange-%s useCursorPointer" aria-label="%s" title="%s" data-server-id="%s"></i>',
2019-09-13 11:49:12 +02:00
$direction,
$direction,
$direction === 'up' ? __('Move server priority up') : __('Move server priority down'),
$direction === 'up' ? __('Move server priority up') : __('Move server priority down'),
$server['Server']['id']
);
}
2015-10-18 09:36:55 +02:00
?>
2019-09-13 11:49:12 +02:00
<tr id="row_<?php echo h($server['Server']['id']); ?>">
2018-07-20 09:29:50 +02:00
<td class="short"><?php echo h($server['Server']['id']); ?></td>
<td>
<?php
if (!empty($server['Server']['name'])) echo h($server['Server']['name']);
else echo h($server['Server']['url']);
?>
</td>
2021-01-07 18:05:10 +01:00
<td id="priority_<?php echo $server['Server']['id'];?>"><?= $arrows ?></td>
2019-11-13 19:09:37 +01:00
<td class="short" id="connection_test_<?php echo $server['Server']['id'];?>"><span role="button" tabindex="0" aria-label="<?php echo __('Test the connection to the remote instance');?>" title="<?php echo __('Test the connection to the remote instance');?>" class="btn btn-primary" style="line-height:10px; padding: 4px 4px;" onClick="testConnection('<?php echo $server['Server']['id'];?>');"><?php echo __('Run');?></span></td>
<td class="short" id="sync_user_test_<?php echo $server['Server']['id'];?>"><span role="button" tabindex="0" aria-label="<?php echo __('View the sync user of the remote instance');?>" title="<?php echo __('View the sync user of the remote instance');?>" class="btn btn-primary" style="line-height:10px; padding: 4px 4px;" onClick="getRemoteSyncUser('<?php echo $server['Server']['id'];?>');"><?php echo __('View');?></span></td>
2019-09-09 13:00:21 +02:00
<td id="reset_api_key_<?php echo $server['Server']['id'];?>">
<?php
echo $this->Form->postLink(
__('Reset'),
$baseurl . '/servers/resetRemoteAuthKey/' . $server['Server']['id'],
array(
'style' => 'line-height:10px; padding: 4px 4px;',
'title' => __('Remotely reset API key'),
'aria-label' => __('Remotely reset API key'),
'class' => 'btn btn-primary'
)
);
?>
</td>
Accessibility: added roles and aria labels for many icons and icon links (server list, tags, users, roles, attributes, ...)
There is still much work to be done. But we are on the road.
Ideally, and in order to avoid code dupplicates, we should have some utility functions to generate a proper and accessible yes/no icon, an accessible icon link, etc. This would prevent the code from being filled with "aria-label" tags, since the "title" and "aria-label" properties are nearly always the same.
2019-04-02 15:31:34 +02:00
2021-01-07 18:05:10 +01:00
<td><span class="<?= $server['Server']['internal']? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['internal']? __('Yes') : __('No') ?>" title="<?= $server['Server']['internal'] ? __('Internal instance that ignores distribution level degradation *WARNING: Only use this setting if you have several internal instances and the sync link is to an internal extension of the current MISP community*') : __('Normal sync link to an external MISP instance. Distribution degradation will follow the normal rules.') ?>"></span></td>
<td><span class="<?= $server['Server']['push']? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['push']? __('Yes') : __('No') ?>"></span><span class="short <?php if (!$server['Server']['push'] || empty($ruleDescription['push'])) echo "hidden"; ?>" data-toggle="popover" title="Distribution List" data-content="<?= $ruleDescription['push'] ?>"> (<?= __('Rules') ?>)</span></td>
<td><span class="<?= $server['Server']['pull']? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['pull']? __('Yes') : __('No') ?>"></span><span class="short <?php if (!$server['Server']['pull'] || empty($ruleDescription['pull'])) echo "hidden"; ?>" data-toggle="popover" title="Distribution List" data-content="<?= $ruleDescription['pull'] ?>"> (<?= __('Rules') ?>)</span></td>
<td class="short"><span class="<?= $server['Server']['push_sightings'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['push_sightings'] ? __('Yes') : __('No'); ?>"></span></td>
<td class="short"><span class="<?= $server['Server']['push_galaxy_clusters'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['push_galaxy_clusters'] ? __('Yes') : __('No'); ?>"></span></td>
<td class="short"><span class="<?= $server['Server']['pull_galaxy_clusters'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['pull_galaxy_clusters'] ? __('Yes') : __('No'); ?>"></span></td>
2019-01-20 10:19:05 +01:00
<td>
<?php
if ($server['Server']['caching_enabled']) {
if (!empty($server['Server']['cache_timestamp'])) {
$units = array('m', 'h', 'd');
$intervals = array(60, 60, 24);
$unit = 's';
$last = time() - $server['Server']['cache_timestamp'];
foreach ($units as $k => $v) {
if ($last > $intervals[$k]) {
$unit = $v;
$last = floor($last / $intervals[$k]);
} else {
break;
}
}
echo sprintf(
2021-01-07 18:05:10 +01:00
'<span class="blue bold">%s</span> %s',
__('Age: %s%s', $last, $unit),
'<span class="fa fa-check"></span>'
2019-01-20 10:19:05 +01:00
);
} else {
echo sprintf(
'<span class="red bold">%s</span> %s',
__('Not cached'),
2021-01-07 18:05:10 +01:00
'<span class="fa fa-check"></span>'
2019-01-20 10:19:05 +01:00
);
}
} else {
2021-01-07 18:05:10 +01:00
echo '<span class="fa fa-times" role="img" aria-label="' . __('No') . '"></span>';
2019-01-20 10:19:05 +01:00
}
?>
</td>
2021-01-07 18:05:10 +01:00
<td class="short"><span class="<?= $server['Server']['unpublish_event'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['unpublish_event'] ? __('Yes') : __('No'); ?>"></span></td>
<td class="short"><span class="<?= $server['Server']['publish_without_email'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['publish_without_email'] ? __('Yes') : __('No'); ?>"></span></td>
<td><?php echo h($server['Server']['url']); ?></td>
2020-08-17 15:59:27 +02:00
<td><a href="<?php echo $baseurl . "/organisations/view/" . h($server['RemoteOrg']['id']); ?>"><?php echo h($server['RemoteOrg']['name']); ?></a></td>
2021-01-07 18:05:10 +01:00
<td class="short"><?php echo h($server['Server']['cert_file']); ?></td>
<td class="short"><?php echo h($server['Server']['client_cert_file']); ?></td>
<td class="short"><span class="<?= $server['Server']['self_signed'] ? 'fa fa-check' : 'fa fa-times'; ?>" role="img" aria-label="<?= $server['Server']['self_signed'] ? __('Yes') : __('No'); ?>"></span></td>
<td class="short"><span class="<?= $server['Server']['skip_proxy'] ? 'fa fa-check' : 'fa fa-times'; ?>" role="img" aria-label="<?= $server['Server']['skip_proxy'] ? __('Yes') : __('No'); ?>"></span></td>
2020-08-17 15:59:27 +02:00
<td class="short"><a href="<?php echo $baseurl . "/organisations/view/" . h($server['Organisation']['id']); ?>"><?php echo h($server['Organisation']['name']); ?></a></td>
2018-07-20 09:29:50 +02:00
<td class="short action-links">
<?php
Accessibility: added roles and aria labels for many icons and icon links (server list, tags, users, roles, attributes, ...)
There is still much work to be done. But we are on the road.
Ideally, and in order to avoid code dupplicates, we should have some utility functions to generate a proper and accessible yes/no icon, an accessible icon link, etc. This would prevent the code from being filled with "aria-label" tags, since the "title" and "aria-label" properties are nearly always the same.
2019-04-02 15:31:34 +02:00
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/previewIndex/' . h($server['Server']['id']), __('Explore'), __('Explore'), 'fa fa-search');
2019-03-23 11:18:22 +01:00
if ($server['Server']['pull']) {
Accessibility: added roles and aria labels for many icons and icon links (server list, tags, users, roles, attributes, ...)
There is still much work to be done. But we are on the road.
Ideally, and in order to avoid code dupplicates, we should have some utility functions to generate a proper and accessible yes/no icon, an accessible icon link, etc. This would prevent the code from being filled with "aria-label" tags, since the "title" and "aria-label" properties are nearly always the same.
2019-04-02 15:31:34 +02:00
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/pull/' . h($server['Server']['id']) . '/update', __('Pull updates to events that already exist locally'), __('Pull updates'), 'fa fa-sync');
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/pull/' . h($server['Server']['id']) . '/full', __('Pull all'), __('Pull all'), 'fa fa-arrow-circle-down');
2019-03-23 11:18:22 +01:00
}
2020-11-12 11:26:37 +01:00
if ($server['Server']['pull'] && $server['Server']['pull_galaxy_clusters']) {
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/pull/' . h($server['Server']['id']) . '/pull_relevant_clusters', __('Pull known relevant custom clusters'), __('Pull relevant clusters'), 'fa fa-tags');
2020-06-25 15:01:54 +02:00
}
2019-11-26 19:40:49 +01:00
if ($server['Server']['push'] || $server['Server']['push_sightings']) {
Accessibility: added roles and aria labels for many icons and icon links (server list, tags, users, roles, attributes, ...)
There is still much work to be done. But we are on the road.
Ideally, and in order to avoid code dupplicates, we should have some utility functions to generate a proper and accessible yes/no icon, an accessible icon link, etc. This would prevent the code from being filled with "aria-label" tags, since the "title" and "aria-label" properties are nearly always the same.
2019-04-02 15:31:34 +02:00
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/push/' . h($server['Server']['id']) . '/full', __('Push all'), __('Push all'), 'fa fa-arrow-circle-up');
2019-03-23 11:18:22 +01:00
}
if ($server['Server']['caching_enabled']) {
2021-01-07 18:05:10 +01:00
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/cache/' . h($server['Server']['id']), __('Cache instance'), __('Cache instance'), 'fa fa-memory');
2019-03-23 11:18:22 +01:00
}
2021-01-07 18:05:10 +01:00
if ($isSiteAdmin) {
Accessibility: added roles and aria labels for many icons and icon links (server list, tags, users, roles, attributes, ...)
There is still much work to be done. But we are on the road.
Ideally, and in order to avoid code dupplicates, we should have some utility functions to generate a proper and accessible yes/no icon, an accessible icon link, etc. This would prevent the code from being filled with "aria-label" tags, since the "title" and "aria-label" properties are nearly always the same.
2019-04-02 15:31:34 +02:00
echo sprintf('<a href="%s" title="%s" aria-label="%s" class="%s"></a>', $baseurl . '/servers/edit/' . h($server['Server']['id']), __('Edit'), __('Edit'), 'fa fa-edit');
2021-01-07 18:05:10 +01:00
echo $this->Form->postLink('', array('action' => 'delete', $server['Server']['id']), array('class' => 'fa fa-trash', 'title' => __('Delete'), 'aria-label' => __('Delete')), __('Are you sure you want to delete #%s?', $server['Server']['id']));
2019-03-23 11:18:22 +01:00
}
2018-07-20 09:29:50 +02:00
?>
</td>
</tr>
<?php
2012-12-18 20:25:12 +01:00
endforeach; ?>
2018-07-20 09:29:50 +02:00
</table>
<p>
<?php
echo $this->Paginator->counter(array(
'format' => __('Page {:page} of {:pages}, showing {:current} records out of {:count} total, starting on record {:start}, ending on {:end}')
));
?>
</p>
<div class="pagination">
<ul>
<?php
echo $this->Paginator->prev('« ' . __('previous'), array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'prev disabled', 'escape' => false, 'disabledTag' => 'span'));
echo $this->Paginator->numbers(array('modulus' => 20, 'separator' => '', 'tag' => 'li', 'currentClass' => 'active', 'currentTag' => 'span'));
echo $this->Paginator->next(__('next') . ' »', array('tag' => 'li', 'escape' => false), null, array('tag' => 'li', 'class' => 'next disabled', 'escape' => false, 'disabledTag' => 'span'));
?>
</ul>
</div>
2012-05-22 13:58:37 +02:00
2012-04-04 20:22:22 +02:00
</div>
2016-06-04 01:10:45 +02:00
<script type="text/javascript">
2021-01-07 18:05:10 +01:00
$(function(){
2018-07-20 09:29:50 +02:00
popoverStartup();
2019-09-13 11:49:12 +02:00
$('.rearrange-up').click(function() {
moveIndexRow($(this).data('server-id'), 'up', '/servers/changePriority');
});
$('.rearrange-down').click(function() {
moveIndexRow($(this).data('server-id'), 'down', '/servers/changePriority');
});
2018-07-20 09:29:50 +02:00
});
2015-10-18 09:36:55 +02:00
</script>
2021-01-07 18:05:10 +01:00
<?= $this->element('/genericElements/SideMenu/side_menu', array('menuList' => 'sync', 'menuItem' => 'index'));