mirror of https://github.com/MISP/MISP
chg: [server:sync/analyst-data] Started integration of server synchronisation - WiP
parent
ceb423ae76
commit
8cef82f1ea
|
@ -1888,6 +1888,7 @@ class ServersController extends AppController
|
|||
'perm_sync' => (bool) $user['Role']['perm_sync'],
|
||||
'perm_sighting' => (bool) $user['Role']['perm_sighting'],
|
||||
'perm_galaxy_editor' => (bool) $user['Role']['perm_galaxy_editor'],
|
||||
'perm_analyst_data' => (bool) $user['Role']['perm_analyst_data'],
|
||||
'request_encoding' => $this->CompressedRequestHandler->supportedEncodings(),
|
||||
'filter_sightings' => true, // check if Sightings::filterSightingUuidsForPush method is supported
|
||||
];
|
||||
|
|
|
@ -37,6 +37,10 @@ class MispAdminSyncTestWidget
|
|||
$colour = 'orange';
|
||||
$message .= ' ' . __('No sighting access.');
|
||||
}
|
||||
if (empty($result['info']['perm_analyst_data'])) {
|
||||
$colour = 'orange';
|
||||
$message .= ' ' . __('No analyst data sync access.');
|
||||
}
|
||||
} else {
|
||||
$colour = 'red';
|
||||
$message = $syncTestErrorCodes[$result['status']];
|
||||
|
|
|
@ -270,4 +270,22 @@ class AnalystData extends AppModel
|
|||
]);
|
||||
return array_unique(array_merge($existingRelationships, $objectRelationships));
|
||||
}
|
||||
|
||||
/**
|
||||
* Push sightings to remote server.
|
||||
* @param array $user
|
||||
* @param ServerSyncTool $serverSync
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public function pushAnalystData(array $user, array $serverSync): array
|
||||
{
|
||||
$server = $serverSync->server();
|
||||
|
||||
if (!$server['Server']['push_analyst_data']) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2088,6 +2088,9 @@ class AppModel extends Model
|
|||
|
||||
$sqlArray[] = "ALTER TABLE `roles` ADD `perm_analyst_data` tinyint(1) NOT NULL DEFAULT 0;";
|
||||
$sqlArray[] = "UPDATE `roles` SET `perm_analyst_data`=1 WHERE `perm_add` = 1;";
|
||||
|
||||
$sqlArray[] = "ALTER TABLE `servers` ADD `push_analyst_data` tinyint(1) NOT NULL DEFAULT 0 AFTER `push_galaxy_clusters`;";
|
||||
$sqlArray[] = "ALTER TABLE `servers` ADD `pull_analyst_data` tinyint(1) NOT NULL DEFAULT 0 AFTER `push_analyst_data`;";
|
||||
break;
|
||||
case 120:
|
||||
$sqlArray[] = "CREATE TABLE `collections` (
|
||||
|
|
|
@ -1227,6 +1227,20 @@ class Server extends AppModel
|
|||
} else {
|
||||
$successes = array_merge($successes, $sightingSuccesses);
|
||||
}
|
||||
|
||||
if ($push['canPush'] || $push['canEditAnalystData']) {
|
||||
$this->AnalystData = ClassRegistry::init('AnalystData');
|
||||
$analystDataSuccesses = $this->AnalystData->pushAnalystData($user, $serverSync);
|
||||
} else {
|
||||
$analystDataSuccesses = array();
|
||||
}
|
||||
|
||||
if (!isset($successes)) {
|
||||
$successes = $analystDataSuccesses;
|
||||
} else {
|
||||
$successes = array_merge($successes, $analystDataSuccesses);
|
||||
}
|
||||
|
||||
if (!isset($fails)) {
|
||||
$fails = array();
|
||||
}
|
||||
|
@ -2742,6 +2756,7 @@ class Server extends AppModel
|
|||
$canPush = isset($remoteVersion['perm_sync']) ? $remoteVersion['perm_sync'] : false;
|
||||
$canSight = isset($remoteVersion['perm_sighting']) ? $remoteVersion['perm_sighting'] : false;
|
||||
$canEditGalaxyCluster = isset($remoteVersion['perm_galaxy_editor']) ? $remoteVersion['perm_galaxy_editor'] : false;
|
||||
$canEditAnalystData = isset($remoteVersion['perm_analyst_data']) ? $remoteVersion['perm_analyst_data'] : false;
|
||||
$remoteVersionString = $remoteVersion['version'];
|
||||
$remoteVersion = explode('.', $remoteVersion['version']);
|
||||
if (!isset($remoteVersion[0])) {
|
||||
|
@ -2791,6 +2806,7 @@ class Server extends AppModel
|
|||
'response' => $response,
|
||||
'canPush' => $canPush,
|
||||
'canSight' => $canSight,
|
||||
'canEditAnalystData' => $canEditAnalystData,
|
||||
'canEditGalaxyCluster' => $canEditGalaxyCluster,
|
||||
'version' => $remoteVersion,
|
||||
'protectedMode' => $protectedMode,
|
||||
|
|
|
@ -93,6 +93,8 @@
|
|||
echo $this->Form->input('caching_enabled', array());
|
||||
echo $this->Form->input('push_galaxy_clusters', array());
|
||||
echo $this->Form->input('pull_galaxy_clusters', array());
|
||||
echo $this->Form->input('push_analyst_data', array());
|
||||
echo $this->Form->input('pull_analyst_data', array());
|
||||
echo '<div class="input clear" style="width:100%;"><hr><h4>' . __('Misc settings') . '</h4></div>';
|
||||
echo $this->Form->input('unpublish_event', array(
|
||||
'type' => 'checkbox',
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
<th><?php echo $this->Paginator->sort('push_sightings', 'Push Sightings');?></th>
|
||||
<th><?php echo $this->Paginator->sort('push_galaxy_clusters', 'Push Clusters');?></th>
|
||||
<th><?php echo $this->Paginator->sort('pull_galaxy_clusters', 'Pull Clusters');?></th>
|
||||
<th><?php echo $this->Paginator->sort('push_analyst_data', 'Push Analyst Data');?></th>
|
||||
<th><?php echo $this->Paginator->sort('pull_analyst_data', 'Pull Analyst Data');?></th>
|
||||
<th><?php echo $this->Paginator->sort('caching_enabled', 'Cache');?></th>
|
||||
<th><?php echo $this->Paginator->sort('unpublish_event');?></th>
|
||||
<th><?php echo $this->Paginator->sort('publish_without_email');?></th>
|
||||
|
@ -120,6 +122,8 @@ foreach ($servers as $server):
|
|||
<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>
|
||||
<td class="short"><span class="<?= $server['Server']['push_analyst_data'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['push_analyst_data'] ? __('Yes') : __('No'); ?>"></span></td>
|
||||
<td class="short"><span class="<?= $server['Server']['pull_analyst_data'] ? 'fa fa-check' : 'fa fa-times' ?>" role="img" aria-label="<?= $server['Server']['pull_analyst_data'] ? __('Yes') : __('No'); ?>"></span></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($server['Server']['caching_enabled']) {
|
||||
|
|
Loading…
Reference in New Issue