chg: [internal] Use correlation object from attribute

pull/7727/head
Jakub Onderka 2021-09-03 12:28:54 +02:00
parent cd0a2bdf4b
commit 12cc881ff6
3 changed files with 3 additions and 10 deletions

View File

@ -2970,7 +2970,7 @@ class AttributesController extends AppController
if ($attribute['Attribute']['disable_correlation']) {
$attribute['Attribute']['disable_correlation'] = 0;
$this->Attribute->save($attribute);
ClassRegistry::init('Correlation')->afterSaveCorrelation($attribute['Attribute'], false, $attribute);
$this->Attribute->Correlation->afterSaveCorrelation($attribute['Attribute'], false, $attribute);
} else {
$attribute['Attribute']['disable_correlation'] = 1;
$this->Attribute->save($attribute);

View File

@ -15,6 +15,7 @@ App::uses('ComplexTypeTool', 'Tools');
* @property Sighting $Sighting
* @property MispObject $Object
* @property SharingGroup $SharingGroup
* @property Correlation $Correlation
* @property-read array $typeDefinitions
* @property-read array $categoryDefinitions
*/
@ -415,9 +416,6 @@ class Attribute extends AppModel
}
// update correlation...
if (isset($this->data['Attribute']['deleted']) && $this->data['Attribute']['deleted']) {
if (empty($this->Correlation)) {
$this->Correlation = ClassRegistry::init('Correlation');
}
$this->Correlation->beforeSaveCorrelation($this->data['Attribute']);
if (isset($this->data['Attribute']['event_id'])) {
$this->__alterAttributeCount($this->data['Attribute']['event_id'], false);
@ -2276,7 +2274,6 @@ class Attribute extends AppModel
public function generateCorrelation($jobId = false, $startPercentage = 0, $eventId = false, $attributeId = false)
{
$this->Correlation = ClassRegistry::init('Correlation');
$this->purgeCorrelations($eventId);
$this->FuzzyCorrelateSsdeep = ClassRegistry::init('FuzzyCorrelateSsdeep');
@ -2358,7 +2355,6 @@ class Attribute extends AppModel
if (!$eventId) {
$this->query('TRUNCATE TABLE correlations;');
} elseif (!$attributeId) {
$this->Correlation = ClassRegistry::init('Correlation');
$this->Correlation->deleteAll(
array('OR' => array(
'Correlation.1_event_id' => $eventId,

View File

@ -712,9 +712,6 @@ class Event extends AppModel
if (!isset($sgids) || empty($sgids)) {
$sgids = array(-1);
}
if (!isset($this->Correlation)) {
$this->Correlation = ClassRegistry::init('Correlation');
}
// search the correlation table for the event ids of the related events
// Rules:
// 1. Event is owned by the user (org_id matches)
@ -727,7 +724,7 @@ class Event extends AppModel
// ii. Atttibute has a distribution between 1-3 (community only, connected communities, all orgs)
// iii. Attribute has a sharing group that the user is accessible to view
$conditionsCorrelation = $this->__buildEventConditionsCorrelation($user, $eventId, $sgids);
$relatedEventIds = $this->Correlation->find('column', array(
$relatedEventIds = $this->Attribute->Correlation->find('column', array(
'fields' => array('Correlation.event_id'),
'conditions' => $conditionsCorrelation,
'unique' => true,