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

Fixed deploy new agent refactor secure connection conditions #5295

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
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
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