Skip to content

Commit

Permalink
Fix duplicate implicit filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesús Ángel committed Sep 7, 2018
1 parent 17d1e4d commit b182cd5
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
2 changes: 1 addition & 1 deletion public/kibana-integrations/kibana-discover.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ $scope.toggleRefresh = () => {
if($location.search().tab != 'configuration') {
loadedVisualizations.removeAll();
$rootScope.rendered = false;
$rootScope.loadingStatus = "DEBUG 410 Fetching data...";
$rootScope.loadingStatus = "Fetching data...";
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
Expand Down
37 changes: 36 additions & 1 deletion public/services/common-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,48 @@ import { uiModules } from 'ui/modules'
const app = uiModules.get('app/wazuh', []);

class CommonData {
constructor($rootScope, $timeout, genericReq, appState, errorHandler, $location, shareAgent) {
constructor($rootScope, $timeout, genericReq, appState, errorHandler, $location, shareAgent, globalState) {
this.$rootScope = $rootScope;
this.$timeout = $timeout;
this.genericReq = genericReq;
this.appState = appState;
this.errorHandler = errorHandler;
this.$location = $location;
this.shareAgent = shareAgent;
this.globalState = globalState;
}

removeDuplicateRuleGroups(group) {

const globalRuleGroupFilters = this.globalState.filters.map(item => {
if(item.query && item.query.match && item.query.match["rule.groups"] && item.query.match["rule.groups"].query) {
return item.query.match["rule.groups"].query
}

return null;
})

if(globalRuleGroupFilters.includes(group)) {
this.globalState.filters.splice(globalRuleGroupFilters.indexOf(group), 1);
}
}

removeDuplicateExists(condition) {

const globalRuleExistsFilters = this.globalState.filters.map(item => {
if(item.exists && item.exists.field) {
return item.exists.field
}

return null;
})

if(globalRuleExistsFilters.includes(condition)) {
this.globalState.filters.splice(globalRuleExistsFilters.indexOf(condition), 1);
}
}


af(filterHandler, tab, localChange, agent) {
try{
const tabFilters = {
Expand Down Expand Up @@ -51,10 +83,13 @@ class CommonData {

if(tab !== 'general'){
if(tab === 'pci') {
this.removeDuplicateExists('rule.pci_dss')
filters.push(filterHandler.pciQuery())
} else if(tab === 'gdpr') {
this.removeDuplicateExists('rule.gdpr')
filters.push(filterHandler.gdprQuery())
} else {
this.removeDuplicateRuleGroups(tabFilters[tab].group)
filters.push(filterHandler.ruleGroupQuery(tabFilters[tab].group));
}
}
Expand Down

0 comments on commit b182cd5

Please sign in to comment.