mirror of https://github.com/MISP/MISP
fix: [correlation] Delete correlations when deleting event
parent
50a5683ced
commit
a6fbc5dc6c
|
@ -13,6 +13,7 @@ App::uses('AppModel', 'Model');
|
|||
* @method getContainRules($filter = null)
|
||||
* @method updateContainedCorrelations(array $data, string $type, array $options = [])
|
||||
* @method purgeCorrelations(int $evenId = null)
|
||||
* @method getTableName()
|
||||
*/
|
||||
class Correlation extends AppModel
|
||||
{
|
||||
|
|
|
@ -1222,15 +1222,16 @@ class Event extends AppModel
|
|||
);
|
||||
}
|
||||
if (!Configure::read('MISP.completely_disable_correlation')) {
|
||||
$correlationTableName = $this->Attribute->Correlation->getTableName();
|
||||
array_push(
|
||||
$relations,
|
||||
array(
|
||||
'table' => 'correlations',
|
||||
'table' => $correlationTableName,
|
||||
'foreign_key' => 'event_id',
|
||||
'value' => $id
|
||||
),
|
||||
array(
|
||||
'table' => 'correlations',
|
||||
'table' => $correlationTableName,
|
||||
'foreign_key' => '1_event_id',
|
||||
'value' => $id
|
||||
)
|
||||
|
@ -1293,7 +1294,7 @@ class Event extends AppModel
|
|||
}
|
||||
$tagScopes = array('Event', 'Attribute');
|
||||
$this->AttributeTag = ClassRegistry::init('AttributeTag');
|
||||
$tagIds = $this->AttributeTag->Tag->find('list', array(
|
||||
$tagIds = $this->AttributeTag->Tag->find('column', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('Tag.name LIKE' => $params['wildcard']),
|
||||
'fields' => array('Tag.id')
|
||||
|
@ -1320,9 +1321,7 @@ class Event extends AppModel
|
|||
foreach ($attributeParams as $attributeParam) {
|
||||
$tempConditions[] = array('Attribute.' . $attributeParam . ' LIKE' => $params['wildcard']);
|
||||
}
|
||||
$tagScopes = array('Event', 'Attribute');
|
||||
$this->AttributeTag = ClassRegistry::init('AttributeTag');
|
||||
$tagIds = $this->AttributeTag->Tag->find('list', array(
|
||||
$tagIds = $this->Attribute->AttributeTag->Tag->find('column', array(
|
||||
'recursive' => -1,
|
||||
'conditions' => array('Tag.name LIKE' => $params['wildcard']),
|
||||
'fields' => array('Tag.id')
|
||||
|
@ -1341,7 +1340,7 @@ class Event extends AppModel
|
|||
),
|
||||
'fields' => array('attribute_id')
|
||||
);
|
||||
$tempConditions[] = $this->subQueryGenerator($this->AttributeTag, $subQueryOptions, 'Attribute.id');
|
||||
$tempConditions[] = $this->subQueryGenerator($this->Attribute->AttributeTag, $subQueryOptions, 'Attribute.id');
|
||||
}
|
||||
return $tempConditions;
|
||||
}
|
||||
|
@ -1466,7 +1465,7 @@ class Event extends AppModel
|
|||
return $results;
|
||||
}
|
||||
|
||||
public function fetchSimpleEventIds($user, $params = array())
|
||||
public function fetchSimpleEventIds(array $user, $params = array())
|
||||
{
|
||||
$conditions = $this->createEventConditions($user);
|
||||
$conditions['AND'][] = $params['conditions'];
|
||||
|
|
Loading…
Reference in New Issue