mirror of https://github.com/MISP/MISP
Merge pull request #6417 from JakubOnderka/fetch-event-optimisation
Fetch event optimisationpull/6432/head
commit
2a9feb7cd3
|
@ -1082,6 +1082,7 @@ class EventsController extends AppController
|
||||||
$conditions['includeAllTags'] = true;
|
$conditions['includeAllTags'] = true;
|
||||||
$conditions['includeGranularCorrelations'] = 1;
|
$conditions['includeGranularCorrelations'] = 1;
|
||||||
$conditions['includeEventCorrelations'] = false;
|
$conditions['includeEventCorrelations'] = false;
|
||||||
|
$conditions['noEventReports'] = true; // event reports for view are loaded dynamically
|
||||||
if (!empty($filters['includeRelatedTags'])) {
|
if (!empty($filters['includeRelatedTags'])) {
|
||||||
$this->set('includeRelatedTags', 1);
|
$this->set('includeRelatedTags', 1);
|
||||||
$conditions['includeRelatedTags'] = 1;
|
$conditions['includeRelatedTags'] = 1;
|
||||||
|
@ -1504,7 +1505,8 @@ class EventsController extends AppController
|
||||||
$this->set('advancedFilteringActive', $advancedFiltering['active'] ? 1 : 0);
|
$this->set('advancedFilteringActive', $advancedFiltering['active'] ? 1 : 0);
|
||||||
$this->set('advancedFilteringActiveRules', $advancedFiltering['activeRules']);
|
$this->set('advancedFilteringActiveRules', $advancedFiltering['activeRules']);
|
||||||
$this->set('defaultFilteringRules', $this->defaultFilteringRules);
|
$this->set('defaultFilteringRules', $this->defaultFilteringRules);
|
||||||
$this->set('mitreAttackGalaxyId', $this->Event->GalaxyCluster->Galaxy->getMitreAttackGalaxyId());
|
$this->loadModel('Galaxy');
|
||||||
|
$this->set('mitreAttackGalaxyId', $this->Galaxy->getMitreAttackGalaxyId());
|
||||||
$this->set('modificationMapCSV', $modificationMapCSV);
|
$this->set('modificationMapCSV', $modificationMapCSV);
|
||||||
$this->set('title_for_layout', __('Event #%s', $event['Event']['id']));
|
$this->set('title_for_layout', __('Event #%s', $event['Event']['id']));
|
||||||
}
|
}
|
||||||
|
@ -1523,6 +1525,7 @@ class EventsController extends AppController
|
||||||
$conditions['includeAttachments'] = true;
|
$conditions['includeAttachments'] = true;
|
||||||
} else {
|
} else {
|
||||||
$conditions['includeAllTags'] = true;
|
$conditions['includeAllTags'] = true;
|
||||||
|
$conditions['noEventReports'] = true; // event reports for view are loaded dynamically
|
||||||
}
|
}
|
||||||
$deleted = 0;
|
$deleted = 0;
|
||||||
if (isset($this->params['named']['deleted'])) {
|
if (isset($this->params['named']['deleted'])) {
|
||||||
|
|
|
@ -59,8 +59,6 @@ class Event extends AppModel
|
||||||
0 => 'Your organisation only', 1 => 'This community only', 2 => 'Connected communities', 3 => 'All communities', 4 => 'Sharing group'
|
0 => 'Your organisation only', 1 => 'This community only', 2 => 'Connected communities', 3 => 'All communities', 4 => 'Sharing group'
|
||||||
);
|
);
|
||||||
|
|
||||||
private $__fTool = false;
|
|
||||||
|
|
||||||
public $shortDist = array(0 => 'Organisation', 1 => 'Community', 2 => 'Connected', 3 => 'All', 4 => ' sharing Group');
|
public $shortDist = array(0 => 'Organisation', 1 => 'Community', 2 => 'Connected', 3 => 'All', 4 => ' sharing Group');
|
||||||
|
|
||||||
public $export_types = array(
|
public $export_types = array(
|
||||||
|
@ -1963,20 +1961,16 @@ class Event extends AppModel
|
||||||
'includeFeedCorrelations',
|
'includeFeedCorrelations',
|
||||||
'includeServerCorrelations',
|
'includeServerCorrelations',
|
||||||
'includeWarninglistHits',
|
'includeWarninglistHits',
|
||||||
|
'noEventReports', // do not include event report in event data
|
||||||
|
'noShadowAttributes', // do not fetch proposals
|
||||||
);
|
);
|
||||||
if (!isset($options['excludeLocalTags']) && !empty($user['Role']['perm_sync']) && empty($user['Role']['perm_site_admin'])) {
|
if (!isset($options['excludeLocalTags']) && !empty($user['Role']['perm_sync']) && empty($user['Role']['perm_site_admin'])) {
|
||||||
$options['excludeLocalTags'] = 1;
|
$options['excludeLocalTags'] = 1;
|
||||||
}
|
}
|
||||||
if (!isset($options['excludeGalaxy']) || !$options['excludeGalaxy']) {
|
|
||||||
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
|
|
||||||
}
|
|
||||||
if (!empty($options['includeDecayScore'])) {
|
|
||||||
$this->DecayingModel = ClassRegistry::init('DecayingModel');
|
|
||||||
}
|
|
||||||
if (!isset($options['includeEventCorrelations'])) {
|
if (!isset($options['includeEventCorrelations'])) {
|
||||||
$options['includeEventCorrelations'] = true;
|
$options['includeEventCorrelations'] = true;
|
||||||
}
|
}
|
||||||
foreach ($possibleOptions as &$opt) {
|
foreach ($possibleOptions as $opt) {
|
||||||
if (!isset($options[$opt])) {
|
if (!isset($options[$opt])) {
|
||||||
$options[$opt] = false;
|
$options[$opt] = false;
|
||||||
}
|
}
|
||||||
|
@ -2021,10 +2015,9 @@ class Event extends AppModel
|
||||||
}
|
}
|
||||||
$conditionsAttributes = array();
|
$conditionsAttributes = array();
|
||||||
$conditionsObjects = array();
|
$conditionsObjects = array();
|
||||||
$conditionsObjectReferences = array();
|
|
||||||
$conditionsEventReport = array();
|
$conditionsEventReport = array();
|
||||||
|
|
||||||
if (isset($options['flatten']) && $options['flatten']) {
|
if ($options['flatten']) {
|
||||||
$flatten = true;
|
$flatten = true;
|
||||||
} else {
|
} else {
|
||||||
$flatten = false;
|
$flatten = false;
|
||||||
|
@ -2191,7 +2184,6 @@ class Event extends AppModel
|
||||||
$fieldsShadowAtt = array('ShadowAttribute.id', 'ShadowAttribute.type', 'ShadowAttribute.category', 'ShadowAttribute.value', 'ShadowAttribute.to_ids', 'ShadowAttribute.uuid', 'ShadowAttribute.event_uuid', 'ShadowAttribute.event_id', 'ShadowAttribute.old_id', 'ShadowAttribute.comment', 'ShadowAttribute.org_id', 'ShadowAttribute.proposal_to_delete', 'ShadowAttribute.timestamp', 'ShadowAttribute.first_seen', 'ShadowAttribute.last_seen');
|
$fieldsShadowAtt = array('ShadowAttribute.id', 'ShadowAttribute.type', 'ShadowAttribute.category', 'ShadowAttribute.value', 'ShadowAttribute.to_ids', 'ShadowAttribute.uuid', 'ShadowAttribute.event_uuid', 'ShadowAttribute.event_id', 'ShadowAttribute.old_id', 'ShadowAttribute.comment', 'ShadowAttribute.org_id', 'ShadowAttribute.proposal_to_delete', 'ShadowAttribute.timestamp', 'ShadowAttribute.first_seen', 'ShadowAttribute.last_seen');
|
||||||
$fieldsOrg = array('id', 'name', 'uuid', 'local');
|
$fieldsOrg = array('id', 'name', 'uuid', 'local');
|
||||||
$fieldsEventReport = array('*');
|
$fieldsEventReport = array('*');
|
||||||
$sharingGroupData = $this->__cacheSharingGroupData($user, $useCache);
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'conditions' => $conditions,
|
'conditions' => $conditions,
|
||||||
'recursive' => 0,
|
'recursive' => 0,
|
||||||
|
@ -2243,6 +2235,12 @@ class Event extends AppModel
|
||||||
if ($flatten) {
|
if ($flatten) {
|
||||||
unset($params['contain']['Object']);
|
unset($params['contain']['Object']);
|
||||||
}
|
}
|
||||||
|
if ($options['noEventReports']) {
|
||||||
|
unset($params['contain']['EventReport']);
|
||||||
|
}
|
||||||
|
if ($options['noShadowAttributes']) {
|
||||||
|
unset($params['contain']['ShadowAttribute']);
|
||||||
|
}
|
||||||
if ($options['metadata']) {
|
if ($options['metadata']) {
|
||||||
unset($params['contain']['Attribute']);
|
unset($params['contain']['Attribute']);
|
||||||
unset($params['contain']['ShadowAttribute']);
|
unset($params['contain']['ShadowAttribute']);
|
||||||
|
@ -2254,6 +2252,15 @@ class Event extends AppModel
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sharingGroupData = $this->__cacheSharingGroupData($user, $useCache);
|
||||||
|
|
||||||
|
// Initialize classes that will be necessary during event fetching
|
||||||
|
if ((empty($options['metadata']) && empty($options['noSightings'])) && !isset($this->Sighting)) {
|
||||||
|
$this->Sighting = ClassRegistry::init('Sighting');
|
||||||
|
}
|
||||||
|
if (!empty($options['includeDecayScore']) && !isset($this->DecayingModel)) {
|
||||||
|
$this->DecayingModel = ClassRegistry::init('DecayingModel');
|
||||||
|
}
|
||||||
if (($options['includeFeedCorrelations'] || $options['includeServerCorrelations']) && !isset($this->Feed)) {
|
if (($options['includeFeedCorrelations'] || $options['includeServerCorrelations']) && !isset($this->Feed)) {
|
||||||
$this->Feed = ClassRegistry::init('Feed');
|
$this->Feed = ClassRegistry::init('Feed');
|
||||||
}
|
}
|
||||||
|
@ -2457,7 +2464,6 @@ class Event extends AppModel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (empty($options['metadata']) && empty($options['noSightings'])) {
|
if (empty($options['metadata']) && empty($options['noSightings'])) {
|
||||||
$this->Sighting = ClassRegistry::init('Sighting');
|
|
||||||
$event['Sighting'] = $this->Sighting->attachToEvent($event, $user);
|
$event['Sighting'] = $this->Sighting->attachToEvent($event, $user);
|
||||||
}
|
}
|
||||||
if ($options['includeSightingdb']) {
|
if ($options['includeSightingdb']) {
|
||||||
|
@ -2572,6 +2578,10 @@ class Event extends AppModel
|
||||||
'eventsExtendingUuid' => $event['Event']['uuid'],
|
'eventsExtendingUuid' => $event['Event']['uuid'],
|
||||||
'includeEventCorrelations' => $options['includeEventCorrelations'],
|
'includeEventCorrelations' => $options['includeEventCorrelations'],
|
||||||
'includeWarninglistHits' => $options['includeWarninglistHits'],
|
'includeWarninglistHits' => $options['includeWarninglistHits'],
|
||||||
|
'noShadowAttributes' => $options['noShadowAttributes'],
|
||||||
|
'noEventReports' => $options['noEventReports'],
|
||||||
|
'noSightings' => isset($options['noSightings']) ? $options['noSightings'] : null,
|
||||||
|
'sgReferenceOnly' => $options['sgReferenceOnly'],
|
||||||
]);
|
]);
|
||||||
foreach ($extensions as $extensionEvent) {
|
foreach ($extensions as $extensionEvent) {
|
||||||
$eventMeta = array(
|
$eventMeta = array(
|
||||||
|
@ -2588,6 +2598,10 @@ class Event extends AppModel
|
||||||
foreach ($thingsToMerge as $thingToMerge) {
|
foreach ($thingsToMerge as $thingToMerge) {
|
||||||
$event[$thingToMerge] = array_merge($event[$thingToMerge], $extensionEvent[$thingToMerge]);
|
$event[$thingToMerge] = array_merge($event[$thingToMerge], $extensionEvent[$thingToMerge]);
|
||||||
}
|
}
|
||||||
|
// Merge event reports if requested
|
||||||
|
if (!$options['noEventReports']) {
|
||||||
|
$event['EventReport'] = array_merge($event['EventReport'], $extensionEvent['EventReport']);
|
||||||
|
}
|
||||||
// Merge just tags that are not already in main event
|
// Merge just tags that are not already in main event
|
||||||
foreach ($extensionEvent['EventTag'] as $eventTag) {
|
foreach ($extensionEvent['EventTag'] as $eventTag) {
|
||||||
foreach ($event['EventTag'] as $eT) {
|
foreach ($event['EventTag'] as $eT) {
|
||||||
|
@ -6175,11 +6189,12 @@ class Event extends AppModel
|
||||||
public function massageTags($data, $dataType = 'Event', $excludeGalaxy = false, $cullGalaxyTags = false)
|
public function massageTags($data, $dataType = 'Event', $excludeGalaxy = false, $cullGalaxyTags = false)
|
||||||
{
|
{
|
||||||
$data['Galaxy'] = array();
|
$data['Galaxy'] = array();
|
||||||
if (empty($this->GalaxyCluster)) {
|
|
||||||
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
|
|
||||||
}
|
|
||||||
// unset empty event tags that got added because the tag wasn't exportable
|
// unset empty event tags that got added because the tag wasn't exportable
|
||||||
if (!empty($data[$dataType . 'Tag'])) {
|
if (!empty($data[$dataType . 'Tag'])) {
|
||||||
|
if (!isset($this->GalaxyCluster)) {
|
||||||
|
$this->GalaxyCluster = ClassRegistry::init('GalaxyCluster');
|
||||||
|
}
|
||||||
foreach ($data[$dataType . 'Tag'] as $k => &$dataTag) {
|
foreach ($data[$dataType . 'Tag'] as $k => &$dataTag) {
|
||||||
if (empty($dataTag['Tag'])) {
|
if (empty($dataTag['Tag'])) {
|
||||||
unset($data[$dataType . 'Tag'][$k]);
|
unset($data[$dataType . 'Tag'][$k]);
|
||||||
|
|
Loading…
Reference in New Issue