diff --git a/.eslintignore b/.eslintignore index f1a8dafa0..ff55b787b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,4 @@ node_modules/ public/utils/codemirror/ public/kibana-integrations/ -public/utils/table-col-resizable.js \ No newline at end of file +public/utils/jquery-ui.js \ No newline at end of file diff --git a/package.json b/package.json index 3e0641487..444e4a226 100644 --- a/package.json +++ b/package.json @@ -1,67 +1,67 @@ { - "name": "wazuh", - "version": "3.9.0", - "revision": "0429", - "code": "0429-0", - "kibana": { - "version": "6.7.1" - }, - "description": "Wazuh app", - "main": "index.js", - "keywords": [ - "kibana", - "wazuh", - "ossec" - ], - "node_build": "8.14.0", - "author": "Wazuh, Inc", - "license": "GPL-2.0", - "repository": { - "type": "git", - "url": "https://github.com/wazuh/wazuh-kibana-app.git" - }, - "bugs": { - "url": "https://github.com/wazuh/wazuh-kibana-app/issues" - }, - "homepage": "https://www.wazuh.com/", - "scripts": { - "pretty": "prettier --single-quote \"{,!(node_modules)/**/}*.js\" --write", - "tslint": "tslint -c .tslint.yml server/**/*.ts server/**/*.tsx public/**/*.ts public/**/*.tsx", - "lint": "eslint . --ext .js -c .eslintrc.json --color", - "prebuild": "tsc; find . -name \"*.ts*\" -type f -not -path \"./node_modules/*\" -delete", - "build": "plugin-helpers build", - "test": "_mocha test/**/*" - }, - "dependencies": { - "angular-animate": "1.6.5", - "angular-chart.js": "^1.1.1", - "angular-cookies": "1.6.5", - "angular-material": "1.1.10", - "dom-to-image": "^2.6.0", - "install": "^0.10.1", - "js2xmlparser": "^3.0.0", - "json2csv": "^4.1.2", - "needle": "^2.0.1", - "node-cron": "^1.1.2", - "pdfmake": "^0.1.37", - "pug-loader": "^2.4.0", - "querystring-browser": "1.0.4", - "simple-tail": "^1.1.0", - "timsort": "^0.3.0", - "winston": "3.0.0" - }, - "devDependencies": { - "@elastic/plugin-helpers": "^7.1.8", - "babel-eslint": "^8.2.6", - "chai": "^4.1.2", - "eslint": "^5.10.0", - "eslint-plugin-async-await": "^0.0.0", - "eslint-plugin-import": "^2.14.0", - "eslint-plugin-node": "^7.0.1", - "mocha": "^5.2.0", - "prettier": "^1.14.2", - "tslint": "^5.11.0", - "typescript": "^3.0.1", - "typescript-eslint-parser": "^18.0.0" - } + "name": "wazuh", + "version": "3.9.0", + "revision": "0429", + "code": "0429-0", + "kibana": { + "version": "6.7.1" + }, + "description": "Wazuh app", + "main": "index.js", + "keywords": [ + "kibana", + "wazuh", + "ossec" + ], + "node_build": "8.14.0", + "author": "Wazuh, Inc", + "license": "GPL-2.0", + "repository": { + "type": "git", + "url": "https://github.com/wazuh/wazuh-kibana-app.git" + }, + "bugs": { + "url": "https://github.com/wazuh/wazuh-kibana-app/issues" + }, + "homepage": "https://www.wazuh.com/", + "scripts": { + "pretty": "prettier --single-quote \"{,!(node_modules)/**/}*.js\" --write", + "tslint": "tslint -c .tslint.yml server/**/*.ts server/**/*.tsx public/**/*.ts public/**/*.tsx", + "lint": "eslint . --ext .js -c .eslintrc.json --color", + "prebuild": "tsc; find . -name \"*.ts*\" -type f -not -path \"./node_modules/*\" -delete", + "build": "plugin-helpers build", + "test": "_mocha test/**/*" + }, + "dependencies": { + "angular-animate": "1.6.5", + "angular-chart.js": "^1.1.1", + "angular-cookies": "1.6.5", + "angular-material": "1.1.10", + "dom-to-image": "^2.6.0", + "install": "^0.10.1", + "js2xmlparser": "^3.0.0", + "json2csv": "^4.1.2", + "needle": "^2.0.1", + "node-cron": "^1.1.2", + "pdfmake": "^0.1.37", + "pug-loader": "^2.4.0", + "querystring-browser": "1.0.4", + "simple-tail": "^1.1.0", + "timsort": "^0.3.0", + "winston": "3.0.0" + }, + "devDependencies": { + "@elastic/plugin-helpers": "^7.1.8", + "babel-eslint": "^8.2.6", + "chai": "^4.1.2", + "eslint": "^5.10.0", + "eslint-plugin-async-await": "^0.0.0", + "eslint-plugin-import": "^2.14.0", + "eslint-plugin-node": "^7.0.1", + "mocha": "^5.2.0", + "prettier": "^1.14.2", + "tslint": "^5.11.0", + "typescript": "^3.0.1", + "typescript-eslint-parser": "^18.0.0" + } } diff --git a/public/app.js b/public/app.js index 690938179..c82f821eb 100644 --- a/public/app.js +++ b/public/app.js @@ -193,7 +193,7 @@ import './utils/fontawesome/css/font-awesome.min.css'; // Dev tools import './utils/codemirror'; -import './utils/table-col-resizable'; +import './utils/jquery-ui'; // Material import 'angular-material/angular-material.css'; diff --git a/public/controllers/management/decoders.js b/public/controllers/management/decoders.js index a5fb31ce2..33206d76d 100644 --- a/public/controllers/management/decoders.js +++ b/public/controllers/management/decoders.js @@ -158,6 +158,13 @@ export class DecodersController { return this.$sce.trustAsHtml(coloredString); } + switchLocalDecoders() { + this.removeFilter('path'); + if (!this.showingLocalDecoders) { + this.appliedFilters.push({ name: 'path', value: 'etc/decoders' }); + } + } + /** * This perfoms a search by a given term * @param {String} term @@ -165,12 +172,14 @@ export class DecodersController { search(term) { if (term && term.startsWith('path:') && term.split('path:')[1].trim()) { this.custom_search = ''; - const filter = { name: 'path', value: term.split('path:')[1].trim() }; - this.appliedFilters = this.appliedFilters.filter( - item => item.name !== 'path' - ); - this.appliedFilters.push(filter); - this.$scope.$broadcast('wazuhFilter', { filter }); + if (!this.showingLocalDecoders) { + const filter = { name: 'path', value: term.split('path:')[1].trim() }; + this.appliedFilters = this.appliedFilters.filter( + item => item.name !== 'path' + ); + this.appliedFilters.push(filter); + this.$scope.$broadcast('wazuhFilter', { filter }); + } } else if ( term && term.startsWith('file:') && diff --git a/public/controllers/management/rules.js b/public/controllers/management/rules.js index 7995ea143..16aec62a9 100644 --- a/public/controllers/management/rules.js +++ b/public/controllers/management/rules.js @@ -35,6 +35,7 @@ export function RulesController( * This performs a search with a given term */ $scope.search = term => { + let clearInput = true; if (term && term.startsWith('group:') && term.split('group:')[1].trim()) { $scope.custom_search = ''; const filter = { name: 'group', value: term.split('group:')[1].trim() }; @@ -97,15 +98,23 @@ export function RulesController( term.split('path:')[1].trim() ) { $scope.custom_search = ''; - const filter = { name: 'path', value: term.split('path:')[1].trim() }; - $scope.appliedFilters = $scope.appliedFilters.filter( - item => item.name !== 'path' - ); - $scope.appliedFilters.push(filter); - $scope.$broadcast('wazuhFilter', { filter }); + if (!$scope.mctrl.showingLocalRules) { + const filter = { name: 'path', value: term.split('path:')[1].trim() }; + $scope.appliedFilters = $scope.appliedFilters.filter( + item => item.name !== 'path' + ); + $scope.appliedFilters.push(filter); + $scope.$broadcast('wazuhFilter', { filter }); + } } else { + clearInput = false; $scope.$broadcast('wazuhSearch', { term, removeFilters: 0 }); } + if (clearInput) { + const searchBar = $('#search-input-rules'); + searchBar.val(''); + } + $scope.$applyAsync(); }; /** @@ -126,6 +135,13 @@ export function RulesController( return filtered.length ? filtered[0].value : ''; }; + $scope.switchLocalRules = () => { + $scope.removeFilter('path'); + if (!$scope.mctrl.showingLocalRules) { + $scope.appliedFilters.push({ name: 'path', value: 'etc/rules' }); + } + }; + /** * This a the filter given its name * @param {String} filterName @@ -253,16 +269,19 @@ export function RulesController( ); const response = (((ruleReloaded || {}).data || {}).data || {}).items || []; - if (!response.length) { - $scope.currentRule = null; - $scope.closeDetailView(true); + if (response.length) { + const result = response.filter(rule => rule.details.overwrite); + $scope.currentRule = result.length ? result[0] : response[0]; } else { - $scope.currentRule = response[0]; + $scope.currentRule = false; + $scope.closeDetailView(true); } + $scope.fetchedXML = false; } catch (error) { errorHandler.handle(error.message || error); } } + $scope.editingFile = false; $scope.$applyAsync(); appState.setNavigation({ status: true }); @@ -279,6 +298,7 @@ export function RulesController( * This function changes to the rules list view */ $scope.closeDetailView = clear => { + $scope.mctrl.showingLocalRules = !$scope.mctrl.showingLocalRules; if (clear) $scope.appliedFilters = $scope.appliedFilters.slice( 0, @@ -288,6 +308,8 @@ export function RulesController( $scope.currentRule = false; $scope.closeEditingFile(); $scope.$emit('removeCurrentRule'); + $scope.switchLocalRules(); + $scope.mctrl.showingLocalRules = !$scope.mctrl.showingLocalRules; $scope.$applyAsync(); }; @@ -297,7 +319,11 @@ export function RulesController( apiReq .request('get', `/rules/${incomingRule}`, {}) .then(data => { - $scope.currentRule = data.data.data.items[0]; + const response = (((data || {}).data || {}).data || {}).items || []; + if (response.length) { + const result = response.filter(rule => rule.details.overwrite); + $scope.currentRule = result.length ? result[0] : response[0]; + } $scope.$emit('setCurrentRule', { currentRule: $scope.currentRule }); if ( !(Object.keys(($scope.currentRule || {}).details || {}) || []).length diff --git a/public/controllers/settings/settings.js b/public/controllers/settings/settings.js index adc20284b..7bb9b24cc 100644 --- a/public/controllers/settings/settings.js +++ b/public/controllers/settings/settings.js @@ -124,12 +124,10 @@ export class SettingsController { */ async removeManager(item) { try { + const currentApi = this.appState.getCurrentAPI(); let index = this.apiEntries.indexOf(item); - if (this.appState.getCurrentAPI()) { - if ( - this.apiEntries[index]._id === - JSON.parse(this.appState.getCurrentAPI()).id - ) { + if (currentApi) { + if (this.apiEntries[index]._id === JSON.parse(currentApi).id) { // We are trying to remove the one selected as default this.appState.removeCurrentAPI(); } diff --git a/public/directives/wz-data-table/wz-data-table.html b/public/directives/wz-data-table/wz-data-table.html index 4989b953f..993d8055b 100644 --- a/public/directives/wz-data-table/wz-data-table.html +++ b/public/directives/wz-data-table/wz-data-table.html @@ -30,7 +30,7 @@