mirror of https://github.com/MISP/MISP
fix: [correlations] Do not fetch unnecessary data
parent
21335d7d1f
commit
f8f2e0e43d
|
@ -1704,9 +1704,6 @@ class AttributesController extends AppController
|
|||
$clusters = [];
|
||||
}
|
||||
|
||||
// Fetch correlations in one query
|
||||
$correlations = $this->Attribute->Event->getRelatedAttributes($user, $attributeIds, false, 'attribute');
|
||||
|
||||
// `attachFeedCorrelations` method expects different attribute format, so we need to transform that, then process
|
||||
// and then take information back to original attribute structure.
|
||||
$fakeEventArray = [];
|
||||
|
|
|
@ -204,7 +204,7 @@ class DefaultCorrelationBehavior extends ModelBehavior
|
|||
/**
|
||||
* Fetch correlations for given event.
|
||||
* @param array $user
|
||||
* @param int $eventId
|
||||
* @param int|array $eventId
|
||||
* @param array $sgids
|
||||
* @param bool $primary
|
||||
* @return array
|
||||
|
@ -245,7 +245,6 @@ class DefaultCorrelationBehavior extends ModelBehavior
|
|||
'contain' => [
|
||||
'CorrelationValue' => [
|
||||
'fields' => [
|
||||
'CorrelationValue.id',
|
||||
'CorrelationValue.value'
|
||||
]
|
||||
]
|
||||
|
@ -264,7 +263,7 @@ class DefaultCorrelationBehavior extends ModelBehavior
|
|||
/**
|
||||
* @param Correlation $Model
|
||||
* @param array $user
|
||||
* @param int $id Event ID
|
||||
* @param int|array $id Event ID
|
||||
* @param array $sgids
|
||||
* @return array
|
||||
*/
|
||||
|
|
|
@ -180,7 +180,6 @@ class NoAclCorrelationBehavior extends ModelBehavior
|
|||
'contain' => [
|
||||
'CorrelationValue' => [
|
||||
'fields' => [
|
||||
'CorrelationValue.id',
|
||||
'CorrelationValue.value'
|
||||
]
|
||||
]
|
||||
|
@ -193,7 +192,7 @@ class NoAclCorrelationBehavior extends ModelBehavior
|
|||
/**
|
||||
* @param Model $Model
|
||||
* @param array $user
|
||||
* @param int $id Event ID
|
||||
* @param int|array $id Event ID
|
||||
* @return array
|
||||
*/
|
||||
public function runGetAttributesRelatedToEvent(Model $Model, array $user, $id)
|
||||
|
|
|
@ -689,26 +689,18 @@ class Event extends AppModel
|
|||
}
|
||||
|
||||
/**
|
||||
* Get related attributes for event
|
||||
* @param array $user
|
||||
* @param int|array $id Event ID when $scope is 'event', Attribute ID when $scope is 'attribute'
|
||||
* @param bool $shadowAttribute
|
||||
* @param string $scope 'event' or 'attribute'
|
||||
* @param int|array $eventIds Event IDs
|
||||
* @return array
|
||||
*/
|
||||
public function getRelatedAttributes(array $user, $id, $shadowAttribute = false, $scope = 'event')
|
||||
public function getRelatedAttributes(array $user, $eventIds)
|
||||
{
|
||||
if ($shadowAttribute) {
|
||||
// no longer supported
|
||||
return [];
|
||||
} else {
|
||||
$parentIdField = '1_attribute_id';
|
||||
$correlationModelName = 'Correlation';
|
||||
}
|
||||
if (!isset($this->{$correlationModelName})) {
|
||||
$this->{$correlationModelName} = ClassRegistry::init($correlationModelName);
|
||||
if (!isset($this->Correlation)) {
|
||||
$this->Correlation = ClassRegistry::init('Correlation');
|
||||
}
|
||||
$sgids = $this->SharingGroup->authorizedIds($user);
|
||||
$relatedAttributes = $this->{$correlationModelName}->getAttributesRelatedToEvent($user, $id, $sgids);
|
||||
$relatedAttributes = $this->Correlation->getAttributesRelatedToEvent($user, $eventIds, $sgids);
|
||||
return $relatedAttributes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue