Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate wazuh.yml configuration to opensearch_dashboards.yml #7175

Draft
wants to merge 23 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e2ecc3d
Added wazuh configuration in wazuh_core plugin
Machi3mfl Nov 25, 2024
ea8ad34
Add hosts config on opensearch_dashboards.yml
Machi3mfl Nov 27, 2024
4c25766
Merge branch 'master' into enhancement/migrate-wazuh-configuration
Machi3mfl Dec 2, 2024
25886e3
Add advanced settings (ui_settings)
Machi3mfl Dec 4, 2024
0467def
Move all configurations to yml and ui settings
Machi3mfl Dec 4, 2024
c7922d3
Add new configuration providers and repository
Machi3mfl Dec 9, 2024
c933616
Update providers
Machi3mfl Dec 9, 2024
4855482
Update core with new configuration store interface
Machi3mfl Dec 9, 2024
94a9dad
Fix main errores
Machi3mfl Dec 9, 2024
1dacb0b
Create configuration services folder on common
Machi3mfl Dec 12, 2024
634f43d
Update server configuration services and types
Machi3mfl Dec 12, 2024
511b3e5
Create public configuration types
Machi3mfl Dec 12, 2024
d6b66e5
Apply new configuration store implementation on server
Machi3mfl Dec 12, 2024
9a4d2fe
Apply new configuration store implementation on public context
Machi3mfl Dec 12, 2024
3ab5831
Moved ui settings to common
Machi3mfl Dec 13, 2024
e5d0f95
Update providers and configuration types
Machi3mfl Dec 13, 2024
4fc58e2
Use configuration service on public
Machi3mfl Dec 13, 2024
ff50249
Add configuration store unit tests
Machi3mfl Dec 13, 2024
86bc999
Update configuration service unit tests
Machi3mfl Dec 13, 2024
bced596
Adapt the plugin settings to ui settings
Machi3mfl Dec 17, 2024
d6ae59d
Use settings adapter to create plugin config
Machi3mfl Dec 18, 2024
ddea925
Merge branch 'master' into enhancement/migrate-wazuh-configuration
Machi3mfl Dec 19, 2024
da87f62
Fix conflicts with master
Machi3mfl Dec 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions docker/osd-dev/config/2.x/osd/opensearch_dashboards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ opensearch.ssl.verificationMode: certificate
# opensearch.requestHeadersWhitelist: ["securitytenant","Authorization"]
#
# osd 2.0
opensearch.requestHeadersAllowlist: ["securitytenant", "Authorization"]
opensearch.requestHeadersAllowlist: ['securitytenant', 'Authorization']
#
opensearch_security.multitenancy.enabled: false
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
opensearch_security.readonly_mode.roles: ['kibana_read_only']
server.ssl.enabled: true
server.ssl.key: "/home/node/kbn/certs/osd.key"
server.ssl.certificate: "/home/node/kbn/certs/osd.pem"
opensearch.ssl.certificateAuthorities: ["/home/node/kbn/certs/ca.pem"]
server.ssl.key: '/home/node/kbn/certs/osd.key'
server.ssl.certificate: '/home/node/kbn/certs/osd.pem'
opensearch.ssl.certificateAuthorities: ['/home/node/kbn/certs/ca.pem']
uiSettings.overrides.defaultRoute: /app/wz-home
opensearch.username: "kibanaserver"
opensearch.password: "kibanaserver"
opensearch.username: 'kibanaserver'
opensearch.password: 'kibanaserver'
opensearchDashboards.branding:
useExpandedHeader: false

wazuh_core.hosts:
manager:
url: 'https://wazuh.manager'
port: 55000
username: wazuh-wui
password: MyS3cr37P450r.*-
run_as: false
27 changes: 0 additions & 27 deletions plugins/main/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
setWazuhEnginePlugin,
setWazuhFleetPlugin,
} from './kibana-services';
import { validate as validateNodeCronInterval } from 'node-cron';

Check failure on line 30 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

`node-cron` import should occur before import of `./kibana-services`

Check failure on line 30 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'validateNodeCronInterval' is defined but never used. Allowed unused vars must match /[iI]gnored$/u
import {
AppPluginStartDependencies,
WazuhSetup,
Expand All @@ -35,39 +35,34 @@
WazuhStart,
WazuhStartPlugins,
} from './types';
import { Cookies } from 'react-cookie';

Check failure on line 38 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

`react-cookie` import should occur before import of `./kibana-services`
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 store from './redux/store';

Check failure on line 42 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'store' is defined but never used. Allowed unused vars must match /[iI]gnored$/u
import { updateAppConfig } from './redux/actions/appConfigActions';

Check failure on line 43 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'updateAppConfig' is defined but never used. Allowed unused vars must match /[iI]gnored$/u
import {
initializeInterceptor,
unregisterInterceptor,
} from './services/request-handler';
import { Applications, Categories } from './utils/applications';
import { euiPaletteColorBlind } from '@elastic/eui';

Check failure on line 49 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

`@elastic/eui` import should occur before import of `./kibana-services`
import NavigationService from './react-services/navigation-service';
import { createHashHistory } from 'history';

Check failure on line 51 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

`history` import should occur before import of `./kibana-services`
import { reportingDefinitions } from './react-services/reporting/reporting-definitions';

