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

[Backport 4.4-7.16] Fix typos and errors code status replacement in wazuh-api controller #4733

Merged
merged 3 commits into from
Oct 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed a bug where the Wazuh logo was used instead of the custom one [#4539](https://github.com/wazuh/wazuh-kibana-app/pull/4539)
- Fixed rendering problems of the `Agent Overview` section in low resolutions [#4516](https://github.com/wazuh/wazuh-kibana-app/pull/4516)
- Fixed issue when logging out from Wazuh when SAML is enabled [#4595](https://github.com/wazuh/wazuh-kibana-app/issues/4595)
- Fixed server errors with code 500 when the Wazuh API is not reachable / up. [#4710](https://github.com/wazuh/wazuh-kibana-app/pull/4710)
- Fixed server errors with code 500 when the Wazuh API is not reachable / up. [#4710](https://github.com/wazuh/wazuh-kibana-app/pull/4710) [#4728](https://github.com/wazuh/wazuh-kibana-app/pull/4728)


- Fixed pagination to SCA table [#4653](https://github.com/wazuh/wazuh-kibana-app/issues/4653)

## Wazuh v4.3.9 - Kibana 7.10.2, 7.16.x, 7.17.x - Revision 4310
Expand Down
10 changes: 5 additions & 5 deletions server/controllers/wazuh-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,7 @@ export class WazuhApiCtrl {
const idApi = getCookieValueByName(request.headers.cookie, 'wz-api');
if (idApi !== request.body.id) { // if the current token belongs to a different API id, we relogin to obtain a new token
return ErrorResponse(
'status code HTTP_STATUS_CODES.UNAUTHORIZED',
'status code 401',
HTTP_STATUS_CODES.UNAUTHORIZED,
HTTP_STATUS_CODES.UNAUTHORIZED,
response
Expand Down Expand Up @@ -935,7 +935,7 @@ export class WazuhApiCtrl {
log('wazuh-api:getTimeStamp', error.message || error);
return ErrorResponse(
error.message || 'Could not fetch wazuh-version registry',
HTTP_STATUS_CODES.BAD_REQUEST1,
4001,
HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,
response
);
Expand Down Expand Up @@ -963,7 +963,7 @@ export class WazuhApiCtrl {
log('wazuh-api:setExtensions', error.message || error);
return ErrorResponse(
error.message || 'Could not set extensions',
HTTP_STATUS_CODES.BAD_REQUEST1,
4001,
HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,
response
);
Expand Down Expand Up @@ -991,7 +991,7 @@ export class WazuhApiCtrl {
log('wazuh-api:getExtensions', error.message || error);
return ErrorResponse(
error.message || 'Could not fetch wazuh-version registry',
HTTP_STATUS_CODES.BAD_REQUEST1,
4001,
HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,
response
);
Expand All @@ -1018,7 +1018,7 @@ export class WazuhApiCtrl {
log('wazuh-api:getSetupInfo', error.message || error);
return ErrorResponse(
`Could not get data from wazuh-version registry due to ${error.message || error}`,
HTTP_STATUS_CODES.BAD_REQUEST5,
4005,
HTTP_STATUS_CODES.INTERNAL_SERVER_ERROR,
response
);
Expand Down
7 changes: 2 additions & 5 deletions server/routes/wazuh-api-http-status.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
// To launch this file
// yarn test:jest --testEnvironment node --verbose server/routes/wazuh-api
// yarn test:jest --testEnvironment node --verbose server/routes/wazuh-api-http-status.test.ts
import { Router } from '../../../../src/core/server/http/router/router';
import { HttpServer } from '../../../../src/core/server/http/http_server';
import { loggingSystemMock } from '../../../../src/core/server/logging/logging_system.mock';
import { ByteSizeValue } from '@kbn/config-schema';
import supertest from 'supertest';
import { WazuhApiRoutes } from './wazuh-api';
import { WazuhApiCtrl } from '../controllers/wazuh-api';
import { createDataDirectoryIfNotExists, createDirectoryIfNotExists } from '../lib/filesystem';
import {
HTTP_STATUS_CODES,
Expand All @@ -32,6 +31,7 @@ const enhanceWithContext = (fn: (...args: any[]) => any) => fn.bind(null, contex
let server, innerServer;

beforeAll(async () => {

// Create <PLUGIN_PLATFORM_PATH>/data/wazuh directory.
createDataDirectoryIfNotExists();
// Create <PLUGIN_PLATFORM_PATH>/data/wazuh/config directory.
Expand All @@ -58,9 +58,6 @@ beforeAll(async () => {
const { registerRouter, server: innerServerTest, ...rest } = await server.setup(config);
innerServer = innerServerTest;

// const spyRouteDecoratorProtectedAdministratorRoleValidToken = jest.spyOn(WazuhApiCtrl.prototype as any, 'routeDecoratorProtectedAdministratorRoleValidToken')
// .mockImplementation((handler) => async (...args) => handler(...args));

// Register routes
WazuhApiRoutes(router);

Expand Down