mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-07 10:18:57 +00:00
commit
8a4ef586de
@ -215,7 +215,8 @@ app.controller('clusterController', function(
|
||||
$scope.status = status.data.data.running;
|
||||
if ($scope.status === 'no') {
|
||||
$scope.isClusterRunning = false;
|
||||
throw new Error('Cluster is not running');
|
||||
$scope.loading = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const data = await Promise.all([
|
||||
|
@ -55,8 +55,7 @@ class HealthCheck {
|
||||
this.$scope.totalChecks = 0;
|
||||
}
|
||||
|
||||
handleError(error) {
|
||||
this.errorHandler.handle(error, 'Health Check');
|
||||
handleError(error) {
|
||||
this.$scope.errors.push(
|
||||
this.errorHandler.handle(error, 'Health Check', false, true)
|
||||
);
|
||||
@ -222,7 +221,7 @@ class HealthCheck {
|
||||
if (!this.$scope.$$phase) this.$scope.$digest();
|
||||
return;
|
||||
} catch (error) {
|
||||
this.errorHandler.handle(error, 'Health Check');
|
||||
this.handleError(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,11 @@ app.controller('settingsController', function(
|
||||
// Get settings function
|
||||
const getSettings = async () => {
|
||||
try {
|
||||
const patternList = await genericReq.request('GET', '/elastic/index-patterns', {});
|
||||
const patternList = await genericReq.request(
|
||||
'GET',
|
||||
'/elastic/index-patterns',
|
||||
{}
|
||||
);
|
||||
$scope.indexPatterns = patternList.data.data;
|
||||
|
||||
if (!patternList.data.data.length) {
|
||||
@ -189,7 +193,7 @@ app.controller('settingsController', function(
|
||||
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
getCurrentAPIIndex();
|
||||
if (!currentApiEntryIndex) return;
|
||||
if (!currentApiEntryIndex && currentApiEntryIndex !== 0) return;
|
||||
|
||||
if (currentApi && !appState.getExtensions(JSON.parse(currentApi).id)) {
|
||||
appState.setExtensions(
|
||||
@ -296,11 +300,7 @@ app.controller('settingsController', function(
|
||||
tmpData.cluster_info = checkData.data;
|
||||
|
||||
// Insert new API entry
|
||||
const data = await genericReq.request(
|
||||
'PUT',
|
||||
'/elastic/api',
|
||||
tmpData
|
||||
);
|
||||
const data = await genericReq.request('PUT', '/elastic/api', tmpData);
|
||||
appState.setExtensions(data.data.response._id, tmpData.extensions);
|
||||
const newEntry = {
|
||||
_id: data.data.response._id,
|
||||
@ -411,11 +411,7 @@ app.controller('settingsController', function(
|
||||
|
||||
const data = await testAPI.check(tmpData);
|
||||
tmpData.cluster_info = data.data;
|
||||
await genericReq.request(
|
||||
'PUT',
|
||||
'/elastic/api-settings',
|
||||
tmpData
|
||||
);
|
||||
await genericReq.request('PUT', '/elastic/api-settings', tmpData);
|
||||
$scope.apiEntries[index]._source.cluster_info = tmpData.cluster_info;
|
||||
|
||||
wzMisc.setApiIsDown(false);
|
||||
@ -446,9 +442,9 @@ app.controller('settingsController', function(
|
||||
($scope.addManagerContainer = !$scope.addManagerContainer);
|
||||
|
||||
// Check manager connectivity
|
||||
$scope.checkManager = async item => {
|
||||
$scope.checkManager = async (item, isIndex) => {
|
||||
try {
|
||||
const index = $scope.apiEntries.indexOf(item);
|
||||
const index = isIndex ? item : $scope.apiEntries.indexOf(item);
|
||||
|
||||
const tmpData = {
|
||||
user: $scope.apiEntries[index]._source.api_user,
|
||||
@ -463,9 +459,7 @@ app.controller('settingsController', function(
|
||||
const data = await testAPI.check(tmpData);
|
||||
tmpData.cluster_info = data.data;
|
||||
|
||||
const tmpUrl = `/elastic/api-hostname/${
|
||||
$scope.apiEntries[index]._id
|
||||
}`;
|
||||
const tmpUrl = `/elastic/api-hostname/${$scope.apiEntries[index]._id}`;
|
||||
await genericReq.request('PUT', tmpUrl, {
|
||||
cluster_info: tmpData.cluster_info
|
||||
});
|
||||
@ -479,7 +473,7 @@ app.controller('settingsController', function(
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
} catch (error) {
|
||||
printError(error);
|
||||
if(!wzMisc.getApiIsDown()) printError(error);
|
||||
}
|
||||
};
|
||||
|
||||
@ -503,7 +497,11 @@ app.controller('settingsController', function(
|
||||
$scope.changeIndexPattern = async newIndexPattern => {
|
||||
try {
|
||||
appState.setCurrentPattern(newIndexPattern);
|
||||
await genericReq.request('GET', `/elastic/known-fields/${newIndexPattern}`, {});
|
||||
await genericReq.request(
|
||||
'GET',
|
||||
`/elastic/known-fields/${newIndexPattern}`,
|
||||
{}
|
||||
);
|
||||
$scope.$emit('updatePattern', {});
|
||||
errorHandler.info(
|
||||
'Successfully changed the default index-pattern',
|
||||
@ -585,7 +583,10 @@ app.controller('settingsController', function(
|
||||
if ($scope.tab === 'logs') {
|
||||
getAppLogs();
|
||||
}
|
||||
|
||||
getCurrentAPIIndex();
|
||||
if (currentApiEntryIndex || currentApiEntryIndex === 0) {
|
||||
await $scope.checkManager(currentApiEntryIndex, true);
|
||||
}
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
return;
|
||||
} catch (error) {
|
||||
|
@ -20,7 +20,7 @@ export function clickAction(
|
||||
) {
|
||||
if (
|
||||
instance.path === '/agents' ||
|
||||
new RegExp(/^\/agents\/groups\/[a-zA-Z0-9]*$/).test(instance.path)
|
||||
new RegExp(/^\/agents\/groups\/[a-zA-Z0-9_\-\.]*$/).test(instance.path)
|
||||
) {
|
||||
shareAgent.setAgent(item);
|
||||
|
||||
@ -49,7 +49,7 @@ export function clickAction(
|
||||
} else if (instance.path === '/agents/groups') {
|
||||
$scope.$emit('wazuhShowGroup', { group: item });
|
||||
} else if (
|
||||
new RegExp(/^\/agents\/groups\/[a-zA-Z0-9]*\/files$/).test(instance.path)
|
||||
new RegExp(/^\/agents\/groups\/[a-zA-Z0-9_\-\.]*\/files$/).test(instance.path)
|
||||
) {
|
||||
$scope.$emit('wazuhShowGroupFile', {
|
||||
groupName: instance.path.split('groups/')[1].split('/files')[0],
|
||||
|
@ -13,7 +13,7 @@
|
||||
export async function nextPage(currentPage, $scope, errorHandler, fetch) {
|
||||
try {
|
||||
$scope.error = false;
|
||||
if (!currentPage && $scope.currentPage < $scope.pagedItems.length - 1) {
|
||||
if (!currentPage && currentPage !== 0 && $scope.currentPage < $scope.pagedItems.length - 1) {
|
||||
$scope.currentPage++;
|
||||
}
|
||||
if ($scope.pagedItems[currentPage || $scope.currentPage].includes(null)) {
|
||||
|
@ -23,18 +23,19 @@ export function settingsWizard(
|
||||
genericReq,
|
||||
errorHandler,
|
||||
wzMisc,
|
||||
wazuhConfig
|
||||
wazuhConfig,
|
||||
disableErrors = false
|
||||
) {
|
||||
try {
|
||||
const deferred = $q.defer();
|
||||
|
||||
!$location.path().includes('health-check') &&
|
||||
!disableErrors &&
|
||||
totalRAM(genericReq, errorHandler);
|
||||
|
||||
const checkResponse = data => {
|
||||
let fromElastic = false;
|
||||
if (parseInt(data.data.error) === 2) {
|
||||
errorHandler.handle(
|
||||
!disableErrors && errorHandler.handle(
|
||||
'Wazuh App: Please set up Wazuh API credentials.',
|
||||
'Routes',
|
||||
true
|
||||
@ -45,7 +46,7 @@ export function settingsWizard(
|
||||
(data && data.data && data.data.data && data.data.data.apiIsDown)
|
||||
) {
|
||||
wzMisc.setApiIsDown(true);
|
||||
errorHandler.handle('Wazuh RESTful API seems to be down.', 'Routes');
|
||||
!disableErrors && errorHandler.handle('Wazuh RESTful API seems to be down.', 'Routes');
|
||||
} else {
|
||||
fromElastic = true;
|
||||
wzMisc.setBlankScr(errorHandler.handle(data, 'Routes'));
|
||||
@ -67,7 +68,7 @@ export function settingsWizard(
|
||||
parseInt(data.data.error) === 7 &&
|
||||
data.data.message === '401 Unauthorized'
|
||||
) {
|
||||
errorHandler.handle(
|
||||
!disableErrors && errorHandler.handle(
|
||||
'Wrong Wazuh API credentials, please add a new API and/or modify the existing one.',
|
||||
'Routes'
|
||||
);
|
||||
@ -161,8 +162,8 @@ export function settingsWizard(
|
||||
.catch(error => {
|
||||
appState.removeCurrentAPI();
|
||||
|
||||
errorHandler.handle(error, 'Routes');
|
||||
errorHandler.handle(
|
||||
!disableErrors && errorHandler.handle(error, 'Routes');
|
||||
!disableErrors && errorHandler.handle(
|
||||
'Please insert a new Wazuh API or select an existing valid one.',
|
||||
'Routes',
|
||||
true
|
||||
@ -175,7 +176,7 @@ export function settingsWizard(
|
||||
};
|
||||
|
||||
if (
|
||||
!$location.path().includes('/health-check') &&
|
||||
!disableErrors &&
|
||||
healthCheck($window, $rootScope)
|
||||
) {
|
||||
$location.path('/health-check');
|
||||
@ -213,7 +214,7 @@ export function settingsWizard(
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
errorHandler.handle(error, 'Routes');
|
||||
!disableErrors && errorHandler.handle(error, 'Routes');
|
||||
wzMisc.setWizard(true);
|
||||
if (!$location.path().includes('/settings')) {
|
||||
$location.search('_a', null);
|
||||
@ -229,6 +230,6 @@ export function settingsWizard(
|
||||
|
||||
return deferred.promise;
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Routes');
|
||||
!disableErrors && errorHandler.handle(error, 'Routes');
|
||||
}
|
||||
}
|
||||
|
@ -81,6 +81,7 @@ function nestedResolve(
|
||||
wzMisc
|
||||
) {
|
||||
assignPreviousLocation($rootScope, $location);
|
||||
const location = $location.path();
|
||||
return getWzConfig($q, genericReq, errorHandler, wazuhConfig).then(() =>
|
||||
settingsWizard(
|
||||
$rootScope,
|
||||
@ -92,7 +93,8 @@ function nestedResolve(
|
||||
genericReq,
|
||||
errorHandler,
|
||||
wzMisc,
|
||||
wazuhConfig
|
||||
wazuhConfig,
|
||||
location && location.includes('/health-check')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
<!-- End back button, title and status indicator -->
|
||||
|
||||
<!-- Decoder information ribbon -->
|
||||
<div layout="row">
|
||||
<div layout="row" class="wz-padding-left-16">
|
||||
<md-card flex class="wz-metric-color wz-md-card">
|
||||
<md-card-content layout="row" class="wz-padding-metric">
|
||||
<div flex="20" ng-if="currentDecoder.position || currentDecoder.position == 0" class="wz-text-truncatable">Position: <span class="wz-text-bold">{{currentDecoder.position}}</span></div>
|
||||
@ -24,7 +24,7 @@
|
||||
<!-- Rest of decoder information -->
|
||||
<div layout="column" layout-align="start">
|
||||
|
||||
<div layout="row" layout-align="start stretch">
|
||||
<div layout="row" class="wz-padding-left-16" layout-align="start stretch">
|
||||
|
||||
<!-- Details section -->
|
||||
<md-card flex class="wz-md-card">
|
||||
@ -127,7 +127,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="start stretch">
|
||||
<div layout="row" class="wz-padding-left-16" layout-align="start stretch">
|
||||
|
||||
<!-- Match section -->
|
||||
<md-card flex class="wz-md-card" ng-if="isArray(currentDecoder.details.match)">
|
||||
@ -160,7 +160,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Related decoders section -->
|
||||
<div layout="row" ng-if="currentDecoder">
|
||||
<div layout="row" class="wz-padding-left-16" ng-if="currentDecoder">
|
||||
<h1 class="md-headline wz-headline"><i class="fa fa-fw fa-link" aria-hidden="true"></i> Related decoders</h1>
|
||||
</div>
|
||||
<div layout="row" ng-if="currentDecoder" class="md-padding">
|
||||
|
@ -11,7 +11,7 @@
|
||||
<!-- End back button, title and status indicator -->
|
||||
|
||||
<!-- Rule information ribbon -->
|
||||
<div layout="row">
|
||||
<div layout="row" class="wz-padding-left-16">
|
||||
<md-card flex class="wz-metric-color wz-md-card">
|
||||
<md-card-content layout="row" class="wz-padding-metric">
|
||||
<div flex="15" ng-if="currentRule.id" class="wz-text-truncatable">ID: <span class="wz-text-bold">{{currentRule.id}}</span></div>
|
||||
@ -27,7 +27,7 @@
|
||||
<!-- Rest of rule information -->
|
||||
<div layout="column" layout-align="start">
|
||||
|
||||
<div layout="row" layout-align="start stretch">
|
||||
<div layout="row" class="wz-padding-left-16" layout-align="start stretch">
|
||||
|
||||
<!-- Groups section -->
|
||||
<md-card ng-if="currentRule.groups.length > 0" flex class="wz-md-card">
|
||||
@ -122,7 +122,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="start stretch" ng-if="currentRule.pci.length > 0 || currentRule.gdpr.length > 0">
|
||||
<div layout="row" class="wz-padding-left-16" layout-align="start stretch" ng-if="currentRule.pci.length > 0 || currentRule.gdpr.length > 0">
|
||||
|
||||
<!-- PCI section -->
|
||||
<md-card ng-if="currentRule.pci.length > 0" flex class="wz-md-card">
|
||||
@ -154,7 +154,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div layout="row" layout-align="start stretch" ng-if="isArray(currentRule.details.regex) || isArray(currentRule.details.match) || isArray(currentRule.details.prematch)">
|
||||
<div layout="row" class="wz-padding-left-16" layout-align="start stretch" ng-if="isArray(currentRule.details.regex) || isArray(currentRule.details.match) || isArray(currentRule.details.prematch)">
|
||||
|
||||
<!-- Regex section -->
|
||||
<md-card flex class="wz-md-card" ng-if="isArray(currentRule.details.regex)">
|
||||
@ -201,7 +201,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Related rules section -->
|
||||
<div layout="row" ng-if="currentRule">
|
||||
<div layout="row" class="wz-padding-left-16" ng-if="currentRule">
|
||||
<h1 class="md-headline wz-headline"><i class="fa fa-fw fa-link" aria-hidden="true"></i> Related rules</h1>
|
||||
</div>
|
||||
<div layout="row" ng-if="currentRule" class="md-padding">
|
||||
|
@ -12,7 +12,7 @@
|
||||
<md-card flex class="wz-md-card">
|
||||
<md-card-content>
|
||||
<div layout="row">
|
||||
<p class="md-body-1"><strong>Note:</strong> The index pattern chosen must use the template for Wazuh alerts, otherwise you won't be able to select it.<p>
|
||||
<p class="md-body-1"><strong>Note:</strong> The chosen index pattern must use the template for Wazuh alerts, otherwise, you won't be able to select it.</p>
|
||||
</div>
|
||||
<div flex="25" layout="column" class="wz-select-input wz-margin-top-10">
|
||||
<select class="kuiSelect wz-border-none cursor-pointer" ng-model="selectedIndexPattern" ng-change="changeIndexPattern(selectedIndexPattern)" aria-label="Select index pattern">
|
||||
|
@ -21,9 +21,6 @@ import { Monitoring } from '../monitoring';
|
||||
import { ErrorResponse } from './error-response';
|
||||
import { Parser } from 'json2csv';
|
||||
import { getConfiguration } from '../lib/get-configuration';
|
||||
import { totalmem } from 'os';
|
||||
import simpleTail from 'simple-tail';
|
||||
import path from 'path';
|
||||
import { log } from '../logger';
|
||||
import { KeyEquivalenece } from '../../util/csv-key-equivalence';
|
||||
import { cleanKeys } from '../../util/remove-key';
|
||||
@ -47,19 +44,19 @@ export class WazuhApiCtrl {
|
||||
'Valid credentials not found in Elasticsearch. It seems the credentials were not saved.'
|
||||
);
|
||||
}
|
||||
|
||||
const credInfo = {
|
||||
headers: {
|
||||
'wazuh-app-version': packageInfo.version
|
||||
},
|
||||
username: wapi_config.user,
|
||||
password: wapi_config.password,
|
||||
rejectUnauthorized: !wapi_config.insecure
|
||||
};
|
||||
let response = await needle(
|
||||
'get',
|
||||
`${wapi_config.url}:${wapi_config.port}/version`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
'wazuh-app-version': packageInfo.version
|
||||
},
|
||||
username: wapi_config.user,
|
||||
password: wapi_config.password,
|
||||
rejectUnauthorized: !wapi_config.insecure
|
||||
}
|
||||
credInfo
|
||||
);
|
||||
|
||||
if (parseInt(response.body.error) === 0 && response.body.data) {
|
||||
@ -68,31 +65,36 @@ export class WazuhApiCtrl {
|
||||
'get',
|
||||
`${wapi_config.url}:${wapi_config.port}/cluster/status`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
'wazuh-app-version': packageInfo.version
|
||||
},
|
||||
username: wapi_config.user,
|
||||
password: wapi_config.password,
|
||||
rejectUnauthorized: !wapi_config.insecure
|
||||
}
|
||||
credInfo
|
||||
);
|
||||
|
||||
if (!response.body.error) {
|
||||
try {
|
||||
const managerInfo = await needle(
|
||||
'get',
|
||||
`${wapi_config.url}:${wapi_config.port}/agents/000`,
|
||||
{},
|
||||
credInfo
|
||||
);
|
||||
const updatedManagerName = managerInfo.body.data.name;
|
||||
wapi_config.cluster_info.manager = updatedManagerName;
|
||||
await this.wzWrapper.updateWazuhIndexDocument(req.payload, {
|
||||
doc: { cluster_info: wapi_config.cluster_info }
|
||||
});
|
||||
} catch (error) {
|
||||
log(
|
||||
'POST /api/check-stored-api :: Error updating Wazuh manager name.',
|
||||
error.message || error
|
||||
);
|
||||
}
|
||||
|
||||
// If cluster mode is active
|
||||
if (response.body.data.enabled === 'yes') {
|
||||
response = await needle(
|
||||
'get',
|
||||
`${wapi_config.url}:${wapi_config.port}/cluster/node`,
|
||||
{},
|
||||
{
|
||||
headers: {
|
||||
'wazuh-app-version': packageInfo.version
|
||||
},
|
||||
username: wapi_config.user,
|
||||
password: wapi_config.password,
|
||||
rejectUnauthorized: !wapi_config.insecure
|
||||
}
|
||||
credInfo
|
||||
);
|
||||
|
||||
if (!response.body.error) {
|
||||
|
@ -16,7 +16,7 @@ export default [
|
||||
_source: {
|
||||
title: 'Top 5 instances',
|
||||
visState:
|
||||
'{"title":"Top 5 instances","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":false,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"data.aws.resource.instanceDetails.instanceId","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
|
||||
'{"title":"Top 5 instances","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":true,"legendPosition":"right","isDonut":true,"labels":{"show":false,"values":true,"last_level":true,"truncate":100}},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"terms","schema":"segment","params":{"field":"data.aws.requestParameters.instanceId","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
|
||||
uiStateJSON: '{}',
|
||||
description: '',
|
||||
version: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user