Skip to content

Commit

Permalink
Fix conflicts with master
Browse files Browse the repository at this point in the history
  • Loading branch information
Machi3mfl committed Dec 19, 2024
1 parent ddea925 commit da87f62
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 49 deletions.
40 changes: 0 additions & 40 deletions plugins/wazuh-core/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -511,46 +511,6 @@ export interface TPluginSetting {
validate?: (value: any) => string | undefined;
};

export type TPluginSettingWithKey = TPluginSetting & { key: TPluginSettingKey };
export type TPluginSettingCategory = {
title: string;
description?: string;
documentationLink?: string;
renderOrder?: number;
};

export const PLUGIN_SETTINGS_CATEGORIES: {
[category: number]: TPluginSettingCategory;
} = {
[SettingCategory.HEALTH_CHECK]: {
title: 'Health check',
description: "Checks will be executed by the app's Healthcheck.",
renderOrder: SettingCategory.HEALTH_CHECK,
},
[SettingCategory.GENERAL]: {
title: 'General',
description:
'Basic app settings related to alerts index pattern, hide the manager alerts in the dashboards, logs level and more.',
renderOrder: SettingCategory.GENERAL,
},
[SettingCategory.SECURITY]: {
title: 'Security',
description: 'Application security options such as unauthorized roles.',
renderOrder: SettingCategory.SECURITY,
},
[SettingCategory.VULNERABILITIES]: {
title: 'Vulnerabilities',
description:
'Options related to the agent vulnerabilities monitoring job and its storage in indexes.',
renderOrder: SettingCategory.VULNERABILITIES,
},
[SettingCategory.API_CONNECTION]: {
title: 'API connections',
description: 'Options related to the API connections.',
renderOrder: SettingCategory.API_CONNECTION,
},
};

export const PLUGIN_SETTINGS: { [key: string]: TPluginSetting } = {
'alerts.sample.prefix': {
title: 'Sample alerts prefix',
Expand Down
20 changes: 13 additions & 7 deletions plugins/wazuh-core/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as hooks from './hooks';
import { UISettingsConfigProvider } from './services/configuration/ui-settings-provider';
import { InitializerConfigProvider } from './services/configuration/initializer-context-provider';
import { EConfigurationProviders } from '../common/constants';
import { CoreSetup, CoreStart, Plugin } from 'opensearch-dashboards/public';
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'opensearch-dashboards/public';
import { API_USER_STATUS_RUN_AS } from '../common/api-user-status-run-as';
import { Configuration } from '../common/services/configuration';
import * as utils from './utils';
Expand All @@ -22,9 +22,15 @@ export class WazuhCorePlugin
internal: Record<string, any> = {};
services: Record<string, any> = {};

constructor(private initializerContext: PluginInitializerContext){
this.services = {};
this.internal = {};
}

public async setup(core: CoreSetup): Promise<WazuhCorePluginSetup> {
// No operation logger
const noopLogger = {

const logger = {
info: noop,
error: noop,
debug: noop,
Expand All @@ -34,26 +40,26 @@ export class WazuhCorePlugin
log: noop,
get: () => logger,
};
this._internal.configurationStore = new ConfigurationStore(
this.internal.configurationStore = new ConfigurationStore(
logger
);

this._internal.configurationStore.registerProvider(
this.internal.configurationStore.registerProvider(
EConfigurationProviders.INITIALIZER_CONTEXT,
new InitializerConfigProvider(this.initializerContext)
);

// register the uiSettins on the configuration store to avoid the use inside of configuration service
this._internal.configurationStore.registerProvider(
this.internal.configurationStore.registerProvider(
EConfigurationProviders.PLUGIN_UI_SETTINGS,
new UISettingsConfigProvider(core.uiSettings)
);

console.log('uiSettings', await this._internal.configurationStore.getProviderConfiguration(EConfigurationProviders.INITIALIZER_CONTEXT));
console.log('uiSettings', await this.internal.configurationStore.getProviderConfiguration(EConfigurationProviders.INITIALIZER_CONTEXT));

console.log('uiSettings core', core.uiSettings.getAll())

console.log('uiSettings from configuration', await this._internal.configurationStore.getProviderConfiguration(EConfigurationProviders.PLUGIN_UI_SETTINGS));
console.log('uiSettings from configuration', await this.internal.configurationStore.getProviderConfiguration(EConfigurationProviders.PLUGIN_UI_SETTINGS));

this.services.configuration = new Configuration(
logger,
Expand Down
2 changes: 2 additions & 0 deletions plugins/wazuh-core/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ServerDataProps } from './services/http/ui/components/types';
import { DashboardSecurity } from './utils/dashboard-security';

export interface WazuhCorePluginSetup {
_internal: any;
utils: { formatUIDate: (date: Date) => string };
API_USER_STATUS_RUN_AS: typeof API_USER_STATUS_RUN_AS;
configuration: Configuration;
Expand All @@ -26,6 +27,7 @@ export interface WazuhCorePluginSetup {
}

export interface WazuhCorePluginStart {
_internal: any;
hooks: {
useDockedSideNav: UseDockedSideNav;
useStateStorage: UseStateStorageHook; // TODO: enhance
Expand Down
4 changes: 2 additions & 2 deletions plugins/wazuh-core/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ export class WazuhCorePlugin
core.uiSettings.register(uiSettingsDefs);

this.services.dashboardSecurity = createDashboardSecurity(plugins);
this._internal.configurationStore = new ConfigurationStore(
this.internal.configurationStore = new ConfigurationStore(
this.logger.get('configuration-store')
);

// add the initializer context config to the configuration store
this._internal.configurationStore.registerProvider(
this.internal.configurationStore.registerProvider(
EConfigurationProviders.PLUGIN_UI_SETTINGS,
new InitializerConfigProvider(this.initializerContext)
)
Expand Down

0 comments on commit da87f62

Please sign in to comment.