chg: [eventFiltering] WIP - fixed filtering bugs and improved warning

filtering
pull/4076/head
mokaddem 2019-02-01 09:46:41 +01:00
parent 7bf66a0d14
commit bd47e9c38d
2 changed files with 14 additions and 5 deletions

View File

@ -1024,7 +1024,7 @@ class EventsController extends AppController
$conditions['overrideLimit'] = 1;
}
if (isset($filters['deleted'])) {
$conditions['deleted'] = 1;
$conditions['deleted'] = $filters['deleted'] == 2 ? 0 : 1;
}
$conditions['includeFeedCorrelations'] = true;
$conditions['includeAllTags'] = true;
@ -1390,7 +1390,7 @@ class EventsController extends AppController
$conditions['includeAttachments'] = true;
}
if (isset($this->params['named']['deleted'])) {
$conditions['deleted'] = 1;
$conditions['deleted'] = $filters['deleted'] == 2 ? 0 : 1;
}
if (isset($this->params['named']['includeRelatedTags']) && $this->params['named']['includeRelatedTags']) {
$conditions['includeRelatedTags'] = 1;

View File

@ -4495,7 +4495,13 @@ class Event extends AppModel
$object['category'] = $object['meta-category'];
$proposal['objectType'] = 'object';
// filters depend on child objects
$include = $this->__checkObjectByFilter($object, $filterType, $correlatedAttributes, $correlatedShadowAttributes);
$include = empty($filterType['attributeFilter']) || $filterType['attributeFilter'] == 'object' || $filterType['attributeFilter'] == 'all' || $object['meta-category'] === $filterType['attributeFilter'];
if (in_array($filterType['attributeFilter'], array('correlation', 'proposal'))
|| $filterType['correlation'] != 0
|| $filterType['proposal'] != 0
) {
$include = $this->__checkObjectByFilter($object, $filterType, $correlatedAttributes, $correlatedShadowAttributes);
}
if (!empty($object['Attribute'])) {
$temp = array();
@ -4515,6 +4521,9 @@ class Event extends AppModel
$object['Attribute'] = $temp;
}
if ($filterType['attributeFilter'] === 'warning' || $filterType['warning'] != 0) {
$include = $this->__checkObjectByFilter($object, $filterType, $correlatedAttributes, $correlatedShadowAttributes);
}
return array('include' => $include, 'data' => $object);
}
@ -4575,12 +4584,12 @@ class Event extends AppModel
$flagKeep = false;
foreach ($object['Attribute'] as $k => $attribute) { // check if object contains at least 1 warning
if (in_array($attribute['id'], $correlatedAttributes)) {
$flagKeep = true && ($filterType['warning'] == 1); // do not keep if warning are excluded
$flagKeep = true && ($filterType['correlation'] == 1); // do not keep if warning are excluded
}
if (!$flagKeep && !empty($attribute['ShadowAttribute'])) {
foreach ($attribute['ShadowAttribute'] as $k => $shadowAttribute) {
if (in_array($shadowAttribute['id'], $correlatedShadowAttributes)) {
$flagKeep = true && ($filterType['warning'] == 1); // do not keep if warning are excluded
$flagKeep = true && ($filterType['correlation'] == 1); // do not keep if warning are excluded
break;
}
}