From 69fd41ba08a4ced960d441ecf0d7fdbb774f002f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Fri, 4 Dec 2020 17:08:17 +0100 Subject: [PATCH 1/8] Modified agent registration adding groups and arch --- .../agent/components/register-agent.js | 240 +++++++++++++----- 1 file changed, 179 insertions(+), 61 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 3900a15c01..4f32d1c521 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -18,6 +18,9 @@ import { EuiFlexItem, EuiPanel, EuiButtonToggle, + EuiButtonGroup, + EuiFormRow, + EuiComboBox, EuiFieldText, EuiText, EuiCodeBlock, @@ -34,6 +37,42 @@ import { } from '@elastic/eui'; import { WzRequest } from '../../../react-services/wz-request'; + +const architectureBottons = [ + { + id: 'x86', + label: 'x86' + }, + { + id: 'x64', + label: 'x64' + }, + { + id: 'arm', + label: 'arm' + } +]; +const architectureCentos5 = [ + { + id: 'x86', + label: 'x86' + }, + { + id: 'x64', + label: 'x64' + } +]; + +const versionBottonsCentos = [ + { + id: 'centos5', + label: 'CentOS5' + }, + { + id: 'centos6', + label: 'CentOS6 o superior' + } +]; export class RegisterAgent extends Component { constructor(props) { super(props); @@ -42,8 +81,13 @@ export class RegisterAgent extends Component { this.state = { status: 'incomplete', selectedOS: '', + selectedArchitecture: '', + selectedVersion: '', + version: '', serverAddress: '', wazuhPassword: '', + groups: [], + selectedGroup: [], udpProtocol: false }; this.restartAgentCommand = { @@ -72,14 +116,21 @@ export class RegisterAgent extends Component { hidePasswordInput = true; } } + + const udpProtocol = await this.getRemoteInfo(); + const groups = await this.getGroups(); this.setState({ serverAddress, needsPassword, hidePasswordInput, + versionBottonsCentos, + architectureBottons, + architectureCentos5, wazuhPassword, udpProtocol, wazuhVersion, + groups, loading: false }); } catch (error) { @@ -125,18 +176,21 @@ export class RegisterAgent extends Component { this.setState({ serverAddress: event.target.value }); } - setWazuhPassword(event) { - this.setState({ wazuhPassword: event.target.value }); + setGroupName(selectedGroup) { + this.setState({ selectedGroup }); + } + + setArchitecture(selectedArchitecture) { + this.setState({ selectedArchitecture }); + } + + setVersion(selectedVersion) { + console.log("VERSION", selectedVersion) + this.setState({ selectedVersion }); } - /** - * Checks if the password is not needed, in that case remove the input password step - * @param {Array} steps - */ - cleanSteps(steps) { - if (!this.state.needsPassword || this.state.hidePasswordInput) - steps.splice(2, 1); - return steps; + setWazuhPassword(event) { + this.setState({ wazuhPassword: event.target.value }); } obfuscatePassword(text) { @@ -151,6 +205,63 @@ export class RegisterAgent extends Component { return text; } + async getGroups() { + try { + const result = await WzRequest.apiReq( + 'GET', + '/groups', + {} + ); + return result.data.data.affected_items.map(item => + ({ label: item.name, id: item.name }) + ) + } catch (error) { + return []; + } + } + + optionalDeploymentVariables() { + let deployment = `WAZUH_MANAGER='${this.state.serverAddress}' ${this.state.selectedOS == 'win' ? `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' ` : ''}${this.state.needsPassword + ? ` WAZUH_REGISTRATION_PASSWORD='${this.state.wazuhPassword}'` + : '' + }${this.state.udpProtocol + ? " WAZUH_PROTOCOL='UDP'" + : '' + }${this.state.selectedGroup.length ? `WAZUH_AGENT_GROUP='${this.state.selectedGroup.map(item => item.label).join(',')}' ` : ''}` + return deployment; + } + + optionalPackets() { + + let ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + if ((this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x86')) { + ret = `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm` + return ret; + } else if (this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x64') { + ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.el5.x86_64.rpm` + return ret; + } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x86') { + ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm` + return ret; + } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x64') { + ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm` + return ret; + } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'arm') { + ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7h.rpm` + return ret; + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x86') { + ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_i386.deb` + return ret; + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x64') { + ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_arm64.deb` + return ret; + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'arm') { + ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb` + return ret; + } + return ret; + } + render() { const rpmButton = ( ); + const groupInput = ( + +

+ You can predefine the group where you want to enroll the agent. +

+ { + this.setGroupName(group); + }} + isClearable={true} + data-test-subj="demoComboBox" + /> +
+ ); + const passwordInput = ( ); - + console.log("VERSIONAFADF", this.state.selectedVersion) const steps = [ { title: 'Choose OS', @@ -306,13 +393,44 @@ export class RegisterAgent extends Component { ) }, + ...((this.state.selectedOS == 'rpm') ? [{ + title: 'Choose your CentOS version', + children: this.setVersion(version)} + /> + }] : []), + ...((this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5') ? [{ + title: 'Choose your architecture', + children: this.setArchitecture(architecture)} + /> + }] : []), + ...((this.state.selectedOS == 'deb' || (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6')) ? [{ + title: 'Choose your architecture', + children: this.setArchitecture(architecture)} + /> + }] : []), { title: 'Wazuh server address', children: {ipInput} }, - { + ...(!(!this.state.needsPassword || this.state.hidePasswordInput) ? [{ title: 'Wazuh password', children: {passwordInput} + }] : []), + { + title: 'Assign the agent to a group', + children: {groupInput} }, { title: 'Install and enroll the agent', @@ -393,7 +511,7 @@ export class RegisterAgent extends Component { )} {!this.state.loading && ( - + )} From 3b9f1d1c3d72749500574188a2d4f2a81718ffbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Fri, 4 Dec 2020 17:20:30 +0100 Subject: [PATCH 2/8] CHANGELOG modified --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 383e542a3b..c1a75c7757 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,10 @@ All notable changes to the Wazuh app project will be documented in this file. - Create index pattern even if there arenĀ“t available indices [#2620](https://github.com/wazuh/wazuh-kibana-app/issues/2620) - Top bar overlayed over expanded visualizations [#2667](https://github.com/wazuh/wazuh-kibana-app/issues/2667) +### Added + +- Modified agent registration adding groups and architecture [#2666](https://github.com/wazuh/wazuh-kibana-app/issues/2666)[#2652](https://github.com/wazuh/wazuh-kibana-app/issues/2652) + ## Wazuh v4.0.3 - Kibana v7.9.1, v7.9.2, v7.9.3 - Revision 4014 ### Added From 4b42f5b20db45185ccdd4c676dcb31c4232f93b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Wed, 9 Dec 2020 12:23:32 +0100 Subject: [PATCH 3/8] Added architectures and fixed errors --- .../agent/components/register-agent.js | 54 +++++++++++-------- 1 file changed, 31 insertions(+), 23 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 4f32d1c521..90c4d6104f 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -40,26 +40,30 @@ import { WzRequest } from '../../../react-services/wz-request'; const architectureBottons = [ { - id: 'x86', - label: 'x86' + id: 'i386', + label: 'i386' }, { - id: 'x64', - label: 'x64' + id: 'x86_64', + label: 'x86_64' }, { - id: 'arm', - label: 'arm' + id: 'armhf', + label: 'armhf' + }, + { + id: 'aarch64', + label: 'aarch64' } ]; const architectureCentos5 = [ { - id: 'x86', - label: 'x86' + id: 'x86_64', + label: 'x86_64' }, { - id: 'x64', - label: 'x64' + id: 'i386', + label: 'i386' } ]; @@ -169,7 +173,7 @@ export class RegisterAgent extends Component { } selectOS(os) { - this.setState({ selectedOS: os }); + this.setState({ selectedOS: os, selectedVersion: '', selectedArchitecture: '' }); } setServerAddress(event) { @@ -185,7 +189,6 @@ export class RegisterAgent extends Component { } setVersion(selectedVersion) { - console.log("VERSION", selectedVersion) this.setState({ selectedVersion }); } @@ -232,32 +235,38 @@ export class RegisterAgent extends Component { } optionalPackets() { + let ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`;; - let ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - if ((this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x86')) { + if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'i386') { ret = `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm` return ret; - } else if (this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x64') { + } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x86_64') { ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.el5.x86_64.rpm` return ret; - } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x86') { + } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'i386') { ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm` return ret; - } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x64') { + } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'aarch64') { ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm` return ret; - } else if (this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'arm') { + } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x86_64') { + ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm` + return ret; + } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'armhf') { ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7h.rpm` return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x86') { + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'i386') { ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_i386.deb` return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x64') { + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'aarch64') { ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_arm64.deb` return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'arm') { + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'armhf') { ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb` return ret; + } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x86_64') { + ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb` + return ret; } return ret; } @@ -341,7 +350,7 @@ export class RegisterAgent extends Component { rpmText: `sudo ${this.optionalDeploymentVariables()}yum install ${this.optionalPackets()}`, debText: `curl -so wazuh-agent.deb ${this.optionalPackets()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent.deb`, macosText: `curl -so wazuh-agent.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.pkg -target /`, + }-1.pkg && sudo launchctl setenv ${this.optionalDeploymentVariables()}sudo installer -pkg ./wazuh-agent.pkg -target /`, winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-${this.state.wazuhVersion }-1.msi -OutFile wazuh-agent.msi; ./wazuh-agent.msi /q ${this.optionalDeploymentVariables()}` }; @@ -383,7 +392,6 @@ export class RegisterAgent extends Component { )} ); - console.log("VERSIONAFADF", this.state.selectedVersion) const steps = [ { title: 'Choose OS', From bcdd3a4469834f8730e99500cd1385a878c45f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Wed, 9 Dec 2020 14:11:02 +0100 Subject: [PATCH 4/8] Requested changes --- .../agent/components/register-agent.js | 84 ++++++++++--------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 90c4d6104f..e856cd71a8 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -57,13 +57,13 @@ const architectureBottons = [ } ]; const architectureCentos5 = [ - { - id: 'x86_64', - label: 'x86_64' - }, { id: 'i386', label: 'i386' + }, + { + id: 'x86_64', + label: 'x86_64' } ]; @@ -224,7 +224,7 @@ export class RegisterAgent extends Component { } optionalDeploymentVariables() { - let deployment = `WAZUH_MANAGER='${this.state.serverAddress}' ${this.state.selectedOS == 'win' ? `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' ` : ''}${this.state.needsPassword + const deployment = `WAZUH_MANAGER='${this.state.serverAddress}' ${this.state.selectedOS == 'win' ? `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' ` : ''}${this.state.needsPassword ? ` WAZUH_REGISTRATION_PASSWORD='${this.state.wazuhPassword}'` : '' }${this.state.udpProtocol @@ -234,41 +234,45 @@ export class RegisterAgent extends Component { return deployment; } - optionalPackets() { - let ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`;; + resolveRPMPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'centos5-i386': + return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm` + case 'centos5-x86_64': + return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.el5.x86_64.rpm` + case 'centos6-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm` + case 'centos6-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm` + case 'centos6-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm` + case 'centos6-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7h.rpm` + } + } + + resolveDEBPackage() { + switch (`${this.state.selectedArchitecture}`) { + case 'i386': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_i386.deb` + case 'aarch64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_arm64.deb` + case 'armhf': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb` + case 'x86_64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb` + } + } - if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'i386') { - ret = `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm` - return ret; - } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' && this.state.selectedArchitecture == 'x86_64') { - ret = `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.el5.x86_64.rpm` - return ret; - } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'i386') { - ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm` - return ret; - } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'aarch64') { - ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm` - return ret; - } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'x86_64') { - ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm` - return ret; - } else if (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' && this.state.selectedArchitecture == 'armhf') { - ret = `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7h.rpm` - return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'i386') { - ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_i386.deb` - return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'aarch64') { - ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_arm64.deb` - return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'armhf') { - ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb` - return ret; - } else if (this.state.selectedOS == 'deb' && this.state.selectedArchitecture == 'x86_64') { - ret = `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb` - return ret; + optionalPackages() { + switch (this.state.selectedOS) { + case 'rpm': + return this.resolveRPMPackage(); + case 'deb': + return this.resolveDEBPackage(); + default: + return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; } - return ret; } render() { @@ -347,8 +351,8 @@ export class RegisterAgent extends Component { zIndex: '100' }; const customTexts = { - rpmText: `sudo ${this.optionalDeploymentVariables()}yum install ${this.optionalPackets()}`, - debText: `curl -so wazuh-agent.deb ${this.optionalPackets()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent.deb`, + rpmText: `sudo ${this.optionalDeploymentVariables()}yum install ${this.optionalPackages()}`, + debText: `curl -so wazuh-agent.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent.deb`, macosText: `curl -so wazuh-agent.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.pkg -target /`, winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/4.x/windows/wazuh-agent-${this.state.wazuhVersion From 02c3c6de661a9552114c8d0086bc6b9c80fea38c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Thu, 10 Dec 2020 09:05:55 +0100 Subject: [PATCH 5/8] Typerror fixed and added default architectures --- public/controllers/agent/components/register-agent.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index e856cd71a8..c8c458f27f 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -74,7 +74,7 @@ const versionBottonsCentos = [ }, { id: 'centos6', - label: 'CentOS6 o superior' + label: 'CentOS6 or higher' } ]; export class RegisterAgent extends Component { @@ -248,6 +248,8 @@ export class RegisterAgent extends Component { return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm` case 'centos6-armhf': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7h.rpm` + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm` } } @@ -261,6 +263,8 @@ export class RegisterAgent extends Component { return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb` case 'x86_64': return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb` + default: + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb` } } From b43a27bb616fd7c10f7df6518305339e8258f5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Mart=C3=ADnez?= Date: Thu, 10 Dec 2020 14:18:19 +0100 Subject: [PATCH 6/8] Errors fixed --- .../agent/components/register-agent.js | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index c8c458f27f..7904a9d288 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -38,7 +38,7 @@ import { import { WzRequest } from '../../../react-services/wz-request'; -const architectureBottons = [ +const architectureButtons = [ { id: 'i386', label: 'i386' @@ -67,7 +67,7 @@ const architectureCentos5 = [ } ]; -const versionBottonsCentos = [ +const versionButtonsCentos = [ { id: 'centos5', label: 'CentOS5' @@ -128,8 +128,8 @@ export class RegisterAgent extends Component { serverAddress, needsPassword, hidePasswordInput, - versionBottonsCentos, - architectureBottons, + versionButtonsCentos, + architectureButtons, architectureCentos5, wazuhPassword, udpProtocol, @@ -189,7 +189,7 @@ export class RegisterAgent extends Component { } setVersion(selectedVersion) { - this.setState({ selectedVersion }); + this.setState({ selectedVersion, selectedArchitecture: '' }); } setWazuhPassword(event) { @@ -225,7 +225,7 @@ export class RegisterAgent extends Component { optionalDeploymentVariables() { const deployment = `WAZUH_MANAGER='${this.state.serverAddress}' ${this.state.selectedOS == 'win' ? `WAZUH_REGISTRATION_SERVER='${this.state.serverAddress}' ` : ''}${this.state.needsPassword - ? ` WAZUH_REGISTRATION_PASSWORD='${this.state.wazuhPassword}'` + ? `WAZUH_REGISTRATION_PASSWORD='${this.state.wazuhPassword}' ` : '' }${this.state.udpProtocol ? " WAZUH_PROTOCOL='UDP'" @@ -413,7 +413,7 @@ export class RegisterAgent extends Component { title: 'Choose your CentOS version', children: this.setVersion(version)} /> @@ -431,7 +431,7 @@ export class RegisterAgent extends Component { title: 'Choose your architecture', children: this.setArchitecture(architecture)} /> @@ -448,7 +448,7 @@ export class RegisterAgent extends Component { title: 'Assign the agent to a group', children: {groupInput} }, - { + ...((this.state.selectedArchitecture || this.state.selectedOS == 'win' || this.state.selectedOS == 'macos') ? [{ title: 'Install and enroll the agent', children: (
@@ -457,7 +457,7 @@ export class RegisterAgent extends Component {
) - }, + }] : []), ...(this.state.selectedOS && restartAgentCommand ? [ { title: 'Start the agent', From 84830580e19d1de0645efc9db41ff1ea2fa54c21 Mon Sep 17 00:00:00 2001 From: Desvelao Date: Fri, 18 Dec 2020 17:10:51 +0100 Subject: [PATCH 7/8] feat(): Add message to show information about OS options are missing: - Replaced OS buttons by button group - Show a message with OS, OS version or OS architecture are missing. Hide the command to install the agent when some of these options are missing. - The start agent step is showing when OS options are all selected --- .../agent/components/register-agent.js | 132 ++++++++++-------- 1 file changed, 71 insertions(+), 61 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 7904a9d288..7580e7ccb9 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -77,6 +77,26 @@ const versionButtonsCentos = [ label: 'CentOS6 or higher' } ]; + +const osButtons = [ + { + id: 'rpm', + label: 'Red Hat / CentOS' + }, + { + id: 'deb', + label: 'Debian / Ubuntu' + }, + { + id: 'win', + label: 'Windows' + }, + { + id: 'macos', + label: 'MacOS' + } +]; + export class RegisterAgent extends Component { constructor(props) { super(props); @@ -279,46 +299,34 @@ export class RegisterAgent extends Component { } } - render() { - const rpmButton = ( - this.selectOS('rpm')} - fill={this.state.selectedOS === 'rpm'} - /> - ); - - const debButton = ( - this.selectOS('deb')} - fill={this.state.selectedOS === 'deb'} - /> - ); - - const windowsButton = ( - this.selectOS('win')} - fill={this.state.selectedOS === 'win'} - /> - ); - - const macOSButton = ( - this.selectOS('macos')} - fill={this.state.selectedOS === 'macos'} - /> - ); + checkMissingOSSelection(){ + if(!this.state.selectedOS){ + return ['Operating system']; + }; + switch (this.state.selectedOS) { + case 'rpm': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture ? ['OS architecture'] : []) + ]; + case 'deb': + return [ + ...(!this.state.selectedArchitecture ? ['OS architecture'] : []) + ]; + default: + return []; + } + }; + render() { + const missingOSSelection = this.checkMissingOSSelection(); const ipInput = (

You can predefine the Wazuh server address with the enrollment.dns Wazuh app setting.

this.setServerAddress(event)} /> @@ -328,7 +336,7 @@ export class RegisterAgent extends Component { const groupInput = (

- You can predefine the group where you want to enroll the agent. + Select one or more existing groups

{ this.setGroupName(group); }} + isDisabled={!this.state.groups.length} isClearable={true} data-test-subj="demoComboBox" /> @@ -345,7 +354,7 @@ export class RegisterAgent extends Component { const passwordInput = ( this.setWazuhPassword(event)} /> @@ -381,7 +390,7 @@ export class RegisterAgent extends Component {
{this.state.selectedOS && ( -

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

+

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

{this.state.wazuhPassword ? this.obfuscatePassword(text) : text} @@ -402,39 +411,40 @@ export class RegisterAgent extends Component { ); const steps = [ { - title: 'Choose OS', - children: ( - - {rpmButton} {debButton} {windowsButton} {macOSButton} - - ) + title: 'Choose the Operating system', + children: this.selectOS(os)} + /> }, ...((this.state.selectedOS == 'rpm') ? [{ - title: 'Choose your CentOS version', - children: this.setVersion(version)} - /> + /> }] : []), ...((this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5') ? [{ - title: 'Choose your architecture', - children: this.setArchitecture(architecture)} - /> + /> }] : []), ...((this.state.selectedOS == 'deb' || (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6')) ? [{ - title: 'Choose your architecture', - children: this.setArchitecture(architecture)} - /> + /> }] : []), { title: 'Wazuh server address', @@ -448,17 +458,17 @@ export class RegisterAgent extends Component { title: 'Assign the agent to a group', children: {groupInput} }, - ...((this.state.selectedArchitecture || this.state.selectedOS == 'win' || this.state.selectedOS == 'macos') ? [{ + { title: 'Install and enroll the agent', - children: ( -
- -
{guide}
-
-
- ) - }] : []), - ...(this.state.selectedOS && restartAgentCommand ? [ + children: missingOSSelection.length + ? + :
{guide}
+ }, + ...(!missingOSSelection.length && restartAgentCommand ? [ { title: 'Start the agent', children: ( From fd0d124d3564514d0d06692af38aab46f3daad54 Mon Sep 17 00:00:00 2001 From: Desvelao Date: Fri, 18 Dec 2020 17:18:14 +0100 Subject: [PATCH 8/8] fix: fix text in input to select group on the deploy agent section --- public/controllers/agent/components/register-agent.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 7580e7ccb9..1ab947b472 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -339,7 +339,7 @@ export class RegisterAgent extends Component { Select one or more existing groups

{