From 1f1c7fe28fad9d779b4f08b76332c967e3a58e27 Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Thu, 15 Sep 2022 15:43:18 -0300 Subject: [PATCH 01/11] Modified the message to be clearer, removed --- .../components/health-check/services/check-setup.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/components/health-check/services/check-setup.service.ts b/public/components/health-check/services/check-setup.service.ts index 73e6576276..3e39663afa 100644 --- a/public/components/health-check/services/check-setup.service.ts +++ b/public/components/health-check/services/check-setup.service.ts @@ -14,7 +14,7 @@ import { AppState, GenericRequest, WzRequest } from '../../../react-services'; import { CheckLogger } from '../types/check_logger'; -import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_UPGRADE_PLATFORM } from '../../../../common/constants'; +import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING } from '../../../../common/constants'; import { webDocumentationLink } from '../../../../common/services/web_documentation'; export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => { @@ -44,7 +44,7 @@ export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => api.groups.version !== appSplit[0] || api.groups.minor !== appSplit[1] ) { - checkLogger.error(`Wazuh API and Wazuh App version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. At least, major and minor should match. Check more info about upgrading Wazuh App here.`); + checkLogger.error(`Wazuh API and Wazuh App version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Check more info about this error on ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`); } } } From bab9f40e1264543333f1ba888f31bfd9f7e35a34 Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Thu, 15 Sep 2022 15:44:26 -0300 Subject: [PATCH 02/11] Added function to add to urls in errors --- .../container/health-check.container.tsx | 132 +++++++++++------- 1 file changed, 82 insertions(+), 50 deletions(-) diff --git a/public/components/health-check/container/health-check.container.tsx b/public/components/health-check/container/health-check.container.tsx index 9f726b5452..4533b79d38 100644 --- a/public/components/health-check/container/health-check.container.tsx +++ b/public/components/health-check/container/health-check.container.tsx @@ -12,17 +12,9 @@ * */ -import { - EuiButton, - EuiCallOut, - EuiDescriptionList, - EuiSpacer, -} from '@elastic/eui'; +import { EuiButton, EuiCallOut, EuiDescriptionList, EuiSpacer } from '@elastic/eui'; import React, { Fragment, useState, useEffect, useRef } from 'react'; -import { - EuiFlexGroup, - EuiFlexItem -} from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import { AppState, ErrorHandler } from '../../../react-services'; import { useAppConfig, useRootScope } from '../../../components/common/hooks'; import { @@ -53,7 +45,7 @@ import { compose } from 'redux'; import { getThemeAssetURL, getAssetURL } from '../../../utils/assets'; const checks = { - api: { + api: { title: 'Check Wazuh API connection', label: 'API connection', validator: checkApiService, @@ -64,7 +56,7 @@ const checks = { title: 'Check Wazuh API version', label: 'API version', validator: checkSetupService, - awaitFor: ["api"], + awaitFor: ['api'], }, pattern: { title: 'Check alerts index pattern', @@ -77,7 +69,11 @@ const checks = { patternMonitoring: { title: 'Check monitoring index pattern', label: 'Monitoring index pattern', - validator: (appConfig) => checkPatternSupportService(appConfig.data['wazuh.monitoring.pattern'], WAZUH_INDEX_TYPE_MONITORING), + validator: (appConfig) => + checkPatternSupportService( + appConfig.data['wazuh.monitoring.pattern'], + WAZUH_INDEX_TYPE_MONITORING + ), awaitFor: [], shouldCheck: true, canRetry: true, @@ -85,7 +81,11 @@ const checks = { patternStatistics: { title: 'Check statistics index pattern', label: 'Statistics index pattern', - validator: (appConfig) => checkPatternSupportService(`${appConfig.data['cron.prefix']}-${appConfig.data['cron.statistics.index.name']}-*`, WAZUH_INDEX_TYPE_STATISTICS), + validator: (appConfig) => + checkPatternSupportService( + `${appConfig.data['cron.prefix']}-${appConfig.data['cron.statistics.index.name']}-*`, + WAZUH_INDEX_TYPE_STATISTICS + ), awaitFor: [], shouldCheck: true, canRetry: true, @@ -93,32 +93,43 @@ const checks = { maxBuckets: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS} setting`, - validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS, WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS), + validator: checkPluginPlatformSettings( + PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS, + WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS + ), awaitFor: [], canRetry: true, }, metaFields: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS} setting`, - validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS, WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS), + validator: checkPluginPlatformSettings( + PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS, + WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS + ), awaitFor: [], canRetry: true, }, timeFilter: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`, - validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER, JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER), (checkLogger: CheckLogger, options: {defaultAppValue: any}) => { - getDataPlugin().query.timefilter.timefilter.setTime(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER) - && checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`); - }), + validator: checkPluginPlatformSettings( + PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER, + JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER), + (checkLogger: CheckLogger, options: { defaultAppValue: any }) => { + getDataPlugin().query.timefilter.timefilter.setTime( + WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER + ) && checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`); + } + ), awaitFor: [], canRetry: true, - } + }, }; function HealthCheckComponent() { - const [checkErrors, setCheckErrors] = useState<{[key:string]: []}>({}); - const [checksReady, setChecksReady] = useState<{[key: string]: boolean}>({}); + const [checkErrors, setCheckErrors] = useState<{ [key: string]: [] }>({}); + const [checksReady, setChecksReady] = useState<{ [key: string]: boolean }>({}); const [isDebugMode, setIsDebugMode] = useState(false); const appConfig = useAppConfig(); const checksInitiated = useRef(false); @@ -126,7 +137,9 @@ function HealthCheckComponent() { const redirectionPassHealthcheck = () => { const params = $rootScope.previousParams || {}; - const queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&'); + const queryString = Object.keys(params) + .map((key) => key + '=' + params[key]) + .join('&'); const url = '/app/wazuh#' + ($rootScope.previousLocation || '') + '?' + queryString; window.location.href = getHttp().basePath.prepend(url); }; @@ -140,16 +153,15 @@ function HealthCheckComponent() { useEffect(() => { // Redirect to app when all checks are ready - Object.keys(checks) - .every(check => checksReady[check]) - && !isDebugMode && (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME) - )() + Object.keys(checks).every((check) => checksReady[check]) && + !isDebugMode && + (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME))(); }, [checksReady]); useEffect(() => { // Check if Health should not redirect automatically (Debug mode) setIsDebugMode(window.location.href.includes('debug')); - },[]); + }, []); const handleErrors = (checkID, errors, parsed) => { const newErrors = parsed @@ -157,24 +169,27 @@ function HealthCheckComponent() { ErrorHandler.handle(error, 'Health Check', { warning: false, silent: true }) ) : errors; - setCheckErrors((prev) => ({...prev, [checkID]: newErrors})); + setCheckErrors((prev) => ({ ...prev, [checkID]: newErrors })); }; const cleanErrors = (checkID: string) => { delete checkErrors[checkID]; - setCheckErrors({...checkErrors}); - } - - const handleCheckReady = (checkID, isReady) => { - setChecksReady(prev => ({...prev, [checkID]: isReady})); - } + setCheckErrors({ ...checkErrors }); + }; + const handleCheckReady = (checkID, isReady) => { + setChecksReady((prev) => ({ ...prev, [checkID]: isReady })); + }; - const logoUrl = getHttp().basePath.prepend(appConfig.data['customization.logo.healthcheck'] ? getAssetURL(appConfig.data['customization.logo.healthcheck']) : getThemeAssetURL('logo.svg')); + const logoUrl = getHttp().basePath.prepend( + appConfig.data['customization.logo.healthcheck'] + ? getAssetURL(appConfig.data['customization.logo.healthcheck']) + : getThemeAssetURL('logo.svg') + ); const thereAreErrors = Object.keys(checkErrors).length > 0; const renderChecks = () => { - const showLogButton = (thereAreErrors || isDebugMode); + const showLogButton = thereAreErrors || isDebugMode; return Object.keys(checks).map((check, index) => { return ( @@ -196,21 +211,41 @@ function HealthCheckComponent() { }); }; + const addTagsToUrl = (error) => { + const words = error.split(' '); + words.forEach((word, index) => { + if (word.includes('http://') || word.includes('https://')) { + if (word.endsWith('.') || word.endsWith(',')) { + words[index] = `${word.slice(0, -1)}.`; + } else { + words[index] = `${word}`; + } + } + }); + return words.join(' '); + }; + const renderErrors = () => { - return Object.keys(checkErrors).map((checkID) => + return Object.keys(checkErrors).map((checkID) => checkErrors[checkID].map((error, index) => ( {`[${checks[checkID].label}]`} )} + title={ + <> + {`[${checks[checkID].label}]`}{' '} + + + } color="danger" iconType="alert" style={{ textAlign: 'left' }} - data-test-subj='callOutError' + data-test-subj="callOutError" > + )) - ) + ); }; return ( @@ -230,7 +265,7 @@ function HealthCheckComponent() { {(thereAreErrors || isDebugMode) && ( <> - + {thereAreErrors && ( @@ -238,7 +273,7 @@ function HealthCheckComponent() { )} - {isDebugMode && Object.keys(checks).every(check => checksReady[check]) && ( + {isDebugMode && Object.keys(checks).every((check) => checksReady[check]) && ( Continue @@ -247,15 +282,12 @@ function HealthCheckComponent() { )} - ) - } + )} ); } -export const HealthCheck = compose (withErrorBoundary,withReduxProvider) (HealthCheckComponent); +export const HealthCheck = compose(withErrorBoundary, withReduxProvider)(HealthCheckComponent); export const HealthCheckTest = HealthCheckComponent; - - From ceaf9bc061312f41eca0b1d1d81cd776ebf330ef Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Thu, 15 Sep 2022 15:50:31 -0300 Subject: [PATCH 03/11] changed structure --- .../container/health-check.container.tsx | 120 ++++++++---------- 1 file changed, 50 insertions(+), 70 deletions(-) diff --git a/public/components/health-check/container/health-check.container.tsx b/public/components/health-check/container/health-check.container.tsx index 4533b79d38..12679749f5 100644 --- a/public/components/health-check/container/health-check.container.tsx +++ b/public/components/health-check/container/health-check.container.tsx @@ -12,9 +12,17 @@ * */ -import { EuiButton, EuiCallOut, EuiDescriptionList, EuiSpacer } from '@elastic/eui'; +import { + EuiButton, + EuiCallOut, + EuiDescriptionList, + EuiSpacer, +} from '@elastic/eui'; import React, { Fragment, useState, useEffect, useRef } from 'react'; -import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; +import { + EuiFlexGroup, + EuiFlexItem +} from '@elastic/eui'; import { AppState, ErrorHandler } from '../../../react-services'; import { useAppConfig, useRootScope } from '../../../components/common/hooks'; import { @@ -45,7 +53,7 @@ import { compose } from 'redux'; import { getThemeAssetURL, getAssetURL } from '../../../utils/assets'; const checks = { - api: { + api: { title: 'Check Wazuh API connection', label: 'API connection', validator: checkApiService, @@ -56,7 +64,7 @@ const checks = { title: 'Check Wazuh API version', label: 'API version', validator: checkSetupService, - awaitFor: ['api'], + awaitFor: ["api"], }, pattern: { title: 'Check alerts index pattern', @@ -69,11 +77,7 @@ const checks = { patternMonitoring: { title: 'Check monitoring index pattern', label: 'Monitoring index pattern', - validator: (appConfig) => - checkPatternSupportService( - appConfig.data['wazuh.monitoring.pattern'], - WAZUH_INDEX_TYPE_MONITORING - ), + validator: (appConfig) => checkPatternSupportService(appConfig.data['wazuh.monitoring.pattern'], WAZUH_INDEX_TYPE_MONITORING), awaitFor: [], shouldCheck: true, canRetry: true, @@ -81,11 +85,7 @@ const checks = { patternStatistics: { title: 'Check statistics index pattern', label: 'Statistics index pattern', - validator: (appConfig) => - checkPatternSupportService( - `${appConfig.data['cron.prefix']}-${appConfig.data['cron.statistics.index.name']}-*`, - WAZUH_INDEX_TYPE_STATISTICS - ), + validator: (appConfig) => checkPatternSupportService(`${appConfig.data['cron.prefix']}-${appConfig.data['cron.statistics.index.name']}-*`, WAZUH_INDEX_TYPE_STATISTICS), awaitFor: [], shouldCheck: true, canRetry: true, @@ -93,43 +93,32 @@ const checks = { maxBuckets: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS} setting`, - validator: checkPluginPlatformSettings( - PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS, - WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS - ), + validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_MAX_BUCKETS, WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS), awaitFor: [], canRetry: true, }, metaFields: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS} setting`, - validator: checkPluginPlatformSettings( - PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS, - WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS - ), + validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_METAFIELDS, WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS), awaitFor: [], canRetry: true, }, timeFilter: { title: `Check ${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`, label: `${PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER} setting`, - validator: checkPluginPlatformSettings( - PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER, - JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER), - (checkLogger: CheckLogger, options: { defaultAppValue: any }) => { - getDataPlugin().query.timefilter.timefilter.setTime( - WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER - ) && checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`); - } - ), + validator: checkPluginPlatformSettings(PLUGIN_PLATFORM_SETTING_NAME_TIME_FILTER, JSON.stringify(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER), (checkLogger: CheckLogger, options: {defaultAppValue: any}) => { + getDataPlugin().query.timefilter.timefilter.setTime(WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER) + && checkLogger.action(`Timefilter set to ${JSON.stringify(options.defaultAppValue)}`); + }), awaitFor: [], canRetry: true, - }, + } }; function HealthCheckComponent() { - const [checkErrors, setCheckErrors] = useState<{ [key: string]: [] }>({}); - const [checksReady, setChecksReady] = useState<{ [key: string]: boolean }>({}); + const [checkErrors, setCheckErrors] = useState<{[key:string]: []}>({}); + const [checksReady, setChecksReady] = useState<{[key: string]: boolean}>({}); const [isDebugMode, setIsDebugMode] = useState(false); const appConfig = useAppConfig(); const checksInitiated = useRef(false); @@ -137,9 +126,7 @@ function HealthCheckComponent() { const redirectionPassHealthcheck = () => { const params = $rootScope.previousParams || {}; - const queryString = Object.keys(params) - .map((key) => key + '=' + params[key]) - .join('&'); + const queryString = Object.keys(params).map(key => key + '=' + params[key]).join('&'); const url = '/app/wazuh#' + ($rootScope.previousLocation || '') + '?' + queryString; window.location.href = getHttp().basePath.prepend(url); }; @@ -153,15 +140,16 @@ function HealthCheckComponent() { useEffect(() => { // Redirect to app when all checks are ready - Object.keys(checks).every((check) => checksReady[check]) && - !isDebugMode && - (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME))(); + Object.keys(checks) + .every(check => checksReady[check]) + && !isDebugMode && (() => setTimeout(redirectionPassHealthcheck, HEALTH_CHECK_REDIRECTION_TIME) + )() }, [checksReady]); useEffect(() => { // Check if Health should not redirect automatically (Debug mode) setIsDebugMode(window.location.href.includes('debug')); - }, []); + },[]); const handleErrors = (checkID, errors, parsed) => { const newErrors = parsed @@ -169,27 +157,24 @@ function HealthCheckComponent() { ErrorHandler.handle(error, 'Health Check', { warning: false, silent: true }) ) : errors; - setCheckErrors((prev) => ({ ...prev, [checkID]: newErrors })); + setCheckErrors((prev) => ({...prev, [checkID]: newErrors})); }; const cleanErrors = (checkID: string) => { delete checkErrors[checkID]; - setCheckErrors({ ...checkErrors }); - }; + setCheckErrors({...checkErrors}); + } - const handleCheckReady = (checkID, isReady) => { - setChecksReady((prev) => ({ ...prev, [checkID]: isReady })); - }; + const handleCheckReady = (checkID, isReady) => { + setChecksReady(prev => ({...prev, [checkID]: isReady})); + } - const logoUrl = getHttp().basePath.prepend( - appConfig.data['customization.logo.healthcheck'] - ? getAssetURL(appConfig.data['customization.logo.healthcheck']) - : getThemeAssetURL('logo.svg') - ); + + const logoUrl = getHttp().basePath.prepend(appConfig.data['customization.logo.healthcheck'] ? getAssetURL(appConfig.data['customization.logo.healthcheck']) : getThemeAssetURL('logo.svg')); const thereAreErrors = Object.keys(checkErrors).length > 0; const renderChecks = () => { - const showLogButton = thereAreErrors || isDebugMode; + const showLogButton = (thereAreErrors || isDebugMode); return Object.keys(checks).map((check, index) => { return ( ); }); }; - const addTagsToUrl = (error) => { const words = error.split(' '); words.forEach((word, index) => { @@ -224,28 +208,21 @@ function HealthCheckComponent() { }); return words.join(' '); }; - const renderErrors = () => { - return Object.keys(checkErrors).map((checkID) => + return Object.keys(checkErrors).map((checkID) => checkErrors[checkID].map((error, index) => ( - {`[${checks[checkID].label}]`}{' '} - - - } + title={(<>{`[${checks[checkID].label}]`} )} color="danger" iconType="alert" style={{ textAlign: 'left' }} - data-test-subj="callOutError" + data-test-subj='callOutError' > - )) - ); + ) }; return ( @@ -265,7 +242,7 @@ function HealthCheckComponent() { {(thereAreErrors || isDebugMode) && ( <> - + {thereAreErrors && ( @@ -273,7 +250,7 @@ function HealthCheckComponent() { )} - {isDebugMode && Object.keys(checks).every((check) => checksReady[check]) && ( + {isDebugMode && Object.keys(checks).every(check => checksReady[check]) && ( Continue @@ -282,12 +259,15 @@ function HealthCheckComponent() { )} - )} + ) + } ); } -export const HealthCheck = compose(withErrorBoundary, withReduxProvider)(HealthCheckComponent); +export const HealthCheck = compose (withErrorBoundary,withReduxProvider) (HealthCheckComponent); export const HealthCheckTest = HealthCheckComponent; + + From b11d5c44a24ed90663dab404a78414f823accf9a Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Thu, 15 Sep 2022 16:00:45 -0300 Subject: [PATCH 04/11] Fixed error on function --- .../health-check/container/health-check.container.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/components/health-check/container/health-check.container.tsx b/public/components/health-check/container/health-check.container.tsx index 12679749f5..341136b83e 100644 --- a/public/components/health-check/container/health-check.container.tsx +++ b/public/components/health-check/container/health-check.container.tsx @@ -200,7 +200,7 @@ function HealthCheckComponent() { words.forEach((word, index) => { if (word.includes('http://') || word.includes('https://')) { if (word.endsWith('.') || word.endsWith(',')) { - words[index] = `${word.slice(0, -1)}.`; + words[index] = `${word.slice(0, -1)}${word.slice(-1)}`; } else { words[index] = `${word}`; } From 361f0be1a34622353a26e1b249154322bcea9cbd Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Fri, 16 Sep 2022 14:09:51 -0300 Subject: [PATCH 05/11] Add PLUGIN_APP_NAME constant to match wzd --- common/constants.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/constants.ts b/common/constants.ts index c6f627e2a1..6412dfba86 100644 --- a/common/constants.ts +++ b/common/constants.ts @@ -372,6 +372,9 @@ export const PLUGIN_PLATFORM_REQUEST_HEADERS = { 'kbn-xsrf': 'kibana' }; +// Plugin app +export const PLUGIN_APP_NAME = 'Wazuh App'; + // UI export const API_NAME_AGENT_STATUS = { ACTIVE: 'active', From fe9b268bab27876cf1554eb681502837027f7898 Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Fri, 16 Sep 2022 14:10:11 -0300 Subject: [PATCH 06/11] Change error message to match structure of wzd --- .../components/health-check/services/check-setup.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/components/health-check/services/check-setup.service.ts b/public/components/health-check/services/check-setup.service.ts index 3e39663afa..86a21c1da9 100644 --- a/public/components/health-check/services/check-setup.service.ts +++ b/public/components/health-check/services/check-setup.service.ts @@ -14,7 +14,7 @@ import { AppState, GenericRequest, WzRequest } from '../../../react-services'; import { CheckLogger } from '../types/check_logger'; -import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING } from '../../../../common/constants'; +import { PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING, PLUGIN_APP_NAME } from '../../../../common/constants'; import { webDocumentationLink } from '../../../../common/services/web_documentation'; export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => { @@ -44,7 +44,7 @@ export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => api.groups.version !== appSplit[0] || api.groups.minor !== appSplit[1] ) { - checkLogger.error(`Wazuh API and Wazuh App version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Check more info about this error on ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`); + checkLogger.error(`Wazuh API and ${PLUGIN_APP_NAME} version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Check more info about this error on our troubleshooting guide: ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`); } } } From b504e34e7452f41f5d294764df194885efb6fe9e Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Fri, 16 Sep 2022 14:10:38 -0300 Subject: [PATCH 07/11] Improve addTagsToUrl --- .../container/health-check.container.tsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/public/components/health-check/container/health-check.container.tsx b/public/components/health-check/container/health-check.container.tsx index 341136b83e..e28a95c381 100644 --- a/public/components/health-check/container/health-check.container.tsx +++ b/public/components/health-check/container/health-check.container.tsx @@ -199,10 +199,19 @@ function HealthCheckComponent() { const words = error.split(' '); words.forEach((word, index) => { if (word.includes('http://') || word.includes('https://')) { - if (word.endsWith('.') || word.endsWith(',')) { - words[index] = `${word.slice(0, -1)}${word.slice(-1)}`; - } else { - words[index] = `${word}`; + if (words[index - 1] === 'guide:') { + if (word.endsWith('.') || word.endsWith(',')) { + words[index - 2] = `${words[index - 2]} ${words[index - 1].slice(0, -1)}${word.slice(-1)}`; + } else { + words[index - 2] = `${words[index - 2]} ${words[index - 1].slice(0, -1)} `; + } + words.splice(index - 1, 2); + } else{ + if (word.endsWith('.') || word.endsWith(',')) { + words[index] = `${word.slice(0, -1)}${word.slice(-1)}`; + } else { + words[index] = `${word}`; + } } } }); From b1ecda0d97b997095d7dc427cfa1242b6a42d4c0 Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Fri, 16 Sep 2022 14:47:17 -0300 Subject: [PATCH 08/11] Add change to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9419f6072c..dd24d50836 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to the Wazuh app project will be documented in this file. - Improve alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376) - Endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874) - Makes Agents Overview loading icons independent [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363) +- Enhance the message shown when a mismatch between Wazuh API and Wazuh APP occurs [#4529](https://github.com/wazuh/wazuh-kibana-app/pull/4529) ### Fixed From 4e7d59ae1cd6866bfc4a72cd1b2cb9c0d03703a1 Mon Sep 17 00:00:00 2001 From: Nico Guevara Date: Fri, 16 Sep 2022 14:52:30 -0300 Subject: [PATCH 09/11] Change structure --- .../health-check/container/health-check.container.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/public/components/health-check/container/health-check.container.tsx b/public/components/health-check/container/health-check.container.tsx index e28a95c381..fbde8110cd 100644 --- a/public/components/health-check/container/health-check.container.tsx +++ b/public/components/health-check/container/health-check.container.tsx @@ -195,6 +195,7 @@ function HealthCheckComponent() { ); }); }; + const addTagsToUrl = (error) => { const words = error.split(' '); words.forEach((word, index) => { @@ -217,6 +218,7 @@ function HealthCheckComponent() { }); return words.join(' '); }; + const renderErrors = () => { return Object.keys(checkErrors).map((checkID) => checkErrors[checkID].map((error, index) => ( From 9de1f8100a6501659a94fb8073d13401f023c045 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex?= Date: Mon, 26 Sep 2022 11:16:49 +0200 Subject: [PATCH 10/11] Update CHANGELOG.md --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67149c21f0..5287676e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,10 @@ All notable changes to the Wazuh app project will be documented in this file. ### Changed - Changed the HTTP verb from `GET` to `POST` in the requests to login to the Wazuh API [#4103](https://github.com/wazuh/wazuh-kibana-app/pull/4103) +- Improved alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376) +- The endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874) +- Made Agents Overview icons load independently [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363) +- Improved the message displayed when there is a versions mismatch between the Wazuh API and the Wazuh APP [#4529](https://github.com/wazuh/wazuh-kibana-app/pull/4529) ### Fixed @@ -20,10 +24,6 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed nested field rendering in security alerts table details [#4428](https://github.com/wazuh/wazuh-kibana-app/pull/4428) - Fixed a bug where the Wazuh logo was used instead of the custom one [#4539](https://github.com/wazuh/wazuh-kibana-app/pull/4539) - Fixed rendering problems of the `Agent Overview` section in low resolutions [#4516](https://github.com/wazuh/wazuh-kibana-app/pull/4516) -- Improved alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376) -- The endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874) -- Made Agents Overview icons load independently [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363) -- Improved the message displayed when there is a versions mismatch between the Wazuh API and the Wazuh APP [#4529](https://github.com/wazuh/wazuh-kibana-app/pull/4529) ## Wazuh v4.3.8 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4309 From 6eebd86221204bfe87af16d7ebaa8beae2b403ba Mon Sep 17 00:00:00 2001 From: Nico Guevara <42900763+Tostti@users.noreply.github.com> Date: Mon, 26 Sep 2022 09:23:51 -0300 Subject: [PATCH 11/11] Improve message --- public/components/health-check/services/check-setup.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/components/health-check/services/check-setup.service.ts b/public/components/health-check/services/check-setup.service.ts index 86a21c1da9..48a674d79a 100644 --- a/public/components/health-check/services/check-setup.service.ts +++ b/public/components/health-check/services/check-setup.service.ts @@ -44,7 +44,7 @@ export const checkSetupService = appInfo => async (checkLogger: CheckLogger) => api.groups.version !== appSplit[0] || api.groups.minor !== appSplit[1] ) { - checkLogger.error(`Wazuh API and ${PLUGIN_APP_NAME} version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Check more info about this error on our troubleshooting guide: ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`); + checkLogger.error(`Wazuh API and ${PLUGIN_APP_NAME} version mismatch. API version: ${apiVersion}. App version: ${setupData.data.data['app-version']}. Read more about this error in our troubleshooting guide: ${webDocumentationLink(PLUGIN_PLATFORM_WAZUH_DOCUMENTATION_URL_PATH_TROUBLESHOOTING)}.`); } } }