Skip to content

Commit e3d0b4f

Browse files
committed
change: remove wazuh_core.hosts settings
- Remove wazuh_core.hosts settings - Removed initiation of ManageHosts and ServerAPIClient in the server side - Removed server API client exposed through the wazuh_core plugin in the plugin lifecycle methods - Disconnected/mocked some services to allow the plugins does not fail
1 parent ab59afc commit e3d0b4f

File tree

6 files changed

+21
-214
lines changed

6 files changed

+21
-214
lines changed

docker/osd-dev/config/2.x/osd/opensearch_dashboards.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,3 @@ opensearch.username: 'kibanaserver'
1919
opensearch.password: 'kibanaserver'
2020
opensearchDashboards.branding:
2121
useExpandedHeader: false
22-
wazuh_core.hosts:
23-
manager:
24-
url: 'https://wazuh.manager'
25-
port: 55000
26-
username: wazuh-wui
27-
password: MyS3cr37P450r.*-
28-
run_as: false

plugins/wazuh-core/common/constants.ts

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -621,115 +621,6 @@ export const PLUGIN_SETTINGS: Record<string, TPluginSetting> = {
621621
defaultValue: false,
622622
validate: SettingsValidator.isBoolean,
623623
},
624-
/* `# The following configuration is the default structure to define a host.
625-
#
626-
# hosts:
627-
# # Host ID / name,
628-
# - env-1:
629-
# # Host URL
630-
# url: https://env-1.example
631-
# # Host / API port
632-
# port: 55000
633-
# # Host / API username
634-
# username: wazuh-wui
635-
# # Host / API password
636-
# password: wazuh-wui
637-
# # Use RBAC or not. If set to true, the username must be "wazuh-wui".
638-
# run_as: true
639-
# - env-2:
640-
# url: https://env-2.example
641-
# port: 55000
642-
# username: wazuh-wui
643-
# password: wazuh-wui
644-
# run_as: true
645-
646-
hosts:
647-
- default:
648-
url: https://localhost
649-
port: 55000
650-
username: wazuh-wui
651-
password: wazuh-wui
652-
run_as: false`,
653-
*/
654-
hosts: {
655-
title: 'Server hosts',
656-
description: 'Configure the API connections.',
657-
source: EConfigurationProviders.INITIALIZER_CONTEXT,
658-
category: SettingCategory.API_CONNECTION,
659-
type: EpluginSettingType.objectOf,
660-
defaultValue: [],
661-
options: {
662-
objectOf: {
663-
url: {
664-
title: 'URL',
665-
description: 'Server URL address',
666-
type: EpluginSettingType.text,
667-
defaultValue: 'https://localhost',
668-
validate: SettingsValidator.compose(
669-
SettingsValidator.isString,
670-
SettingsValidator.isNotEmptyString,
671-
),
672-
},
673-
port: {
674-
title: 'Port',
675-
description: 'Port',
676-
type: EpluginSettingType.number,
677-
defaultValue: 55000,
678-
options: {
679-
number: {
680-
min: 0,
681-
max: 65535,
682-
integer: true,
683-
},
684-
},
685-
validate: function (value) {
686-
return SettingsValidator.number(this.options?.number)(value);
687-
},
688-
},
689-
username: {
690-
title: 'Username',
691-
description: 'Server API username',
692-
type: EpluginSettingType.text,
693-
defaultValue: 'wazuh-wui',
694-
validate: SettingsValidator.compose(
695-
SettingsValidator.isString,
696-
SettingsValidator.isNotEmptyString,
697-
),
698-
},
699-
password: {
700-
title: 'Password',
701-
description: "User's Password",
702-
type: EpluginSettingType.password,
703-
defaultValue: 'wazuh-wui',
704-
validate: SettingsValidator.compose(
705-
SettingsValidator.isString,
706-
SettingsValidator.isNotEmptyString,
707-
),
708-
},
709-
run_as: {
710-
title: 'Run as',
711-
description: 'Use the authentication context.',
712-
type: EpluginSettingType.switch,
713-
defaultValue: false,
714-
options: {
715-
switch: {
716-
values: {
717-
disabled: { label: 'false', value: false },
718-
enabled: { label: 'true', value: true },
719-
},
720-
},
721-
},
722-
validate: SettingsValidator.isBoolean,
723-
},
724-
},
725-
},
726-
isConfigurableFromSettings: false,
727-
// TODO: add validation
728-
// validate: SettingsValidator.isBoolean,
729-
// validate: function (schema) {
730-
// return schema.boolean();
731-
// },
732-
},
733624
'ip.ignore': {
734625
title: 'Index pattern ignore',
735626
description:

plugins/wazuh-core/public/plugin.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { NoopLogger } from '../common/logger/noop-logger';
1414
import { WazuhCorePluginSetup, WazuhCorePluginStart } from './types';
1515
import { setChrome, setCore, setUiSettings } from './plugin-services';
1616
import { UISettingsConfigProvider } from './services/configuration/ui-settings-provider';
17-
import { InitializerConfigProvider } from './services/configuration/initializer-context-provider';
1817
import * as utils from './utils';
1918
import * as uiComponents from './components';
2019
import {
@@ -73,10 +72,11 @@ export class WazuhCorePlugin
7372

7473
this.internal.configurationStore = new ConfigurationStore(logger);
7574

76-
this.internal.configurationStore.registerProvider(
77-
EConfigurationProviders.INITIALIZER_CONTEXT,
78-
new InitializerConfigProvider(this.initializerContext),
79-
);
75+
// Uncomment if there is at least one setting of "wazuh_core" plugin
76+
// this.internal.configurationStore.registerProvider(
77+
// EConfigurationProviders.INITIALIZER_CONTEXT,
78+
// new InitializerConfigProvider(this.initializerContext),
79+
// );
8080

8181
// register the uiSettins on the configuration store to avoid the use inside of configuration service
8282
this.internal.configurationStore.registerProvider(

plugins/wazuh-core/server/index.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { schema, TypeOf } from '@osd/config-schema';
2-
import {
3-
PluginConfigDescriptor,
4-
PluginInitializerContext,
5-
} from '../../../src/core/server';
6-
import { PLUGIN_SETTINGS } from '../common/constants';
7-
import { getConfigSettingsDefinitions } from '../common/settings-adapter';
1+
import { PluginInitializerContext } from '../../../src/core/server';
82
import { WazuhCorePlugin } from './plugin';
93

104
// This exports static code and TypeScript types,
@@ -14,17 +8,5 @@ export function plugin(initializerContext: PluginInitializerContext) {
148
return new WazuhCorePlugin(initializerContext);
159
}
1610

17-
const initiliazerConfig = getConfigSettingsDefinitions(PLUGIN_SETTINGS);
18-
19-
export const configSchema = schema.object(initiliazerConfig);
20-
export type CorePluginConfigType = TypeOf<typeof configSchema>;
21-
22-
export const config: PluginConfigDescriptor<CorePluginConfigType> = {
23-
exposeToBrowser: {
24-
hosts: true,
25-
},
26-
schema: configSchema,
27-
};
28-
2911
export type { WazuhCorePluginSetup, WazuhCorePluginStart } from './types';
3012
export * from './types';

plugins/wazuh-core/server/plugin.ts

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
WAZUH_PLUGIN_PLATFORM_SETTING_MAX_BUCKETS,
1313
WAZUH_PLUGIN_PLATFORM_SETTING_METAFIELDS,
1414
WAZUH_PLUGIN_PLATFORM_SETTING_TIME_FILTER,
15-
EConfigurationProviders,
1615
PLUGIN_SETTINGS,
1716
} from '../common/constants';
1817
import {
@@ -26,16 +25,9 @@ import {
2625
WazuhCorePluginStart,
2726
} from './types';
2827
import { setCore } from './plugin-services';
29-
import {
30-
ManageHosts,
31-
createDashboardSecurity,
32-
ServerAPIClient,
33-
InitializationService,
34-
} from './services';
28+
import { createDashboardSecurity, InitializationService } from './services';
3529
// configuration common
3630
// configuration server
37-
import { InitializerConfigProvider } from './services/configuration';
38-
import { initializationTaskCreatorServerAPIConnectionCompatibility } from './initialization/server-api';
3931
import {
4032
initializationTaskCreatorExistTemplate,
4133
initializationTaskCreatorIndexPattern,
@@ -86,10 +78,11 @@ export class WazuhCorePlugin
8678
);
8779

8880
// add the initializer context config to the configuration store
89-
this.internal.configurationStore.registerProvider(
90-
EConfigurationProviders.PLUGIN_UI_SETTINGS,
91-
new InitializerConfigProvider(this.initializerContext),
92-
);
81+
// Uncomment if there is at least one setting of "wazuh_core" plugin
82+
// this.internal.configurationStore.registerProvider(
83+
// EConfigurationProviders.PLUGIN_UI_SETTINGS,
84+
// new InitializerConfigProvider(this.initializerContext),
85+
// );
9386

9487
// create the configuration service to use like a facede pattern
9588
this.services.configuration = new Configuration(
@@ -99,19 +92,6 @@ export class WazuhCorePlugin
9992

10093
this.services.configuration.setup();
10194

102-
this.services.manageHosts = new ManageHosts(
103-
this.logger.get('manage-hosts'),
104-
this.services.configuration,
105-
);
106-
107-
this.services.serverAPIClient = new ServerAPIClient(
108-
this.logger.get('server-api-client'),
109-
this.services.manageHosts,
110-
this.services.dashboardSecurity,
111-
);
112-
113-
this.services.manageHosts.setServerAPIClient(this.services.serverAPIClient);
114-
11595
this.services.initialization = new InitializationService(
11696
this.logger.get('initialization'),
11797
this.services,
@@ -120,11 +100,12 @@ export class WazuhCorePlugin
120100
this.services.initialization.setup({ core });
121101

122102
// Register initialization tasks
123-
this.services.initialization.register(
124-
initializationTaskCreatorServerAPIConnectionCompatibility({
125-
taskName: 'check-server-api-connection-compatibility',
126-
}),
127-
);
103+
// TODO: remove because the server API management is not used
104+
// this.services.initialization.register(
105+
// initializationTaskCreatorServerAPIConnectionCompatibility({
106+
// taskName: 'check-server-api-connection-compatibility',
107+
// }),
108+
// );
128109

129110
// Index pattern: alerts
130111
// TODO: this task should be registered by the related plugin
@@ -337,25 +318,10 @@ export class WazuhCorePlugin
337318
logger: this.logger.get(
338319
`${request.route.method.toUpperCase()} ${request.route.path}`,
339320
),
340-
api: {
341-
client: {
342-
asInternalUser: this.services.serverAPIClient.asInternalUser,
343-
asCurrentUser: this.services.serverAPIClient.asScoped(
344-
context,
345-
request,
346-
),
347-
},
348-
},
349321
}));
350322

351323
return {
352324
...this.services,
353-
api: {
354-
client: {
355-
asInternalUser: this.services.serverAPIClient.asInternalUser,
356-
asScoped: this.services.serverAPIClient.asScoped,
357-
},
358-
},
359325
} as WazuhCorePluginSetup;
360326
}
361327

@@ -365,17 +331,10 @@ export class WazuhCorePlugin
365331
setCore(core);
366332

367333
await this.services.configuration.start();
368-
await this.services.manageHosts.start();
369334
await this.services.initialization.start({ core });
370335

371336
return {
372337
...this.services,
373-
api: {
374-
client: {
375-
asInternalUser: this.services.serverAPIClient.asInternalUser,
376-
asScoped: this.services.serverAPIClient.asScoped,
377-
},
378-
},
379338
} as WazuhCorePluginSetup;
380339
}
381340

