mirror of
https://github.com/valitydev/wazuh-kibana-app.git
synced 2024-11-06 09:55:18 +00:00
Yarn prettier
This commit is contained in:
parent
f20e78de11
commit
342120db22
@ -295,9 +295,9 @@ export function GroupsController(
|
||||
$scope.$broadcast('saveXmlFile', { group: $scope.currentGroup.name });
|
||||
};
|
||||
|
||||
$scope.$on('configurationSuccess',() => {
|
||||
$scope.$on('configurationSuccess', () => {
|
||||
$scope.editingFile = false;
|
||||
if(!$scope.$$phase) $scope.$digest();
|
||||
if (!$scope.$$phase) $scope.$digest();
|
||||
});
|
||||
|
||||
$scope.reload = async (element, searchTerm, addOffset, start) => {
|
||||
|
@ -26,10 +26,9 @@ app.directive('wzXmlFileEditor', function() {
|
||||
targetName: '=targetName'
|
||||
},
|
||||
controller($scope, $document, errorHandler, groupHandler) {
|
||||
|
||||
/**
|
||||
* Custom .replace method. Instead of using .replace which
|
||||
* evaluates regular expressions.
|
||||
* Custom .replace method. Instead of using .replace which
|
||||
* evaluates regular expressions.
|
||||
* Alternative using split + join, same result.
|
||||
*/
|
||||
String.prototype.xmlReplace = function(str, newstr) {
|
||||
@ -41,7 +40,7 @@ app.directive('wzXmlFileEditor', function() {
|
||||
|
||||
/**
|
||||
* Escape "&" characters.
|
||||
* @param {*} text
|
||||
* @param {*} text
|
||||
*/
|
||||
const replaceIllegalXML = text => {
|
||||
const oDOM = parser.parseFromString(text, 'text/html');
|
||||
@ -62,7 +61,7 @@ app.directive('wzXmlFileEditor', function() {
|
||||
};
|
||||
|
||||
// Block function if there is another check in progress
|
||||
let checkingXmlError = false;
|
||||
let checkingXmlError = false;
|
||||
const checkXmlParseError = () => {
|
||||
if (checkingXmlError) return;
|
||||
checkingXmlError = true;
|
||||
@ -90,11 +89,14 @@ app.directive('wzXmlFileEditor', function() {
|
||||
return;
|
||||
};
|
||||
|
||||
const autoFormat = (xml) => {
|
||||
const autoFormat = xml => {
|
||||
var reg = /(>)\s*(<)(\/*)/g;
|
||||
var wsexp = / *(.*) +\n/g;
|
||||
var contexp = /(<.+>)(.+\n)/g;
|
||||
xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2');
|
||||
xml = xml
|
||||
.replace(reg, '$1\n$2$3')
|
||||
.replace(wsexp, '$1\n')
|
||||
.replace(contexp, '$1\n$2');
|
||||
var formatted = '';
|
||||
var lines = xml.split('\n');
|
||||
var indent = 0;
|
||||
@ -121,13 +123,19 @@ app.directive('wzXmlFileEditor', function() {
|
||||
for (var i = 0; i < lines.length; i++) {
|
||||
var ln = lines[i];
|
||||
if (ln.match(/\s*<\?xml/)) {
|
||||
formatted += ln + "\n";
|
||||
formatted += ln + '\n';
|
||||
continue;
|
||||
}
|
||||
var single = Boolean(ln.match(/<.+\/>/)); // is this line a single tag? ex. <br />
|
||||
var closing = Boolean(ln.match(/<\/.+>/)); // is this a closing tag? ex. </a>
|
||||
var opening = Boolean(ln.match(/<[^!].*>/)); // is this even a tag (that's not <!something>)
|
||||
var type = single ? 'single' : closing ? 'closing' : opening ? 'opening' : 'other';
|
||||
var type = single
|
||||
? 'single'
|
||||
: closing
|
||||
? 'closing'
|
||||
: opening
|
||||
? 'opening'
|
||||
: 'other';
|
||||
var fromTo = lastType + '->' + type;
|
||||
lastType = type;
|
||||
var padding = '';
|
||||
@ -137,9 +145,9 @@ app.directive('wzXmlFileEditor', function() {
|
||||
padding += '\t';
|
||||
}
|
||||
if (fromTo == 'opening->closing')
|
||||
formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'; // substr removes line break (\n) from prev loop
|
||||
else
|
||||
formatted += padding + ln + '\n';
|
||||
formatted = formatted.substr(0, formatted.length - 1) + ln + '\n';
|
||||
// substr removes line break (\n) from prev loop
|
||||
else formatted += padding + ln + '\n';
|
||||
}
|
||||
return formatted.trim();
|
||||
};
|
||||
@ -150,7 +158,7 @@ app.directive('wzXmlFileEditor', function() {
|
||||
const xml = replaceIllegalXML(text);
|
||||
await groupHandler.sendConfiguration(params.group, xml);
|
||||
errorHandler.info('Success. Group has been updated', '');
|
||||
$scope.$emit('configurationSuccess')
|
||||
$scope.$emit('configurationSuccess');
|
||||
} catch (error) {
|
||||
errorHandler.handle(error, 'Send file error');
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
this.currentKey = null;
|
||||
this.templates = {
|
||||
interval: intervalTemplate,
|
||||
filter: filterTemplate,
|
||||
filter: filterTemplate
|
||||
};
|
||||
this.locals = new Map();
|
||||
|
||||
@ -31,9 +31,10 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
addItems(rawOpts) {
|
||||
if (!isArray(rawOpts)) rawOpts = [rawOpts];
|
||||
|
||||
rawOpts.forEach((rawOpt) => {
|
||||
rawOpts.forEach(rawOpt => {
|
||||
const opt = this._applyOptDefault(rawOpt);
|
||||
if (!opt.key) throw new TypeError('KbnTopNav: menu items must have a key');
|
||||
if (!opt.key)
|
||||
throw new TypeError('KbnTopNav: menu items must have a key');
|
||||
this.opts.push(opt);
|
||||
if (!opt.hideButton()) this.menuItems.push(opt);
|
||||
if (opt.template) this.templates[opt.key] = opt.template;
|
||||
@ -44,7 +45,7 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
}
|
||||
|
||||
// change the current key and rerender
|
||||
setCurrent = (key) => {
|
||||
setCurrent = key => {
|
||||
if (key && !this.templates.hasOwnProperty(key)) {
|
||||
throw new TypeError(`KbnTopNav: unknown template key "${key}"`);
|
||||
}
|
||||
@ -54,13 +55,27 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
};
|
||||
|
||||
// little usability helpers
|
||||
getCurrent = () => { return this.currentKey; };
|
||||
isCurrent = (key) => { return this.getCurrent() === key; };
|
||||
open = (key) => { this.setCurrent(key); };
|
||||
close = (key) => { (!key || this.isCurrent(key)) && this.setCurrent(null); };
|
||||
toggle = (key) => { this.setCurrent(this.isCurrent(key) ? null : key); };
|
||||
click = (key) => { this.handleClick(this.getItem(key)); };
|
||||
getItem = (key) => { return this.menuItems.find(i => i.key === key); };
|
||||
getCurrent = () => {
|
||||
return this.currentKey;
|
||||
};
|
||||
isCurrent = key => {
|
||||
return this.getCurrent() === key;
|
||||
};
|
||||
open = key => {
|
||||
this.setCurrent(key);
|
||||
};
|
||||
close = key => {
|
||||
(!key || this.isCurrent(key)) && this.setCurrent(null);
|
||||
};
|
||||
toggle = key => {
|
||||
this.setCurrent(this.isCurrent(key) ? null : key);
|
||||
};
|
||||
click = key => {
|
||||
this.handleClick(this.getItem(key));
|
||||
};
|
||||
getItem = key => {
|
||||
return this.menuItems.find(i => i.key === key);
|
||||
};
|
||||
handleClick = (menuItem, event) => {
|
||||
if (menuItem.disableButton()) {
|
||||
return false;
|
||||
@ -74,17 +89,25 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
const defaultedOpt = {
|
||||
label: optLabel,
|
||||
hasFunction: !!opt.run,
|
||||
description: opt.run ? optLabel : i18n.translate('common.ui.topNav.toggleViewAriaLabel', {
|
||||
defaultMessage: 'Toggle {optLabel} view',
|
||||
values: { optLabel }
|
||||
}),
|
||||
run: (item) => this.toggle(item.key),
|
||||
description: opt.run
|
||||
? optLabel
|
||||
: i18n.translate('common.ui.topNav.toggleViewAriaLabel', {
|
||||
defaultMessage: 'Toggle {optLabel} view',
|
||||
values: { optLabel }
|
||||
}),
|
||||
run: item => this.toggle(item.key),
|
||||
...opt
|
||||
};
|
||||
|
||||
defaultedOpt.hideButton = isFunction(opt.hideButton) ? opt.hideButton : () => !!opt.hideButton;
|
||||
defaultedOpt.disableButton = isFunction(opt.disableButton) ? opt.disableButton : () => !!opt.disableButton;
|
||||
defaultedOpt.tooltip = isFunction(opt.tooltip) ? opt.tooltip : () => opt.tooltip;
|
||||
defaultedOpt.hideButton = isFunction(opt.hideButton)
|
||||
? opt.hideButton
|
||||
: () => !!opt.hideButton;
|
||||
defaultedOpt.disableButton = isFunction(opt.disableButton)
|
||||
? opt.disableButton
|
||||
: () => !!opt.disableButton;
|
||||
defaultedOpt.tooltip = isFunction(opt.tooltip)
|
||||
? opt.tooltip
|
||||
: () => opt.tooltip;
|
||||
|
||||
return defaultedOpt;
|
||||
}
|
||||
@ -123,7 +146,10 @@ export function KbnTopNavControllerProvider($compile) {
|
||||
if (this.locals.has(currentKey)) {
|
||||
Object.assign($childScope, this.locals.get(currentKey));
|
||||
}
|
||||
const $el = $element.find('#template_wrapper').html(templateToRender).contents();
|
||||
const $el = $element
|
||||
.find('#template_wrapper')
|
||||
.html(templateToRender)
|
||||
.contents();
|
||||
$compile($el)($childScope);
|
||||
|
||||
this.rendered = { $childScope, $el, key: currentKey };
|
||||
|
@ -143,7 +143,9 @@ function discoverController(
|
||||
location: 'Discover'
|
||||
});
|
||||
const getUnhashableStates = Private(getUnhashableStatesProvider);
|
||||
const shareContextMenuExtensions = Private(ShareContextMenuExtensionsRegistryProvider);
|
||||
const shareContextMenuExtensions = Private(
|
||||
ShareContextMenuExtensionsRegistryProvider
|
||||
);
|
||||
const inspectorAdapters = {
|
||||
requests: new RequestAdapter()
|
||||
};
|
||||
@ -269,19 +271,27 @@ function discoverController(
|
||||
const pageTitleSuffix =
|
||||
savedSearch.id && savedSearch.title ? `: ${savedSearch.title}` : '';
|
||||
docTitle.change(`Discover${pageTitleSuffix}`);
|
||||
const discoverBreadcrumbsTitle = i18n('kbn.discover.discoverBreadcrumbTitle', {
|
||||
defaultMessage: 'Discover',
|
||||
});
|
||||
const discoverBreadcrumbsTitle = i18n(
|
||||
'kbn.discover.discoverBreadcrumbTitle',
|
||||
{
|
||||
defaultMessage: 'Discover'
|
||||
}
|
||||
);
|
||||
|
||||
if (savedSearch.id && savedSearch.title) {
|
||||
chrome.breadcrumbs.set([{
|
||||
text: discoverBreadcrumbsTitle,
|
||||
href: '#/discover'
|
||||
}, { text: savedSearch.title }]);
|
||||
chrome.breadcrumbs.set([
|
||||
{
|
||||
text: discoverBreadcrumbsTitle,
|
||||
href: '#/discover'
|
||||
},
|
||||
{ text: savedSearch.title }
|
||||
]);
|
||||
} else {
|
||||
chrome.breadcrumbs.set([{
|
||||
text: discoverBreadcrumbsTitle,
|
||||
}]);
|
||||
chrome.breadcrumbs.set([
|
||||
{
|
||||
text: discoverBreadcrumbsTitle
|
||||
}
|
||||
]);
|
||||
}
|
||||
|
||||
let stateMonitor;
|
||||
@ -389,22 +399,22 @@ function discoverController(
|
||||
$state.sort = getSort.array($state.sort, $scope.indexPattern);
|
||||
|
||||
$scope.getBucketIntervalToolTipText = () => {
|
||||
return (
|
||||
i18n('kbn.discover.bucketIntervalTooltip', {
|
||||
// eslint-disable-next-line max-len
|
||||
defaultMessage: 'This interval creates {bucketsDescription} to show in the selected time range, so it has been scaled to {bucketIntervalDescription}',
|
||||
values: {
|
||||
bucketsDescription: $scope.bucketInterval.scale > 1
|
||||
return i18n('kbn.discover.bucketIntervalTooltip', {
|
||||
// eslint-disable-next-line max-len
|
||||
defaultMessage:
|
||||
'This interval creates {bucketsDescription} to show in the selected time range, so it has been scaled to {bucketIntervalDescription}',
|
||||
values: {
|
||||
bucketsDescription:
|
||||
$scope.bucketInterval.scale > 1
|
||||
? i18n('kbn.discover.bucketIntervalTooltip.tooLargeBucketsText', {
|
||||
defaultMessage: 'buckets that are too large',
|
||||
})
|
||||
defaultMessage: 'buckets that are too large'
|
||||
})
|
||||
: i18n('kbn.discover.bucketIntervalTooltip.tooManyBucketsText', {
|
||||
defaultMessage: 'too many buckets',
|
||||
}),
|
||||
bucketIntervalDescription: $scope.bucketInterval.description,
|
||||
},
|
||||
})
|
||||
);
|
||||
defaultMessage: 'too many buckets'
|
||||
}),
|
||||
bucketIntervalDescription: $scope.bucketInterval.description
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.$watchCollection('state.columns', function() {
|
||||
@ -565,7 +575,8 @@ function discoverController(
|
||||
|
||||
prev = current;
|
||||
};
|
||||
}()));
|
||||
})()
|
||||
);
|
||||
|
||||
if ($scope.opts.timefield) {
|
||||
setupVisualization();
|
||||
@ -662,12 +673,12 @@ function discoverController(
|
||||
*
|
||||
* @type {String}
|
||||
*/
|
||||
const sortBy = (function () {
|
||||
const sortBy = (function() {
|
||||
if (!Array.isArray(sort)) return 'implicit';
|
||||
else if (sort[0] === '_score') return 'implicit';
|
||||
else if (sort[0] === timeField) return 'time';
|
||||
else return 'non-time';
|
||||
}());
|
||||
})();
|
||||
|
||||
let sortFn = null;
|
||||
if (sortBy !== 'implicit') {
|
||||
@ -680,7 +691,7 @@ function discoverController(
|
||||
segmented.setMaxSegments(1);
|
||||
}
|
||||
|
||||
segmented.setDirection(sortBy === 'time' ? (sort[1] || 'desc') : 'desc');
|
||||
segmented.setDirection(sortBy === 'time' ? sort[1] || 'desc' : 'desc');
|
||||
segmented.setSortFn(sortFn);
|
||||
segmented.setSize($scope.opts.sampleSize);
|
||||
|
||||
@ -705,17 +716,25 @@ function discoverController(
|
||||
|
||||
if (status.remaining > 0) {
|
||||
const inspectorRequest = inspectorAdapters.requests.start(
|
||||
i18n('kbn.discover.inspectorRequest.segmentFetchCompleteStatusTitle', {
|
||||
defaultMessage: 'Segment {fetchCompleteStatus}',
|
||||
values: {
|
||||
fetchCompleteStatus: $scope.fetchStatus.complete,
|
||||
i18n(
|
||||
'kbn.discover.inspectorRequest.segmentFetchCompleteStatusTitle',
|
||||
{
|
||||
defaultMessage: 'Segment {fetchCompleteStatus}',
|
||||
values: {
|
||||
fetchCompleteStatus: $scope.fetchStatus.complete
|
||||
}
|
||||
}
|
||||
}),
|
||||
),
|
||||
{
|
||||
description: i18n('kbn.discover.inspectorRequest.segmentFetchCompleteStatusDescription', {
|
||||
defaultMessage: 'This request queries Elasticsearch to fetch the data for the search.',
|
||||
}),
|
||||
});
|
||||
description: i18n(
|
||||
'kbn.discover.inspectorRequest.segmentFetchCompleteStatusDescription',
|
||||
{
|
||||
defaultMessage:
|
||||
'This request queries Elasticsearch to fetch the data for the search.'
|
||||
}
|
||||
)
|
||||
}
|
||||
);
|
||||
inspectorRequest.stats(getRequestInspectorStats($scope.searchSource));
|
||||
$scope.searchSource.getSearchRequestBody().then(body => {
|
||||
inspectorRequest.json(body);
|
||||
@ -748,13 +767,11 @@ function discoverController(
|
||||
if ($scope.opts.timefield) {
|
||||
const tabifiedData = tabifyAggResponse($scope.vis.aggs, merged);
|
||||
$scope.searchSource.rawResponse = merged;
|
||||
Promise
|
||||
.resolve(responseHandler(tabifiedData))
|
||||
.then(resp => {
|
||||
if(visualizeHandler) {
|
||||
visualizeHandler.render(resp);
|
||||
}
|
||||
});
|
||||
Promise.resolve(responseHandler(tabifiedData)).then(resp => {
|
||||
if (visualizeHandler) {
|
||||
visualizeHandler.render(resp);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$scope.hits = merged.hits.total;
|
||||
@ -780,7 +797,7 @@ function discoverController(
|
||||
const fields = _.keys(indexPattern.flattenHit(hit));
|
||||
let n = fields.length;
|
||||
let field;
|
||||
while (field = fields[--n]) {
|
||||
while ((field = fields[--n])) {
|
||||
// eslint-disable-line
|
||||
if (counts[field]) counts[field] += 1;
|
||||
else counts[field] = 1;
|
||||
@ -918,14 +935,14 @@ function discoverController(
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
// we have a vis, just modify the aggs
|
||||
if ($scope.vis) {
|
||||
const visState = $scope.vis.getEnabledState();
|
||||
visState.aggs = visStateAggs;
|
||||
$scope.vis.setState(visState);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const visSavedObject = {
|
||||
indexPattern: $scope.indexPattern.id,
|
||||
@ -958,18 +975,22 @@ function discoverController(
|
||||
// return $scope.vis.getAggConfig().toDsl(); //
|
||||
///////////////////////////////////////////////////////////
|
||||
const result = $scope.vis.getAggConfig().toDsl();
|
||||
if (((result[2] || {}).date_histogram || {}).interval === '0ms') {
|
||||
if (((result[2] || {}).date_histogram || {}).interval === '0ms') {
|
||||
result[2].date_histogram.interval = '1d';
|
||||
}
|
||||
return result;
|
||||
///////////////////////////////////////////////////////////
|
||||
});
|
||||
|
||||
|
||||
$timeout(async () => {
|
||||
const visEl = $element.find('#discoverHistogram')[0];
|
||||
visualizeHandler = await visualizeLoader.embedVisualizationWithSavedObject(visEl, visSavedObject, {
|
||||
autoFetch: false,
|
||||
});
|
||||
visualizeHandler = await visualizeLoader.embedVisualizationWithSavedObject(
|
||||
visEl,
|
||||
visSavedObject,
|
||||
{
|
||||
autoFetch: false
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@ -987,36 +1008,47 @@ function discoverController(
|
||||
}
|
||||
|
||||
if (stateVal && !stateValFound) {
|
||||
const warningTitle = i18n('kbn.discover.valueIsNotConfiguredIndexPatternIDWarningTitle', {
|
||||
defaultMessage: '{stateVal} is not a configured index pattern ID',
|
||||
values: {
|
||||
stateVal: `"${stateVal}"`,
|
||||
},
|
||||
});
|
||||
const warningTitle = i18n(
|
||||
'kbn.discover.valueIsNotConfiguredIndexPatternIDWarningTitle',
|
||||
{
|
||||
defaultMessage: '{stateVal} is not a configured index pattern ID',
|
||||
values: {
|
||||
stateVal: `"${stateVal}"`
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
if (ownIndexPattern) {
|
||||
toastNotifications.addWarning({
|
||||
title: warningTitle,
|
||||
text: i18n('kbn.discover.showingSavedIndexPatternWarningDescription', {
|
||||
defaultMessage: 'Showing the saved index pattern: "{ownIndexPatternTitle}" ({ownIndexPatternId})',
|
||||
values: {
|
||||
ownIndexPatternTitle: ownIndexPattern.title,
|
||||
ownIndexPatternId: ownIndexPattern.id,
|
||||
},
|
||||
}),
|
||||
text: i18n(
|
||||
'kbn.discover.showingSavedIndexPatternWarningDescription',
|
||||
{
|
||||
defaultMessage:
|
||||
'Showing the saved index pattern: "{ownIndexPatternTitle}" ({ownIndexPatternId})',
|
||||
values: {
|
||||
ownIndexPatternTitle: ownIndexPattern.title,
|
||||
ownIndexPatternId: ownIndexPattern.id
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
return ownIndexPattern;
|
||||
}
|
||||
|
||||
toastNotifications.addWarning({
|
||||
title: warningTitle,
|
||||
text: i18n('kbn.discover.showingDefaultIndexPatternWarningDescription', {
|
||||
defaultMessage: 'Showing the default index pattern: "{loadedIndexPatternTitle}" ({loadedIndexPatternId})',
|
||||
values: {
|
||||
loadedIndexPatternTitle: loadedIndexPattern.title,
|
||||
loadedIndexPatternId: loadedIndexPattern.id,
|
||||
},
|
||||
}),
|
||||
text: i18n(
|
||||
'kbn.discover.showingDefaultIndexPatternWarningDescription',
|
||||
{
|
||||
defaultMessage:
|
||||
'Showing the default index pattern: "{loadedIndexPatternTitle}" ({loadedIndexPatternId})',
|
||||
values: {
|
||||
loadedIndexPatternTitle: loadedIndexPattern.title,
|
||||
loadedIndexPatternId: loadedIndexPattern.id
|
||||
}
|
||||
}
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
@ -1025,10 +1057,9 @@ function discoverController(
|
||||
|
||||
// Block the UI from loading if the user has loaded a rollup index pattern but it isn't
|
||||
// supported.
|
||||
$scope.isUnsupportedIndexPattern = (
|
||||
!isDefaultTypeIndexPattern($route.current.locals.ip.loaded)
|
||||
&& !hasSearchStategyForIndexPattern($route.current.locals.ip.loaded)
|
||||
);
|
||||
$scope.isUnsupportedIndexPattern =
|
||||
!isDefaultTypeIndexPattern($route.current.locals.ip.loaded) &&
|
||||
!hasSearchStategyForIndexPattern($route.current.locals.ip.loaded);
|
||||
|
||||
if ($scope.isUnsupportedIndexPattern) {
|
||||
$scope.unsupportedIndexPatternType = $route.current.locals.ip.loaded.type;
|
||||
|
@ -66,13 +66,15 @@ export function ErrorResponse(
|
||||
}
|
||||
}
|
||||
|
||||
return h.response({
|
||||
message: filteredMessage
|
||||
? `${code || 1000} - ${filteredMessage}`
|
||||
: typeof message === 'string'
|
||||
? `${code || 1000} - ${message}`
|
||||
: `${code || 1000} - Unexpected error`,
|
||||
code: code || 1000,
|
||||
statusCode: statusCode || 500
|
||||
}).code(statusCode || 500);
|
||||
return h
|
||||
.response({
|
||||
message: filteredMessage
|
||||
? `${code || 1000} - ${filteredMessage}`
|
||||
: typeof message === 'string'
|
||||
? `${code || 1000} - ${message}`
|
||||
: `${code || 1000} - Unexpected error`,
|
||||
code: code || 1000,
|
||||
statusCode: statusCode || 500
|
||||
})
|
||||
.code(statusCode || 500);
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ export class WazuhApiElasticCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
return (result);
|
||||
return result;
|
||||
} catch (error) {
|
||||
log('GET /elastic/apis', error.message || error);
|
||||
return ErrorResponse(error.message || error, 2001, 500, reply);
|
||||
@ -69,7 +69,7 @@ export class WazuhApiElasticCtrl {
|
||||
try {
|
||||
const data = await this.wzWrapper.deleteWazuhAPIEntriesWithRequest(req);
|
||||
|
||||
return (data);
|
||||
return data;
|
||||
} catch (error) {
|
||||
log('DELETE /elastic/apis/{id}', error.message || error);
|
||||
return ErrorResponse(error.message || error, 2002, 500, reply);
|
||||
@ -154,7 +154,7 @@ export class WazuhApiElasticCtrl {
|
||||
settings
|
||||
);
|
||||
|
||||
return ({ statusCode: 200, message: 'ok', response });
|
||||
return { statusCode: 200, message: 'ok', response };
|
||||
} catch (error) {
|
||||
log('PUT /elastic/api', error.message || error);
|
||||
return ErrorResponse(
|
||||
@ -178,7 +178,7 @@ export class WazuhApiElasticCtrl {
|
||||
doc: { cluster_info: req.payload.cluster_info }
|
||||
});
|
||||
|
||||
return ({ statusCode: 200, message: 'ok' });
|
||||
return { statusCode: 200, message: 'ok' };
|
||||
} catch (error) {
|
||||
log('PUT /elastic/api-hostname/{id}', error.message || error);
|
||||
return ErrorResponse(
|
||||
@ -216,7 +216,7 @@ export class WazuhApiElasticCtrl {
|
||||
doc: settings
|
||||
});
|
||||
|
||||
return ({ statusCode: 200, message: 'ok' });
|
||||
return { statusCode: 200, message: 'ok' };
|
||||
} catch (error) {
|
||||
log('PUT /elastic/api-settings', error.message || error);
|
||||
return ErrorResponse(
|
||||
|
@ -110,11 +110,11 @@ export class WazuhApiCtrl {
|
||||
api.cluster_info.node = response.body.data.node;
|
||||
api.cluster_info.cluster = response.body.data.cluster;
|
||||
api.password = '****';
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
data: api,
|
||||
idChanged: req.idChanged || null
|
||||
});
|
||||
};
|
||||
} else if (response.body.error) {
|
||||
const tmpMsg =
|
||||
((response || {}).body || {}).message ||
|
||||
@ -131,11 +131,11 @@ export class WazuhApiCtrl {
|
||||
api.cluster_info.manager = managerName;
|
||||
api.password = '****';
|
||||
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
data: api,
|
||||
idChanged: req.idChanged || null
|
||||
});
|
||||
};
|
||||
}
|
||||
} else {
|
||||
const tmpMsg =
|
||||
@ -154,10 +154,10 @@ export class WazuhApiCtrl {
|
||||
} catch (error) {
|
||||
if (error.code === 'ECONNREFUSED') {
|
||||
log('POST /api/check-stored-api', error.message || error);
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
data: { password: '****', apiIsDown: true }
|
||||
});
|
||||
};
|
||||
} else {
|
||||
// Check if we can connect to a different API
|
||||
if (
|
||||
@ -309,20 +309,20 @@ export class WazuhApiCtrl {
|
||||
);
|
||||
|
||||
if (!response.body.error) {
|
||||
return ({
|
||||
return {
|
||||
manager: managerName,
|
||||
node: response.body.data.node,
|
||||
cluster: response.body.data.cluster,
|
||||
status: 'enabled'
|
||||
});
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// Cluster mode is not active
|
||||
return ({
|
||||
return {
|
||||
manager: managerName,
|
||||
cluster: 'Disabled',
|
||||
status: 'disabled'
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -351,7 +351,7 @@ export class WazuhApiCtrl {
|
||||
|
||||
if (req.params.requirement === 'all') {
|
||||
if (!req.headers.id) {
|
||||
return (pciRequirementsFile);
|
||||
return pciRequirementsFile;
|
||||
}
|
||||
let api = await this.wzWrapper.getWazuhConfigurationById(
|
||||
req.headers.id
|
||||
@ -383,7 +383,7 @@ export class WazuhApiCtrl {
|
||||
if (typeof pciRequirementsFile[item] !== 'undefined')
|
||||
PCIobject[item] = pciRequirementsFile[item];
|
||||
}
|
||||
return (PCIobject);
|
||||
return PCIobject;
|
||||
} else {
|
||||
return ErrorResponse(
|
||||
'An error occurred trying to parse PCI DSS requirements',
|
||||
@ -399,12 +399,12 @@ export class WazuhApiCtrl {
|
||||
pci_description = pciRequirementsFile[req.params.requirement];
|
||||
}
|
||||
|
||||
return ({
|
||||
return {
|
||||
pci: {
|
||||
requirement: req.params.requirement,
|
||||
description: pci_description
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3010, 400, reply);
|
||||
@ -423,7 +423,7 @@ export class WazuhApiCtrl {
|
||||
|
||||
if (req.params.requirement === 'all') {
|
||||
if (!req.headers.id) {
|
||||
return (gdprRequirementsFile);
|
||||
return gdprRequirementsFile;
|
||||
}
|
||||
const api = await this.wzWrapper.getWazuhConfigurationById(
|
||||
req.headers.id
|
||||
@ -453,7 +453,7 @@ export class WazuhApiCtrl {
|
||||
(major >= 3 && minor < 2) ||
|
||||
(major >= 3 && minor >= 2 && patch < 3)
|
||||
) {
|
||||
return ({});
|
||||
return {};
|
||||
}
|
||||
|
||||
if (api.error_code > 1) {
|
||||
@ -482,7 +482,7 @@ export class WazuhApiCtrl {
|
||||
if (typeof gdprRequirementsFile[item] !== 'undefined')
|
||||
GDPRobject[item] = gdprRequirementsFile[item];
|
||||
}
|
||||
return (GDPRobject);
|
||||
return GDPRobject;
|
||||
} else {
|
||||
return ErrorResponse(
|
||||
'An error occurred trying to parse GDPR requirements',
|
||||
@ -498,12 +498,12 @@ export class WazuhApiCtrl {
|
||||
gdpr_description = gdprRequirementsFile[req.params.requirement];
|
||||
}
|
||||
|
||||
return ({
|
||||
return {
|
||||
gdpr: {
|
||||
requirement: req.params.requirement,
|
||||
description: gdpr_description
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3027, 400, reply);
|
||||
@ -564,11 +564,11 @@ export class WazuhApiCtrl {
|
||||
((response || {}).body || {}).data
|
||||
) {
|
||||
cleanKeys(response);
|
||||
return (response.body);
|
||||
return response.body;
|
||||
}
|
||||
|
||||
if (((response || {}).body || {}).error && devTools) {
|
||||
return (response.body);
|
||||
return response.body;
|
||||
}
|
||||
|
||||
throw ((response || {}).body || {}).error &&
|
||||
@ -577,7 +577,7 @@ export class WazuhApiCtrl {
|
||||
: new Error('Unexpected error fetching data from the Wazuh API');
|
||||
} catch (error) {
|
||||
if (devTools) {
|
||||
return ({ error: '3013', message: error.message || error });
|
||||
return { error: '3013', message: error.message || error };
|
||||
} else {
|
||||
return ErrorResponse(
|
||||
error.message || error,
|
||||
@ -700,12 +700,12 @@ export class WazuhApiCtrl {
|
||||
async fetchAgents(req, reply) {
|
||||
try {
|
||||
const output = await this.monitoringInstance.fetchAgentsExternal();
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: '0',
|
||||
data: '',
|
||||
output
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3018, 500, reply);
|
||||
}
|
||||
@ -949,7 +949,7 @@ export class WazuhApiCtrl {
|
||||
Object.assign(result.lastAgent, lastAgent.items[0]);
|
||||
}
|
||||
|
||||
return ({ error: 0, result });
|
||||
return { error: 0, result };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3035, 500, reply);
|
||||
}
|
||||
|
@ -43,10 +43,10 @@ export class WazuhElasticCtrl {
|
||||
((((data || {}).hits || {}).hits || [])[0] || {})._source || {};
|
||||
|
||||
if (source.installationDate && source.lastRestart) {
|
||||
return ({
|
||||
return {
|
||||
installationDate: data.hits.hits[0]._source.installationDate,
|
||||
lastRestart: data.hits.hits[0]._source.lastRestart
|
||||
});
|
||||
};
|
||||
} else {
|
||||
throw new Error('Could not fetch .wazuh-version index');
|
||||
}
|
||||
@ -115,16 +115,16 @@ export class WazuhElasticCtrl {
|
||||
});
|
||||
|
||||
return isIncluded && Array.isArray(isIncluded) && isIncluded.length
|
||||
? ({
|
||||
? {
|
||||
statusCode: 200,
|
||||
status: true,
|
||||
data: `Template found for ${req.params.pattern}`
|
||||
})
|
||||
: ({
|
||||
}
|
||||
: {
|
||||
statusCode: 200,
|
||||
status: false,
|
||||
data: `No template found for ${req.params.pattern}`
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
log('GET /elastic/template/{pattern}', error.message || error);
|
||||
return ErrorResponse(
|
||||
@ -152,13 +152,13 @@ export class WazuhElasticCtrl {
|
||||
);
|
||||
|
||||
return filtered.length >= 1
|
||||
? ({ statusCode: 200, status: true, data: 'Index pattern found' })
|
||||
: ({
|
||||
? { statusCode: 200, status: true, data: 'Index pattern found' }
|
||||
: {
|
||||
statusCode: 500,
|
||||
status: false,
|
||||
error: 10020,
|
||||
message: 'Index pattern not found'
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
log('GET /elastic/index-patterns/{pattern}', error.message || error);
|
||||
return ErrorResponse(
|
||||
@ -218,11 +218,11 @@ export class WazuhElasticCtrl {
|
||||
|
||||
return data.hits.total === 0 ||
|
||||
typeof data.aggregations['2'].buckets[0] === 'undefined'
|
||||
? ({ statusCode: 200, data: '' })
|
||||
: ({
|
||||
? { statusCode: 200, data: '' }
|
||||
: {
|
||||
statusCode: 200,
|
||||
data: data.aggregations['2'].buckets[0].key
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 4004, 500, reply);
|
||||
}
|
||||
@ -239,8 +239,8 @@ export class WazuhElasticCtrl {
|
||||
const data = await this.wzWrapper.getWazuhVersionIndexAsSearch();
|
||||
|
||||
return data.hits.total === 0
|
||||
? ({ statusCode: 200, data: '' })
|
||||
: ({ statusCode: 200, data: data.hits.hits[0]._source });
|
||||
? { statusCode: 200, data: '' }
|
||||
: { statusCode: 200, data: data.hits.hits[0]._source };
|
||||
} catch (error) {
|
||||
log('GET /elastic/setup', error.message || error);
|
||||
return ErrorResponse(
|
||||
@ -351,12 +351,12 @@ export class WazuhElasticCtrl {
|
||||
item && item.title && !config['ip.ignore'].includes(item.title)
|
||||
);
|
||||
}
|
||||
return ({
|
||||
return {
|
||||
data:
|
||||
isXpackEnabled && !isSuperUser
|
||||
? await this.filterAllowedIndexPatternList(list, req)
|
||||
: list
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
@ -528,7 +528,7 @@ export class WazuhElasticCtrl {
|
||||
: AgentsVisualizations[tabSufix];
|
||||
|
||||
const raw = await this.buildVisualizationsRaw(file, req.params.pattern);
|
||||
return ({ acknowledge: true, raw: raw });
|
||||
return { acknowledge: true, raw: raw };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 4007, 500, reply);
|
||||
}
|
||||
@ -573,7 +573,7 @@ export class WazuhElasticCtrl {
|
||||
pattern_name
|
||||
);
|
||||
|
||||
return ({ acknowledge: true, raw: raw });
|
||||
return { acknowledge: true, raw: raw };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 4009, 500, reply);
|
||||
}
|
||||
@ -596,7 +596,7 @@ export class WazuhElasticCtrl {
|
||||
req.params.pattern
|
||||
);
|
||||
|
||||
return ({ acknowledge: true, output: output });
|
||||
return { acknowledge: true, output: output };
|
||||
} catch (error) {
|
||||
log('GET /elastic/known-fields/{pattern}', error.message || error);
|
||||
return ErrorResponse(error.message || error, 4008, 500, reply);
|
||||
@ -661,7 +661,7 @@ export class WazuhElasticCtrl {
|
||||
'rule.description'
|
||||
];
|
||||
const data = await this.wzWrapper.searchWazuhAlertsWithPayload(payload);
|
||||
return ({ alerts: data.hits.hits });
|
||||
return { alerts: data.hits.hits };
|
||||
} catch (error) {
|
||||
log('POST /elastic/alerts', error.message || error);
|
||||
return ErrorResponse(error.message || error, 4010, 500, reply);
|
||||
|
@ -1617,7 +1617,7 @@ export class WazuhReportingCtrl {
|
||||
);
|
||||
pdfDoc.end();
|
||||
}
|
||||
return ({ error: 0, data: null });
|
||||
return { error: 0, data: null };
|
||||
} catch (error) {
|
||||
// Delete generated file if an error occurred
|
||||
if (
|
||||
@ -1659,7 +1659,7 @@ export class WazuhReportingCtrl {
|
||||
list.push(file);
|
||||
});
|
||||
TimSort.sort(list, sortFunction);
|
||||
return ({ list: list });
|
||||
return { list: list };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 5031, 500, reply);
|
||||
}
|
||||
@ -1694,7 +1694,7 @@ export class WazuhReportingCtrl {
|
||||
fs.unlinkSync(
|
||||
path.join(__dirname, REPORTING_PATH + '/' + req.params.name)
|
||||
);
|
||||
return ({ error: 0 });
|
||||
return { error: 0 };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 5032, 500, reply);
|
||||
}
|
||||
|
@ -35,11 +35,11 @@ export class WazuhUtilsCtrl {
|
||||
try {
|
||||
const configFile = getConfiguration();
|
||||
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: 0,
|
||||
data: configFile || {}
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3019, 500, reply);
|
||||
}
|
||||
@ -54,11 +54,11 @@ export class WazuhUtilsCtrl {
|
||||
async updateConfigurationFile(req, reply) {
|
||||
try {
|
||||
const result = updateConfigurationFile.updateConfiguration(req);
|
||||
return ({
|
||||
return {
|
||||
statusCode: 200,
|
||||
error: 0,
|
||||
data: result.needRestart
|
||||
});
|
||||
};
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3021, 500, reply);
|
||||
}
|
||||
@ -74,7 +74,7 @@ export class WazuhUtilsCtrl {
|
||||
try {
|
||||
// RAM in MB
|
||||
const ram = Math.ceil(totalmem() / 1024 / 1024);
|
||||
return ({ statusCode: 200, error: 0, ram });
|
||||
return { statusCode: 200, error: 0, ram };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3033, 500, reply);
|
||||
}
|
||||
@ -93,13 +93,13 @@ export class WazuhUtilsCtrl {
|
||||
20
|
||||
);
|
||||
return lastLogs && Array.isArray(lastLogs)
|
||||
? ({
|
||||
? {
|
||||
error: 0,
|
||||
lastLogs: lastLogs.filter(
|
||||
item => typeof item === 'string' && item.length
|
||||
)
|
||||
})
|
||||
: ({ error: 0, lastLogs: [] });
|
||||
}
|
||||
: { error: 0, lastLogs: [] };
|
||||
} catch (error) {
|
||||
return ErrorResponse(error.message || error, 3036, 500, reply);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ export default [
|
||||
version: 1,
|
||||
kibanaSavedObjectMeta: {
|
||||
searchSourceJSON:
|
||||
'{"index":"wazuh-alerts","query":{"query":"","language":"lucene"},"filter":[]}'
|
||||
'{"index":"wazuh-alerts","query":{"query":"","language":"lucene"},"filter":[]}'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -193,7 +193,7 @@ export default [
|
||||
_source: {
|
||||
title: 'Alert level evolution',
|
||||
visState:
|
||||
"{\"title\":\"Alert level evolution\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":true,\"style\":{\"color\":\"#eee\"}},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"line\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"cardinal\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":true,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"timeRange\":{\"from\":\"now-15m\",\"to\":\"now\",\"mode\":\"quick\"},\"useNormalizedEsInterval\":true,\"interval\":\"auto\",\"time_zone\":\"Europe/Berlin\",\"drop_partials\":false,\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}},{\"id\":\"3\",\"enabled\":true,\"type\":\"terms\",\"schema\":\"group\",\"params\":{\"field\":\"rule.level\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"}}]}",
|
||||
'{"title":"Alert level evolution","type":"area","params":{"type":"area","grid":{"categoryLines":true,"style":{"color":"#eee"}},"categoryAxes":[{"id":"CategoryAxis-1","type":"category","position":"bottom","show":true,"style":{},"scale":{"type":"linear"},"labels":{"show":true,"truncate":100},"title":{}}],"valueAxes":[{"id":"ValueAxis-1","name":"LeftAxis-1","type":"value","position":"left","show":true,"style":{},"scale":{"type":"linear","mode":"normal"},"labels":{"show":true,"rotate":0,"filter":false,"truncate":100},"title":{"text":"Count"}}],"seriesParams":[{"show":"true","type":"line","mode":"stacked","data":{"label":"Count","id":"1"},"drawLinesBetweenPoints":true,"showCircles":true,"interpolate":"cardinal","valueAxis":"ValueAxis-1"}],"addTooltip":true,"addLegend":true,"legendPosition":"right","times":[],"addTimeMarker":false},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"date_histogram","schema":"segment","params":{"field":"@timestamp","timeRange":{"from":"now-15m","to":"now","mode":"quick"},"useNormalizedEsInterval":true,"interval":"auto","time_zone":"Europe/Berlin","drop_partials":false,"customInterval":"2h","min_doc_count":1,"extended_bounds":{}}},{"id":"3","enabled":true,"type":"terms","schema":"group","params":{"field":"rule.level","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
|
||||
uiStateJSON: '{}',
|
||||
description: '',
|
||||
version: 1,
|
||||
@ -209,7 +209,7 @@ export default [
|
||||
_source: {
|
||||
title: 'Alerts',
|
||||
visState:
|
||||
"{\"title\":\"Alerts\",\"type\":\"area\",\"params\":{\"type\":\"area\",\"grid\":{\"categoryLines\":true,\"style\":{\"color\":\"#eee\"},\"valueAxis\":null},\"categoryAxes\":[{\"id\":\"CategoryAxis-1\",\"type\":\"category\",\"position\":\"bottom\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\"},\"labels\":{\"show\":true,\"truncate\":100},\"title\":{}}],\"valueAxes\":[{\"id\":\"ValueAxis-1\",\"name\":\"LeftAxis-1\",\"type\":\"value\",\"position\":\"left\",\"show\":true,\"style\":{},\"scale\":{\"type\":\"linear\",\"mode\":\"normal\"},\"labels\":{\"show\":true,\"rotate\":0,\"filter\":false,\"truncate\":100},\"title\":{\"text\":\"Count\"}}],\"seriesParams\":[{\"show\":\"true\",\"type\":\"area\",\"mode\":\"stacked\",\"data\":{\"label\":\"Count\",\"id\":\"1\"},\"drawLinesBetweenPoints\":true,\"showCircles\":true,\"interpolate\":\"cardinal\",\"valueAxis\":\"ValueAxis-1\"}],\"addTooltip\":true,\"addLegend\":false,\"legendPosition\":\"right\",\"times\":[],\"addTimeMarker\":false},\"aggs\":[{\"id\":\"1\",\"enabled\":true,\"type\":\"count\",\"schema\":\"metric\",\"params\":{}},{\"id\":\"2\",\"enabled\":true,\"type\":\"date_histogram\",\"schema\":\"segment\",\"params\":{\"field\":\"@timestamp\",\"timeRange\":{\"from\":\"now-15m\",\"to\":\"now\",\"mode\":\"quick\"},\"useNormalizedEsInterval\":true,\"interval\":\"auto\",\"time_zone\":\"Europe/Berlin\",\"drop_partials\":false,\"customInterval\":\"2h\",\"min_doc_count\":1,\"extended_bounds\":{}}}]}",
|
||||
'{"title":"Alerts","type":"area","params":{"type":"area","grid":{"categoryLines":true,"style":{"color":"#eee"},"valueAxis":null},"categoryAxes":[{"id":"CategoryAxis-1","type":"category","position":"bottom","show":true,"style":{},"scale":{"type":"linear"},"labels":{"show":true,"truncate":100},"title":{}}],"valueAxes":[{"id":"ValueAxis-1","name":"LeftAxis-1","type":"value","position":"left","show":true,"style":{},"scale":{"type":"linear","mode":"normal"},"labels":{"show":true,"rotate":0,"filter":false,"truncate":100},"title":{"text":"Count"}}],"seriesParams":[{"show":"true","type":"area","mode":"stacked","data":{"label":"Count","id":"1"},"drawLinesBetweenPoints":true,"showCircles":true,"interpolate":"cardinal","valueAxis":"ValueAxis-1"}],"addTooltip":true,"addLegend":false,"legendPosition":"right","times":[],"addTimeMarker":false},"aggs":[{"id":"1","enabled":true,"type":"count","schema":"metric","params":{}},{"id":"2","enabled":true,"type":"date_histogram","schema":"segment","params":{"field":"@timestamp","timeRange":{"from":"now-15m","to":"now","mode":"quick"},"useNormalizedEsInterval":true,"interval":"auto","time_zone":"Europe/Berlin","drop_partials":false,"customInterval":"2h","min_doc_count":1,"extended_bounds":{}}}]}',
|
||||
uiStateJSON:
|
||||
'{"spy":{"mode":{"name":null,"fill":false}},"vis":{"legendOpen":false}}',
|
||||
description: '',
|
||||
@ -226,8 +226,8 @@ export default [
|
||||
_source: {
|
||||
title: 'Top 5 agents',
|
||||
visState:
|
||||
"{\"title\":\"overrview-05\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":false,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":true,\"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\":\"agent.name\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"}}]}",
|
||||
uiStateJSON: "{\"vis\":{\"legendOpen\":false}}",
|
||||
'{"title":"overrview-05","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":false,"legendPosition":"right","isDonut":true,"labels":{"show":true,"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":"agent.name","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
|
||||
uiStateJSON: '{"vis":{"legendOpen":false}}',
|
||||
description: '',
|
||||
version: 1,
|
||||
kibanaSavedObjectMeta: {
|
||||
@ -242,8 +242,8 @@ export default [
|
||||
_source: {
|
||||
title: 'Top 5 rule groups',
|
||||
visState:
|
||||
"{\"title\":\"Top 5 rule groups\",\"type\":\"pie\",\"params\":{\"type\":\"pie\",\"addTooltip\":true,\"addLegend\":false,\"legendPosition\":\"right\",\"isDonut\":true,\"labels\":{\"show\":true,\"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\":\"rule.groups\",\"size\":5,\"order\":\"desc\",\"orderBy\":\"1\",\"otherBucket\":false,\"otherBucketLabel\":\"Other\",\"missingBucket\":false,\"missingBucketLabel\":\"Missing\"}}]}",
|
||||
uiStateJSON: "{\"vis\":{\"legendOpen\":false}}",
|
||||
'{"title":"Top 5 rule groups","type":"pie","params":{"type":"pie","addTooltip":true,"addLegend":false,"legendPosition":"right","isDonut":true,"labels":{"show":true,"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":"rule.groups","size":5,"order":"desc","orderBy":"1","otherBucket":false,"otherBucketLabel":"Other","missingBucket":false,"missingBucketLabel":"Missing"}}]}',
|
||||
uiStateJSON: '{"vis":{"legendOpen":false}}',
|
||||
description: '',
|
||||
version: 1,
|
||||
kibanaSavedObjectMeta: {
|
||||
|
@ -160,7 +160,7 @@ export class Monitoring {
|
||||
payload,
|
||||
options
|
||||
);
|
||||
|
||||
|
||||
await this.saveStatus(api.clusterName);
|
||||
|
||||
return;
|
||||
@ -215,10 +215,13 @@ export class Monitoring {
|
||||
await this.checkStatus(api, response.body.data.totalItems);
|
||||
} else if ((response || {}).error) {
|
||||
const msg = ((response || {}).body || {}).message || false;
|
||||
const extraLog = msg || 'Wazuh API credentials not found or are not correct. Open the app in your browser and configure it to start monitoring agents.';
|
||||
|
||||
const extraLog =
|
||||
msg ||
|
||||
'Wazuh API credentials not found or are not correct. Open the app in your browser and configure it to start monitoring agents.';
|
||||
|
||||
!this.quiet && log('[monitoring][checkAndSaveStatus]', extraLog);
|
||||
!this.quiet && this.server.log([blueWazuh, 'monitoring', 'error'], extraLog);
|
||||
!this.quiet &&
|
||||
this.server.log([blueWazuh, 'monitoring', 'error'], extraLog);
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
|
Loading…
Reference in New Issue
Block a user