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

Add agent name to the deployment command #4739

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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the Wazuh app project will be documented in this file.

- Added the option to sort by the agents count in the group table. [#4323](https://github.com/wazuh/wazuh-kibana-app/pull/4323)
- Added agent synchronization status in the agent module. [#3874](https://github.com/wazuh/wazuh-kibana-app/pull/3874)
- The input name was added and when the user adds a value the variable WAZUH_AGENT_NAME with its value appears in the installation command. [#4739](https://github.com/wazuh/wazuh-kibana-app/pull/4739)
- Redesign the SCA table from agent's dashboard [#4512](https://github.com/wazuh/wazuh-kibana-app/pull/4512)
- Enhanced the plugin setting description displayed in the UI and the configuration file. [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4501)
- Added validation to the plugin settings in the form of `Settings/Configuration` and the endpoint to update the plugin configuration [#4501](https://github.com/wazuh/wazuh-kibana-app/pull/4503)
Expand Down
105 changes: 64 additions & 41 deletions public/controllers/agent/components/register-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const RegisterAgent = withErrorBoundary(
version: '',
wazuhVersion: '',
serverAddress: '',
agentName: '',
wazuhPassword: '',
groups: [],
selectedGroup: [],
Expand Down Expand Up @@ -188,25 +189,25 @@ export const RegisterAgent = withErrorBoundary(
if (this.state.selectedVersion === 'redhat7' || this.state.selectedVersion === 'amazonlinux2022' || this.state.selectedVersion === 'centos7' || this.state.selectedVersion === 'suse11' || this.state.selectedVersion === 'suse12' || this.state.selectedVersion === 'oraclelinux5' || this.state.selectedVersion === '22' || this.state.selectedVersion === 'amazonlinux2' || this.state.selectedVersion === 'debian8' || this.state.selectedVersion === 'debian9' || this.state.selectedVersion === 'debian10' || this.state.selectedVersion === 'busterorgreater' || this.state.selectedVersion === 'ubuntu15' || this.state.selectedVersion === 'ubuntu16' || this.state.selectedVersion === 'leap15') {
return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent';
} else if (this.state.selectedVersion === 'redhat5' || this.state.selectedVersion === 'redhat6' || this.state.selectedVersion === 'centos5' || this.state.selectedVersion === 'centos6' || this.state.selectedVersion === 'oraclelinux6' || this.state.selectedVersion === 'amazonlinux1' || this.state.selectedVersion === 'debian7' || this.state.selectedVersion === 'ubuntu14') {
return ('service wazuh-agent start')
return ('service wazuh-agent start');
}
}

systemSelectorNet() {
if (this.state.selectedVersion === 'windowsxp' || this.state.selectedVersion === 'windows8') {
return ('update-rc.d wazuh-agent defaults && service wazuh-agent start')
return ('update-rc.d wazuh-agent defaults && service wazuh-agent start');
}
}

systemSelectorWazuhControlMacos() {
if (this.state.selectedVersion == 'sierra' || this.state.selectedVersion == 'highSierra' || this.state.selectedVersion == 'mojave' || this.state.selectedVersion == 'catalina' || this.state.selectedVersion == 'bigSur' || this.state.selectedVersion == 'monterrey') {
return ('/Library/Ossec/bin/wazuh-control start')
return ('/Library/Ossec/bin/wazuh-control start');
}
}

systemSelectorWazuhControl() {
if (this.state.selectedVersion === 'solaris10' || this.state.selectedVersion === 'solaris11' || this.state.selectedVersion === '6.1 TL9' || this.state.selectedVersion === '11.31') {
return ('/var/ossec/bin/wazuh-control start')
return ('/var/ossec/bin/wazuh-control start');
}
}

Expand All @@ -218,6 +219,10 @@ export const RegisterAgent = withErrorBoundary(
this.setState({ serverAddress: event.target.value });
}

setAgentName(event) {
this.setState({ agentName: event.target.value });
}

setGroupName(selectedGroup) {
this.setState({ selectedGroup });
}
Expand Down Expand Up @@ -260,9 +265,7 @@ export const RegisterAgent = withErrorBoundary(
}

optionalDeploymentVariables() {
let deployment = `WAZUH_MANAGER='${this.state.serverAddress}' `;
const protocol = false

let deployment = `WAZUH_MANAGER='${this.state.serverAddress}' `;
if (this.state.selectedOS == 'win') {
deployment += `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' `;
}
Expand All @@ -289,6 +292,16 @@ export const RegisterAgent = withErrorBoundary(
return deployment;
}

agentNameVariable() {
let agentName = `WAZUH_AGENT_NAME='${this.state.agentName}' `;
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved

if(this.state.selectedArchitecture && this.state.agentName !== '') {
return agentName;
} else {
return '';
}
}

resolveRPMPackage() {
switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) {
case 'redhat5-i386':
Expand Down Expand Up @@ -716,35 +729,45 @@ export const RegisterAgent = withErrorBoundary(
</EuiText>
);

const agentName = (
<EuiFieldText
placeholder="Name agent"
value={this.state.agentName}
onChange={(event) => this.setAgentName(event)}
/>
);
const groupInput = (
<>
{!this.state.groups.length && (
<>
<EuiCallOut
<EuiCallOut style={{marginTop: '1.5rem'}}
color="warning"
title='This section could not be configured because you do not have permission to read groups.'
iconType="iInCircle"
/>
<EuiSpacer />
</>
)}
<EuiText>
<p>Select one or more existing groups</p>
<EuiComboBox
placeholder={!this.state.groups.length ? "Default" : "Select group"}
options={this.state.groups}
selectedOptions={this.state.selectedGroup}
onChange={(group) => {
this.setGroupName(group);
}}
isDisabled={!this.state.groups.length}
isClearable={true}
data-test-subj="demoComboBox"
/>
</EuiText>
</>
);



const agentGroup = (
<EuiText style={{marginTop: '1.5rem'}}>
<p>Select one or more existing groups</p>
<EuiComboBox
placeholder={!this.state.groups.length ? "Default" : "Select group"}
options={this.state.groups}
selectedOptions={this.state.selectedGroup}
onChange={(group) => {
this.setGroupName(group);
}}
isDisabled={!this.state.groups.length}
isClearable={true}
data-test-subj="demoComboBox"
/>
</EuiText>
)
const passwordInput = (
<EuiFieldText
placeholder="Wazuh password"
Expand All @@ -757,31 +780,31 @@ export const RegisterAgent = withErrorBoundary(
zIndex: '100',
};
const customTexts = {
Machi3mfl marked this conversation as resolved.
Show resolved Hide resolved
rpmText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
centText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
rpmText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
centText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
debText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
ubuText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
macosText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-${this.state.wazuhVersion
}-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()} && sudo installer -pkg ./wazuh-agent-${this.state.wazuhVersion
}-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()}${this.agentNameVariable()}&& sudo installer -pkg ./wazuh-agent-${this.state.wazuhVersion
}.pkg -target /`,
winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-${this.state.wazuhVersion
}-1.msi -OutFile \${env:tmp}\\wazuh-agent-${this.state.wazuhVersion}.msi; msiexec.exe /i \${env:tmp}\\wazuh-agent-${this.state.wazuhVersion
}.msi /q ${this.optionalDeploymentVariables()}`,
openText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()} zypper install -y ${this.optionalPackages()}`,
solText: `sudo curl -so ${this.optionalPackages()} && ${this.state.selectedVersion == 'solaris11' ? 'pkg install -g wazuh-agent.p5p wazuh-agent' : 'pkgadd -d wazuh-agent.pkg'}`,
aixText: `sudo ${this.optionalDeploymentVariables()} rpm -ivh ${this.optionalPackages()}`,
hpText: `cd / && sudo curl -so ${this.optionalPackages()} && sudo groupadd wazuh && sudo useradd -G wazuh wazuh && sudo tar -xvf wazuh-agent.tar`,
amazonlinuxText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
fedoraText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
oraclelinuxText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
suseText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`,
}.msi /q ${this.optionalDeploymentVariables()}${this.agentNameVariable()}`,
openText: `sudo rpm --import https://packages.wazuh.com/key/GPG-KEY-WAZUH && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()} zypper install -y ${this.optionalPackages()}`,
solText: `sudo curl -so ${this.optionalPackages()} && sudo ${this.agentNameVariable()}&& ${this.state.selectedVersion == 'solaris11' ? 'pkg install -g wazuh-agent.p5p wazuh-agent' : 'pkgadd -d wazuh-agent.pkg'}`,
aixText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}rpm -ivh ${this.optionalPackages()}`,
hpText: `cd / && sudo curl -so ${this.optionalPackages()} && sudo ${this.agentNameVariable()}groupadd wazuh && sudo useradd -G wazuh wazuh && sudo tar -xvf wazuh-agent.tar`,
amazonlinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
fedoraText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
oraclelinuxText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
suseText: `sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}yum install -y ${this.optionalPackages()}`,
raspbianText: `curl -so wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}${this.agentNameVariable()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion
}.deb`,
};

Expand Down Expand Up @@ -1327,8 +1350,8 @@ export const RegisterAgent = withErrorBoundary(
]
: []),
{
title: 'Assign the agent to a group',
children: <Fragment>{groupInput}</Fragment>,
title: 'Assign a name and a group to the agent',
children: <Fragment>{agentName}{groupInput}{agentGroup}</Fragment>,
},
{
title: 'Install and enroll the agent',
Expand Down Expand Up @@ -1468,4 +1491,4 @@ export const RegisterAgent = withErrorBoundary(
);
}
}
);
);