diff --git a/CHANGELOG.md b/CHANGELOG.md index d76031c7c6..f266d4e5f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to the Wazuh app project will be documented in this file. ### Fixed - Fixed path in logo customization section [#4352](https://github.com/wazuh/wazuh-kibana-app/pull/4352) +- Fixed a TypeError in Firefox. Change the Get request that was made with a Kibana core.http.get(/api/check-wazuh) resource to the WzRequest.genericReq resource and it no longer fails, also add a test capture to public/plugin.ts that wraps the request and in case of failure, the error is detected when the browser does not work with the V8 engine. [#4362](https://github.com/wazuh/wazuh-kibana-app/pull/4362) - Fixed an error of an undefined username hash related to reporting when using Kibana with X-Pack and security was disabled [#4358](https://github.com/wazuh/wazuh-kibana-app/pull/4358) ## Wazuh v4.3.6 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4307 diff --git a/public/plugin.ts b/public/plugin.ts index 2c1505ecee..07a3dad2a6 100644 --- a/public/plugin.ts +++ b/public/plugin.ts @@ -28,70 +28,68 @@ import { AppState } from './react-services/app-state'; import { setErrorOrchestrator } from './react-services/common-services'; import { ErrorOrchestratorService } from './react-services/error-orchestrator/error-orchestrator.service'; import { getThemeAssetURL, getAssetURL } from './utils/assets'; - +import { WzRequest } from './react-services/wz-request'; const innerAngularName = 'app/wazuh'; - export class WazuhPlugin implements Plugin { constructor(private readonly initializerContext: PluginInitializerContext) {} public initializeInnerAngular?: () => void; private innerAngularInitialized: boolean = false; private stateUpdater = new BehaviorSubject(() => ({})); private hideTelemetryBanner?: () => void; - public setup(core: CoreSetup, plugins: WazuhSetupPlugins): WazuhSetup { const UI_THEME = core.uiSettings.get('theme:darkMode') ? 'dark' : 'light'; - core.application.register({ id: `wazuh`, title: 'Wazuh', icon: core.http.basePath.prepend(getThemeAssetURL('icon.svg', UI_THEME)), mount: async (params: AppMountParameters) => { - if (!this.initializeInnerAngular) { - throw Error('Wazuh plugin method initializeInnerAngular is undefined'); - } - - // hide the telemetry banner. - // Set the flag in the telemetry saved object as the notice was seen and dismissed - this.hideTelemetryBanner && await this.hideTelemetryBanner(); - - setScopedHistory(params.history); - // Load application bundle - const { renderApp } = await import('./application'); - // Get start services as specified in kibana.json - const [coreStart, depsStart] = await core.getStartServices(); - setErrorOrchestrator(ErrorOrchestratorService); - setHttp(core.http); - setCookies(new Cookies()); - if(!AppState.checkCookies() || params.history.parentHistory.action === 'PUSH') { - window.location.reload(); - } - - await this.initializeInnerAngular(); - - //Check is user has Wazuh disabled - const response = await core.http.get(`/api/check-wazuh`); - - params.element.classList.add('dscAppWrapper', 'wz-app'); - const unmount = await renderApp(innerAngularName, params.element); - - //Update if user has Wazuh disabled - this.stateUpdater.next(() => { - if (response.isWazuhDisabled) { - unmount(); + try { + if (!this.initializeInnerAngular) { + throw Error('Wazuh plugin method initializeInnerAngular is undefined'); } - - return { - status: response.isWazuhDisabled, - category: { - id: 'wazuh', - label: 'Wazuh', - order: 0, - euiIconType: core.http.basePath.prepend(response.logoSidebar ? getAssetURL(response.logoSidebar) : getThemeAssetURL('icon.svg', UI_THEME)), - }} - }) - return () => { - unmount(); - }; + // hide the telemetry banner. + // Set the flag in the telemetry saved object as the notice was seen and dismissed + this.hideTelemetryBanner && await this.hideTelemetryBanner(); + setScopedHistory(params.history); + // Load application bundle + const { renderApp } = await import('./application'); + // Get start services as specified in kibana.json + const [coreStart, depsStart] = await core.getStartServices(); + setErrorOrchestrator(ErrorOrchestratorService); + setHttp(core.http); + setCookies(new Cookies()); + if(!AppState.checkCookies() || params.history.parentHistory.action === 'PUSH') { + window.location.reload(); + } + await this.initializeInnerAngular(); + //Check is user has Wazuh disabled + const response = await WzRequest.genericReq( + 'GET', + `/api/check-wazuh`, + ) + + params.element.classList.add('dscAppWrapper', 'wz-app'); + const unmount = await renderApp(innerAngularName, params.element); + //Update if user has Wazuh disabled + this.stateUpdater.next(() => { + if (response.data.isWazuhDisabled) { + unmount(); + } + return { + status: response.data.isWazuhDisabled, + category: { + id: 'wazuh', + label: 'Wazuh', + order: 0, + euiIconType: core.http.basePath.prepend(response.data.logoSidebar ? getAssetURL(response.data.logoSidebar) : getThemeAssetURL('icon.svg', UI_THEME)), + }} + }) + return () => { + unmount(); + }; + }catch(error){ + console.debug(error); + } }, category: { id: 'wazuh', @@ -103,13 +101,11 @@ export class WazuhPlugin implements Plugin plugins.telemetry.telemetryNotifications.setOptedInNoticeSeen(); @@ -133,8 +129,6 @@ export class WazuhPlugin implements Plugin