Skip to content

Commit

Permalink
TypeError resolved (#4362)
Browse files Browse the repository at this point in the history
* Solve TypeError

* Add CHANGELOG

* Change request service

* Fix request's response structure

(cherry picked from commit 44a43cb)
  • Loading branch information
chantal-kelm committed Aug 5, 2022
1 parent 84f541e commit 515f14f
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 53 deletions.
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
105 changes: 52 additions & 53 deletions public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<WazuhSetup, WazuhStart, WazuhSetupPlugins, WazuhStartPlugins> {
constructor(private readonly initializerContext: PluginInitializerContext) {}
public initializeInnerAngular?: () => void;
private innerAngularInitialized: boolean = false;
private stateUpdater = new BehaviorSubject<AppUpdater>(() => ({}));
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',
Expand All @@ -103,8 +101,11 @@ export class WazuhPlugin implements Plugin<WazuhSetup, WazuhStart, WazuhSetupPlu
});
return {};
}

public start(core: CoreStart, plugins: AppPluginStartDependencies): WazuhStart {
// hide security alert
if(plugins.securityOss) {
plugins.securityOss.insecureCluster.hideAlert(true);
};
if(plugins?.telemetry?.telemetryNotifications?.setOptedInNoticeSeen) {
// assign to a method to hide the telemetry banner used when the app is mounted
this.hideTelemetryBanner = () => plugins.telemetry.telemetryNotifications.setOptedInNoticeSeen();
Expand All @@ -128,8 +129,6 @@ export class WazuhPlugin implements Plugin<WazuhSetup, WazuhStart, WazuhSetupPlu
setAngularModule(module);
this.innerAngularInitialized = true;
};


setCore(core);
setPlugins(plugins);
setHttp(core.http);
Expand All @@ -144,4 +143,4 @@ export class WazuhPlugin implements Plugin<WazuhSetup, WazuhStart, WazuhSetupPlu
setErrorOrchestrator(ErrorOrchestratorService);
return {};
}
}
}

0 comments on commit 515f14f

Please sign in to comment.