Quick & Dirty 'without_email' & 'Unpublish_event' options for Sync Server

pull/1809/head
devnull- 2017-01-05 16:43:22 +01:00
parent d500f8682d
commit 4795c86295
7 changed files with 57 additions and 15 deletions

View File

@ -286,7 +286,7 @@ class ServersController extends AppController {
}
if (!$fail) {
// say what fields are to be updated
$fieldList = array('id', 'url', 'push', 'pull', 'remote_org_id', 'name' ,'self_signed', 'cert_file', 'client_cert_file', 'push_rules', 'pull_rules', 'internal');
$fieldList = array('id', 'url', 'push', 'pull', 'unpublish_event', 'publish_without_email', 'remote_org_id', 'name' ,'self_signed', 'cert_file', 'client_cert_file', 'push_rules', 'pull_rules', 'internal');
$this->request->data['Server']['id'] = $id;
if ("" != $this->request->data['Server']['authkey']) $fieldList[] = 'authkey';
if ($this->request->data['Server']['organisation_type'] < 2) $this->request->data['Server']['remote_org_id'] = $json['id'];

View File

@ -722,7 +722,13 @@ class Event extends AppModel {
$event['Event']['orgc'] = $event['Orgc']['name'];
$event['mangle'] = true;
} else return 'Trying to push to an outdated instance.';
}
}
$unpublish_event = $server['Server']['unpublish_event'];
// $publish_without_email = $server['Server']['publish_without_email'];
// if ($publish_without_email) {
if ($unpublish_event) {
$event['Event']['published'] = 0;
}
$updated = null;
$newLocation = $newTextBody = '';
$result = $this->restfulEventToServer($event, $server, null, $newLocation, $newTextBody, $HttpSocket);
@ -2008,7 +2014,7 @@ class Event extends AppModel {
if ($fromXml) $created_id = $this->id;
if (!empty($data['Event']['published']) && 1 == $data['Event']['published']) {
// do the necessary actions to publish the event (email, upload,...)
if ('true' != Configure::read('MISP.disablerestalert')) {
if (('true' != Configure::read('MISP.disablerestalert')) && ('0' == $server['Server']['unpublish_event'])) {
$this->sendAlertEmailRouter($this->getID(), $user);
}
$this->publish($this->getID(), $passAlong);

View File

@ -160,8 +160,10 @@ var formInfoValues = {
'ServerOrganization' : "The organization having the external server you want to sync with. Example: BE",
'ServerAuthkey' : "You can find the authentication key on your profile on the external server.",
'ServerPush' : "Allow the upload of events and their attributes.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerSubmittedCert' : "You can also upload a certificate file if the instance you are trying to connect to has its own signing authority.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerUnpublishEvent' : 'Unpublish new event (working with Push event).',
'ServerPublishWithoutEmail' : 'Publish new event without email (working with Pull event).',
'ServerSubmittedCert' : "You can also upload a certificate file if the instance you are trying to connect to has its own signing authority.",
'ServerSelfSigned' : "Click this, if you would like to allow a connection despite the other instance using a self-signed certificate (not recommended)."
};

View File

@ -402,7 +402,9 @@ In order to share data with a remote server via pushes and pulls, you need to re
<li><b>Authkey:</b> The authentication key that you have received from the hosting organisation of the remote instance.</li>
<li><b>Push:</b> This check-box controls whether your server is allowed to push to the remote instance.</li>
<li><b>Pull:</b> This check-box controls whether your server can request to pull all data from the remote instance.</li>
<li><b>Self Signed:</b> Ticking this checkbox will allow syncing with instances using self-signed certificates.</li>
<li><b>Unpublish event (Push only):</b> This check-box controls to unpublish new event (working with Push events).</li>
<li><b>Publish without email (Pull only):</b> This check-box controls whether your server is allowed to publish event without email (working with Pull events).</li>
<li><b>Self Signed:</b> Ticking this checkbox will allow syncing with instances using self-signed certificates.</li>
<li><b>Certificate File:</b> If the instance that you want to connect to has their entire own certificate chain, you can use this to import a .pem file with it and override CakePHP's standard root CA file.</li>
</ul>
<b>If you are an administrator</b>, trying to allow another instance to connect to your own, it is vital that two rules are followed when setting up a synchronisation account: <br />

View File

@ -70,7 +70,19 @@
echo $this->Form->input('pull', array(
));
?>
?>
<div class = "input clear"></div>
<?php
echo $this->Form->input('unpublish_event', array(
'type' => 'checkbox',
));
?>
<div class = "input clear"></div>
<?php
echo $this->Form->input('publish_without_email', array(
'type' => 'checkbox',
));
?>
<div class = "input clear"></div>
<?php
echo $this->Form->input('self_signed', array(
@ -128,7 +140,9 @@ var formInfoValues = {
'ServerOrganization' : "The organization having the external server you want to sync with. Example: BE",
'ServerAuthkey' : "You can find the authentication key on your profile on the external server.",
'ServerPush' : "Allow the upload of events and their attributes.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerUnpublishEvent' : 'Unpublish new event (working with Pull event).',
'ServerPublishWithoutEmail' : 'Publish new event without email (working with Push event).',
'ServerSubmittedCert' : "You can also upload a certificate file if the instance you are trying to connect to has its own signing authority.",
'ServerSelfSigned' : "Click this, if you would like to allow a connection despite the other instance using a self-signed certificate (not recommended)."
};
@ -159,11 +173,11 @@ $(document).ready(function() {
?>
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerSubmittedCert, #ServerSelfSigned").on('mouseleave', function(e) {
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSelfSigned").on('mouseleave', function(e) {
$('#'+e.currentTarget.id).popover('destroy');
});
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerSubmittedCert, #ServerSelfSigned").on('mouseover', function(e) {
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSelfSigned").on('mouseover', function(e) {
var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({

View File

@ -76,6 +76,18 @@
echo $this->Form->input('pull', array(
));
?>
<div class = "input clear"></div>
<?php
echo $this->Form->input('unpublish_event', array(
'type' => 'checkbox',
));
?>
<div class = "input clear"></div>
<?php
echo $this->Form->input('publish_without_email', array(
'type' => 'checkbox',
));
?>
<div class = "input clear"></div>
<?php
@ -170,7 +182,9 @@ var formInfoValues = {
'ServerName' : "A name that will make it clear to your users what this instance is. For example: Organisation A's instance",
'ServerAuthkey' : "You can find the authentication key on your profile on the external server.",
'ServerPush' : "Allow the upload of events and their attributes.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerPull' : "Allow the download of events and their attributes from the server.",
'ServerUnpublishEvent' : 'Unpublish new event (working with Push event).',
'ServerPublishWithoutEmail' : 'Publish new event without email (working with Pull event).',
'ServerSubmittedCert' : "You can also upload a certificate file if the instance you are trying to connect to has its own signing authority.",
'ServerSubmittedClientCert' : "You can also upload a client certificate file if the instance you are trying to connect requires this.",
'ServerSelfSigned' : "Click this, if you would like to allow a connection despite the other instance using a self-signed certificate (not recommended)."
@ -192,11 +206,11 @@ $(document).ready(function() {
serverOrgTypeChange();
});
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseleave', function(e) {
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseleave', function(e) {
$('#'+e.currentTarget.id).popover('destroy');
});
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseover', function(e) {
$("#ServerUrl, #ServerOrganization, #ServerName, #ServerAuthkey, #ServerPush, #ServerPull, #ServerUnpublishEvent, #ServerPublishWithoutEmail, #ServerSubmittedCert, #ServerSubmittedClientCert, #ServerSelfSigned").on('mouseover', function(e) {
var $e = $(e.target);
$('#'+e.currentTarget.id).popover('destroy');
$('#'+e.currentTarget.id).popover({

View File

@ -22,7 +22,9 @@
<th>Connection test</th>
<th><?php echo $this->Paginator->sort('internal');?></th>
<th><?php echo $this->Paginator->sort('push');?></th>
<th><?php echo $this->Paginator->sort('pull');?></th>
<th><?php echo $this->Paginator->sort('pull');?></th>
<th><?php echo $this->Paginator->sort('unpublish_event (push event)');?></th>
<th><?php echo $this->Paginator->sort('publish_without_email (pull event)');?></th>
<th><?php echo $this->Paginator->sort('url');?></th>
<th>Remote Organisation</th>
<th><?php echo $this->Paginator->sort('cert_file');?></th>
@ -67,7 +69,9 @@ foreach ($servers as $server):
<td><span class="<?php echo ($server['Server']['internal']? 'icon-ok' : 'icon-remove'); ?>" title="<?php echo ($server['Server']['internal']? 'Internal instance that ignores distribution level degradation *WARNING: Only use this setting if you have several insternal 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="<?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']); ?>&nbsp;</td>
<td class="short"><span class="<?php echo ($server['Server']['unpublish_event'] ? 'icon-ok' : 'icon-remove'); ?>"></span></td>
<td class="short"><span class="<?php echo ($server['Server']['publish_without_email'] ? 'icon-ok' : 'icon-remove'); ?>"></span></td>
<td><?php echo h($server['Server']['url']); ?>&nbsp;</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']); ?>&nbsp;</td>
<td class="short"><?php echo h($server['Server']['client_cert_file']); ?>&nbsp;</td>