mirror of https://github.com/MISP/MISP
new: add param to get exact matches on attribute values
parent
1f4e2af37a
commit
bb9e406f85
|
@ -73,6 +73,9 @@ class AttributesController extends AppController
|
|||
{
|
||||
$user = $this->Auth->user();
|
||||
$this->paginate['conditions']['AND'][] = $this->Attribute->buildConditions($user);
|
||||
|
||||
$this->__setIndexFilterConditions();
|
||||
|
||||
$attributes = $this->paginate();
|
||||
|
||||
if ($this->_isRest()) {
|
||||
|
@ -3017,4 +3020,15 @@ class AttributesController extends AppController
|
|||
$sg = $this->Attribute->Event->SharingGroup->fetchAllAuthorised($this->Auth->user(), 'name', true, $sharingGroupId);
|
||||
return !empty($sg);
|
||||
}
|
||||
|
||||
private function __setIndexFilterConditions() {
|
||||
// search by attribute value
|
||||
if ($this->params['named']['searchvalue']) {
|
||||
$v = $this->params['named']['searchvalue'];
|
||||
$this->paginate['conditions']['AND']['OR'] = [
|
||||
['Attribute.value1' => $v],
|
||||
['Attribute.value2' => $v],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -669,6 +669,25 @@ class EventsController extends AppController
|
|||
[$eventReportQuery]
|
||||
]
|
||||
];
|
||||
break;
|
||||
case 'value':
|
||||
if ($v == "") {
|
||||
continue 2;
|
||||
}
|
||||
$conditions['OR'] = [
|
||||
['Attribute.value1' => $v],
|
||||
['Attribute.value2' => $v],
|
||||
];
|
||||
|
||||
$eventIds = $this->Event->Attribute->fetchAttributes($this->Auth->user(), array(
|
||||
'conditions' => $conditions,
|
||||
'flatten' => true,
|
||||
'event_ids' => true,
|
||||
'list' => true,
|
||||
));
|
||||
|
||||
$this->paginate['conditions']['AND'][] = array('Event.id' => $eventIds);
|
||||
|
||||
break;
|
||||
default:
|
||||
continue 2;
|
||||
|
@ -682,7 +701,7 @@ class EventsController extends AppController
|
|||
{
|
||||
// list the events
|
||||
$urlparams = "";
|
||||
$overrideAbleParams = array('all', 'attribute', 'published', 'eventid', 'datefrom', 'dateuntil', 'org', 'eventinfo', 'tag', 'tags', 'distribution', 'sharinggroup', 'analysis', 'threatlevel', 'email', 'hasproposal', 'timestamp', 'publishtimestamp', 'publish_timestamp', 'minimal');
|
||||
$overrideAbleParams = array('all', 'attribute', 'published', 'eventid', 'datefrom', 'dateuntil', 'org', 'eventinfo', 'tag', 'tags', 'distribution', 'sharinggroup', 'analysis', 'threatlevel', 'email', 'hasproposal', 'timestamp', 'publishtimestamp', 'publish_timestamp', 'minimal', 'value');
|
||||
$paginationParams = array('limit', 'page', 'sort', 'direction', 'order');
|
||||
$passedArgs = $this->passedArgs;
|
||||
if (!empty($this->request->data)) {
|
||||
|
|
Loading…
Reference in New Issue