mirror of https://github.com/MISP/MISP
Merge branch 'develop' of github.com:MISP/MISP into develop
commit
e60fe35e0a
|
@ -1490,7 +1490,6 @@ class EventsController extends AppController
|
|||
$containsProposals = true;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($event['Object'] as $k => $object) {
|
||||
$modDate = date("Y-m-d", $object['timestamp']);
|
||||
$modificationMap[$modDate] = !isset($modificationMap[$modDate])? 1 : $modificationMap[$modDate] + 1;
|
||||
|
@ -1522,7 +1521,6 @@ class EventsController extends AppController
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($containsProposals && $this->__canPublishEvent($event, $user)) {
|
||||
$mess = $this->Session->read('Message');
|
||||
if (empty($mess)) {
|
||||
|
@ -1696,8 +1694,8 @@ class EventsController extends AppController
|
|||
}
|
||||
|
||||
$namedParams = $this->request->params['named'];
|
||||
$conditions['includeAnalystData'] = true;
|
||||
if ($this->_isRest()) {
|
||||
$conditions['includeAnalystData'] = true;
|
||||
$conditions['includeAttachments'] = isset($namedParams['includeAttachments']) ? $namedParams['includeAttachments'] : true;
|
||||
} else {
|
||||
$conditions['includeAllTags'] = true;
|
||||
|
|
|
@ -76,7 +76,7 @@ class AnalystDataBehavior extends ModelBehavior
|
|||
]);
|
||||
$results = [];
|
||||
foreach ($temp as $result) {
|
||||
$results[$result[$type]['object_uuid']] = $result;
|
||||
$results[$result[$type]['object_uuid']][$type][] = $result[$type];
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
|
|
@ -38,10 +38,31 @@ class AnalystDataParentBehavior extends ModelBehavior
|
|||
return $data;
|
||||
}
|
||||
|
||||
public function fetchAnalystDataBulk(Model $model, array $uuids, array $types = ['Note', 'Opinion', 'Relationship']) {
|
||||
$uuids = array_chunk($uuids, 10000);
|
||||
if (empty($this->__currentUser)) {
|
||||
$user_id = Configure::read('CurrentUserId');
|
||||
$this->User = ClassRegistry::init('User');
|
||||
if ($user_id) {
|
||||
$this->__currentUser = $this->User->getAuthUser($user_id);
|
||||
}
|
||||
}
|
||||
$results = [];
|
||||
foreach ($uuids as $uuid_chunk) {
|
||||
foreach ($types as $type) {
|
||||
$this->{$type} = ClassRegistry::init($type);
|
||||
$this->{$type}->fetchRecursive = !empty($model->includeAnalystDataRecursive);
|
||||
$temp = $this->{$type}->fetchForUuids($uuid_chunk, $this->__currentUser);
|
||||
$results = array_merge($results, $temp);
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function attachAnalystDataBulk(Model $model, array $objects, array $types = ['Note', 'Opinion', 'Relationship'])
|
||||
{
|
||||
$uuids = [];
|
||||
$objects = array_chunk($objects, 10000);
|
||||
$objects = array_chunk($objects, 10000, true);
|
||||
if (empty($this->__currentUser)) {
|
||||
$user_id = Configure::read('CurrentUserId');
|
||||
$this->User = ClassRegistry::init('User');
|
||||
|
|
|
@ -5587,6 +5587,7 @@ class Event extends AppModel
|
|||
$passedArgs['page'] = 0;
|
||||
}
|
||||
$params = $customPagination->applyRulesOnArray($objects, $passedArgs, 'events', 'category');
|
||||
$objects = $this->attachAnalystDataToViewObjects($objects);
|
||||
foreach ($objects as $k => $object) {
|
||||
if (isset($referencedByArray[$object['uuid']])) {
|
||||
foreach ($referencedByArray[$object['uuid']] as $objectType => $references) {
|
||||
|
@ -5599,6 +5600,44 @@ class Event extends AppModel
|
|||
return $params;
|
||||
}
|
||||
|
||||
// take a list of paginated, rearranged objects from the event view generation's viewUI() function
|
||||
// collect all attribute and object uuids from the object list
|
||||
// fetch the related analyst data and inject them back into the object list
|
||||
public function attachAnalystDataToViewObjects($objects)
|
||||
{
|
||||
$attribute_notes = [];
|
||||
$object_notes = [];
|
||||
foreach ($objects as $k => $object) {
|
||||
if ($object['objectType'] === 'object') {
|
||||
$object_notes[] = $object['uuid'];
|
||||
foreach ($object['Attribute'] as $a) {
|
||||
$attribute_notes[] = $a['uuid'];
|
||||
}
|
||||
} else if ($object['objectType'] === 'attribute') {
|
||||
$attribute_notes[] = $object['uuid'];
|
||||
}
|
||||
}
|
||||
$attribute_notes = $this->Attribute->fetchAnalystDataBulk($attribute_notes);
|
||||
$object_notes = $this->Object->fetchAnalystDataBulk($object_notes);
|
||||
foreach ($objects as $k => $object) {
|
||||
if ($object['objectType'] === 'object') {
|
||||
if (!empty($object_notes[$object['uuid']])) {
|
||||
$objects[$k] = array_merge($object, $object_notes[$object['uuid']]);
|
||||
}
|
||||
foreach ($object['Attribute'] as $k2 => $a) {
|
||||
if (!empty($attribute_notes[$a['uuid']])) {
|
||||
$objects[$k]['Attribute'][$k2] = array_merge($a, $attribute_notes[$a['uuid']]);
|
||||
}
|
||||
}
|
||||
} else if ($object['objectType'] === 'attribute') {
|
||||
if (!empty($attribute_notes[$object['uuid']])) {
|
||||
$objects[$k] = array_merge($object, $attribute_notes[$object['uuid']]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $objects;
|
||||
}
|
||||
|
||||
// pass along a json from the server filter rules
|
||||
// returns a conditions set to be merged into pagination / event fetch / etc
|
||||
public function filterRulesToConditions($rules)
|
||||
|
|
Loading…
Reference in New Issue