From adec4da304c413e0e76a33d5bded1e03932dd50d Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Tue, 14 Mar 2023 12:41:52 -0300 Subject: [PATCH 1/5] Fixed default connection secure param when request fail --- .../components/register-agent-service.ts | 81 ++++++++++--------- 1 file changed, 43 insertions(+), 38 deletions(-) diff --git a/public/controllers/agent/components/register-agent-service.ts b/public/controllers/agent/components/register-agent-service.ts index c7ed1235fd..bf453797b7 100644 --- a/public/controllers/agent/components/register-agent-service.ts +++ b/public/controllers/agent/components/register-agent-service.ts @@ -40,47 +40,52 @@ export const clusterStatusResponse = async (): Promise => { async function getRemoteConfiguration(nodeName: string): Promise { let config: RemoteConfig = { name: nodeName, - isUdp: null, - haveSecureConnection: null, + isUdp: false, + haveSecureConnection: false, }; - const clusterStatus = await clusterStatusResponse(); - let result; - if (clusterStatus) { - result = await WzRequest.apiReq( - 'GET', - `/cluster/${nodeName}/configuration/request/remote`, - {}, - ); - } else { - result = await WzRequest.apiReq( - 'GET', - '/manager/configuration/request/remote', - {}, - ); - } - const items = ((result.data || {}).data || {}).affected_items || []; - const remote = items[0]?.remote; - if (remote) { - const remoteFiltered = remote.filter((item: RemoteItem) => { - return item.connection === 'secure'; - }); - - remoteFiltered.length > 0 - ? (config.haveSecureConnection = true) - : (config.haveSecureConnection = false); - - let protocolsAvailable: Protocol[] = []; - remote.forEach((item: RemoteItem) => { - // get all protocols available - item.protocol.forEach(protocol => { - protocolsAvailable = protocolsAvailable.concat(protocol); + + try { + const clusterStatus = await clusterStatusResponse(); + let result; + if (clusterStatus) { + result = await WzRequest.apiReq( + 'GET', + `/cluster/${nodeName}/configuration/request/remote`, + {}, + ); + } else { + result = await WzRequest.apiReq( + 'GET', + '/manager/configuration/request/remote', + {}, + ); + } + const items = ((result.data || {}).data || {}).affected_items || []; + const remote = items[0]?.remote; + if (remote) { + const remoteFiltered = remote.filter((item: RemoteItem) => { + return item.connection === 'secure'; }); - }); - - config.isUdp = - getRemoteProtocol(protocolsAvailable) === 'UDP' ? true : false; + + remoteFiltered.length > 0 + ? (config.haveSecureConnection = true) + : (config.haveSecureConnection = false); + + let protocolsAvailable: Protocol[] = []; + remote.forEach((item: RemoteItem) => { + // get all protocols available + item.protocol.forEach(protocol => { + protocolsAvailable = protocolsAvailable.concat(protocol); + }); + }); + + config.isUdp = + getRemoteProtocol(protocolsAvailable) === 'UDP' ? true : false; + } + return config; + }catch(error){ + return config; } - return config; } /** From 12a175b7008b62203dd1df73eeefc62679f7ad2f Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Tue, 14 Mar 2023 12:42:56 -0300 Subject: [PATCH 2/5] Removed unnecessary condtions in code with duplicated code --- .../agent/components/register-agent.js | 182 +++--------------- 1 file changed, 29 insertions(+), 153 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 9b82b3bfa1..ee7e389e63 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -1089,9 +1089,7 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`, title='This section could not be displayed because you do not have permission to get access to the registration service.' iconType='iInCircle' /> - ) : this.state.selectedOS && - this.state.connectionSecure === true && - this.state.udpProtocol === false ? ( + ) : this.state.selectedOS && ( {this.state.agentName.length > 0 ? (

@@ -1109,19 +1107,39 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`, title={warningUpgrade} iconType='iInCircle' /> - - {windowsAdvice} - {this.state.selectedVersion === 'windowsxp' && ( + + {!this.state.connectionSecure && ( <> + + {/** Warning connection NO SECURE */} + Warning: there's no{' '} + + secure protocol configured + {' '} + and agents will not be able to communicate with the + manager. + + } iconType='iInCircle' /> - + {/** END Warning connection NO SECURE */} )} - {this.state.selectedVersion === 'windowsserver2008' && ( + + {windowsAdvice} + {['windowsxp', 'windowsserver2008'].includes( + this.state.selectedVersion, + ) === 'windowsxp' && ( <> - + {copy => (

@@ -1333,148 +1351,6 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`, )} - ) : this.state.selectedOS && this.state.connectionSecure === false ? ( - -

- You can use this command to install and enroll the Wazuh agent - in one or more hosts. -

- - - - Warning: there's no{' '} - - secure protocol configured - {' '} - and agents will not be able to communicate with the manager. - - } - iconType='iInCircle' - /> - - {windowsAdvice} - {this.state.selectedVersion === 'windowsxp' && ( - <> - - - - )} - {this.state.selectedVersion === 'windowsserver2008' && ( - <> - - - - )} -
- - {this.state.wazuhPassword && - !this.state.showPassword && - !['sol', 'hp', 'alpine'].includes(this.state.selectedOS) - ? this.obfuscatePassword(text) - : text} - - - {copy => ( -
-

- Copy command -

-
- )} -
-
- {this.state.needsPassword && ( - this.setShowPassword(active)} - /> - )} - - - ) : ( - this.state.selectedOS && ( - -

- You can use this command to install and enroll the Wazuh agent - in one or more hosts. -

- - - {windowsAdvice} - {this.state.selectedVersion === 'windowsxp' && ( - <> - - - - )} - {this.state.selectedVersion === 'windowsserver2008' && ( - <> - - - - )} -
- - {this.state.wazuhPassword && - !this.state.showPassword && - !['sol', 'hp', 'alpine'].includes(this.state.selectedOS) - ? this.obfuscatePassword(text) - : text} - - - {copy => ( -
-

- Copy command -

-
- )} -
-
- {this.state.needsPassword && ( - this.setShowPassword(active)} - /> - )} - -
- ) )}
); From 57cd418530eb313f7635c11fd8e46428d7bb80f7 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Tue, 14 Mar 2023 13:47:46 -0300 Subject: [PATCH 3/5] Fixed warning message in windows xp and 2008 --- public/controllers/agent/components/register-agent.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index ee7e389e63..fa4b364377 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -1138,8 +1138,7 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`, {windowsAdvice} {['windowsxp', 'windowsserver2008'].includes( - this.state.selectedVersion, - ) === 'windowsxp' && ( + this.state.selectedVersion) && ( <> Date: Tue, 14 Mar 2023 14:19:03 -0300 Subject: [PATCH 4/5] Fixed style in enrollment message --- public/controllers/agent/components/register-agent.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index fa4b364377..b468542294 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -1199,8 +1199,8 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`, After installing the agent, you need to enroll it in the Wazuh server. Check the Wazuh agent enrollment{' '} - Wazuh agent enrollment{' '} - + Wazuh agent enrollment + {' '} section to learn more. } From 12274eb4c8d2810c75669a1b35c68baa59adeeb2 Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Tue, 14 Mar 2023 15:04:41 -0300 Subject: [PATCH 5/5] Updated CHANGELOG --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0243ebfdd4..1ef8b87c85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -86,10 +86,9 @@ All notable changes to the Wazuh app project will be documented in this file. - Fixed the module information button in Office365 and Github Panel tab to open the nav drawer. [#5167](https://github.com/wazuh/wazuh-kibana-app/pull/5167) - Fixed a UI crash due to `external_references` field could be missing in some vulnerability data [#5200](https://github.com/wazuh/wazuh-kibana-app/pull/5200) - Fixed Wazuh main menu not displayed when navigation menu is locked [#5273](https://github.com/wazuh/wazuh-kibana-app/pull/5273) -- Fixed Deploy Agent wrong use of connection secure property [#5285](https://github.com/wazuh/wazuh-kibana-app/pull/5285) +- Fixed Deploy Agent wrong use of connection secure property [#5285](https://github.com/wazuh/wazuh-kibana-app/pull/5285) [#5295](https://github.com/wazuh/wazuh-kibana-app/pull/5295) - Fixed events view when search bar language is `lucene` [#5286](https://github.com/wazuh/wazuh-kibana-app/pull/5286) - Fixed head rendering in agent view [#5291](https://github.com/wazuh/wazuh-kibana-app/pull/5291) - ### Removed - Removed custom styles from kibana 7.9.0 [#4491](https://github.com/wazuh/wazuh-kibana-app/pull/4491)