mirror of https://github.com/MISP/MISP
Fixed an issue where a proposal correlation would fail
parent
f8495c1790
commit
70eebafa9f
|
@ -201,17 +201,21 @@ class ShadowAttribute extends AppModel {
|
|||
}
|
||||
|
||||
private function __beforeDeleteCorrelation(&$sa) {
|
||||
$temp = $sa;
|
||||
if (isset($temp['ShadowAttribute'])) $temp = $temp['ShadowAttribute'];
|
||||
$this->ShadowAttributeCorrelation = ClassRegistry::init('ShadowAttributeCorrelation');
|
||||
$this->ShadowAttributeCorrelation->deleteAll(array('ShadowAttributeCorrelation.1_shadow_attribute_id' => $sa['id']));
|
||||
$this->ShadowAttributeCorrelation->deleteAll(array('ShadowAttributeCorrelation.1_shadow_attribute_id' => $temp['id']));
|
||||
}
|
||||
|
||||
private function __afterSaveCorrelation(&$sa) {
|
||||
if (in_array($sa['type'], $this->Event->Attribute->nonCorrelatingTypes)) return;
|
||||
$temp = $sa;
|
||||
if (isset($temp['ShadowAttribute'])) $temp = $temp['ShadowAttribute'];
|
||||
if (in_array($temp['type'], $this->Event->Attribute->nonCorrelatingTypes)) return;
|
||||
$this->ShadowAttributeCorrelation = ClassRegistry::init('ShadowAttributeCorrelation');
|
||||
$shadow_attribute_correlations = array();
|
||||
$fields = array('value1', 'value2');
|
||||
$correlatingValues = array($sa['value1']);
|
||||
if (!empty($sa['value2'])) $correlatingValues[] = $sa['value2'];
|
||||
$correlatingValues = array($temp['value1']);
|
||||
if (!empty($temp['value2'])) $correlatingValues[] = $temp['value2'];
|
||||
foreach ($correlatingValues as $k => $cV) {
|
||||
$correlatingAttributes[$k] = $this->Event->Attribute->find('all', array(
|
||||
'conditions' => array(
|
||||
|
@ -229,14 +233,14 @@ class ShadowAttribute extends AppModel {
|
|||
'order' => array(),
|
||||
));
|
||||
foreach ($correlatingAttributes[$k] as $key => &$correlatingAttribute) {
|
||||
if ($correlatingAttribute['Attribute']['event_id'] == $sa['event_id']) unset($correlatingAttributes[$k][$key]);
|
||||
if ($correlatingAttribute['Attribute']['event_id'] == $temp['event_id']) unset($correlatingAttributes[$k][$key]);
|
||||
}
|
||||
foreach ($correlatingAttributes as $k => $cA) {
|
||||
foreach ($cA as $corr) {
|
||||
$shadow_attribute_correlations[] = array(
|
||||
'value' => $correlatingValues[$k],
|
||||
'1_event_id' => $sa['event_id'],
|
||||
'1_shadow_attribute_id' => $sa['id'],
|
||||
'1_event_id' => $temp['event_id'],
|
||||
'1_shadow_attribute_id' => $temp['id'],
|
||||
'event_id' => $corr['Attribute']['event_id'],
|
||||
'attribute_id' => $corr['Attribute']['id'],
|
||||
'org_id' => $corr['Event']['org_id'],
|
||||
|
|
Loading…
Reference in New Issue