mirror of https://github.com/MISP/MISP
fix: [module results] References between objects returned with module results and the original object attribute are now pointing to the original object itself
- A reference between an object and an object attribute is supported in the API, but does not appear on the event graph - Instead of pointing to the initial object attribute then, we look for the uuid of the object containing the attribute and use this uuid for the reference - The references between objects returned as module results and the object containing the attribute initially used for the enrichment with a module are then handled properlypull/7420/head
parent
63181d2219
commit
258e68df9b
|
@ -6299,21 +6299,13 @@ 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.deleted' => 0,
|
||||
'Attribute.type' => $attribute['type'],
|
||||
'Attribute.value' => $attribute['value']
|
||||
),
|
||||
'recursive' => -1,
|
||||
'fields' => array('Attribute.uuid')
|
||||
)
|
||||
$original_uuid = $this->__findOriginalUUID(
|
||||
$attribute['type'],
|
||||
$attribute['value'],
|
||||
$id
|
||||
);
|
||||
if (!empty($original_uuid)) {
|
||||
$recovered_uuids[$attribute['uuid']] = $original_uuid['Attribute']['uuid'];
|
||||
$recovered_uuids[$attribute['uuid']] = $original_uuid;
|
||||
} else {
|
||||
$failed[] = $attribute['uuid'];
|
||||
}
|
||||
|
@ -6619,6 +6611,52 @@ class Event extends AppModel
|
|||
return 0;
|
||||
}
|
||||
|
||||
private function __findOriginalUUID($attribute_type, $attribute_value, $event_id)
|
||||
{
|
||||
$original_uuid = $this->Object->Attribute->find(
|
||||
'first',
|
||||
array(
|
||||
'conditions' => array(
|
||||
'Attribute.event_id' => $event_id,
|
||||
'Attribute.deleted' => 0,
|
||||
'Attribute.object_id' => 0,
|
||||
'Attribute.type' => $attribute_type,
|
||||
'Attribute.value' => $attribute_value
|
||||
),
|
||||
'recursive' => -1,
|
||||
'fields' => array('Attribute.uuid')
|
||||
)
|
||||
);
|
||||
if (!empty($original_uuid)) {
|
||||
return ['Attribute']['uuid'];
|
||||
}
|
||||
$original_uuid = $this->Object->find(
|
||||
'first',
|
||||
array(
|
||||
'conditions' => array(
|
||||
'Attribute.event_id' => $event_id,
|
||||
'Attribute.deleted' => 0,
|
||||
'Attribute.type' => $attribute_type,
|
||||
'Attribute.value1' => $attribute_value,
|
||||
'Object.event_id' => $event_id
|
||||
),
|
||||
'recursive' => -1,
|
||||
'fields' => array('Object.uuid'),
|
||||
'joins' => array(
|
||||
array(
|
||||
'table' => 'attributes',
|
||||
'alias' => 'Attribute',
|
||||
'type' => 'inner',
|
||||
'conditions' => array(
|
||||
'Attribute.object_id = Object.id'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
return (!empty($original_uuid)) ? $original_uuid['Object']['uuid'] : $original_uuid;
|
||||
}
|
||||
|
||||
private function __saveObjectAttribute($attribute, $default_comment, $event_id, $object_id, $user)
|
||||
{
|
||||
$attribute['object_id'] = $object_id;
|
||||
|
|
Loading…
Reference in New Issue