mirror of https://github.com/MISP/MISP
chg: [analyst-data:pull] Continuation implementation of pull - WiP
parent
8e6758e6f6
commit
ea88d5c7bb
|
@ -217,6 +217,14 @@ class AnalystDataController extends AppController
|
|||
return $this->RestResponse->viewData($allData, $this->response->type());
|
||||
}
|
||||
|
||||
public function indexForPull()
|
||||
{
|
||||
$this->loadModel('AnalystData');
|
||||
$allData = $this->AnalystData->indexForPull($this->Auth->user());
|
||||
|
||||
return $this->RestResponse->viewData($allData, $this->response->type());
|
||||
}
|
||||
|
||||
public function pushAnalystData()
|
||||
{
|
||||
if (!$this->Auth->user()['Role']['perm_sync'] || !$this->Auth->user()['Role']['perm_analyst_data']) {
|
||||
|
|
|
@ -222,7 +222,7 @@ class ServerSyncTool
|
|||
* @throws HttpSocketHttpException
|
||||
* @throws HttpSocketJsonException
|
||||
*/
|
||||
public function analystDataSearch(array $rules)
|
||||
public function filterAnalystDataForPush(array $rules)
|
||||
{
|
||||
if (!$this->isSupported(self::PERM_ANALYST_DATA)) {
|
||||
return [];
|
||||
|
@ -231,6 +231,21 @@ class ServerSyncTool
|
|||
return $this->post('/analyst_data/filterAnalystDataForPush', $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $rules
|
||||
* @return HttpSocketResponseExtended
|
||||
* @throws HttpSocketHttpException
|
||||
* @throws HttpSocketJsonException
|
||||
*/
|
||||
public function analystDataSearch(array $rules)
|
||||
{
|
||||
if (!$this->isSupported(self::PERM_ANALYST_DATA)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->post('/analyst_data/indexForPull', $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws HttpSocketJsonException
|
||||
* @throws HttpSocketHttpException
|
||||
|
|
|
@ -515,7 +515,6 @@ class AnalystData extends AppModel
|
|||
'Relationship' => ClassRegistry::init('Relationship'),
|
||||
];
|
||||
|
||||
|
||||
$allData = ['Note' => [], 'Opinion' => [], 'Relationship' => []];
|
||||
foreach ($allIncomingAnalystData as $model => $entries) {
|
||||
$incomingAnalystData = $entries;
|
||||
|
@ -540,6 +539,28 @@ class AnalystData extends AppModel
|
|||
return $allData;
|
||||
}
|
||||
|
||||
public function indexForPull(array $user): array
|
||||
{
|
||||
$options = [
|
||||
'recursive' => -1,
|
||||
'conditions' => [
|
||||
'AND' => [
|
||||
$this->buildConditions($user),
|
||||
]
|
||||
],
|
||||
'fields' => ['uuid', 'modified', 'locked']
|
||||
];
|
||||
$tmp = $this->getAllAnalystData('all', $options);
|
||||
$allData = [];
|
||||
foreach ($tmp as $type => $entries) {
|
||||
foreach ($entries as $i => $entry) {
|
||||
$entry = $entry[$type];
|
||||
$allData[$type][$entry['uuid']] = $entry['modified'];
|
||||
}
|
||||
}
|
||||
return $allData;
|
||||
}
|
||||
|
||||
/**
|
||||
* getAllAnalystData Collect all analyst data regardless if they are notes, opinions or relationships
|
||||
*
|
||||
|
@ -549,10 +570,11 @@ class AnalystData extends AppModel
|
|||
public function getAllAnalystData($findType='all', array $findOptions=[]): array
|
||||
{
|
||||
$allData = [];
|
||||
$this->Note = ClassRegistry::init('Note');
|
||||
$this->Opinion = ClassRegistry::init('Opinion');
|
||||
$this->Relationship = ClassRegistry::init('Relationship');
|
||||
$validModels = [$this->Note, $this->Opinion, $this->Relationship];
|
||||
$validModels = [
|
||||
'Note' => ClassRegistry::init('Note'),
|
||||
'Opinion' => ClassRegistry::init('Opinion'),
|
||||
'Relationship' => ClassRegistry::init('Relationship'),
|
||||
];
|
||||
foreach ($validModels as $model) {
|
||||
$result = $model->find($findType, $findOptions);
|
||||
$allData[$model->alias] = $result;
|
||||
|
|
|
@ -679,7 +679,7 @@ class Server extends AppModel
|
|||
}
|
||||
|
||||
$change = sprintf(
|
||||
'%s events, %s proposals, %s sightings, %s galaxy clusters and %s pulled or updated. %s events failed or didn\'t need an update.',
|
||||
'%s events, %s proposals, %s sightings, %s galaxy clusters and %s analyst data pulled or updated. %s events failed or didn\'t need an update.',
|
||||
count($successes),
|
||||
$pulledProposals,
|
||||
$pulledSightings,
|
||||
|
|
Loading…
Reference in New Issue