Check failure on line 52 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

'reportingDefinitions' is defined but never used. Allowed unused vars must match /[iI]gnored$/u

export class WazuhPlugin
implements
Plugin<WazuhSetup, WazuhStart, WazuhSetupPlugins, WazuhStartPlugins>
{
constructor(private readonly initializerContext: PluginInitializerContext) {}
private hideTelemetryBanner?: () => void;

Check failure on line 59 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Expected blank line between class members
public async setup(

Check failure on line 60 in plugins/main/public/plugin.ts

View workflow job for this annotation

GitHub Actions / Ensure the code format on the changed files

Expected blank line between class members
core: CoreSetup,
plugins: WazuhSetupPlugins,
): Promise<WazuhSetup> {
// Get custom logos configuration to start up the app with the correct logos
let logosInitialState = {};
try {
logosInitialState = await core.http.get(`/api/logos`);
} catch (error) {
console.error('plugin.ts: Error getting logos configuration', error);
}

// Redefine the mapKeys method to change the properties sent to euiPaletteColorBlind.
// This is a workaround until the issue reported in Opensearch Dashboards is fixed.
Expand Down Expand Up @@ -128,32 +123,10 @@
order,
mount: async (params: AppMountParameters) => {
try {
/* Workaround: Redefine the validation functions of cron.statistics.interval setting.
There is an optimization error of the frontend side source code due to some modules can
not be loaded
*/
const setting = plugins.wazuhCore.configuration._settings.get(
'cron.statistics.interval',
);
!setting.validateUIForm &&
(setting.validateUIForm = function (value) {
return this.validate(value);
});
!setting.validate &&
(setting.validate = function (value: string) {
return validateNodeCronInterval(value)
? undefined
: 'Interval is not valid.';
});
setWzCurrentAppID(id);
// Set the dynamic redirection
setWzMainParams(redirectTo());
initializeInterceptor(core);

// Update redux app state logos with the custom logos
if (logosInitialState?.logos) {
store.dispatch(updateAppConfig(logosInitialState.logos));
}
// hide the telemetry banner.
// Set the flag in the telemetry saved object as the notice was seen and dismissed
this.hideTelemetryBanner && (await this.hideTelemetryBanner());
Expand Down
11 changes: 8 additions & 3 deletions plugins/main/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
});

// Sanitize uploaded files tasks
// error: [error][plugins][sanitize-uploaded-files-task][wazuh] sanitize:sanitizeUploadedSVG: Error: Configuration undefined not found
/*
jobSanitizeUploadedFilesTasksRun({
core,
wazuh: {
Expand All @@ -143,7 +145,8 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
wazuh_core: plugins.wazuhCore,
server: contextServer,
});

*/

// Migration tasks
jobMigrationTasksRun({
core,
Expand All @@ -155,7 +158,7 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
server: contextServer,
});

// Monitoring
/* Monitoring
jobMonitoringRun({
core,
wazuh: {
Expand All @@ -165,8 +168,9 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
wazuh_core: plugins.wazuhCore,
server: contextServer,
});
*/

// Scheduler
/* Scheduler
jobSchedulerRun({
core,
wazuh: {
Expand All @@ -176,6 +180,7 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
wazuh_core: plugins.wazuhCore,
server: contextServer,
});
*/

// Queue
jobQueueRun({
Expand Down
4 changes: 3 additions & 1 deletion plugins/main/server/routes/wazuh-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ export function WazuhApiRoutes(router: IRouter) {
ctrl.getSyscollector(context, request, response),
);

// Return app logos configuration
/* Return app logos configuration
ToDo: Change (maybe) to get the opensearch logo settings
router.get(
{
path: '/api/logos',
Expand All @@ -138,6 +139,7 @@ export function WazuhApiRoutes(router: IRouter) {
async (context, request, response) =>
ctrl.getAppLogos(context, request, response),
);
*/

// Return binary dashboard
router.get(
Expand Down
5 changes: 3 additions & 2 deletions plugins/main/server/start/monitoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let MONITORING_ENABLED,
async function initMonitoringConfiguration(context) {
try {
context.wazuh.logger.debug('Reading configuration');
const appConfig = await context.wazuh_core.configuration.get();
const appConfig = await context.wazuh_core.configuration.getAll();
MONITORING_ENABLED =
(appConfig['wazuh.monitoring.enabled'] &&
appConfig['wazuh.monitoring.enabled'] !== 'worker') ||
Expand Down Expand Up @@ -90,6 +90,7 @@ async function initMonitoringConfiguration(context) {
*/
async function init(context) {
try {
const config = await context.wazuh_core.configuration.getAll();
if (MONITORING_ENABLED) {
await checkTemplate(context);
}
Expand Down Expand Up @@ -519,7 +520,7 @@ async function fetchAllAgentsFromApiHost(context, apiHost) {
export async function jobMonitoringRun(context) {
context.wazuh.logger.debug('Task:Monitoring initializing');
// Init the monitoring variables
await initMonitoringConfiguration(context);
//await initMonitoringConfiguration(context);
// Check Kibana index and if it is prepared, start the initialization of Wazuh App.
await checkPluginPlatformStatus(context);
// // Run the cron job only it it's enabled
Expand Down
Loading
Loading