mirror of https://github.com/MISP/MISP
chg: [attribute search] by uuid updated
- pre-checks if the passed UUID is actually an event UUID before going with the slow query against both tablesfeature/better-logic-for-merge-attribute-into-object
parent
45176f7dcd
commit
4dd5d369b4
|
@ -1580,6 +1580,7 @@ class AttributesController extends AppController
|
|||
}
|
||||
|
||||
$this->paginate['conditions'] = $params['conditions'];
|
||||
$this->paginate['ignoreIndexHint'] = 'deleted';
|
||||
$attributes = $this->paginate();
|
||||
$this->Attribute->attachTagsToAttributes($attributes, ['includeAllTags' => true]);
|
||||
|
||||
|
|
|
@ -3163,6 +3163,7 @@ class Attribute extends AppModel
|
|||
'includeFullModel' => !empty($filters['includeFullModel']) ? $filters['includeFullModel'] : 0,
|
||||
'allow_proposal_blocking' => !empty($filters['allow_proposal_blocking']) ? $filters['allow_proposal_blocking'] : 0
|
||||
);
|
||||
|
||||
if (!empty($filters['attackGalaxy'])) {
|
||||
$params['attackGalaxy'] = $filters['attackGalaxy'];
|
||||
}
|
||||
|
@ -3388,6 +3389,32 @@ class Attribute extends AppModel
|
|||
if (!empty($params['uuid'])) {
|
||||
$params['uuid'] = $this->convert_filters($params['uuid']);
|
||||
if (!empty($params['uuid']['OR'])) {
|
||||
if ($options['scope'] == 'Attribute') {
|
||||
$subQuery = [
|
||||
'conditions' => ['uuid' => $params['uuid']['OR']],
|
||||
'fields' => ['id']
|
||||
];
|
||||
$pre_lookup = $this->Event->find('first', [
|
||||
'conditions' => ['Event.uuid' => $params['uuid']['OR']],
|
||||
'recursive' => -1,
|
||||
'fields' => ['Event.id']
|
||||
]);
|
||||
if (empty($pre_lookup)) {
|
||||
$conditions['AND'][] = array(
|
||||
'OR' => array(
|
||||
'Attribute.uuid' => $params['uuid']['OR']
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$conditions['AND'][] = array(
|
||||
'OR' => array(
|
||||
$this->subQueryGenerator($this->Event, $subQuery, 'Attribute.event_id'),
|
||||
'Attribute.uuid' => $params['uuid']['OR']
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
} else {
|
||||
$conditions['AND'][] = array(
|
||||
'OR' => array(
|
||||
'Event.uuid' => $params['uuid']['OR'],
|
||||
|
@ -3395,7 +3422,20 @@ class Attribute extends AppModel
|
|||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
if (!empty($params['uuid']['NOT'])) {
|
||||
if ($options['scope'] == 'Attribute') {
|
||||
$subQuery = [
|
||||
'conditions' => ['uuid' => $params['uuid']['OR']],
|
||||
'fields' => ['id']
|
||||
];
|
||||
$conditions['AND'][] = [
|
||||
'NOT' => [
|
||||
$this->subQueryGenerator($this->Event, $subQuery, 'Attribute.event_id'),
|
||||
'Attribute.uuid' => $params['uuid']['NOT']
|
||||
]
|
||||
];
|
||||
} else {
|
||||
$conditions['AND'][] = array(
|
||||
'NOT' => array(
|
||||
'Event.uuid' => $params['uuid']['NOT'],
|
||||
|
@ -3404,6 +3444,7 @@ class Attribute extends AppModel
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $conditions;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue