diff --git a/public/controllers/agent/agents.js b/public/controllers/agent/agents.js index 2cd0b6e6d..dadb9d368 100644 --- a/public/controllers/agent/agents.js +++ b/public/controllers/agent/agents.js @@ -90,8 +90,9 @@ export class AgentsController { this.ignoredTabs = ['syscollector', 'welcome', 'configuration']; this.$scope.showSyscheckFiles = false; - this.$scope.editGroup = false; + this.$scope.showRootcheckScan = false; + this.$scope.editGroup = false; this.$scope.addingGroupToAgent = false; } @@ -183,6 +184,12 @@ export class AgentsController { this.$scope.searchSyscheckFile = (term, specificFilter) => this.$scope.$broadcast('wazuhSearch', { term, specificFilter }); + this.$scope.searchRootcheck = (term, specificFilter) => + this.$scope.$broadcast('wazuhSearch', { term, specificFilter }); + + this.$scope.launchRootcheckScan = () => this.launchRootcheckScan(); + this.$scope.launchSyscheckScan = () => this.launchSyscheckScan(); + this.$scope.startVis2Png = () => this.startVis2Png(); this.$scope.$on('$destroy', () => { @@ -309,6 +316,16 @@ export class AgentsController { if (!this.$scope.$$phase) this.$scope.$digest(); }; + this.$scope.switchRootcheckScan = () => { + this.$scope.showRootcheckScan = !this.$scope.showRootcheckScan; + if (!this.$scope.showRootcheckScan) { + this.$rootScope.$emit('changeTabView', { + tabView: this.$scope.tabView + }); + } + if (!this.$scope.$$phase) this.$scope.$digest(); + }; + this.$scope.goDiscover = () => this.goDiscover(); this.$scope.$on('$routeChangeStart', () => @@ -468,10 +485,11 @@ export class AgentsController { (((agentInfo || {}).data || {}).data || {}).status || this.$scope.agent.status; } - } catch (error) {} // eslint-disable-line + } catch (error) { } // eslint-disable-line try { this.$scope.showSyscheckFiles = false; + this.$scope.showRootcheckScan = false; if (tab === 'pci') { const pciTabs = await this.commonData.getPCI(); this.$scope.pciTabs = pciTabs; @@ -485,7 +503,7 @@ export class AgentsController { if (tab === 'syscollector') try { await this.loadSyscollector(this.$scope.agent.id); - } catch (error) {} // eslint-disable-line + } catch (error) { } // eslint-disable-line if (tab === 'configuration') { const isSync = await this.apiReq.request( 'GET', @@ -603,7 +621,7 @@ export class AgentsController { {} ); netifaceResponse = ((resultNetiface || {}).data || {}).data || false; - } catch (error) {} // eslint-disable-line + } catch (error) { } // eslint-disable-line // This API call may fail so we put it out of Promise.all let netaddrResponse = false; @@ -615,7 +633,7 @@ export class AgentsController { ); netaddrResponse = ((resultNetaddrResponse || {}).data || {}).data || false; - } catch (error) {} // eslint-disable-line + } catch (error) { } // eslint-disable-line // Before proceeding, syscollector data is an empty object this.$scope.syscollector = {}; @@ -631,7 +649,7 @@ export class AgentsController { this.$scope.syscollector = { hardware: typeof hardwareResponse === 'object' && - Object.keys(hardwareResponse).length + Object.keys(hardwareResponse).length ? { ...hardwareResponse } : false, os: @@ -815,4 +833,44 @@ export class AgentsController { syscollectorFilters.length ? syscollectorFilters : null ); } + + async launchRootcheckScan() { + try { + const isActive = ((this.$scope.agent || {}).status || '') === 'Active'; + if (!isActive) { + throw new Error('Agent is not active') + } + await this.apiReq.request( + 'PUT', + `/rootcheck/${this.$scope.agent.id}`, + {} + ); + this.errorHandler.info( + `Policy monitoring scan launched successfully on agent ${ + this.$scope.agent.id + }`, + '' + ); + } catch (error) { + this.errorHandler.handle(error, ''); + } + return; + } + + async launchSyscheckScan() { + try { + const isActive = ((this.$scope.agent || {}).status || '') === 'Active'; + if (!isActive) { + throw new Error('Agent is not active') + } + await this.apiReq.request('PUT', `/syscheck/${this.$scope.agent.id}`, {}); + this.errorHandler.info( + `FIM scan launched successfully on agent ${this.$scope.agent.id}`, + '' + ); + } catch (error) { + this.errorHandler.handle(error, ''); + } + return; + } } diff --git a/public/directives/wz-config-viewer/wz-config-viewer.js b/public/directives/wz-config-viewer/wz-config-viewer.js index 1114306d9..7fd3e92b7 100644 --- a/public/directives/wz-config-viewer/wz-config-viewer.js +++ b/public/directives/wz-config-viewer/wz-config-viewer.js @@ -62,8 +62,6 @@ class WzConfigViewer { ); }; - const init = () => {}; - const refreshJsonBox = json => { $scope.jsoncontent = json; if (!$scope.jsonCodeBox) { @@ -102,7 +100,6 @@ class WzConfigViewer { refreshXmlBox(params.data); }); - init(); } } diff --git a/public/directives/wz-data-table/wz-data-table-directive.js b/public/directives/wz-data-table/wz-data-table-directive.js index 6aa23e179..2c15c218b 100644 --- a/public/directives/wz-data-table/wz-data-table-directive.js +++ b/public/directives/wz-data-table/wz-data-table-directive.js @@ -19,12 +19,13 @@ import { checkGap } from '../wz-table/lib/check-gap'; const app = uiModules.get('app/wazuh', []); -app.directive('wzDataTable', function() { +app.directive('wzDataTable', function () { return { restrict: 'E', scope: { rowSizes: '=rowSizes', - data: '=' + data: '=', + keys: '=' }, controller($scope, $filter, errorHandler, $window) { /** @@ -61,8 +62,6 @@ app.directive('wzDataTable', function() { const fetch = () => { try { $scope.filterTable(); - $scope.keys = Object.keys(items[0]); - return; } catch (error) { errorHandler.handle(error, 'Error loading table'); } @@ -121,7 +120,7 @@ app.directive('wzDataTable', function() { $scope.prevPage = () => pagination.prevPage($scope); $scope.nextPage = async currentPage => pagination.nextPage(currentPage, $scope, errorHandler, fetch); - $scope.setPage = function() { + $scope.setPage = function () { $scope.currentPage = this.n; $scope.nextPage(this.n); }; diff --git a/public/directives/wz-table/lib/parse-value.js b/public/directives/wz-table/lib/parse-value.js index 2f449fe05..806ec082f 100644 --- a/public/directives/wz-table/lib/parse-value.js +++ b/public/directives/wz-table/lib/parse-value.js @@ -26,7 +26,28 @@ const checkIfArray = item => { return typeof item === 'object' ? splitArray(item) : item === 0 ? '0' : item; }; -export function parseValue(key, item, instancePath) { +export function parseValue(key, item, instancePath, $sce = null) { + if ( + (key === 'event' || (key.value && key.value === 'event')) && + instancePath.includes('rootcheck') && + $sce + ) { + if (typeof (item || {}).event === 'string') { + const urlRegex = new RegExp( + /https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)/, + 'g' + ); + + const matched = item.event.match(urlRegex); + if (matched) { + item.event = item.event.replace( + matched, + `${matched}` + ); + item.event = $sce.trustAsHtml(item.event); + } + } + } if (key === 'state' && instancePath.includes('processes')) { return ProcessEquivalence[item.state] || 'Unknown'; } diff --git a/public/directives/wz-table/wz-table-directive.js b/public/directives/wz-table/wz-table-directive.js index c42a6afb8..f7b0dc8e6 100644 --- a/public/directives/wz-table/wz-table-directive.js +++ b/public/directives/wz-table/wz-table-directive.js @@ -50,7 +50,8 @@ app.directive('wzTable', function() { appState, globalState, groupHandler, - wazuhConfig + wazuhConfig, + $sce ) { /** * Init variables @@ -205,7 +206,8 @@ app.directive('wzTable', function() { return; }; - $scope.parseValue = (key, item) => parseValue(key, item, instance.path); + $scope.parseValue = (key, item) => + parseValue(key, item, instance.path, $sce); /** * On controller loads diff --git a/public/directives/wz-table/wz-table.html b/public/directives/wz-table/wz-table.html index 87b389bb1..6f88b0629 100644 --- a/public/directives/wz-table/wz-table.html +++ b/public/directives/wz-table/wz-table.html @@ -20,11 +20,9 @@ - {{ - parseValue(key,item) | limitTo: extraLimit ? 100 : 25 - }} - ... - + ... + {{ parseValue(key,item) }} diff --git a/public/templates/agents/agents-fim.html b/public/templates/agents/agents-fim.html index 661bf2ad2..fd95706e7 100644 --- a/public/templates/agents/agents-fim.html +++ b/public/templates/agents/agents-fim.html @@ -1,7 +1,9 @@
- Show files + Run scan + + Show state
@@ -69,7 +71,9 @@
- Show alerts + Run scan + + Show alerts
@@ -94,7 +98,7 @@
- +
@@ -118,7 +122,7 @@
- +
@@ -142,7 +146,7 @@
- +
diff --git a/public/templates/agents/agents-pm.html b/public/templates/agents/agents-pm.html index ff5fa98eb..2caf48c52 100644 --- a/public/templates/agents/agents-pm.html +++ b/public/templates/agents/agents-pm.html @@ -1,42 +1,86 @@ - + +
+ + Run + scan + + + Show state +
+
+ + + Alerts over time + + + + + + + Top 5 CIS Requirements + + + + + + + Top 5 PCI DSS Requirements + + + + +
- - - -
- - - Alerts over time - - - - - - - Top 5 CIS Requirements - - - - - - - Top 5 PCI DSS Requirements - - - - -
- -
- - - Alerts summary - - - - -
+
+ + + Alerts summary + + + + +
+ + + +
+ + Run + scan + + + Show alerts +
+ +
+
+
+ + This agent is never connected. +
+
+
+ +
+ + + Configuration assessment + +
+ +
+
+
+
+
\ No newline at end of file diff --git a/public/templates/agents/agents-syscollector.html b/public/templates/agents/agents-syscollector.html index 5070fff3e..d2279a45a 100644 --- a/public/templates/agents/agents-syscollector.html +++ b/public/templates/agents/agents-syscollector.html @@ -56,9 +56,9 @@
+ row-sizes="[10,8,6]" extra-limit="100" keys="[{value:'name',size:2},'architecture','version',{value:'vendor',size:2},{value:'description',size:3}]" /> + row-sizes="[10,8,6]" extra-limit="100" keys="[{value:'name',size:3},'architecture','version',{value:'vendor',size:2}]" />
@@ -79,9 +79,9 @@
+ row-sizes="[10,8,6]" extra-limit="100" keys="['name','cmd','priority','nlwp']" /> + row-sizes="[10,8,6]" extra-limit="100" keys="['name','euser','nice','state']" />
diff --git a/public/templates/agents/agents.head b/public/templates/agents/agents.head index 0598e6cc5..14a52545a 100644 --- a/public/templates/agents/agents.head +++ b/public/templates/agents/agents.head @@ -59,7 +59,7 @@
- +
@@ -188,11 +188,19 @@ -
+
- Show files + Run scan + + Show state
-
+
+ + Run scan + + Show state +
+
diff --git a/public/templates/management/groups/groups.html b/public/templates/management/groups/groups.html index b7017582b..c519b1a62 100644 --- a/public/templates/management/groups/groups.html +++ b/public/templates/management/groups/groups.html @@ -119,7 +119,7 @@
-
@@ -161,7 +161,7 @@
- diff --git a/public/templates/management/logs.html b/public/templates/management/logs.html index abc3e3eee..2f29f90af 100644 --- a/public/templates/management/logs.html +++ b/public/templates/management/logs.html @@ -66,7 +66,7 @@
diff --git a/util/api-request-list.js b/util/api-request-list.js index c5931b2eb..c633bb4b5 100644 --- a/util/api-request-list.js +++ b/util/api-request-list.js @@ -466,6 +466,22 @@ export const apiRequestList = [ name: '/manager/status', args: [] }, + { + name: '/policy-monitoring/:agent_id', + args: [ + { + name: ':agent_id' + } + ] + }, + { + name: '/policy-monitoring/:agent_id/checks', + args: [ + { + name: ':agent_id' + } + ] + }, { name: '/rootcheck/:agent_id', args: [ diff --git a/util/csv-key-equivalence.js b/util/csv-key-equivalence.js index 6df5d2e7c..5327bef49 100644 --- a/util/csv-key-equivalence.js +++ b/util/csv-key-equivalence.js @@ -29,6 +29,8 @@ export const KeyEquivalenece = { file: 'File', gdpr: 'GDPR', pci: 'PCI', + cis: 'CIS', + event: 'Event', groups: 'Groups', name: 'Name', count: 'Count', @@ -79,5 +81,8 @@ export const KeyEquivalenece = { priority: 'Priority', cmd: 'CMD', nlwp: 'NLWP', - process: 'Process' + process: 'Process', + md5: 'MD5', + sha1: 'SHA1', + sha256: 'SHA256' };