fix: [modules results] Fixed the query to find the uuid of the attribute used as input of a misp-module

- With `Attribute.object_id => 0`, the query did
  only return attributes outside of a MISP object
- This was causing issues with references between
  the MISP objects returned by the modules and the
  attribute used as input to the module. Those
  references were visible in the module results
  preview, but skipped then after the submit
  button is pressed.
- The references are now correctly handled
pull/7420/head
chrisr3d 2021-05-11 11:37:23 +02:00
parent 49cca7256d
commit 7573c5abb9
No known key found for this signature in database
GPG Key ID: 6BBED1B63A6D639F
1 changed files with 13 additions and 6 deletions

View File

@ -6299,12 +6299,19 @@ class Event extends AppModel
} else {
$failed_attributes++;
$lastAttributeError = $this->Attribute->validationErrors;
$original_uuid = $this->Object->Attribute->find('first', array(
'conditions' => array('Attribute.event_id' => $id, 'Attribute.object_id' => 0, 'Attribute.deleted' => 0,
'Attribute.type' => $attribute['type'], 'Attribute.value' => $attribute['value']),
'recursive' => -1,
'fields' => array('Attribute.uuid')
));
$original_uuid = $this->Object->Attribute->find(
'first',
array(
'conditions' => array(
'Attribute.event_id' => $id,
'Attribute.deleted' => 0,
'Attribute.type' => $attribute['type'],
'Attribute.value' => $attribute['value']
),
'recursive' => -1,
'fields' => array('Attribute.uuid')
)
);
if (!empty($original_uuid)) {
$recovered_uuids[$attribute['uuid']] = $original_uuid['Attribute']['uuid'];
} else {