From 515f14f845a6aff7759e7258568357efd503a770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Chantal=20Bel=C3=A9n=20kelm?= <99441266+chantal-kelm@users.noreply.github.com> Date: Fri, 5 Aug 2022 13:05:04 -0300 Subject: [PATCH] TypeError resolved (#4362) * Solve TypeError * Add CHANGELOG * Change request service * Fix request's response structure (cherry picked from commit 44a43cbe28cf92824da60627b38ff50800474e07) --- CHANGELOG.md | 29 +++++++++++++ public/plugin.ts | 105 +++++++++++++++++++++++------------------------ 2 files changed, 81 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cc4b36a68..bad93495ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,35 @@ All notable changes to the Wazuh app project will be documented in this file. +## Wazuh v4.3.7 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4308 + +### Fixed + +- Fixed an error during the generation of a group's report, if the request to the Wazuh API fails [#4350](https://github.com/wazuh/wazuh-kibana-app/pull/4350) +- Fixed a problem with the group's report, when the group has no agents [#4350](https://github.com/wazuh/wazuh-kibana-app/pull/4350) +- 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) +- Fixed persistence of the plugin registry file between updates [#4359](https://github.com/wazuh/wazuh-kibana-app/pull/4359) +- Fixed searchbar error on SCA Inventory table [#4367](https://github.com/wazuh/wazuh-kibana-app/pull/4367) + +# Removed + +- Removed the use of `manager_host` field related to agent information of Wazuh API responses, which is obsolete [#4350](https://github.com/wazuh/wazuh-kibana-app/pull/4350) + +## Wazuh v4.3.6 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4307 + +### Fixed + +- Fixed the search bar component to properly distinguish conjuntion operators (AND, OR) [#4326](https://github.com/wazuh/wazuh-kibana-app/pull/4326) +- Fixed documentation link titles to match the documentation sections to redirect to [#4301](https://github.com/wazuh/wazuh-kibana-app/pull/4301) +- Fixed missing documentation references to the Agent's overview, Agent's Integrity monitoring, and Agent's Inventory data sections, when the agent has never connected. [#4301](https://github.com/wazuh/wazuh-kibana-app/pull/4301) +- The references to the documentation site now links to the appropriate version [#4301](https://github.com/wazuh/wazuh-kibana-app/pull/4301) +- Fixed missing documentation link in the Docker Listener module [#4301](https://github.com/wazuh/wazuh-kibana-app/pull/4301) +- Fixed broken links to the documentation site [#4301](https://github.com/wazuh/wazuh-kibana-app/pull/4301) +- Fix Rules, Decoders and CDB lists uploaders to show errors appropriately [#4307](https://github.com/wazuh/wazuh-kibana-app/pull/4307) +- Sanitize report's inputs and usernames [#4330](https://github.com/wazuh/wazuh-kibana-app/pull/4330) + ## Wazuh v4.3.5 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4306 ### Added diff --git a/public/plugin.ts b/public/plugin.ts index 97914db185..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'); + } + // 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(); } - - 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(); - }; + 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,8 +101,11 @@ export class WazuhPlugin implements Plugin plugins.telemetry.telemetryNotifications.setOptedInNoticeSeen(); @@ -128,8 +129,6 @@ export class WazuhPlugin implements Plugin