plugins/wazuh-core/server/types.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,9 @@
1-
import {
2-
ServerAPIInternalUserClient,
3-
ServerAPIScopedUserClient,
4-
WazuhCoreServices,
5-
} from './services';
1+
import { WazuhCoreServices } from './services';
62

73
// eslint-disable-next-line @typescript-eslint/no-empty-interface
8-
export interface WazuhCorePluginSetup extends WazuhCoreServices {
9-
api: {
10-
client: {
11-
asInternalUser: ServerAPIInternalUserClient;
12-
asScoped: (context: any, request: any) => ServerAPIScopedUserClient;
13-
};
14-
};
15-
}
4+
export interface WazuhCorePluginSetup extends WazuhCoreServices {}
165
// eslint-disable-next-line @typescript-eslint/no-empty-interface
17-
export interface WazuhCorePluginStart extends WazuhCoreServices {
18-
api: {
19-
client: {
20-
asInternalUser: ServerAPIInternalUserClient;
21-
asScoped: (context: any, request: any) => ServerAPIScopedUserClient;
22-
};
23-
};
24-
}
6+
export interface WazuhCorePluginStart extends WazuhCoreServices {}
257

268
export interface PluginSetup {
279
securityDashboards?: object; // TODO: Add OpenSearch Dashboards Security interface

0 commit comments

Comments
 (0)