mirror of https://github.com/MISP/MISP
new: [settings] added setting to (temporarily) disable the loading of sightings via the API
- affected endpoints: restsearch and /events/view - temporarily skips the loading of sightings - helps alleviate absolutely massive sighting data sets from killing server performance - temporary measure, doesn't prevent the creation of sightings / viewing of sightings via the UIpull/9615/head
parent
661b238b3f
commit
3c79ebbc06
|
@ -1406,14 +1406,13 @@ class Event extends AppModel
|
|||
return $this->delete(null, false);
|
||||
}
|
||||
|
||||
public function createEventConditions($user)
|
||||
public function createEventConditions($user, $skip_own_event_rule = false)
|
||||
{
|
||||
$conditions = array();
|
||||
if (!$user['Role']['perm_site_admin']) {
|
||||
$sgids = $this->SharingGroup->authorizedIds($user);
|
||||
$unpublishedPrivate = Configure::read('MISP.unpublishedprivate');
|
||||
$conditions['AND']['OR'] = [
|
||||
'Event.org_id' => $user['org_id'],
|
||||
[
|
||||
'AND' => [
|
||||
'Event.distribution >' => 0,
|
||||
|
@ -1429,6 +1428,9 @@ class Event extends AppModel
|
|||
]
|
||||
]
|
||||
];
|
||||
if (!$skip_own_event_rule) {
|
||||
$conditions['AND']['OR'][] = ['Event.org_id' => $user['org_id']];
|
||||
}
|
||||
}
|
||||
return $conditions;
|
||||
}
|
||||
|
@ -2279,7 +2281,9 @@ class Event extends AppModel
|
|||
$event['EventReport'] = $this->__attachSharingGroups($event['EventReport'], $sharingGroupData);
|
||||
}
|
||||
if (empty($options['metadata']) && empty($options['noSightings'])) {
|
||||
$event['Sighting'] = $this->Sighting->attachToEvent($event, $user);
|
||||
if (empty(Configure::read('MISP.disable_sighting_loading'))) {
|
||||
$event['Sighting'] = $this->Sighting->attachToEvent($event, $user);
|
||||
}
|
||||
}
|
||||
if ($options['includeSightingdb']) {
|
||||
$this->Sightingdb = ClassRegistry::init('Sightingdb');
|
||||
|
|
|
@ -5123,6 +5123,14 @@ class Server extends AppModel
|
|||
'type' => 'numeric',
|
||||
'null' => true
|
||||
),
|
||||
'disable_sighting_loading' => [
|
||||
'level' => 1,
|
||||
'description' => __('If an instance has an extremely high number of sightings, including the sightings in the search algorithms can bring an instance to a grinding halt. Enable this setting to temporarily disable the search until the issue is remedied. This setting will also disable sightings from being attached via /events/view API calls.'),
|
||||
'value' => false,
|
||||
'test' => 'testBoolFalse',
|
||||
'type' => 'boolean',
|
||||
'null' => true
|
||||
],
|
||||
'disable_event_locks' => [
|
||||
'level' => 1,
|
||||
'description' => __('Disable the event locks that are executed periodically when a user browses an event view. It can be useful to leave event locks enabled to warn users that someone else is editing the same event, but generally it\'s extremely verbose and can cause issues in certain setups, so it\'s recommended to disable this.'),
|
||||
|
|
|
@ -1136,34 +1136,37 @@ class Sighting extends AppModel
|
|||
$tmpfile->write($exportTool->header($exportToolParams));
|
||||
$separator = $exportTool->separator($exportToolParams);
|
||||
|
||||
// fetch sightings matching the query without ACL checks
|
||||
if (!empty($conditions['Sighting.event_id']) && is_array($conditions['Sighting.event_id'])) {
|
||||
$conditions_copy = $conditions;
|
||||
$sightingIds = [];
|
||||
foreach ($conditions['Sighting.event_id'] as $e_id) {
|
||||
$conditions_copy['Sighting.event_id'] = $e_id;
|
||||
$tempIds = $this->find('column', [
|
||||
|
||||
if (empty(Configure::read('MISP.disable_sighting_loading'))) {
|
||||
// fetch sightings matching the query without ACL checks
|
||||
if (!empty($conditions['Sighting.event_id']) && is_array($conditions['Sighting.event_id'])) {
|
||||
$conditions_copy = $conditions;
|
||||
$sightingIds = [];
|
||||
foreach ($conditions['Sighting.event_id'] as $e_id) {
|
||||
$conditions_copy['Sighting.event_id'] = $e_id;
|
||||
$tempIds = $this->find('column', [
|
||||
'conditions' => $conditions,
|
||||
'fields' => ['Sighting.id'],
|
||||
'contain' => $contain
|
||||
]);
|
||||
if (!empty($tempIds)) {
|
||||
$sightingIds = array_merge($sightingIds, $tempIds);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sightingIds = $this->find('column', [
|
||||
'conditions' => $conditions,
|
||||
'fields' => ['Sighting.id'],
|
||||
'contain' => $contain
|
||||
]);
|
||||
if (!empty($tempIds)) {
|
||||
$sightingIds = array_merge($sightingIds, $tempIds);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$sightingIds = $this->find('column', [
|
||||
'conditions' => $conditions,
|
||||
'fields' => ['Sighting.id'],
|
||||
'contain' => $contain
|
||||
]);
|
||||
}
|
||||
|
||||
foreach (array_chunk($sightingIds, 500) as $chunk) {
|
||||
// fetch sightings with ACL checks and sighting policies
|
||||
$sightings = $this->getSightings($user, $chunk, $includeEvent, $includeAttribute, $includeUuid);
|
||||
foreach ($sightings as $sighting) {
|
||||
$tmpfile->writeWithSeparator($exportTool->handler($sighting, $exportToolParams), $separator);
|
||||
|
||||
foreach (array_chunk($sightingIds, 500) as $chunk) {
|
||||
// fetch sightings with ACL checks and sighting policies
|
||||
$sightings = $this->getSightings($user, $chunk, $includeEvent, $includeAttribute, $includeUuid);
|
||||
foreach ($sightings as $sighting) {
|
||||
$tmpfile->writeWithSeparator($exportTool->handler($sighting, $exportToolParams), $separator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue