Skip to content

Commit

Permalink
Fix linter error
Browse files Browse the repository at this point in the history
  • Loading branch information
Machi3mfl committed Dec 23, 2024
1 parent b3564d4 commit 42c49c0
Show file tree
Hide file tree
Showing 8 changed files with 181 additions and 673 deletions.
42 changes: 17 additions & 25 deletions plugins/main/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,10 @@ import {
PluginInitializerContext,
SharedGlobalConfig,
} from 'opensearch_dashboards/server';

import { first } from 'rxjs/operators';
import { WazuhPluginSetup, WazuhPluginStart, PluginSetup } from './types';
import { setupRoutes } from './routes';
import {
jobInitializeRun,
jobMonitoringRun,
jobSchedulerRun,
jobQueueRun,
jobMigrationTasksRun,
jobSanitizeUploadedFilesTasksRun,
} from './start';
import { first } from 'rxjs/operators';
import { jobInitializeRun, jobQueueRun, jobMigrationTasksRun } from './start';

declare module 'opensearch_dashboards/server' {
interface RequestHandlerContext {
Expand Down Expand Up @@ -82,31 +74,31 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {

const serverInfo = core.http.getServerInfo();

core.http.registerRouteHandlerContext('wazuh', (context, request) => {
return {
// Create a custom logger with a tag composed of HTTP method and path endpoint
logger: this.logger.get(
`${request.route.method.toUpperCase()} ${request.route.path}`,
),
server: {
info: serverInfo,
},
plugins,
security: plugins.wazuhCore.dashboardSecurity,
api: context.wazuh_core.api,
};
});
core.http.registerRouteHandlerContext('wazuh', (context, request) => ({
// Create a custom logger with a tag composed of HTTP method and path endpoint
logger: this.logger.get(
`${request.route.method.toUpperCase()} ${request.route.path}`,
),
server: {
info: serverInfo,
},
plugins,
security: plugins.wazuhCore.dashboardSecurity,
api: context.wazuh_core.api,
}));

// Add custom headers to the responses
core.http.registerOnPreResponse((request, response, toolkit) => {
const additionalHeaders = {
'x-frame-options': 'sameorigin',
};

return toolkit.next({ headers: additionalHeaders });
});

// Routes
const router = core.http.createRouter();

setupRoutes(router, plugins.wazuhCore);

return {};
Expand All @@ -117,7 +109,6 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
await this.initializerContext.config.legacy.globalConfig$
.pipe(first())
.toPromise();

const contextServer = {
config: globalConfiguration,
};
Expand Down Expand Up @@ -192,6 +183,7 @@ export class WazuhPlugin implements Plugin<WazuhPluginSetup, WazuhPluginStart> {
wazuh_core: plugins.wazuhCore,
server: contextServer,
});

return {};
}

Expand Down
6 changes: 3 additions & 3 deletions plugins/main/server/routes/wazuh-api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IRouter } from 'opensearch_dashboards/server';
import { WazuhApiCtrl } from '../controllers';
import { schema } from '@osd/config-schema';
import { WazuhApiCtrl } from '../controllers';

export function WazuhApiRoutes(router: IRouter) {
const ctrl = new WazuhApiCtrl();
Expand Down Expand Up @@ -28,11 +28,11 @@ export function WazuhApiRoutes(router: IRouter) {
validate: {
body: schema.any({
// TODO: not ready
//id: schema.string(),
// id: schema.string(),
// url: schema.string(),
// port: schema.number(),
// username: schema.string(),
//forceRefresh: schema.boolean({defaultValue:false}),
// forceRefresh: schema.boolean({defaultValue:false}),
// cluster_info: schema.object({
// status: schema.string(),
// manager: schema.string(),
Expand Down
Loading

0 comments on commit 42c49c0

Please sign in to comment.