Skip to content

Commit

Permalink
Fixed WAZUH_PROTOCOL param suggestion (#4849)
Browse files Browse the repository at this point in the history
* Fixed protocol param suggestion

* Updated CHANGELOG

(cherry picked from commit ee0b618)
  • Loading branch information
Machi3mfl committed Nov 11, 2022
1 parent 6fb45d5 commit af3bda9
Show file tree
Hide file tree
Showing 3 changed files with 421 additions and 10 deletions.
12 changes: 2 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,26 @@ All notable changes to the Wazuh app project will be documented in this file.
### Changed

- Changed the HTTP verb from `GET` to `POST` in the requests to login to the Wazuh API [#4103](https://github.com/wazuh/wazuh-kibana-app/pull/4103)
- Improve alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376)
- Endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- Updated and added operating systems, versions, architectures commands of Install and enroll the agent and
commands of Start the agent in the deploy new agent section [#4458](https://github.com/wazuh/wazuh-kibana-app/pull/4458)
- Makes Agents Overview loading icons independent [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)

### Fixed

- Improves Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Improved Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Improved alerts summary performance [#4376](https://github.com/wazuh/wazuh-kibana-app/pull/4376)
- The endpoint `/agents/summary/status` response was adapted. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- Made Agents Overview icons load independently [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- Improved the message displayed when there is a versions mismatch between the Wazuh API and the Wazuh APP [#4529](https://github.com/wazuh/wazuh-kibana-app/pull/4529)
- Changed the endpoint that updates the plugin configuration to support multiple settings. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501)
- Allowed to upload an image for the `customization.logo.*` settings in `Settings/Configuration` [#4504](https://github.com/wazuh/wazuh-kibana-app/pull/4504)
- Fixed the agents wizard OS styles and their versions. [#4832](https://github.com/wazuh/wazuh-kibana-app/pull/4832) [#4838](https://github.com/wazuh/wazuh-kibana-app/pull/4838/files)
- Fixed WAZUH_PROTOCOL param suggestion [#4849](https://github.com/wazuh/wazuh-kibana-app/pull/4849)

### Fixed

- Fixed nested fields filtering in dashboards tables and KPIs [#4425](https://github.com/wazuh/wazuh-kibana-app/pull/4425)
- Fixed nested field rendering in security alerts table details [#4428](https://github.com/wazuh/wazuh-kibana-app/pull/4428)
- Improved Agents Overview performance [#4363](https://github.com/wazuh/wazuh-kibana-app/pull/4363)
- 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) [#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
272 changes: 272 additions & 0 deletions public/controllers/agent/components/register-agent-service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,272 @@
import * as RegisterAgentService from './register-agent-service';
import { WzRequest } from '../../../react-services/wz-request';
import { ServerAddressOptions } from '../register-agent/steps';

jest.mock('../../../react-services', () => ({
...jest.requireActual('../../../react-services') as object,
WzRequest: () => ({
apiReq: jest.fn(),
}),
}));


describe('Register agent service', () => {
beforeEach(() => jest.clearAllMocks());
describe('getRemoteConfiguration', () => {
it('should return secure connection = TRUE when have connection secure', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.haveSecureConnection).toBe(true);
});

it('should return secure connection = FALSE available when dont have connection secure', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP', 'TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.haveSecureConnection).toBe(false);
});

it('should return protocols UDP when is the only connection protocol available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(true);
});

it('should return protocols TCP when is the only connection protocol available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['TCP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(false);
});

it('should return is not UDP when have UDP and TCP protocols available', async () => {
const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['TCP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);
const nodeName = 'example-node';
const res = await RegisterAgentService.getRemoteConfiguration('example-node');
expect(res.name).toBe(nodeName);
expect(res.isUdp).toEqual(false);
});
});

describe('getConnectionConfig', () => {

beforeAll(() => {
jest.clearAllMocks();
})

it('should return IS NOT UDP when the server address is typed manually (custom)', async () => {
const nodeSelected: ServerAddressOptions = {
label: 'node-selected',
value: 'node-selected',
nodetype: 'master'
};

const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);

const config = await RegisterAgentService.getConnectionConfig(nodeSelected, 'default-dns-address');
expect(config.udpProtocol).toEqual(false);
expect(config.serverAddress).toBe('default-dns-address');
})

it('should return IS NOT UDP when the server address is received like default server address dns (custom)', async () => {
const nodeSelected: ServerAddressOptions = {
label: 'node-selected',
value: 'node-selected',
nodetype: 'master'
};

const remoteWithSecureAndNoSecure = [
{
connection: 'syslog',
ipv6: 'no',
protocol: ['UDP'],
port: '514',
'allowed-ips': ['0.0.0.0/0'],
},
{
connection: 'secure',
ipv6: 'no',
protocol: ['UDP'],
port: '1514',
queue_size: '131072',
},
];
const mockedResponse = {
data: {
data: {
affected_items: [
{
remote: remoteWithSecureAndNoSecure,
},
],
},
},
};
WzRequest.apiReq = jest.fn().mockResolvedValueOnce(mockedResponse);

const config = await RegisterAgentService.getConnectionConfig(nodeSelected, 'custom-server-address');
expect(config.udpProtocol).toEqual(false);
})
})
});
Loading

0 comments on commit af3bda9

Please sign in to comment.