From 0f77454876aec4a00e8de8f73a08b974f02b9b57 Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Fri, 17 Dec 2021 15:24:35 +0100 Subject: [PATCH] fix: [event:push] Unset attribute before processing it and nesting typo --- app/Model/Event.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Model/Event.php b/app/Model/Event.php index bffd6a1b7..f749632aa 100755 --- a/app/Model/Event.php +++ b/app/Model/Event.php @@ -1122,15 +1122,16 @@ class Event extends AppModel // prepare attribute for sync if (!empty($data['Attribute'])) { foreach ($data['Attribute'] as $key => $attribute) { + if (!empty(Configure::read('MISP.enable_synchronisation_filtering_on_type')) && in_array($attribute['type'], $pushRules['type_attributes']['NOT'])) { + unset($data['Attribute'][$key]); + continue; + } $data['Attribute'][$key] = $this->__updateAttributeForSync($attribute, $server); if (empty($data['Attribute'][$key])) { unset($data['Attribute'][$key]); } else { $data['Attribute'][$key] = $this->__removeNonExportableTags($data['Attribute'][$key], 'Attribute', $server); } - if (!empty(Configure::read('MISP.enable_synchronisation_filtering_on_type')) && in_array($attribute['type'], $pushRules['type_attributes']['NOT'])) { - unset($data['Attribute'][$key]); - } } $data['Attribute'] = array_values($data['Attribute']); } @@ -1142,6 +1143,10 @@ class Event extends AppModel // prepare Object for sync if (!empty($data['Object'])) { foreach ($data['Object'] as $key => $object) { + if (!empty(Configure::read('MISP.enable_synchronisation_filtering_on_type')) && in_array($object['template_uuid'], $pushRules['type_objects']['NOT'])) { + unset($data['Object'][$key]); + continue; + } $data['Object'][$key] = $this->__updateObjectForSync($object, $server); if (empty($data['Object'][$key])) { unset($data['Object'][$key]); @@ -1149,9 +1154,6 @@ class Event extends AppModel $data['Object'][$key] = $this->__prepareAttributesForSync($data['Object'][$key], $server, $pushRules); } } - if (!empty(Configure::read('MISP.enable_synchronisation_filtering_on_type')) && in_array($object['template_uuid'], $pushRules['type_objects']['NOT'])) { - unset($data['Object'][$key]); - } $data['Object'] = array_values($data['Object']); } return $data;