mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Comment client side functions and normalizing naming
This commit is contained in:
parent
153c528ac6
commit
c166ec598c
@ -27,22 +27,22 @@ import { ConfigurationHandler } from '../../utils/config-handler';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
|
||||
export class AgentsController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {Object} $scope
|
||||
* @param {Object} $location
|
||||
* @param {Object} $rootScope
|
||||
* @param {Object} appState
|
||||
* @param {Object} apiReq
|
||||
* @param {Object} errorHandler
|
||||
* @param {Object} tabVisualizations
|
||||
* @param {Object} shareAgent
|
||||
* @param {Object} commonData
|
||||
* @param {Object} reportingService
|
||||
* @param {Object} visFactoryService
|
||||
* @param {Object} csvReq
|
||||
* @param {Object} wzTableFilter
|
||||
*/
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {Object} $scope
|
||||
* @param {Object} $location
|
||||
* @param {Object} $rootScope
|
||||
* @param {Object} appState
|
||||
* @param {Object} apiReq
|
||||
* @param {Object} errorHandler
|
||||
* @param {Object} tabVisualizations
|
||||
* @param {Object} shareAgent
|
||||
* @param {Object} commonData
|
||||
* @param {Object} reportingService
|
||||
* @param {Object} visFactoryService
|
||||
* @param {Object} csvReq
|
||||
* @param {Object} wzTableFilter
|
||||
*/
|
||||
constructor(
|
||||
$scope,
|
||||
$location,
|
||||
@ -128,6 +128,11 @@ export class AgentsController {
|
||||
this.$scope.securityTabs = ['vuls', 'virustotal', 'osquery'];
|
||||
this.$scope.complianceTabs = ['pci', 'gdpr'];
|
||||
|
||||
/**
|
||||
* This check if given array of items contais a single given item
|
||||
* @param {Object} item
|
||||
* @param {Array<Object>} array
|
||||
*/
|
||||
this.$scope.inArray = (item, array) =>
|
||||
item && Array.isArray(array) && array.includes(item);
|
||||
|
||||
@ -234,7 +239,7 @@ export class AgentsController {
|
||||
this.$scope.agent.id
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
this.$scope.switchConfigurationTab = (configurationTab, navigate) => {
|
||||
this.$scope.navigate = navigate;
|
||||
this.configurationHandler.switchConfigurationTab(
|
||||
@ -291,13 +296,21 @@ export class AgentsController {
|
||||
this.appState.removeSessionStorageItem('configSubTab')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create metric for given object
|
||||
* @param {*} metricsObject
|
||||
*/
|
||||
createMetrics(metricsObject) {
|
||||
for (let key in metricsObject) {
|
||||
this.$scope[key] = () => generateMetric(metricsObject[key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify metrics for create the suitable one
|
||||
* @param {*} tab
|
||||
* @param {*} subtab
|
||||
*/
|
||||
checkMetrics(tab, subtab) {
|
||||
if (subtab === 'panels') {
|
||||
switch (tab) {
|
||||
@ -372,7 +385,11 @@ export class AgentsController {
|
||||
}
|
||||
}
|
||||
|
||||
// Switch tab
|
||||
/**
|
||||
* Switch tab
|
||||
* @param {*} tab
|
||||
* @param {*} force
|
||||
*/
|
||||
async switchTab(tab, force = false) {
|
||||
if (this.ignoredTabs.includes(tab)) {
|
||||
timefilter.setRefreshInterval({ pause: true, value: 0 });
|
||||
@ -444,16 +461,26 @@ export class AgentsController {
|
||||
|
||||
// Agent data
|
||||
|
||||
/**
|
||||
* Checks rootcheck of selected agent
|
||||
*/
|
||||
validateRootCheck() {
|
||||
const result = this.commonData.validateRange(this.$scope.agent.rootcheck);
|
||||
this.$scope.agent.rootcheck = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks syscheck of selected agent
|
||||
*/
|
||||
validateSysCheck() {
|
||||
const result = this.commonData.validateRange(this.$scope.agent.syscheck);
|
||||
this.$scope.agent.syscheck = result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the needed data for load syscollector
|
||||
* @param {*} id
|
||||
*/
|
||||
async loadSyscollector(id) {
|
||||
try {
|
||||
// Check that Syscollector is enabled before proceeding
|
||||
@ -510,7 +537,7 @@ export class AgentsController {
|
||||
this.$scope.syscollector = {
|
||||
hardware:
|
||||
typeof hardwareResponse === 'object' &&
|
||||
Object.keys(hardwareResponse).length
|
||||
Object.keys(hardwareResponse).length
|
||||
? { ...hardwareResponse }
|
||||
: false,
|
||||
os:
|
||||
@ -535,6 +562,10 @@ export class AgentsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all data from agent
|
||||
* @param {*} newAgentId
|
||||
*/
|
||||
async getAgent(newAgentId) {
|
||||
try {
|
||||
this.$scope.isSynchronized = false;
|
||||
@ -585,6 +616,11 @@ export class AgentsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to the groups of an agent
|
||||
* @param {*} agent
|
||||
* @param {*} group
|
||||
*/
|
||||
goGroups(agent, group) {
|
||||
this.visFactoryService.clearAll();
|
||||
this.shareAgent.setAgent(agent, group);
|
||||
@ -592,6 +628,10 @@ export class AgentsController {
|
||||
this.$location.path('/manager');
|
||||
}
|
||||
|
||||
/**
|
||||
* Look for agents that satisfy search term, hidding master
|
||||
* @param {*} searchTerm
|
||||
*/
|
||||
async analyzeAgents(searchTerm) {
|
||||
try {
|
||||
if (searchTerm) {
|
||||
@ -609,6 +649,12 @@ export class AgentsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full data on CSV format from a path
|
||||
* @param {*} path path with data to convert
|
||||
* @param {*} fileName Output file name
|
||||
* @param {*} filters Filters to apply
|
||||
*/
|
||||
async downloadCsv(path, fileName, filters = []) {
|
||||
try {
|
||||
this.errorHandler.info(
|
||||
@ -626,6 +672,9 @@ export class AgentsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
async firstLoad() {
|
||||
try {
|
||||
const globalAgent = this.shareAgent.getAgent();
|
||||
@ -659,6 +708,9 @@ export class AgentsController {
|
||||
}
|
||||
/** End of agent configuration */
|
||||
|
||||
/**
|
||||
* Transform a visualization into an image
|
||||
*/
|
||||
startVis2Png() {
|
||||
const syscollectorFilters = [];
|
||||
if (
|
||||
|
@ -16,6 +16,16 @@ import queryString from 'querystring-browser';
|
||||
import $ from 'jquery';
|
||||
|
||||
export class DevToolsController {
|
||||
/**
|
||||
* Constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} apiReq
|
||||
* @param {*} genericReq
|
||||
* @param {*} $window
|
||||
* @param {*} appState
|
||||
* @param {*} errorHandler
|
||||
* @param {*} $document
|
||||
*/
|
||||
constructor(
|
||||
$scope,
|
||||
apiReq,
|
||||
@ -37,6 +47,9 @@ export class DevToolsController {
|
||||
this.widgets = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
this.apiInputBox = CodeMirror.fromTextArea(
|
||||
this.$document[0].getElementById('api_input'),
|
||||
@ -50,6 +63,7 @@ export class DevToolsController {
|
||||
gutters: ['CodeMirror-foldgutter']
|
||||
}
|
||||
);
|
||||
// Register plugin for code mirror
|
||||
CodeMirror.commands.autocomplete = function(cm) {
|
||||
CodeMirror.showHint(cm, CodeMirror.hint.dictionaryHint, {
|
||||
completeSingle: false
|
||||
@ -103,6 +117,9 @@ export class DevToolsController {
|
||||
this.$scope.send(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Detect de groups of instructions
|
||||
*/
|
||||
analyzeGroups() {
|
||||
try {
|
||||
const currentState = this.apiInputBox.getValue().toString();
|
||||
@ -171,6 +188,10 @@ export class DevToolsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This seta group as active, and highlight it
|
||||
* @param {Object} group
|
||||
*/
|
||||
highlightGroup(group) {
|
||||
for (const line of this.linesWithClass) {
|
||||
this.apiInputBox.removeLineClass(
|
||||
@ -203,6 +224,9 @@ export class DevToolsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This validate fromat of JSON group
|
||||
*/
|
||||
checkJsonParseError() {
|
||||
const affectedGroups = [];
|
||||
for (const widget of this.widgets) {
|
||||
@ -247,6 +271,9 @@ export class DevToolsController {
|
||||
return affectedGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* This loads all available paths of the API to show them in the autocomplete
|
||||
*/
|
||||
async getAvailableMethods() {
|
||||
try {
|
||||
const response = await this.genericReq.request('GET', '/api/routes', {});
|
||||
@ -256,6 +283,9 @@ export class DevToolsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This set some required settings at init
|
||||
*/
|
||||
init() {
|
||||
this.apiInputBox.setSize('auto', '100%');
|
||||
this.apiInputBox.model = [];
|
||||
@ -347,6 +377,10 @@ export class DevToolsController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method highlights one of the groups the first time
|
||||
* @param {Boolean} firstTime
|
||||
*/
|
||||
calculateWhichGroup(firstTime) {
|
||||
try {
|
||||
const selection = this.apiInputBox.getCursor();
|
||||
@ -378,6 +412,10 @@ export class DevToolsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This perfoms the typed request to API
|
||||
* @param {Boolean} firstTime
|
||||
*/
|
||||
async send(firstTime) {
|
||||
try {
|
||||
this.groups = this.analyzeGroups();
|
||||
|
@ -12,6 +12,14 @@
|
||||
import { ConfigurationHandler } from '../../utils/config-handler';
|
||||
|
||||
export class ConfigurationController {
|
||||
/**
|
||||
* Constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $location
|
||||
* @param {*} errorHandler
|
||||
* @param {*} apiReq
|
||||
* @param {*} appState
|
||||
*/
|
||||
constructor($scope, $location, errorHandler, apiReq, appState) {
|
||||
this.$scope = $scope;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -28,6 +36,9 @@ export class ConfigurationController {
|
||||
this.$scope.selectedItem = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
this.$scope.getXML = () => this.configurationHandler.getXML(this.$scope);
|
||||
this.$scope.getJSON = () => this.configurationHandler.getJSON(this.$scope);
|
||||
@ -51,6 +62,10 @@ export class ConfigurationController {
|
||||
this.$scope
|
||||
)
|
||||
};
|
||||
|
||||
/**
|
||||
* Navigate to woodle
|
||||
*/
|
||||
this.$scope.switchWodle = (wodleName, navigate = true) => {
|
||||
this.$scope.navigate = navigate;
|
||||
this.$scope.configWodle = wodleName;
|
||||
@ -60,6 +75,9 @@ export class ConfigurationController {
|
||||
this.configurationHandler.switchWodle(wodleName, this.$scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to configuration
|
||||
*/
|
||||
this.$scope.switchConfigurationTab = (configurationTab, navigate) => {
|
||||
this.$scope.navigate = navigate;
|
||||
this.configurationHandler.switchConfigurationTab(
|
||||
@ -88,6 +106,10 @@ export class ConfigurationController {
|
||||
this.$location.search('configWodle', null);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Navigate to configuration sub tab
|
||||
*/
|
||||
this.$scope.switchConfigurationSubTab = configurationSubTab =>
|
||||
this.configurationHandler.switchConfigurationSubTab(
|
||||
configurationSubTab,
|
||||
|
@ -14,6 +14,15 @@ import * as FileSaver from '../../services/file-saver';
|
||||
import { colors } from './colors';
|
||||
|
||||
export class DecodersController {
|
||||
/**
|
||||
* Class Constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $sce
|
||||
* @param {*} errorHandler
|
||||
* @param {*} appState
|
||||
* @param {*} csvReq
|
||||
* @param {*} wzTableFilter
|
||||
*/
|
||||
constructor($scope, $sce, errorHandler, appState, csvReq, wzTableFilter) {
|
||||
this.$scope = $scope;
|
||||
this.$sce = $sce;
|
||||
@ -23,6 +32,9 @@ export class DecodersController {
|
||||
this.wzTableFilter = wzTableFilter;
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
this.appliedFilters = [];
|
||||
|
||||
@ -45,10 +57,18 @@ export class DecodersController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This show us if new filter is already included in filters
|
||||
* @param {String} filterName
|
||||
*/
|
||||
includesFilter(filterName) {
|
||||
return this.appliedFilters.map(item => item.name).includes(filterName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a filter given its name
|
||||
* @param {String} filterName
|
||||
*/
|
||||
getFilter(filterName) {
|
||||
const filtered = this.appliedFilters.filter(
|
||||
item => item.name === filterName
|
||||
@ -56,6 +76,10 @@ export class DecodersController {
|
||||
return filtered.length ? filtered[0].value : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* This a the filter given its name
|
||||
* @param {String} filterName
|
||||
*/
|
||||
removeFilter(filterName) {
|
||||
this.appliedFilters = this.appliedFilters.filter(
|
||||
item => item.name !== filterName
|
||||
@ -63,6 +87,10 @@ export class DecodersController {
|
||||
return this.$scope.$broadcast('wazuhRemoveFilter', { filterName });
|
||||
}
|
||||
|
||||
/**
|
||||
* This set a color to a given regex
|
||||
* @param {String} regex
|
||||
*/
|
||||
colorRegex(regex) {
|
||||
regex = regex.toString();
|
||||
let valuesArray = regex.match(/\(((?!<\/span>).)*?\)(?!<\/span>)/gim);
|
||||
@ -76,6 +104,10 @@ export class DecodersController {
|
||||
return this.$sce.trustAsHtml(coloredString);
|
||||
}
|
||||
|
||||
/**
|
||||
* This set a color to a given order
|
||||
* @param {String} order
|
||||
*/
|
||||
colorOrder(order) {
|
||||
order = order.toString();
|
||||
let valuesArray = order.split(',');
|
||||
@ -89,6 +121,10 @@ export class DecodersController {
|
||||
return this.$sce.trustAsHtml(coloredString);
|
||||
}
|
||||
|
||||
/**
|
||||
* This perfoms a search by a given term
|
||||
* @param {String} term
|
||||
*/
|
||||
search(term) {
|
||||
if (term && term.startsWith('path:') && term.split('path:')[1].trim()) {
|
||||
this.custom_search = '';
|
||||
@ -115,6 +151,10 @@ export class DecodersController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return only the parents decoder if type is distinct to all
|
||||
* @param {String} typeFilter
|
||||
*/
|
||||
onlyParents(typeFilter) {
|
||||
this.appliedFilters = [];
|
||||
if (typeFilter === 'all')
|
||||
@ -125,6 +165,9 @@ export class DecodersController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get full decoders data on CSV format
|
||||
*/
|
||||
async downloadCsv() {
|
||||
try {
|
||||
const path = this.typeFilter === 'parents' ? '/decoders/parents' : '/decoders';
|
||||
|
@ -30,6 +30,10 @@ export function GroupsController(
|
||||
|
||||
$scope.load = true;
|
||||
|
||||
/**
|
||||
* Get full data on CSV format from a path
|
||||
* @param {String} data_path path with data to convert
|
||||
*/
|
||||
$scope.downloadCsv = async data_path => {
|
||||
try {
|
||||
errorHandler.info('Your download should begin automatically...', 'CSV');
|
||||
@ -50,6 +54,10 @@ export function GroupsController(
|
||||
return;
|
||||
};
|
||||
|
||||
/**
|
||||
* This perfoms a search by a given term
|
||||
* @param {String} term
|
||||
*/
|
||||
$scope.search = term => {
|
||||
$scope.$broadcast('wazuhSearch', { term });
|
||||
};
|
||||
@ -57,6 +65,10 @@ export function GroupsController(
|
||||
// Store a boolean variable to check if come from agents
|
||||
const globalAgent = shareAgent.getAgent();
|
||||
|
||||
|
||||
/**
|
||||
* This load at init some required data
|
||||
*/
|
||||
const load = async () => {
|
||||
try {
|
||||
// If come from agents
|
||||
@ -95,12 +107,18 @@ export function GroupsController(
|
||||
|
||||
$scope.toggle = () => ($scope.lookingGroup = true);
|
||||
|
||||
/**
|
||||
* This navigate to a selected agent
|
||||
*/
|
||||
$scope.showAgent = agent => {
|
||||
shareAgent.setAgent(agent);
|
||||
$location.search('tab', null);
|
||||
$location.path('/agents');
|
||||
};
|
||||
|
||||
/**
|
||||
* This load the group information to a given agent
|
||||
*/
|
||||
$scope.loadGroup = async (group, firstTime) => {
|
||||
try {
|
||||
if (!firstTime) $scope.lookingGroup = true;
|
||||
@ -120,6 +138,7 @@ export function GroupsController(
|
||||
return;
|
||||
};
|
||||
|
||||
//listeners
|
||||
$scope.$on('wazuhShowGroup', (event, parameters) => {
|
||||
return $scope.loadGroup(parameters.group);
|
||||
});
|
||||
@ -128,6 +147,9 @@ export function GroupsController(
|
||||
return $scope.showFile(parameters.groupName, parameters.fileName);
|
||||
});
|
||||
|
||||
/**
|
||||
* This navigate back to agents overview
|
||||
*/
|
||||
$scope.goBackToAgents = () => {
|
||||
$scope.groupsSelectedTab = 'agents';
|
||||
$scope.file = false;
|
||||
@ -135,6 +157,9 @@ export function GroupsController(
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigate back to files
|
||||
*/
|
||||
$scope.goBackFiles = () => {
|
||||
$scope.groupsSelectedTab = 'files';
|
||||
$scope.file = false;
|
||||
@ -143,12 +168,18 @@ export function GroupsController(
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigate back to groups
|
||||
*/
|
||||
$scope.goBackGroups = () => {
|
||||
$scope.currentGroup = false;
|
||||
$scope.lookingGroup = false;
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
};
|
||||
|
||||
/**
|
||||
* This show us a group file, for a given group and file
|
||||
*/
|
||||
$scope.showFile = async (groupName, fileName) => {
|
||||
try {
|
||||
if ($scope.filename) $scope.filename = '';
|
||||
@ -167,7 +198,7 @@ export function GroupsController(
|
||||
};
|
||||
|
||||
// Resetting the factory configuration
|
||||
$scope.$on('$destroy', () => {});
|
||||
$scope.$on('$destroy', () => { });
|
||||
|
||||
$scope.$watch('lookingGroup', value => {
|
||||
if (!value) {
|
||||
|
@ -12,6 +12,15 @@
|
||||
import * as FileSaver from '../../services/file-saver';
|
||||
|
||||
export class LogsController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} apiReq
|
||||
* @param {*} errorHandler
|
||||
* @param {*} csvReq
|
||||
* @param {*} appState
|
||||
* @param {*} wzTableFilter
|
||||
*/
|
||||
constructor($scope, apiReq, errorHandler, csvReq, appState, wzTableFilter) {
|
||||
this.$scope = $scope;
|
||||
this.apiReq = apiReq;
|
||||
@ -90,6 +99,10 @@ export class LogsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This change to a selected node
|
||||
* @param {String} node
|
||||
*/
|
||||
async changeNode(node) {
|
||||
try {
|
||||
this.type_log = 'all';
|
||||
|
@ -12,6 +12,12 @@
|
||||
import { TabNames } from '../../utils/tab-names';
|
||||
|
||||
export class ManagementController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $location
|
||||
* @param {*} shareAgent
|
||||
*/
|
||||
constructor($scope, $location, shareAgent) {
|
||||
this.$scope = $scope;
|
||||
this.$location = $location;
|
||||
@ -23,6 +29,9 @@ export class ManagementController {
|
||||
this.statusReportsTabs = ['status', 'logs', 'reporting', 'monitoring'];
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
if (this.shareAgent.getAgent() && this.shareAgent.getSelectedGroup()) {
|
||||
this.tab = 'groups';
|
||||
@ -36,10 +45,19 @@ export class ManagementController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if given array of items contais a single given item
|
||||
* @param {Object} item
|
||||
* @param {Array<Object>} array
|
||||
*/
|
||||
inArray(item, array) {
|
||||
return item && Array.isArray(array) && array.includes(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* This switch to a selected tab
|
||||
* @param {String} tab
|
||||
*/
|
||||
switchTab(tab) {
|
||||
this.tab = tab;
|
||||
|
||||
@ -59,6 +77,10 @@ export class ManagementController {
|
||||
this.$location.search('tab', this.tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* This set the rules tab
|
||||
* @param {String} tab
|
||||
*/
|
||||
setRulesTab(tab) {
|
||||
this.rulesetTab = tab;
|
||||
this.globalRulesetTab = this.rulesetTab;
|
||||
|
@ -28,7 +28,7 @@ export function ClusterController(
|
||||
appState,
|
||||
genericReq
|
||||
) {
|
||||
timefilter.setRefreshInterval({pause:true,value:0})
|
||||
timefilter.setRefreshInterval({ pause: true, value: 0 })
|
||||
$scope.search = term => {
|
||||
$scope.$broadcast('wazuhSearch', { term });
|
||||
};
|
||||
@ -56,16 +56,26 @@ export function ClusterController(
|
||||
$scope.currentNode = null;
|
||||
$scope.nodeSearchTerm = '';
|
||||
|
||||
/**
|
||||
* This set default boolean flags for a given component
|
||||
* @param {String} component
|
||||
*/
|
||||
const setBooleans = component => {
|
||||
$scope.showConfig = component === 'showConfig';
|
||||
$scope.showNodes = component === 'showNodes';
|
||||
$scope.currentNode = null;
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigates to agents preview
|
||||
*/
|
||||
$scope.goAgents = () => {
|
||||
$window.location.href = '#/agents-preview';
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigates to configuration
|
||||
*/
|
||||
$scope.goConfiguration = () => {
|
||||
setBooleans('showConfig');
|
||||
tabVisualizations.assign({
|
||||
@ -75,6 +85,9 @@ export function ClusterController(
|
||||
$rootScope.$broadcast('updateVis');
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigates to nodes
|
||||
*/
|
||||
$scope.goNodes = () => {
|
||||
setBooleans('showNodes');
|
||||
tabVisualizations.assign({
|
||||
@ -84,6 +97,9 @@ export function ClusterController(
|
||||
$rootScope.$broadcast('updateVis');
|
||||
};
|
||||
|
||||
/**
|
||||
* This navigates back
|
||||
*/
|
||||
$scope.goBack = () => {
|
||||
setBooleans(null);
|
||||
tabVisualizations.assign({
|
||||
@ -93,6 +109,7 @@ export function ClusterController(
|
||||
$rootScope.$broadcast('updateVis');
|
||||
};
|
||||
|
||||
//listeners
|
||||
$scope.$on('wazuhShowClusterNode', async (event, parameters) => {
|
||||
try {
|
||||
tabVisualizations.assign({
|
||||
@ -179,6 +196,10 @@ export function ClusterController(
|
||||
});
|
||||
|
||||
let filters = [];
|
||||
/**
|
||||
* This creatie custom filters for visualizations for a given node
|
||||
* @param {Object} node
|
||||
*/
|
||||
const assignFilters = (node = false) => {
|
||||
try {
|
||||
filters = [];
|
||||
@ -202,6 +223,9 @@ export function ClusterController(
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This set some required settings at init
|
||||
*/
|
||||
const load = async () => {
|
||||
try {
|
||||
visHandlers.removeAll();
|
||||
@ -267,6 +291,8 @@ export function ClusterController(
|
||||
|
||||
if (clusterEnabled) load();
|
||||
|
||||
|
||||
//listeners
|
||||
$scope.$on('$destroy', () => {
|
||||
$location.search('tabView', null);
|
||||
discoverPendingUpdates.removeAll();
|
||||
|
@ -24,6 +24,9 @@ export function RulesController(
|
||||
apiReq
|
||||
) {
|
||||
$scope.appliedFilters = [];
|
||||
/**
|
||||
* This performs a search with a given term
|
||||
*/
|
||||
$scope.search = term => {
|
||||
if (term && term.startsWith('group:') && term.split('group:')[1].trim()) {
|
||||
$scope.custom_search = '';
|
||||
@ -86,9 +89,17 @@ export function RulesController(
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This show us if new filter is already included in filters
|
||||
* @param {String} filterName
|
||||
*/
|
||||
$scope.includesFilter = filterName =>
|
||||
$scope.appliedFilters.map(item => item.name).includes(filterName);
|
||||
|
||||
/**
|
||||
* Get a filter given its name
|
||||
* @param {String} filterName
|
||||
*/
|
||||
$scope.getFilter = filterName => {
|
||||
const filtered = $scope.appliedFilters.filter(
|
||||
item => item.name === filterName
|
||||
@ -96,6 +107,10 @@ export function RulesController(
|
||||
return filtered.length ? filtered[0].value : '';
|
||||
};
|
||||
|
||||
/**
|
||||
* This a the filter given its name
|
||||
* @param {String} filterName
|
||||
*/
|
||||
$scope.removeFilter = filterName => {
|
||||
$scope.appliedFilters = $scope.appliedFilters.filter(
|
||||
item => item.name !== filterName
|
||||
@ -108,6 +123,9 @@ export function RulesController(
|
||||
$scope.viewingDetail = false;
|
||||
$scope.isArray = Array.isArray;
|
||||
|
||||
/**
|
||||
* This set color to a given rule argument
|
||||
*/
|
||||
$scope.colorRuleArg = ruleArg => {
|
||||
ruleArg = ruleArg.toString();
|
||||
let valuesArray = ruleArg.match(/\$\(((?!<\/span>).)*?\)(?!<\/span>)/gim);
|
||||
@ -121,10 +139,10 @@ export function RulesController(
|
||||
coloredString = coloredString.replace(
|
||||
/\$\(((?!<\/span>).)*?\)(?!<\/span>)/im,
|
||||
'<span style="color: ' +
|
||||
colors[i] +
|
||||
' ">' +
|
||||
valuesArray[i] +
|
||||
'</span>'
|
||||
colors[i] +
|
||||
' ">' +
|
||||
valuesArray[i] +
|
||||
'</span>'
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -138,6 +156,9 @@ export function RulesController(
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
|
||||
/**
|
||||
* Get full data on CSV format
|
||||
*/
|
||||
$scope.downloadCsv = async () => {
|
||||
try {
|
||||
errorHandler.info('Your download should begin automatically...', 'CSV');
|
||||
@ -169,6 +190,7 @@ export function RulesController(
|
||||
$scope.closeDetailView();
|
||||
};
|
||||
|
||||
//listeners
|
||||
$scope.$on('wazuhShowRule', (event, parameters) => {
|
||||
$scope.currentRule = parameters.rule;
|
||||
$scope.viewingDetail = true;
|
||||
|
@ -114,6 +114,10 @@ export class StatusController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This change to a selected node
|
||||
* @param {String} node
|
||||
*/
|
||||
async changeNode(node) {
|
||||
try {
|
||||
this.clusterError = false;
|
||||
|
@ -10,6 +10,13 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class BlankScreenController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $location
|
||||
* @param {*} errorHandler
|
||||
* @param {*} wzMisc
|
||||
*/
|
||||
constructor($scope, $location, errorHandler, wzMisc) {
|
||||
this.$scope = $scope;
|
||||
this.$location = $location;
|
||||
@ -17,19 +24,25 @@ export class BlankScreenController {
|
||||
this.wzMisc = wzMisc;
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
const catchedError = this.wzMisc.getBlankScr();
|
||||
if (catchedError) {
|
||||
let parsed = null;
|
||||
try {
|
||||
parsed = this.errorHandler.handle(catchedError, '', false, true);
|
||||
} catch (error) {} // eslint-disable-line
|
||||
} catch (error) { } // eslint-disable-line
|
||||
this.errorToShow = parsed || catchedError;
|
||||
this.wzMisc.setBlankScr(false);
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This navigate to overview
|
||||
*/
|
||||
goOverview() {
|
||||
this.$location.path('/overview');
|
||||
}
|
||||
|
@ -12,6 +12,21 @@
|
||||
import { SavedObjectsClientProvider } from 'ui/saved_objects';
|
||||
|
||||
export class HealthCheck {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $rootScope
|
||||
* @param {*} $timeout
|
||||
* @param {*} $location
|
||||
* @param {*} genericReq
|
||||
* @param {*} apiReq
|
||||
* @param {*} appState
|
||||
* @param {*} testAPI
|
||||
* @param {*} errorHandler
|
||||
* @param {*} wazuhConfig
|
||||
* @param {*} Private
|
||||
* @param {*} $window
|
||||
*/
|
||||
constructor(
|
||||
$scope,
|
||||
$rootScope,
|
||||
@ -53,16 +68,25 @@ export class HealthCheck {
|
||||
this.totalChecks = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Manage an error
|
||||
*/
|
||||
handleError(error) {
|
||||
this.errors.push(
|
||||
this.errorHandler.handle(error, 'Health Check', false, true)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This validates a pattern
|
||||
*/
|
||||
async checkPatterns() {
|
||||
try {
|
||||
const data = await this.savedObjectsClient.get(
|
||||
@ -107,6 +131,9 @@ export class HealthCheck {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This attempts to connect with API
|
||||
*/
|
||||
async checkApiConnection() {
|
||||
try {
|
||||
if (this.checks.api) {
|
||||
@ -151,7 +178,7 @@ export class HealthCheck {
|
||||
if (apiSplit[0] !== appSplit[0] || apiSplit[1] !== appSplit[1]) {
|
||||
this.errors.push(
|
||||
'API version mismatch. Expected v' +
|
||||
setupData.data.data['app-version']
|
||||
setupData.data.data['app-version']
|
||||
);
|
||||
this.results[i].status = 'Error';
|
||||
} else {
|
||||
@ -170,6 +197,9 @@ export class HealthCheck {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
async load() {
|
||||
try {
|
||||
const configuration = this.wazuhConfig.getConfig();
|
||||
@ -226,6 +256,9 @@ export class HealthCheck {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This navigates to app root path or an a previous stored location
|
||||
*/
|
||||
goApp() {
|
||||
this.$window.location.assign(
|
||||
'/app/wazuh#' + this.$rootScope.previousLocation || ''
|
||||
|
@ -10,6 +10,12 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class ReportingController {
|
||||
/**
|
||||
* Class controller
|
||||
* @param {*} $scope
|
||||
* @param {*} errorHandler
|
||||
* @param {*} genericReq
|
||||
*/
|
||||
constructor($scope, errorHandler, genericReq) {
|
||||
this.$scope = $scope;
|
||||
this.errorHandler = errorHandler;
|
||||
@ -22,16 +28,25 @@ export class ReportingController {
|
||||
this.gap = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
this.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* This performs a search
|
||||
*/
|
||||
search() {
|
||||
this.filteredItems = this.items;
|
||||
this.currentPage = 0;
|
||||
this.groupToPages();
|
||||
}
|
||||
|
||||
/**
|
||||
* This delete a report with a given name
|
||||
*/
|
||||
async deleteReport(name) {
|
||||
try {
|
||||
this.loading = true;
|
||||
@ -60,6 +75,12 @@ export class ReportingController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This organize in pages of given size the items
|
||||
* @param {*} size
|
||||
* @param {*} start
|
||||
* @param {*} end
|
||||
*/
|
||||
range(size, start, end) {
|
||||
const ret = [];
|
||||
|
||||
@ -74,23 +95,35 @@ export class ReportingController {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* This navigates to the prevoous page
|
||||
*/
|
||||
prevPage() {
|
||||
if (this.currentPage > 0) {
|
||||
this.currentPage--;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This navigates to the next page
|
||||
*/
|
||||
nextPage(n) {
|
||||
if (!n && n !== 0 && this.currentPage < this.pagedItems.length - 1) {
|
||||
this.currentPage++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This navigates to a given page
|
||||
*/
|
||||
setPage(n) {
|
||||
this.currentPage = n;
|
||||
this.nextPage(n);
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
async load() {
|
||||
try {
|
||||
this.loading = true;
|
||||
|
@ -28,6 +28,20 @@ import { queryConfig } from '../../services/query-config';
|
||||
import { timefilter } from 'ui/timefilter';
|
||||
|
||||
export class OverviewController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $location
|
||||
* @param {*} $rootScope
|
||||
* @param {*} appState
|
||||
* @param {*} errorHandler
|
||||
* @param {*} apiReq
|
||||
* @param {*} tabVisualizations
|
||||
* @param {*} commonData
|
||||
* @param {*} reportingService
|
||||
* @param {*} visFactoryService
|
||||
* @param {*} wazuhConfig
|
||||
*/
|
||||
constructor(
|
||||
$scope,
|
||||
$location,
|
||||
@ -54,8 +68,11 @@ export class OverviewController {
|
||||
this.wazuhConfig = wazuhConfig;
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
timefilter.setRefreshInterval({pause:true,value:0})
|
||||
timefilter.setRefreshInterval({ pause: true, value: 0 })
|
||||
this.wodlesConfiguration = false;
|
||||
this.TabDescription = TabDescription;
|
||||
this.$rootScope.reportStatus = false;
|
||||
@ -96,16 +113,30 @@ export class OverviewController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This check if given array of items contais a single given item
|
||||
* @param {Object} item
|
||||
* @param {Array<Object>} array
|
||||
*/
|
||||
inArray(item, array) {
|
||||
return item && Array.isArray(array) && array.includes(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create metric for given object
|
||||
* @param {*} metricsObject
|
||||
*/
|
||||
createMetrics(metricsObject) {
|
||||
for (const key in metricsObject) {
|
||||
this[key] = () => generateMetric(metricsObject[key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify metrics for create the suitable one
|
||||
* @param {*} tab
|
||||
* @param {*} subtab
|
||||
*/
|
||||
checkMetrics(tab, subtab) {
|
||||
if (subtab === 'panels') {
|
||||
switch (tab) {
|
||||
@ -169,11 +200,19 @@ export class OverviewController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate woodle depending on given tab
|
||||
* @param {*} tab
|
||||
*/
|
||||
calculateWodleTagFromTab(tab) {
|
||||
if (tab === 'aws') return 'aws-s3';
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Classify woodle depending on given tab
|
||||
* @param {*} tab
|
||||
*/
|
||||
filterWodle(tab) {
|
||||
try {
|
||||
const tag = this.calculateWodleTagFromTab(tab);
|
||||
@ -190,10 +229,10 @@ export class OverviewController {
|
||||
}
|
||||
if (result.length) {
|
||||
this.wodlesConfiguration = result[0];
|
||||
if(tab === 'aws') {
|
||||
if (tab === 'aws') {
|
||||
this.awsRegions = [];
|
||||
for(const bucket of this.wodlesConfiguration['aws-s3'].buckets){
|
||||
if(bucket.regions){
|
||||
for (const bucket of this.wodlesConfiguration['aws-s3'].buckets) {
|
||||
if (bucket.regions) {
|
||||
const regions = bucket.regions.split(',');
|
||||
this.awsRegions.push(...regions);
|
||||
}
|
||||
@ -203,11 +242,14 @@ export class OverviewController {
|
||||
} else {
|
||||
this.wodlesConfiguration = false;
|
||||
}
|
||||
} catch (error) {} // eslint-disable-line
|
||||
} catch (error) { } // eslint-disable-line
|
||||
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
}
|
||||
|
||||
/**
|
||||
* This get all available woodles
|
||||
*/
|
||||
async fetchWodles() {
|
||||
try {
|
||||
this.wodlesConfiguration = await queryConfig(
|
||||
@ -224,8 +266,8 @@ export class OverviewController {
|
||||
// Switch tab
|
||||
async switchTab(newTab, force = false) {
|
||||
try {
|
||||
if(newTab === 'welcome') {
|
||||
timefilter.setRefreshInterval({pause:true,value:0})
|
||||
if (newTab === 'welcome') {
|
||||
timefilter.setRefreshInterval({ pause: true, value: 0 })
|
||||
}
|
||||
|
||||
if (newTab !== 'welcome') {
|
||||
@ -287,10 +329,16 @@ export class OverviewController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform a visualization into an image
|
||||
*/
|
||||
startVis2Png() {
|
||||
return this.reportingService.startVis2Png(this.tab);
|
||||
}
|
||||
|
||||
/**
|
||||
* This fetch de agents summary
|
||||
*/
|
||||
async getSummary() {
|
||||
try {
|
||||
const data = await this.apiReq.request('GET', '/agents/summary', {});
|
||||
@ -313,6 +361,9 @@ export class OverviewController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This load the configuration settings
|
||||
*/
|
||||
async loadConfiguration() {
|
||||
try {
|
||||
const configuration = this.wazuhConfig.getConfig();
|
||||
@ -326,6 +377,9 @@ export class OverviewController {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
async init() {
|
||||
try {
|
||||
await this.loadConfiguration();
|
||||
|
@ -14,6 +14,18 @@ import { TabNames } from '../../utils/tab-names';
|
||||
import { configEquivalences } from '../../utils/config-equivalences';
|
||||
|
||||
export class SettingsController {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $scope
|
||||
* @param {*} $window
|
||||
* @param {*} $location
|
||||
* @param {*} testAPI
|
||||
* @param {*} appState
|
||||
* @param {*} genericReq
|
||||
* @param {*} errorHandler
|
||||
* @param {*} wzMisc
|
||||
* @param {*} wazuhConfig
|
||||
*/
|
||||
constructor(
|
||||
$scope,
|
||||
$window,
|
||||
@ -74,11 +86,18 @@ export class SettingsController {
|
||||
this.savingApi = false;
|
||||
}
|
||||
|
||||
/*
|
||||
On controller loads
|
||||
*/
|
||||
$onInit() {
|
||||
// Loading data
|
||||
this.getSettings().then(() => this.getAppInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* This switch to a selected tab
|
||||
* @param {Object} tab
|
||||
*/
|
||||
switchTab(tab) {
|
||||
this.tab = tab;
|
||||
this.$location.search('tab', this.tab);
|
||||
@ -125,6 +144,11 @@ export class SettingsController {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This sort by timestamp two given objects
|
||||
* @param {Object} a
|
||||
* @param {Object} b
|
||||
*/
|
||||
sortByTimestamp(a, b) {
|
||||
const intA = parseInt(a._id);
|
||||
const intB = parseInt(b._id);
|
||||
@ -160,7 +184,7 @@ export class SettingsController {
|
||||
|
||||
this.errorHandler.info(
|
||||
`API ${
|
||||
this.apiEntries[index]._source.cluster_info.manager
|
||||
this.apiEntries[index]._source.cluster_info.manager
|
||||
} set as default`,
|
||||
'Settings'
|
||||
);
|
||||
@ -232,6 +256,10 @@ export class SettingsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This validate format of fileds in a given api connection form
|
||||
* @param {Object} formName
|
||||
*/
|
||||
validator(formName) {
|
||||
// Validate user
|
||||
if (!this.userRegEx.test(this[formName].user)) {
|
||||
@ -264,6 +292,10 @@ export class SettingsController {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This toggle to a given entry
|
||||
* @param {Object} entry
|
||||
*/
|
||||
toggleEditor(entry) {
|
||||
if (this.formUpdate && this.formUpdate.password) {
|
||||
this.formUpdate.password = '';
|
||||
@ -281,7 +313,7 @@ export class SettingsController {
|
||||
// Save settings function
|
||||
async saveSettings() {
|
||||
try {
|
||||
if(this.savingApi) {
|
||||
if (this.savingApi) {
|
||||
this.errorHandler.info('Please, wait for success message', 'Settings');
|
||||
return;
|
||||
}
|
||||
@ -406,6 +438,9 @@ export class SettingsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This show us if editor is updating
|
||||
*/
|
||||
isUpdating() {
|
||||
for (let key in this.showEditForm) {
|
||||
if (this.showEditForm[key]) return true;
|
||||
@ -416,7 +451,7 @@ export class SettingsController {
|
||||
// Update settings function
|
||||
async updateSettings(item) {
|
||||
try {
|
||||
if(this.savingApi) {
|
||||
if (this.savingApi) {
|
||||
this.errorHandler.info('Please, wait for success message', 'Settings');
|
||||
return;
|
||||
}
|
||||
@ -474,6 +509,9 @@ export class SettingsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This toggle the addManagerContainer flag
|
||||
*/
|
||||
switch() {
|
||||
this.addManagerContainer = !this.addManagerContainer;
|
||||
}
|
||||
@ -531,6 +569,10 @@ export class SettingsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This change to a given index pattern
|
||||
* @param {} newIndexPattern
|
||||
*/
|
||||
async changeIndexPattern(newIndexPattern) {
|
||||
try {
|
||||
this.appState.setCurrentPattern(newIndexPattern);
|
||||
@ -556,12 +598,20 @@ export class SettingsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This set the error, and checks if is updating
|
||||
* @param {*} error
|
||||
* @param {*} updating
|
||||
*/
|
||||
printError(error, updating) {
|
||||
const text = this.errorHandler.handle(error, 'Settings');
|
||||
if (!updating) this.messageError = text;
|
||||
else this.messageErrorUpdate = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Wazuh app logs
|
||||
*/
|
||||
async getAppLogs() {
|
||||
try {
|
||||
this.loadingLogs = true;
|
||||
@ -580,6 +630,9 @@ export class SettingsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Wazuh app info
|
||||
*/
|
||||
async getAppInfo() {
|
||||
try {
|
||||
const data = await this.genericReq.request('GET', '/elastic/setup');
|
||||
@ -635,10 +688,17 @@ export class SettingsController {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* This ask again for wazuh logs
|
||||
*/
|
||||
refreshLogs() {
|
||||
return this.getAppLogs();
|
||||
}
|
||||
|
||||
/**
|
||||
* This get the string equivalence for a given key
|
||||
* @param {String} key
|
||||
*/
|
||||
configEquivalence(key) {
|
||||
return configEquivalences[key] || '-';
|
||||
}
|
||||
|
@ -16,6 +16,9 @@ import { uiModules } from 'ui/modules';
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
class WzConfigViewer {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.restrict = 'E';
|
||||
this.scope = {
|
||||
|
@ -58,6 +58,9 @@ app.directive('wzDataTable', function () {
|
||||
};
|
||||
$scope.rowsPerPage = calcTableRows($window.innerHeight, rowSizes);
|
||||
|
||||
/**
|
||||
* This loads data for table, that has been provided by parameter
|
||||
*/
|
||||
const fetch = () => {
|
||||
try {
|
||||
$scope.filterTable();
|
||||
@ -81,6 +84,9 @@ app.directive('wzDataTable', function () {
|
||||
$scope.filterTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* This apply filter and sorting to table data
|
||||
*/
|
||||
$scope.filterTable = () => {
|
||||
items = $filter('orderBy')($filter('filter')($scope.data, $scope.searchTerm), $scope.sortValue, $scope.sortReverse);
|
||||
$scope.totalItems = items.length;
|
||||
@ -89,6 +95,9 @@ app.directive('wzDataTable', function () {
|
||||
$scope.searchTable();
|
||||
}
|
||||
|
||||
/**
|
||||
* On controller loads
|
||||
*/
|
||||
const init = async () => {
|
||||
$scope.error = false;
|
||||
$scope.wazuh_table_loading = true;
|
||||
|
@ -16,6 +16,9 @@ import { uiModules } from 'ui/modules';
|
||||
const app = uiModules.get('app/wazuh', []);
|
||||
|
||||
class WzMenu {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.template = menuTemplate;
|
||||
}
|
||||
@ -45,6 +48,9 @@ class WzMenu {
|
||||
$window.location.href = path;
|
||||
};
|
||||
|
||||
/**
|
||||
* When controller loads
|
||||
*/
|
||||
const load = async () => {
|
||||
try {
|
||||
const list = await patternHandler.getPatternList();
|
||||
@ -106,6 +112,7 @@ class WzMenu {
|
||||
}
|
||||
};
|
||||
|
||||
//listeners
|
||||
$scope.$on('updateAPI', (evt, params) => {
|
||||
const current = appState.getCurrentAPI();
|
||||
if (current) {
|
||||
|
@ -71,7 +71,7 @@ app.directive('wzTable', function () {
|
||||
// Prevents duplicated rows when resizing
|
||||
let resizing = false;
|
||||
$window.onresize = () => {
|
||||
if(resizing) return;
|
||||
if (resizing) return;
|
||||
resizing = true;
|
||||
clearTimeout(doit);
|
||||
doit = setTimeout(() => {
|
||||
@ -111,9 +111,15 @@ app.directive('wzTable', function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This sort data for a given filed
|
||||
*/
|
||||
$scope.sort = async field =>
|
||||
sort(field, $scope, instance, fetch, errorHandler);
|
||||
|
||||
/**
|
||||
* This search in table data with a given term
|
||||
*/
|
||||
const search = async (term, removeFilters) =>
|
||||
searchData(
|
||||
term,
|
||||
@ -125,6 +131,10 @@ app.directive('wzTable', function () {
|
||||
errorHandler
|
||||
);
|
||||
|
||||
/**
|
||||
* This filter table with a given filter
|
||||
* @param {Object} filter
|
||||
*/
|
||||
const filter = async filter =>
|
||||
filterData(
|
||||
filter,
|
||||
@ -135,7 +145,11 @@ app.directive('wzTable', function () {
|
||||
errorHandler
|
||||
);
|
||||
|
||||
const query = async (query, search) =>
|
||||
/**
|
||||
* This filter table with using a q search
|
||||
* @param {Object} filter
|
||||
*/
|
||||
const query = async (query, search) =>
|
||||
queryData(
|
||||
query,
|
||||
search,
|
||||
@ -146,6 +160,9 @@ app.directive('wzTable', function () {
|
||||
errorHandler
|
||||
);
|
||||
|
||||
/**
|
||||
* This refresh data every second
|
||||
*/
|
||||
const realTimeFunction = async () => {
|
||||
try {
|
||||
$scope.error = false;
|
||||
@ -168,6 +185,9 @@ app.directive('wzTable', function () {
|
||||
|
||||
$scope.parseValue = (key, item) => parseValue(key, item, instance.path);
|
||||
|
||||
/**
|
||||
* On controller loads
|
||||
*/
|
||||
const init = async () =>
|
||||
initTable(
|
||||
$scope,
|
||||
|
@ -44,6 +44,9 @@ app.directive('wzTagFilter', function () {
|
||||
$scope.isAutocomplete = false;
|
||||
$scope.dataModel = [];
|
||||
|
||||
/**
|
||||
* This add new tag to bar
|
||||
*/
|
||||
$scope.addTag = (flag = false) => {
|
||||
try {
|
||||
const input = $document[0].getElementById('wz-search-filter-bar-input');
|
||||
@ -79,6 +82,10 @@ app.directive('wzTagFilter', function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This build the q string with given groups of tags for performs the q search
|
||||
* @param {Array<Objects>} groups
|
||||
*/
|
||||
const buildQuery = groups => {
|
||||
try {
|
||||
let queryObj = {
|
||||
@ -117,6 +124,11 @@ app.directive('wzTagFilter', function () {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This group tags by type (filter or search), and for filter key
|
||||
* @param {Array<Objects>} collection
|
||||
* @param {Object} property
|
||||
*/
|
||||
const groupBy = (collection, property) => {
|
||||
let i = 0, val, index,
|
||||
values = [], result = [];
|
||||
@ -133,17 +145,26 @@ app.directive('wzTagFilter', function () {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add key part of filter to search bar
|
||||
*/
|
||||
$scope.addTagKey = (key) => {
|
||||
$scope.newTag = key + ':';
|
||||
$scope.showAutocomplete(true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add value part of filter to search bar, and add complete tag
|
||||
*/
|
||||
$scope.addTagValue = (value) => {
|
||||
$scope.newTag = $scope.newTag.substring(0, $scope.newTag.indexOf(':') + 1);
|
||||
$scope.newTag += value;
|
||||
$scope.addTag();
|
||||
};
|
||||
|
||||
/**
|
||||
* This remove tag from search bar
|
||||
*/
|
||||
$scope.removeTag = (id, deleteGroup) => {
|
||||
if (deleteGroup) {
|
||||
$scope.tagList = $scope.tagList.filter(function (x) { return x.key !== id });
|
||||
@ -155,6 +176,9 @@ app.directive('wzTagFilter', function () {
|
||||
$scope.showAutocomplete(false);
|
||||
};
|
||||
|
||||
/**
|
||||
* This show us the available filters in an autocomplete
|
||||
*/
|
||||
$scope.showAutocomplete = (flag) => {
|
||||
if (flag) {
|
||||
$scope.getAutocompleteContent();
|
||||
@ -163,6 +187,9 @@ app.directive('wzTagFilter', function () {
|
||||
indexAutocomplete(flag);
|
||||
};
|
||||
|
||||
/**
|
||||
* This calculate the autocpmplete content (filter keys or filter values)
|
||||
* */
|
||||
$scope.getAutocompleteContent = () => {
|
||||
const term = $scope.newTag.split(':');
|
||||
const isKey = !term[1] && $scope.newTag.indexOf(':') === -1;
|
||||
@ -182,6 +209,9 @@ app.directive('wzTagFilter', function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This force autocomplete refresh for every key pressed in search bar
|
||||
*/
|
||||
$scope.addSearchKey = () => {
|
||||
if ($scope.autocompleteEnter) {
|
||||
$scope.autocompleteEnter = false;
|
||||
@ -189,6 +219,10 @@ app.directive('wzTagFilter', function () {
|
||||
$scope.getAutocompleteContent();
|
||||
};
|
||||
|
||||
/**
|
||||
* This apply som style to autocomplete, to be displayed exactly below the input
|
||||
* @param {Boolean} flag Indicate if after apply style the autocomplete have to be shown
|
||||
*/
|
||||
const indexAutocomplete = (flag = true) => {
|
||||
$timeout(function () {
|
||||
const bar = $document[0].getElementById('wz-search-filter-bar');
|
||||
@ -202,6 +236,9 @@ app.directive('wzTagFilter', function () {
|
||||
}, 100);
|
||||
}
|
||||
|
||||
/**
|
||||
* When controllers load
|
||||
*/
|
||||
const load = async () => {
|
||||
try {
|
||||
//Use when api call be implemented
|
||||
@ -215,6 +252,9 @@ app.directive('wzTagFilter', function () {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a random id for a tag
|
||||
*/
|
||||
const generateUID = () => {
|
||||
// I generate the UID from two parts here
|
||||
// to ensure the random number provide enough bits.
|
||||
@ -225,6 +265,9 @@ app.directive('wzTagFilter', function () {
|
||||
return firstPart + secondPart;
|
||||
}
|
||||
|
||||
/**
|
||||
* This set to bar a keydown listener to show the autocomplete
|
||||
*/
|
||||
$('#wz-search-filter-bar-input').bind('keydown', function (e) {
|
||||
let $current = $('#wz-search-filter-bar-autocomplete-list li.selected');
|
||||
if ($current.length === 0 && (e.keyCode === 38 || e.keyCode === 40)) {
|
||||
|
@ -11,18 +11,32 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class DiscoverPendingUpdates {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.pendingUpdates = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new pending update
|
||||
* @param {Object} query
|
||||
* @param {Object} filters
|
||||
*/
|
||||
addItem(query, filters) {
|
||||
this.pendingUpdates.push(query, filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of pending updates
|
||||
*/
|
||||
getList() {
|
||||
return this.pendingUpdates;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all pending updates
|
||||
*/
|
||||
removeAll() {
|
||||
this.pendingUpdates = [];
|
||||
}
|
||||
|
@ -11,18 +11,31 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class LoadedVisualizations {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.list = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new item to the loaded visualizations list
|
||||
* @param {Object} item
|
||||
*/
|
||||
addItem(item) {
|
||||
this.list.push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the loaded visualizations list
|
||||
*/
|
||||
getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all loaded visualizations list
|
||||
*/
|
||||
removeAll() {
|
||||
this.list = [];
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class WzMisc {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.state = {
|
||||
apiIsDown: false,
|
||||
@ -20,34 +23,62 @@ export class WzMisc {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set if api is down
|
||||
* @param {String} value
|
||||
*/
|
||||
setApiIsDown(value) {
|
||||
this.state.apiIsDown = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get if api is down
|
||||
*/
|
||||
getApiIsDown() {
|
||||
return this.state.apiIsDown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set wizard
|
||||
* @param {String} value
|
||||
*/
|
||||
setWizard(value) {
|
||||
this.state.comeFromWizard = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get wizard
|
||||
*/
|
||||
getWizard() {
|
||||
return this.state.comeFromWizard;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set blank screen
|
||||
* @param {String} value
|
||||
*/
|
||||
setBlankScr(value) {
|
||||
this.state.blankScreenError = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get blank screen
|
||||
*/
|
||||
getBlankScr() {
|
||||
return this.state.blankScreenError;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set last restart
|
||||
* @param {String} value
|
||||
*/
|
||||
setLastRestart(value) {
|
||||
this.state.lastRestart = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last restart
|
||||
*/
|
||||
getLastRestart() {
|
||||
return this.state.lastRestart;
|
||||
}
|
||||
|
@ -10,22 +10,38 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class RawVisualizations {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.list = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add item to raw visualizations
|
||||
* @param {Object} item
|
||||
*/
|
||||
addItem(item) {
|
||||
this.list.push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set raw raw visualizations with given items
|
||||
* @param {Array<Object>} items
|
||||
*/
|
||||
assignItems(items) {
|
||||
this.list = Array.isArray(items) ? items : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get raw visualizations
|
||||
*/
|
||||
getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all raw visualizations
|
||||
*/
|
||||
removeAll() {
|
||||
this.list = [];
|
||||
}
|
||||
|
@ -11,16 +11,25 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class ShareAgent {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.agent = null;
|
||||
this.selectedGroup = null;
|
||||
this.targetLocation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current agent
|
||||
*/
|
||||
getAgent() {
|
||||
return this.agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get selected group
|
||||
*/
|
||||
getSelectedGroup() {
|
||||
if (this.agent && this.agent.group && (this.selectedGroup || this.selectedGroup === 0)) {
|
||||
return this.agent.group[this.selectedGroup];
|
||||
@ -28,26 +37,44 @@ export class ShareAgent {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a given agent and group as current
|
||||
* @param {*} ag
|
||||
* @param {*} group
|
||||
*/
|
||||
setAgent(ag, group) {
|
||||
this.agent = ag;
|
||||
this.selectedGroup = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete current agent
|
||||
*/
|
||||
deleteAgent() {
|
||||
this.agent = null;
|
||||
this.selectedGroup = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Target location
|
||||
*/
|
||||
getTargetLocation() {
|
||||
return this.targetLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Target location
|
||||
* @param {Object} loc
|
||||
*/
|
||||
setTargetLocation(loc) {
|
||||
if (!loc || typeof loc !== 'object') return;
|
||||
this.targetLocation = {};
|
||||
Object.assign(this.targetLocation, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete target location
|
||||
*/
|
||||
deleteTargetLocation() {
|
||||
this.targetLocation = null;
|
||||
}
|
||||
|
@ -11,6 +11,9 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class TabVisualizations {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.agents = {
|
||||
welcome: 0,
|
||||
@ -48,18 +51,33 @@ export class TabVisualizations {
|
||||
this.currentTab = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set given tab as current
|
||||
* @param {Object} tab
|
||||
*/
|
||||
setTab(tab) {
|
||||
this.currentTab = tab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current tab
|
||||
*/
|
||||
getTab() {
|
||||
return this.currentTab;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get given item
|
||||
* @param {String} item
|
||||
*/
|
||||
getItem(item) {
|
||||
return this.tabVisualizations[item];
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign tab visualization with given tabs
|
||||
* @param {Object} tabs
|
||||
*/
|
||||
assign(tabs) {
|
||||
if (typeof tabs === 'object') {
|
||||
this.tabVisualizations = tabs;
|
||||
@ -69,6 +87,9 @@ export class TabVisualizations {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all tab Visualizations
|
||||
*/
|
||||
removeAll() {
|
||||
this.tabVisualizations = {};
|
||||
}
|
||||
|
@ -13,18 +13,32 @@
|
||||
import dateMath from '@kbn/datemath';
|
||||
|
||||
export class VisHandlers {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.list = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Add given item
|
||||
* @param {Object} item
|
||||
*/
|
||||
addItem(item) {
|
||||
this.list.push(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all items
|
||||
*/
|
||||
getList() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all applied filters
|
||||
* @param {*} syscollector
|
||||
*/
|
||||
getAppliedFilters(syscollector) {
|
||||
const appliedFilters = {};
|
||||
|
||||
@ -42,7 +56,6 @@ export class VisHandlers {
|
||||
}
|
||||
|
||||
// Check raw response from all rendered tables
|
||||
|
||||
const tables = this.list
|
||||
.filter(
|
||||
item => item.vis && item.vis._state && item.vis._state.type === 'table'
|
||||
@ -87,6 +100,9 @@ export class VisHandlers {
|
||||
return appliedFilters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if has data
|
||||
*/
|
||||
hasData() {
|
||||
for (const item of this.list) {
|
||||
if (
|
||||
@ -104,6 +120,9 @@ export class VisHandlers {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all visualizations
|
||||
*/
|
||||
removeAll() {
|
||||
this.list = [];
|
||||
}
|
||||
|
@ -13,6 +13,10 @@
|
||||
import domtoimage from 'dom-to-image';
|
||||
|
||||
export class Vis2PNG {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $rootScope
|
||||
*/
|
||||
constructor($rootScope) {
|
||||
this.$rootScope = $rootScope;
|
||||
this.rawArray = [];
|
||||
@ -20,6 +24,10 @@ export class Vis2PNG {
|
||||
this.working = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a visualizations array
|
||||
* @param {Array<Object>} visArray
|
||||
*/
|
||||
async checkArray(visArray) {
|
||||
try {
|
||||
this.working = true;
|
||||
@ -54,15 +62,26 @@ export class Vis2PNG {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if is working
|
||||
*/
|
||||
isWorking() {
|
||||
return this.working;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear raw array
|
||||
*/
|
||||
clear() {
|
||||
this.rawArray = [];
|
||||
this.htmlObject = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set content to a given html item
|
||||
* @param {String} id
|
||||
* @param {Object} content
|
||||
*/
|
||||
assignHTMLItem(id, content) {
|
||||
this.htmlObject[id] = content;
|
||||
}
|
||||
|
@ -10,14 +10,23 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class WazuhConfig {
|
||||
/**
|
||||
* Class constructor
|
||||
*/
|
||||
constructor() {
|
||||
this.config = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Set given configuration
|
||||
* @param {Object} cfg
|
||||
*/
|
||||
setConfig(cfg) {
|
||||
Object.assign(this.config, cfg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration
|
||||
*/
|
||||
getConfig() {
|
||||
return this.config;
|
||||
}
|
||||
|
@ -10,12 +10,24 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class ApiRequest {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $q
|
||||
* @param {*} genericReq
|
||||
* @param {*} appState
|
||||
*/
|
||||
constructor($q, genericReq, appState) {
|
||||
this.$q = $q;
|
||||
this.genericReq = genericReq;
|
||||
this.appState = appState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform an API request
|
||||
* @param {String} method Eg. GET, PUT
|
||||
* @param {String} path API route
|
||||
* @param {Object} body Request body
|
||||
*/
|
||||
async request(method, path, body) {
|
||||
try {
|
||||
if (!method || !path || !body) {
|
||||
|
@ -12,6 +12,13 @@
|
||||
import chrome from 'ui/chrome';
|
||||
|
||||
export class ApiTester {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $http
|
||||
* @param {*} appState
|
||||
* @param {*} wzMisc
|
||||
* @param {*} wazuhConfig
|
||||
*/
|
||||
constructor($http, appState, wzMisc, wazuhConfig) {
|
||||
this.$http = $http;
|
||||
this.appState = appState;
|
||||
|
@ -10,11 +10,17 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class AppState {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $cookies
|
||||
* @param {*} $window
|
||||
*/
|
||||
constructor($cookies, $window) {
|
||||
this.$cookies = $cookies;
|
||||
this.$window = $window;
|
||||
}
|
||||
|
||||
//Extensions setters and getters
|
||||
getExtensions(id) {
|
||||
const current = this.$cookies.getObject('extensions');
|
||||
return current ? current[id] : false;
|
||||
@ -30,6 +36,8 @@ export class AppState {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Cluster setters and getters
|
||||
getClusterInfo() {
|
||||
return this.$cookies.getObject('_clusterInfo');
|
||||
}
|
||||
@ -46,9 +54,7 @@ export class AppState {
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentPattern() {
|
||||
return this.$cookies.getObject('_currentPattern');
|
||||
}
|
||||
//CreatedAt setters and getters
|
||||
|
||||
setCreatedAt(date) {
|
||||
const exp = new Date();
|
||||
@ -56,18 +62,6 @@ export class AppState {
|
||||
this.$cookies.putObject('_createdAt', date, { expires: exp });
|
||||
}
|
||||
|
||||
setCurrentPattern(newPattern) {
|
||||
const exp = new Date();
|
||||
exp.setDate(exp.getDate() + 365);
|
||||
if (newPattern) {
|
||||
this.$cookies.putObject('_currentPattern', newPattern, { expires: exp });
|
||||
}
|
||||
}
|
||||
|
||||
removeCurrentPattern() {
|
||||
return this.$cookies.remove('_currentPattern');
|
||||
}
|
||||
|
||||
getCreatedAt() {
|
||||
return this.$cookies.getObject('_createdAt');
|
||||
}
|
||||
@ -76,6 +70,8 @@ export class AppState {
|
||||
return this.$cookies.remove('_createdAt');
|
||||
}
|
||||
|
||||
//Current api setters and getters
|
||||
|
||||
getCurrentAPI() {
|
||||
return this.$cookies.getObject('API');
|
||||
}
|
||||
@ -92,6 +88,7 @@ export class AppState {
|
||||
}
|
||||
}
|
||||
|
||||
//Patterns setters and getters
|
||||
getPatternSelector() {
|
||||
return this.$cookies.getObject('patternSelector');
|
||||
}
|
||||
@ -100,6 +97,24 @@ export class AppState {
|
||||
this.$cookies.putObject('patternSelector', value);
|
||||
}
|
||||
|
||||
setCurrentPattern(newPattern) {
|
||||
const exp = new Date();
|
||||
exp.setDate(exp.getDate() + 365);
|
||||
if (newPattern) {
|
||||
this.$cookies.putObject('_currentPattern', newPattern, { expires: exp });
|
||||
}
|
||||
}
|
||||
|
||||
getCurrentPattern() {
|
||||
return this.$cookies.getObject('_currentPattern');
|
||||
}
|
||||
|
||||
removeCurrentPattern() {
|
||||
return this.$cookies.remove('_currentPattern');
|
||||
}
|
||||
|
||||
//Dev tools setters and getters
|
||||
|
||||
setCurrentDevTools(current) {
|
||||
this.$window.localStorage.setItem('currentDevTools', current);
|
||||
}
|
||||
@ -108,6 +123,7 @@ export class AppState {
|
||||
return this.$window.localStorage.getItem('currentDevTools');
|
||||
}
|
||||
|
||||
//Session storage setters and getters
|
||||
setSessionStorageItem(key, value) {
|
||||
this.$window.sessionStorage.setItem(key, value);
|
||||
}
|
||||
|
@ -10,6 +10,17 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class CommonData {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $rootScope
|
||||
* @param {*} $timeout
|
||||
* @param {*} genericReq
|
||||
* @param {*} appState
|
||||
* @param {*} errorHandler
|
||||
* @param {*} $location
|
||||
* @param {*} shareAgent
|
||||
* @param {*} globalState
|
||||
*/
|
||||
constructor(
|
||||
$rootScope,
|
||||
$timeout,
|
||||
@ -30,6 +41,9 @@ export class CommonData {
|
||||
this.globalState = globalState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove rule id
|
||||
*/
|
||||
removeRuleId() {
|
||||
if (!this.globalState || !this.globalState.filters) return;
|
||||
const arr = [];
|
||||
@ -47,6 +61,10 @@ export class CommonData {
|
||||
this.globalState.filters = arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove duplicate rule for a given group
|
||||
* @param {String} group
|
||||
*/
|
||||
removeDuplicateRuleGroups(group) {
|
||||
if (!this.globalState || !this.globalState.filters) return;
|
||||
const globalRuleGroupFilters = this.globalState.filters.map(item => {
|
||||
@ -67,6 +85,10 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove duplicates if exists
|
||||
* @param {String} condition
|
||||
*/
|
||||
removeDuplicateExists(condition) {
|
||||
if (!this.globalState || !this.globalState.filters) return;
|
||||
const globalRuleExistsFilters = this.globalState.filters.map(item => {
|
||||
@ -85,6 +107,13 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* After filter manage
|
||||
* @param {*} filterHandler
|
||||
* @param {*} tab
|
||||
* @param {*} localChange
|
||||
* @param {*} agent
|
||||
*/
|
||||
af(filterHandler, tab, localChange, agent) {
|
||||
try {
|
||||
const tabFilters = {
|
||||
@ -141,6 +170,9 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get GDPR
|
||||
*/
|
||||
async getGDPR() {
|
||||
try {
|
||||
const gdprTabs = [];
|
||||
@ -155,6 +187,9 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GET PCI
|
||||
*/
|
||||
async getPCI() {
|
||||
try {
|
||||
const pciTabs = [];
|
||||
@ -169,10 +204,21 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign given filter
|
||||
* @param {Object} filterHandler
|
||||
* @param {Object} tab
|
||||
* @param {Object} localChange
|
||||
* @param {Object} agent
|
||||
*/
|
||||
assignFilters(filterHandler, tab, localChange, agent) {
|
||||
return this.af(filterHandler, tab, localChange, agent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate range of given data
|
||||
* @param {Object} data
|
||||
*/
|
||||
validateRange(data) {
|
||||
const result = {
|
||||
duration: 'Unknown',
|
||||
@ -192,6 +238,9 @@ export class CommonData {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the tab location
|
||||
*/
|
||||
checkTabLocation() {
|
||||
if (this.$location.search().tab) {
|
||||
return this.$location.search().tab;
|
||||
@ -201,6 +250,9 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the tab view location
|
||||
*/
|
||||
checkTabViewLocation() {
|
||||
if (this.$location.search().tabView) {
|
||||
return this.$location.search().tabView;
|
||||
@ -210,6 +262,11 @@ export class CommonData {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the location of a given agent
|
||||
* @param {String} newAgentId
|
||||
* @param {Boolean} globalAgent
|
||||
*/
|
||||
checkLocationAgentId(newAgentId, globalAgent) {
|
||||
if (newAgentId) {
|
||||
this.$location.search('agent', newAgentId);
|
||||
|
@ -11,6 +11,12 @@
|
||||
*/
|
||||
|
||||
export class DataFactory {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} httpClient
|
||||
* @param {*} path
|
||||
* @param {*} implicitFilter
|
||||
*/
|
||||
constructor(httpClient, path, implicitFilter) {
|
||||
this.implicitFilter = implicitFilter || false;
|
||||
this.httpClient = httpClient;
|
||||
@ -24,16 +30,27 @@ export class DataFactory {
|
||||
if (this.implicitFilter) this.filters.push(...this.implicitFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add sort value
|
||||
* @param {String} value
|
||||
*/
|
||||
addSorting(value) {
|
||||
this.sortValue = value;
|
||||
this.sortDir = !this.sortDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all filters
|
||||
*/
|
||||
removeFilters() {
|
||||
this.filters = [];
|
||||
if (this.implicitFilter) this.filters.push(...this.implicitFilter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize filters
|
||||
* @param {Object} parameters
|
||||
*/
|
||||
serializeFilters(parameters) {
|
||||
if (this.sortValue) {
|
||||
parameters.sort = this.sortDir ? '-' + this.sortValue : this.sortValue;
|
||||
@ -44,6 +61,11 @@ export class DataFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new filter with a given name and value
|
||||
* @param {String} filterName
|
||||
* @param {String} value
|
||||
*/
|
||||
addFilter(filterName, value) {
|
||||
this.filters = this.filters.filter(filter => filter.name !== filterName);
|
||||
|
||||
@ -55,6 +77,10 @@ export class DataFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data
|
||||
* @param {Object} options
|
||||
*/
|
||||
async fetch(options = {}) {
|
||||
try {
|
||||
if(this.busy) return { items: this.items, time: 0 };
|
||||
@ -100,6 +126,9 @@ export class DataFactory {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset filters
|
||||
*/
|
||||
reset() {
|
||||
this.items = [];
|
||||
this.filters = [];
|
||||
|
@ -12,6 +12,13 @@
|
||||
import chrome from 'ui/chrome';
|
||||
|
||||
export class GenericRequest {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $q
|
||||
* @param {*} $http
|
||||
* @param {*} appState
|
||||
* @param {*} wazuhConfig
|
||||
*/
|
||||
constructor($q, $http, appState, wazuhConfig) {
|
||||
this.$q = $q;
|
||||
this.$http = $http;
|
||||
|
@ -10,6 +10,14 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class PatternHandler {
|
||||
/**
|
||||
* Class constructor
|
||||
* @param {*} $location
|
||||
* @param {*} genericReq
|
||||
* @param {*} appState
|
||||
* @param {*} errorHandler
|
||||
* @param {*} wzMisc
|
||||
*/
|
||||
constructor($location, genericReq, appState, errorHandler, wzMisc) {
|
||||
this.$location = $location;
|
||||
this.genericReq = genericReq;
|
||||
@ -18,6 +26,9 @@ export class PatternHandler {
|
||||
this.wzMisc = wzMisc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the available pattern list
|
||||
*/
|
||||
async getPatternList() {
|
||||
try {
|
||||
const patternList = await this.genericReq.request(
|
||||
@ -48,6 +59,10 @@ export class PatternHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change current pattern for the given pattern
|
||||
* @param {String} selectedPattern
|
||||
*/
|
||||
async changePattern(selectedPattern) {
|
||||
try {
|
||||
this.appState.setCurrentPattern(selectedPattern);
|
||||
|
@ -10,6 +10,18 @@
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
export class VisFactoryService {
|
||||
/**
|
||||
* Class Constructor
|
||||
* @param {*} $rootScope
|
||||
* @param {*} appState
|
||||
* @param {*} genericReq
|
||||
* @param {*} discoverPendingUpdates
|
||||
* @param {*} rawVisualizations
|
||||
* @param {*} tabVisualizations
|
||||
* @param {*} loadedVisualizations
|
||||
* @param {*} commonData
|
||||
* @param {*} visHandlers
|
||||
*/
|
||||
constructor(
|
||||
$rootScope,
|
||||
appState,
|
||||
@ -32,6 +44,10 @@ export class VisFactoryService {
|
||||
this.visHandlers = visHandlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove visualizations data
|
||||
* @param {Boolean} onlyAgent
|
||||
*/
|
||||
clear(onlyAgent = false) {
|
||||
if (!onlyAgent) this.visHandlers.removeAll();
|
||||
this.discoverPendingUpdates.removeAll();
|
||||
@ -39,11 +55,22 @@ export class VisFactoryService {
|
||||
this.loadedVisualizations.removeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all visualizations data
|
||||
* @param {Boolean} onlyAgent
|
||||
*/
|
||||
clearAll() {
|
||||
this.clear();
|
||||
this.tabVisualizations.removeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the overview section visualizations
|
||||
* @param {*} filterHandler
|
||||
* @param {*} tab
|
||||
* @param {*} subtab
|
||||
* @param {*} localChange
|
||||
*/
|
||||
async buildOverviewVisualizations(filterHandler, tab, subtab, localChange) {
|
||||
try {
|
||||
const data = await this.genericReq.request(
|
||||
@ -60,6 +87,14 @@ export class VisFactoryService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* BUild the agents section visualizations
|
||||
* @param {*} filterHandler
|
||||
* @param {*} tab
|
||||
* @param {*} subtab
|
||||
* @param {*} localChange
|
||||
* @param {*} id
|
||||
*/
|
||||
async buildAgentsVisualizations(filterHandler, tab, subtab, localChange, id) {
|
||||
try {
|
||||
const data = await this.genericReq.request(
|
||||
|
@ -23,7 +23,7 @@
|
||||
* @param {String} message Error message
|
||||
* @param {Number} code Error code
|
||||
* @param {Number} statusCode Error status code
|
||||
* @returns {Object}
|
||||
* @returns {Object} Error response object
|
||||
*/
|
||||
export function ErrorResponse(
|
||||
message = null,
|
||||
|
@ -31,11 +31,11 @@ export class WazuhApiElasticCtrl {
|
||||
this.wzWrapper = new ElasticWrapper(server);
|
||||
}
|
||||
|
||||
/* This get all API entries */
|
||||
/**
|
||||
*
|
||||
* This get all API entries
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* API entries or ErrorResponse
|
||||
*/
|
||||
async getAPIEntries(req, reply) {
|
||||
try {
|
||||
@ -64,11 +64,11 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
/* This remove an API entry */
|
||||
/**
|
||||
*
|
||||
* This remove an API entry
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Request response or ErrorResponse
|
||||
*/
|
||||
async deleteAPIEntries(req, reply) {
|
||||
try {
|
||||
@ -81,11 +81,11 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
/* This set an API entry as default*/
|
||||
/**
|
||||
*
|
||||
* This set an API entry as default
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Request response or ErrorResponse
|
||||
*/
|
||||
async setAPIEntryDefault(req, reply) {
|
||||
try {
|
||||
@ -114,9 +114,8 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
/* This check if connection and auth on an API is correct */
|
||||
/**
|
||||
*
|
||||
* This check if connection and auth on an API is correct
|
||||
* @param {Object} payload
|
||||
*/
|
||||
validateData(payload) {
|
||||
@ -148,9 +147,8 @@ export class WazuhApiElasticCtrl {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* This build an setting API obect */
|
||||
/**
|
||||
*
|
||||
* This build an setting API obect
|
||||
* @param {Object} payload
|
||||
*/
|
||||
buildSettingsObject(payload) {
|
||||
@ -167,11 +165,11 @@ export class WazuhApiElasticCtrl {
|
||||
};
|
||||
}
|
||||
|
||||
/* This saves a new API entry */
|
||||
/**
|
||||
*
|
||||
* This saves a new API entry
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Status response or ErrorResponse
|
||||
*/
|
||||
async saveAPI(req, reply) {
|
||||
try {
|
||||
@ -206,11 +204,11 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
/* This update an API hostname */
|
||||
/**
|
||||
*
|
||||
* This update an API hostname
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Status response or ErrorResponse
|
||||
*/
|
||||
async updateAPIHostname(req, reply) {
|
||||
try {
|
||||
@ -230,11 +228,11 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
/* This update an API full settings */
|
||||
/**
|
||||
*
|
||||
* This update an API settings into elasticsearch
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Status response or ErrorResponse
|
||||
*/
|
||||
async updateFullAPI(req, reply) {
|
||||
try {
|
||||
|
@ -40,7 +40,7 @@ export class WazuhApiCtrl {
|
||||
* Returns if the wazuh-api configuration is working
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async checkStoredAPI(req, reply) {
|
||||
try {
|
||||
@ -258,7 +258,7 @@ export class WazuhApiCtrl {
|
||||
* This check the wazuh-api configuration received in the POST body will work
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async checkAPI(req, reply) {
|
||||
try {
|
||||
@ -394,7 +394,7 @@ export class WazuhApiCtrl {
|
||||
* This get PCI requirements
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* requirements or ErrorResponse
|
||||
* @returns {Array<Object>} requirements or ErrorResponse
|
||||
*/
|
||||
async getPciRequirement(req, reply) {
|
||||
try {
|
||||
@ -473,7 +473,7 @@ export class WazuhApiCtrl {
|
||||
* This get GDPR Requirements
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* requirements or ErrorResponse
|
||||
* @returns {Array<Object>} requirements or ErrorResponse
|
||||
*/
|
||||
async getGdprRequirement(req, reply) {
|
||||
try {
|
||||
@ -589,7 +589,7 @@ export class WazuhApiCtrl {
|
||||
* @param {Object} data data and params to perform the request
|
||||
* @param {String} id API id
|
||||
* @param {Object} reply
|
||||
* API response or ErrorResponse
|
||||
* @returns {Object} API response or ErrorResponse
|
||||
*/
|
||||
async makeRequest(method, path, data, id, reply) {
|
||||
try {
|
||||
@ -710,7 +710,7 @@ export class WazuhApiCtrl {
|
||||
* This make a request to API
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* api response or ErrorResponse
|
||||
* @returns {Object} api response or ErrorResponse
|
||||
*/
|
||||
requestApi(req, reply) {
|
||||
const configuration = getConfiguration();
|
||||
@ -761,7 +761,7 @@ export class WazuhApiCtrl {
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async fetchAgents(req, reply) {
|
||||
try {
|
||||
@ -781,7 +781,7 @@ export class WazuhApiCtrl {
|
||||
* Get full data on CSV format from a list Wazuh API endpoint
|
||||
* @param {Object} req
|
||||
* @param {Object} res
|
||||
* csv or ErrorResponse
|
||||
* @returns {Object} csv or ErrorResponse
|
||||
*/
|
||||
async csv(req, reply) {
|
||||
try {
|
||||
@ -904,7 +904,7 @@ export class WazuhApiCtrl {
|
||||
* Get the each filed unique values of agents
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* unique fileds or ErrorResponse
|
||||
* @returns {Array<Object>} unique fileds or ErrorResponse
|
||||
*/
|
||||
async getAgentsFieldsUniqueCount(req, reply) {
|
||||
try {
|
||||
|
@ -34,7 +34,7 @@ export class WazuhElasticCtrl {
|
||||
* This get the timestamp field
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* timestamp field or ErrorResponse
|
||||
* @returns {Object} timestamp field or ErrorResponse
|
||||
*/
|
||||
async getTimeStamp(req, reply) {
|
||||
try {
|
||||
@ -67,7 +67,7 @@ export class WazuhElasticCtrl {
|
||||
* This retrieve a template from Elasticsearch
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* template or ErrorResponse
|
||||
* @returns {Object} template or ErrorResponse
|
||||
*/
|
||||
async getTemplate(req, reply) {
|
||||
try {
|
||||
@ -125,7 +125,7 @@ export class WazuhElasticCtrl {
|
||||
* This check index-pattern
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async checkPattern(req, reply) {
|
||||
try {
|
||||
@ -159,7 +159,7 @@ export class WazuhElasticCtrl {
|
||||
* This get the fields keys
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* fields or ErrorResponse
|
||||
* @returns {Array<Object>} fields or ErrorResponse
|
||||
*/
|
||||
async getFieldTop(req, reply) {
|
||||
try {
|
||||
@ -216,7 +216,7 @@ export class WazuhElasticCtrl {
|
||||
* This get the elastic setup settings
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* setup info or ErrorResponse
|
||||
* @returns {Object} setup info or ErrorResponse
|
||||
*/
|
||||
async getSetupInfo(req, reply) {
|
||||
try {
|
||||
@ -242,6 +242,7 @@ export class WazuhElasticCtrl {
|
||||
* an index pattern from the list.
|
||||
* @param {Array<Object>} list List of index patterns
|
||||
* @param {Object} req
|
||||
* @returns {Array<Object>} List of allowed index
|
||||
*/
|
||||
async filterAllowedIndexPatternList(list, req) {
|
||||
let finalList = [];
|
||||
@ -296,7 +297,7 @@ export class WazuhElasticCtrl {
|
||||
* This get the list of index-patterns
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* list of index-patterns or ErrorResponse
|
||||
* @returns {Array<Object>} list of index-patterns or ErrorResponse
|
||||
*/
|
||||
async getlist(req, reply) {
|
||||
try {
|
||||
@ -459,7 +460,7 @@ export class WazuhElasticCtrl {
|
||||
* This creates a visualization of data in req
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* vis obj or ErrorResponse
|
||||
* @returns {Object} vis obj or ErrorResponse
|
||||
*/
|
||||
async createVis(req, reply) {
|
||||
try {
|
||||
@ -496,7 +497,7 @@ export class WazuhElasticCtrl {
|
||||
* This creates a visualization of cluster
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* vis obj or ErrorResponse
|
||||
* @returns {Object} vis obj or ErrorResponse
|
||||
*/
|
||||
async createClusterVis(req, reply) {
|
||||
try {
|
||||
@ -541,7 +542,7 @@ export class WazuhElasticCtrl {
|
||||
* Reload elastic index
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async refreshIndex(req, reply) {
|
||||
try {
|
||||
|
@ -168,8 +168,8 @@ export class WazuhReportingCtrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* This performs the rendering of tables
|
||||
* @param {Array<Object>} tables
|
||||
* This performs the rendering of given tables
|
||||
* @param {Array<Object>} tables tables to render
|
||||
*/
|
||||
renderTables(tables) {
|
||||
for (const table of tables) {
|
||||
@ -231,7 +231,7 @@ export class WazuhReportingCtrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* This performs the rendering of time range and filters
|
||||
* This performs the rendering of given time range and filters
|
||||
* @param {Number} from Timestamp (ms) from
|
||||
* @param {Number} to Timestamp (ms) to
|
||||
* @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability
|
||||
@ -294,7 +294,7 @@ export class WazuhReportingCtrl {
|
||||
/**
|
||||
* This do format to filters
|
||||
* @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability
|
||||
* @param {String} searchBar
|
||||
* @param {String} searchBar search term
|
||||
*/
|
||||
sanitizeFilters(filters, searchBar) {
|
||||
let str = '';
|
||||
@ -324,11 +324,11 @@ export class WazuhReportingCtrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* This performs the rendering of header
|
||||
* @param {String} section
|
||||
* @param {Object} tab
|
||||
* @param {Boolean} isAgents
|
||||
* @param {String} apiId
|
||||
* This performs the rendering of given header
|
||||
* @param {String} section section target
|
||||
* @param {Object} tab tab target
|
||||
* @param {Boolean} isAgents is agents section
|
||||
* @param {String} apiId ID of API
|
||||
*/
|
||||
async renderHeader(section, tab, isAgents, apiId) {
|
||||
try {
|
||||
@ -406,9 +406,9 @@ export class WazuhReportingCtrl {
|
||||
|
||||
/**
|
||||
* This check if title is suitable
|
||||
* @param {Object} item
|
||||
* @param {Boolean} isAgents
|
||||
* @param {Object} tab
|
||||
* @param {Object} item item of the title
|
||||
* @param {Boolean} isAgents is agents section
|
||||
* @param {Object} tab tab target
|
||||
*/
|
||||
checkTitle(item, isAgents, tab) {
|
||||
const title = isAgents
|
||||
@ -418,10 +418,10 @@ export class WazuhReportingCtrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* This performs the rendering of the visualizations
|
||||
* @param {Array<Objecys>} array
|
||||
* @param {Boolean} isAgents
|
||||
* @param {Object} tab
|
||||
* This performs the rendering of given visualizations
|
||||
* @param {Array<Objecys>} array Array of visualizations
|
||||
* @param {Boolean} isAgents is agents section
|
||||
* @param {Object} tab tab target
|
||||
*/
|
||||
renderVisualizations(array, isAgents, tab) {
|
||||
const single_vis = array.filter(item => item.width >= 600);
|
||||
@ -495,8 +495,8 @@ export class WazuhReportingCtrl {
|
||||
|
||||
/**
|
||||
* This build the agents table
|
||||
* @param {Array<Strings>} ids
|
||||
* @param {String} apiId
|
||||
* @param {Array<Strings>} ids ids of agents
|
||||
* @param {String} apiId API id
|
||||
*/
|
||||
async buildAgentsTable(ids, apiId) {
|
||||
if (!ids || !ids.length) return;
|
||||
@ -548,15 +548,16 @@ export class WazuhReportingCtrl {
|
||||
}
|
||||
|
||||
/**
|
||||
* This load more infomration
|
||||
* @param {String} section
|
||||
* @param {Object} tab
|
||||
* @param {String} apiId
|
||||
* This load more information
|
||||
* @param {String} section section target
|
||||
* @param {Object} tab tab target
|
||||
* @param {String} apiId ID of API
|
||||
* @param {Number} from Timestamp (ms) from
|
||||
* @param {Number} to Timestamp (ms) to
|
||||
* @param {String} filters E.g: cluster.name: wazuh AND rule.groups: vulnerability
|
||||
* @param {String} pattern
|
||||
* @param {Object} agent
|
||||
* @param {Object} agent agent target
|
||||
* @returns {Object} Extended information
|
||||
*/
|
||||
async extendedInformation(
|
||||
section,
|
||||
@ -1352,7 +1353,7 @@ export class WazuhReportingCtrl {
|
||||
* Builds a PDF report from multiple PNG images
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* pdf or ErrorResponse
|
||||
* @returns {Object} pdf or ErrorResponse
|
||||
*/
|
||||
async report(req, reply) {
|
||||
try {
|
||||
@ -1462,7 +1463,7 @@ export class WazuhReportingCtrl {
|
||||
* Fetch the reports list
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* reports list or ErrorResponse
|
||||
* @returns {Array<Object>}reports list or ErrorResponse
|
||||
*/
|
||||
async getReports(req, reply) {
|
||||
try {
|
||||
@ -1493,7 +1494,7 @@ export class WazuhReportingCtrl {
|
||||
* Fetch specific report
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* report or ErrorResponse
|
||||
* @returns {Object} report or ErrorResponse
|
||||
*/
|
||||
async getReportByName(req, reply) {
|
||||
try {
|
||||
@ -1510,7 +1511,7 @@ export class WazuhReportingCtrl {
|
||||
* Delete specific report
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* status obj or ErrorResponse
|
||||
* @returns {Object} status obj or ErrorResponse
|
||||
*/
|
||||
async deleteReportByName(req, reply) {
|
||||
try {
|
||||
|
@ -27,7 +27,7 @@ export class WazuhUtilsCtrl {
|
||||
* Returns the config.yml file parsed
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* Configuration File or ErrorResponse
|
||||
* @returns {Object} Configuration File or ErrorResponse
|
||||
*/
|
||||
getConfigurationFile(req, reply) {
|
||||
try {
|
||||
@ -47,7 +47,7 @@ export class WazuhUtilsCtrl {
|
||||
* Returns total RAM available from the current machine where Kibana is being executed
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* total ram or ErrorResponse
|
||||
* @returns {Number} total ram or ErrorResponse
|
||||
*/
|
||||
async totalRam(req, reply) {
|
||||
try {
|
||||
@ -63,7 +63,7 @@ export class WazuhUtilsCtrl {
|
||||
* Returns Wazuh app logs
|
||||
* @param {Object} req
|
||||
* @param {Object} reply
|
||||
* app logos or ErrorResponse
|
||||
* @returns {Array<String>} app logs or ErrorResponse
|
||||
*/
|
||||
async getAppLogs(req, reply) {
|
||||
try {
|
||||
|
@ -9,6 +9,10 @@
|
||||
*
|
||||
* Find more information about this on the LICENSE file.
|
||||
*/
|
||||
/**
|
||||
* Gets the correct path of given url
|
||||
* @param {*} config
|
||||
*/
|
||||
export function getPath(config) {
|
||||
let path = config.url;
|
||||
let protocol;
|
||||
|
Loading…
Reference in New Issue
Block a user