Skip to content

Commit

Permalink
Fixed deploy new agent refactor secure connection conditions (#5295)
Browse files Browse the repository at this point in the history
* Fixed default connection secure param when request fail

* Removed unnecessary condtions in code with duplicated code

* Fixed warning message in windows xp and 2008

* Fixed style in enrollment message

* Updated CHANGELOG

(cherry picked from commit 2e5cb9b)
  • Loading branch information
Machi3mfl authored and github-actions[bot] committed Mar 14, 2023
1 parent 82810de commit f59852f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 195 deletions.
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed the style of the buttons showing more event information in the event view table. [#5137](https://github.com/wazuh/wazuh-kibana-app/pull/5137)
- 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 the `angular-chart.js` dependency [#5014](https://github.com/wazuh/wazuh-kibana-app/pull/5014)
Expand Down
81 changes: 43 additions & 38 deletions public/controllers/agent/components/register-agent-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,47 +40,52 @@ export const clusterStatusResponse = async (): Promise<boolean> => {
async function getRemoteConfiguration(nodeName: string): Promise<RemoteConfig> {
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;
}

/**
Expand Down
185 changes: 30 additions & 155 deletions public/controllers/agent/components/register-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
<EuiText>
{this.state.agentName.length > 0 ? (
<p>
Expand All @@ -1109,19 +1107,38 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
title={warningUpgrade}
iconType='iInCircle'
/>
<EuiSpacer />
{windowsAdvice}
{this.state.selectedVersion === 'windowsxp' && (

{!this.state.connectionSecure && (
<>
<EuiSpacer />
{/** Warning connection NO SECURE */}
<EuiCallOut
color='warning'
title={warningCommand}
color='danger'
title={
<>
Warning: there's no{' '}
<EuiLink
target='_blank'
href={webDocumentationLink(
'user-manual/deployment-variables/deployment-variables.html',
appVersionMajorDotMinor,
)}
>
secure protocol configured
</EuiLink>{' '}
and agents will not be able to communicate with the
manager.
</>
}
iconType='iInCircle'
/>
<EuiSpacer />
{/** END Warning connection NO SECURE */}
</>
)}
{this.state.selectedVersion === 'windowsserver2008' && (
<EuiSpacer />
{windowsAdvice}
{['windowsxp', 'windowsserver2008'].includes(
this.state.selectedVersion) && (
<>
<EuiCallOut
color='warning'
Expand All @@ -1139,7 +1156,7 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
? this.obfuscatePassword(text)
: text}
</EuiCodeBlock>
<EuiCopy textToCopy={text}>
<EuiCopy textToCopy={text || ''}>
{copy => (
<div className='copy-overlay' onClick={copy}>
<p>
Expand Down Expand Up @@ -1182,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{' '}
<EuiLink target='_blank' href={urlWazuhAgentEnrollment}>
Wazuh agent enrollment{' '}
</EuiLink>
Wazuh agent enrollment
</EuiLink>{' '}
section to learn more.
</span>
}
Expand Down Expand Up @@ -1333,148 +1350,6 @@ apk add wazuh-agent=${this.state.wazuhVersion}-r1`,
)}
<EuiSpacer />
</EuiText>
) : this.state.selectedOS && this.state.connectionSecure === false ? (
<EuiText>
<p>
You can use this command to install and enroll the Wazuh agent
in one or more hosts.
</p>
<EuiCallOut
color='warning'
title={warningUpgrade}
iconType='iInCircle'
/>
<EuiSpacer />
<EuiCallOut
color='danger'
title={
<>
Warning: there's no{' '}
<EuiLink
target='_blank'
href={webDocumentationLink(
'user-manual/deployment-variables/deployment-variables.html',
appVersionMajorDotMinor,
)}
>
secure protocol configured
</EuiLink>{' '}
and agents will not be able to communicate with the manager.
</>
}
iconType='iInCircle'
/>
<EuiSpacer />
{windowsAdvice}
{this.state.selectedVersion === 'windowsxp' && (
<>
<EuiCallOut
color='warning'
title={warningCommand}
iconType='iInCircle'
/>
<EuiSpacer />
</>
)}
{this.state.selectedVersion === 'windowsserver2008' && (
<>
<EuiCallOut
color='warning'
title={warningCommand}
iconType='iInCircle'
/>
<EuiSpacer />
</>
)}
<div className='copy-codeblock-wrapper'>
<EuiCodeBlock style={codeBlock} language={language}>
{this.state.wazuhPassword &&
!this.state.showPassword &&
!['sol', 'hp', 'alpine'].includes(this.state.selectedOS)
? this.obfuscatePassword(text)
: text}
</EuiCodeBlock>
<EuiCopy textToCopy={text || ''}>
{copy => (
<div className='copy-overlay' onClick={copy}>
<p>
<EuiIcon type='copy' /> Copy command
</p>
</div>
)}
</EuiCopy>
</div>
{this.state.needsPassword && (
<EuiSwitch
label='Show password'
checked={this.state.showPassword}
onChange={active => this.setShowPassword(active)}
/>
)}
<EuiSpacer />
</EuiText>
) : (
this.state.selectedOS && (
<EuiText>
<p>
You can use this command to install and enroll the Wazuh agent
in one or more hosts.
</p>
<EuiCallOut
color='warning'
title={warningUpgrade}
iconType='iInCircle'
/>
<EuiSpacer />
{windowsAdvice}
{this.state.selectedVersion === 'windowsxp' && (
<>
<EuiCallOut
color='warning'
title={warningCommand}
iconType='iInCircle'
/>
<EuiSpacer />
</>
)}
{this.state.selectedVersion === 'windowsserver2008' && (
<>
<EuiCallOut
color='warning'
title={warningCommand}
iconType='iInCircle'
/>
<EuiSpacer />
</>
)}
<div className='copy-codeblock-wrapper'>
<EuiCodeBlock style={codeBlock} language={language}>
{this.state.wazuhPassword &&
!this.state.showPassword &&
!['sol', 'hp', 'alpine'].includes(this.state.selectedOS)
? this.obfuscatePassword(text)
: text}
</EuiCodeBlock>
<EuiCopy textToCopy={text || ''}>
{copy => (
<div className='copy-overlay' onClick={copy}>
<p>
<EuiIcon type='copy' /> Copy command
</p>
</div>
)}
</EuiCopy>
</div>
{this.state.needsPassword && (
<EuiSwitch
label='Show password'
checked={this.state.showPassword}
onChange={active => this.setShowPassword(active)}
/>
)}
<EuiSpacer />
</EuiText>
)
)}
</div>
);
Expand Down

0 comments on commit f59852f

Please sign in to comment.