From b3f326296571fff397964496615fd507e6ec4314 Mon Sep 17 00:00:00 2001 From: "chantal.kelm" Date: Tue, 25 Oct 2022 08:07:21 -0300 Subject: [PATCH 1/4] variable of deployment wazuh protocol --- .../agent/components/register-agent.js | 968 +++++++++++++++--- 1 file changed, 809 insertions(+), 159 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 7a4ba811d7..2e02f8e19e 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -31,10 +31,9 @@ import { EuiCallOut, EuiSpacer, EuiProgress, - EuiCode, - EuiLink, EuiIcon, - EuiSwitch + EuiSwitch, + EuiLink } from '@elastic/eui'; import { WzRequest } from '../../../react-services/wz-request'; import { withErrorBoundary } from '../../../components/common/hocs'; @@ -42,84 +41,7 @@ import { UI_LOGGER_LEVELS } from '../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../react-services/common-services'; import { webDocumentationLink } from '../../../../common/services/web_documentation'; - -const architectureButtons = [ - { - id: 'i386', - label: 'i386', - }, - { - id: 'x86_64', - label: 'x86_64', - }, - { - id: 'armhf', - label: 'armhf', - }, - { - id: 'aarch64', - label: 'aarch64', - }, -]; -const architectureCentos5OrRedHat5 = [ - { - id: 'i386', - label: 'i386', - }, - { - id: 'x86_64', - label: 'x86_64', - }, -]; - -const versionButtonsCentosOrRedHat = [ - { - id: 'centos5', - label: 'CentOS5', - }, - { - id: 'centos6', - label: 'CentOS6 or higher', - }, - { - id: 'redhat5', - label: 'Red Hat 5', - }, - { - id: 'redhat6', - label: 'Red Hat 6 or higher', - }, -]; - -const osButtons = [ - { - id: 'rpm', - label: 'Red Hat / CentOS', - }, - { - id: 'deb', - label: 'Debian / Ubuntu', - }, - { - id: 'win', - label: 'Windows', - }, - { - id: 'macos', - label: 'MacOS', - }, -]; - -const sysButtons = [ - { - id: 'systemd', - label: 'Systemd', - }, - { - id: 'sysV', - label: 'SysV Init', - }, -]; +import { architectureButtons, architectureButtonsi386, architecturei386Andx86_64, versionButtonsRaspbian, versionButtonsSuse, versionButtonsOracleLinux, versionButtonFedora, architectureButtonsSolaris, architectureButtonsWithPPC64LE, architectureButtonsOpenSuse, architectureButtonsAix, architectureButtonsHpUx, versionButtonAmazonLinux, versionButtonsRedHat, versionButtonsCentos, architectureButtonsMacos, osButtons, versionButtonsDebian, versionButtonsUbuntu, versionButtonsWindows, versionButtonsMacOS, versionButtonsOpenSuse, versionButtonsSolaris, versionButtonsAix, versionButtonsHPUX } from '../wazuh-config' export const RegisterAgent = withErrorBoundary( @@ -146,7 +68,10 @@ export const RegisterAgent = withErrorBoundary( }; this.restartAgentCommand = { rpm: this.systemSelector(), + cent: this.systemSelector(), deb: this.systemSelector(), + ubu: this.systemSelector(), + oraclelinux: this.systemSelector(), macos: 'sudo /Library/Ossec/bin/wazuh-control start', win: 'NET START WazuhSvc' }; @@ -178,9 +103,29 @@ export const RegisterAgent = withErrorBoundary( serverAddress, needsPassword, hidePasswordInput, - versionButtonsCentosOrRedHat, + versionButtonsRedHat, + versionButtonsCentos, + versionButtonsDebian, + versionButtonsUbuntu, + versionButtonsWindows, + versionButtonsMacOS, + versionButtonsOpenSuse, + versionButtonsSolaris, + versionButtonAmazonLinux, + versionButtonsSuse, + versionButtonsAix, + versionButtonsHPUX, + versionButtonsOracleLinux, + versionButtonsRaspbian, + versionButtonFedora, architectureButtons, - architectureCentos5OrRedHat5, + architectureButtonsi386, + architecturei386Andx86_64, + architectureButtonsSolaris, + architectureButtonsAix, + architectureButtonsHpUx, + architectureButtonsMacos, + architectureButtonsWithPPC64LE, wazuhPassword, udpProtocol, wazuhVersion, @@ -221,8 +166,20 @@ export const RegisterAgent = withErrorBoundary( async getRemoteInfo() { try { const result = await WzRequest.apiReq('GET', '/agents/000/config/request/remote', {}); + console.log(result, 'resultt+++') + console.log('remoteee+') const remote = ((result.data || {}).data || {}).remote || {}; - return (remote[0] || {}).protocol !== 'tcp' && (remote[0] || {}).protocol[0] !== 'TCP'; + // return (remote[0] || {}).protocol !== 'tcp' && (remote[0] || {}).protocol[0] !== 'TCP'; + const remoteFiltered = remote.filter((item, key) => { + if (item.connection === 'secure') { + if(item.protocol.length === 1 && item.protocol[0] == 'UDP') { + console.log('entre') + this.setState({ udpProtocol: true }); + } + } + }) + console.log(remoteFiltered, 'remote filter') + console.log(udpProtocol, 'udp') } catch (error) { throw new Error(error); } @@ -233,20 +190,34 @@ export const RegisterAgent = withErrorBoundary( selectedOS: os, selectedVersion: '', selectedArchitecture: '', - selectedSYS: 'systemd', + selectedSYS: '', }); } systemSelector() { - if (this.state.selectedOS === 'rpm') { - if (this.state.selectedSYS === 'systemd') { - return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent'; - } else return 'sudo chkconfig --add wazuh-agent\nsudo service wazuh-agent start'; - } else if (this.state.selectedOS === 'deb') { - if (this.state.selectedSYS === 'systemd') { - return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent'; - } else return 'sudo update-rc.d wazuh-agent defaults 95 10\nsudo service wazuh-agent start'; - } else return ''; + 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') + } + } + + systemSelectorNet() { + if (this.state.selectedVersion === 'windowsxp' || this.state.selectedVersion === 'windows8') { + 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') + } + } + + 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') + } } selectSYS(sys) { @@ -329,22 +300,10 @@ export const RegisterAgent = withErrorBoundary( 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 'redhat5-i386': return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm`; case 'redhat5-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.armv7hl.rpm`; case 'redhat6-i386': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; case 'redhat6-aarch64': @@ -353,23 +312,236 @@ export const RegisterAgent = withErrorBoundary( return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; case 'redhat6-armhf': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; + case 'redhat7-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; + case 'redhat7-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; + case 'redhat7-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + case 'redhat7-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + } + } + + resolveORACLELINUXPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'oraclelinux5-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; + case 'oraclelinux5-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; + case 'oraclelinux5-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + case 'oraclelinux5-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; + case 'oraclelinux5-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; + case 'oraclelinux6-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case 'oraclelinux6-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case 'oraclelinux6-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'oraclelinux6-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + } + } + + resolveCENTPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'centos5-i386': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.el5.i386.rpm`; + case 'centos5-x86_64': + return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}.el5.x86_64.rpm`; + case 'centos6-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case 'centos6-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case 'centos6-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'centos6-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case 'centos7-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case 'centos7-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case 'centos7-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'centos7-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case 'centos7-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + } + } + + resolveSUSEPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'suse11-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case 'suse11-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'suse12-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case 'suse12-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case 'suse12-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'suse12-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case 'suse12-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + } + } + + resolveFEDORAPachage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case '22-i386': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm`; + case '22-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; + case '22-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case '22-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case '22-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + } + } + + resolveAMAZONLPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case '1-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case '1-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case '1-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case '1-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case '1-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; + case '2-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; + case '2-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; + case '2-x86_64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case '2-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; + case '2-powerpc': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; + case 'amazonlinux2022-i386': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; + case 'amazonlinux2022-aarch64': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; + case 'amazonlinux2022-x86_64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + case 'amazonlinux2022-armhf': + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.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`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_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`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; case 'armhf': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_armhf.deb`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_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`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_arm64.deb`; + case 'powerpc': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}.ppc64le.rpm`; default: - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; + } + } + + resolveRASPBIANPackage() { + switch (`${this.state.selectedArchitecture}`) { + case 'busterorgreater-i386': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_i386.deb`; + case 'busterorgreater-aarch64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; + case 'busterorgreater-armhf': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_armhf.deb`; + case 'busterorgreater-x86_64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_arm64.deb`; + case 'busterorgreater-powerpc': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}.ppc64le.rpm`; + default: + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; + } + } + + resolveUBUNTUPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'i386': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_i386.deb`; + case 'aarch64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; + case 'armhf': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_armhf.deb`; + case 'x86_64': + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_arm64.deb`; + default: + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; + } + } + + resolveOPENSUSEPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'leap15-i386': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + case 'leap15-x86_64': + return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm` + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; + } + } + + resolveSOLARISPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case 'solaris10-i386': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol10-i386.pkg`; + case 'solaris10-spark': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol10-sparc.pkg`; + case 'solaris11-i386': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol11-i386.p5p`; + case 'solaris11-spark': + return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}-sol11-sparc.p5p` + default: + return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-sol11-sparc.p5p`; + } + } + + resolveAIXPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case '6.1 TL9-powerpc': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.aix.ppc.rpm`; + default: + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.aix.ppc.rpm`; + } + } + + resolveHPPackage() { + switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { + case '11.31-itanium2': + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-hpux-11v3-ia64.tar`; + default: + return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-hpux-11v3-ia64.tar`; } } @@ -377,10 +549,32 @@ export const RegisterAgent = withErrorBoundary( switch (this.state.selectedOS) { case 'rpm': return this.resolveRPMPackage(); + case 'cent': + return this.resolveCENTPackage(); case 'deb': return this.resolveDEBPackage(); + case 'ubu': + return this.resolveUBUNTUPackage(); + case 'open': + return this.resolveOPENSUSEPackage(); + case 'sol': + return this.resolveSOLARISPackage(); + case 'aix': + return this.resolveAIXPackage(); + case 'hp': + return this.resolveHPPackage(); + case 'amazonlinux': + return this.resolveAMAZONLPackage(); + case 'fedora': + return this.resolveFEDORAPachage(); + case 'oraclelinux': + return this.resolveORACLELINUXPackage(); + case 'suse': + return this.resolveSUSEPackage(); + case 'raspbian': + return this.resolveRASPBIANPackage(); default: - return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; } } @@ -396,8 +590,104 @@ export const RegisterAgent = withErrorBoundary( ? ['OS architecture'] : []), ]; + case 'cent': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; case 'deb': - return [...(!this.state.selectedArchitecture ? ['OS architecture'] : [])]; + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'ubu': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'win': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'macos': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'open': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'sol': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'aix': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'hp': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'amazonlinux': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'fedora': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'oraclelinux': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'suse': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; + case 'raspbian': + return [ + ...(!this.state.selectedVersion ? ['OS version'] : []), + ...(this.state.selectedVersion && !this.state.selectedArchitecture + ? ['OS architecture'] + : []), + ]; default: return []; } @@ -410,7 +700,6 @@ export const RegisterAgent = withErrorBoundary( return 'bash'; } } - render() { const appVersionMajorDotMinor = this.state.wazuhVersion.split('.').slice(0, 2).join('.'); const urlCheckConnectionDocumentation = webDocumentationLink('user-manual/agents/agent-connection.html', appVersionMajorDotMinor); @@ -477,17 +766,32 @@ export const RegisterAgent = withErrorBoundary( zIndex: '100', }; const customTexts = { - rpmText: `sudo ${this.optionalDeploymentVariables()}yum install ${this.optionalPackages()}`, + rpmText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`, + centText: `sudo ${this.optionalDeploymentVariables()}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`, + ubuText: `curl -so wazuh-agent-${this.state.wazuhVersion + }.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}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()} && 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()}`, + raspbianText: `curl -so wazuh-agent-${this.state.wazuhVersion + }.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion + }.deb`, }; const field = `${this.state.selectedOS}Text`; @@ -552,8 +856,8 @@ export const RegisterAgent = withErrorBoundary( {(copy) => ( -
-

Copy command

+
+

Copy command

)} @@ -571,10 +875,10 @@ export const RegisterAgent = withErrorBoundary(
); - const tabs = [ + const tabSysV = [ { - id: 'systemd', - name: 'Systemd', + id: 'sysV', + name: 'SysV Init', content: ( @@ -591,15 +895,18 @@ export const RegisterAgent = withErrorBoundary( )}
- + {textAndLinkToCheckConnectionDocumentation} ), }, + ]; + + const tabSystemD = [ { - id: 'sysV', - name: 'SysV Init', + id: 'systemd', + name: 'Systemd', content: ( @@ -616,7 +923,7 @@ export const RegisterAgent = withErrorBoundary( )} - + {textAndLinkToCheckConnectionDocumentation} @@ -624,17 +931,155 @@ export const RegisterAgent = withErrorBoundary( }, ]; - const steps = [ + const tabNet = [ { - title: 'Choose the Operating system', - children: ( + id: 'NET', + name: 'NET', + content: ( + + + +
+ + {this.systemSelectorNet()} + + + {(copy) => ( +
+

Copy command

+
+ )} +
+
+ + {textAndLinkToCheckConnectionDocumentation} +
+
+ ), + }, + ]; + + const tabWazuhControlMacos = [ + { + id: 'Wazuh-control-macos', + name: 'Wazuh-control-macos', + content: ( + + + +
+ + {this.systemSelectorWazuhControlMacos()} + + + {(copy) => ( +
+

Copy command

+
+ )} +
+
+ + {textAndLinkToCheckConnectionDocumentation} +
+
+ ), + }, + ]; + + const tabWazuhControl = [ + { + id: 'Wazuh-control', + name: 'Wazuh-control', + content: ( + + + +
+ + {this.systemSelectorWazuhControl()} + + + {(copy) => ( +
+

Copy command

+
+ )} +
+
+ + {textAndLinkToCheckConnectionDocumentation} +
+
+ ), + }, + ]; + + const buttonGroup = (legend, options, idSelected, onChange) => { + return ( + + ) + } + + const buttonGroupWithMessage = (legend, options, idSelected, onChange) => { + return ( + <> this.selectOS(os)} + legend={legend} + options={options} + idSelected={idSelected} + onChange={onChange} + className={'osButtonsStyle'} /> + {this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' ? + Might require some extra installation steps. + + }> + : this.state.selectedVersion == '6.1 TL9' ? + Might require some extra installation steps. + + }> + : this.state.selectedVersion == '11.31' ? + Might require some extra installation steps. + + }> + : + The selected OS version reached its end of life (EOL). To install Wazuh follow our guide. + + }> + } + + ) + } + + const selectedVersionMac = (legend, options, idSelected, onChange) => { + return ( + + ) + } + + const steps = [ + { + title: 'Choose the Operating system', + children: ( + buttonGroup("Choose the Operating system", osButtons, this.state.selectedOS, (os) => this.selectOS(os)) ), }, ...(this.state.selectedOS == 'rpm' @@ -642,46 +1087,238 @@ export const RegisterAgent = withErrorBoundary( { title: 'Choose the version', children: ( - this.setVersion(version)} - /> + this.state.selectedVersion == 'redhat5' || this.state.selectedVersion == 'redhat6' ? buttonGroupWithMessage("Choose the version", versionButtonsRedHat, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsRedHat, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'oraclelinux' + ? [ + { + title: 'Choose the version', + children: ( + buttonGroup("Choose the version", versionButtonsOracleLinux, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'raspbian' + ? [ + { + title: 'Choose the version', + children: ( + buttonGroup("Choose the version", versionButtonsRaspbian, this.state.selectedVersion, (version) => this.setVersion(version)) ), }, ] : []), - ...(this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'redhat5' + ...(this.state.selectedOS == 'amazonlinux' + ? [ + { + title: 'Choose the version', + children: ( + buttonGroup("Choose the version", versionButtonAmazonLinux, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'cent' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'centos6' ? buttonGroupWithMessage("Choose the version", versionButtonsCentos, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsCentos, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'fedora' + ? [ + { + title: 'Choose the version', + children: ( + buttonGroup("Choose the version", versionButtonFedora, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'deb' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == 'debian7' || this.state.selectedVersion == 'debian8' ? buttonGroupWithMessage("Choose the version", versionButtonsDebian, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsDebian, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'ubu' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == 'ubuntu14' ? buttonGroupWithMessage("Choose the version", versionButtonsUbuntu, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsUbuntu, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'win' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == 'windowsxp' ? buttonGroupWithMessage("Choose the version", versionButtonsWindows, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsWindows, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'macos' + ? [ + { + title: 'Choose the version', + children: ( + selectedVersionMac("Choose the version", versionButtonsMacOS, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'suse' + ? [ + { + title: 'Choose the version', + children: ( + selectedVersionMac("Choose the version", versionButtonsSuse, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'open' + ? [ + { + title: 'Choose the version', + children: ( + buttonGroup("Choose the version", versionButtonsOpenSuse, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'sol' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' ? buttonGroupWithMessage("Choose the version", versionButtonsSolaris, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsSolaris, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'aix' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == '6.1 TL9' ? buttonGroupWithMessage("Choose the version", versionButtonsAix, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsAix, this.state.selectedVersion, (version) => this.setVersion(version)) + ), + }, + ] + : []), + ...(this.state.selectedOS == 'hp' + ? [ + { + title: 'Choose the version', + children: ( + this.state.selectedVersion == '11.31' ? buttonGroupWithMessage("Choose the version", versionButtonsHPUX, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsHPUX, this.state.selectedVersion, (version) => this.setVersion(version)) + + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'redhat5' || this.state.selectedVersion == 'oraclelinux5' || this.state.selectedVersion == 'suse11' ? [ { title: 'Choose the architecture', children: ( - this.setArchitecture(architecture)} - /> + buttonGroup("Choose the architecture", architecturei386Andx86_64, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) ), }, ] : []), - ...(this.state.selectedOS == 'deb' || - (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' || this.state.selectedVersion == 'redhat6') + ...(this.state.selectedVersion == 'leap15' ? [ { title: 'Choose the architecture', children: ( - this.setArchitecture(architecture)} - /> + buttonGroup("Choose the architecture", architectureButtonsOpenSuse, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'centos6' || this.state.selectedVersion == 'oraclelinux6' || this.state.selectedVersion == 'amazonlinux1' || this.state.selectedVersion == 'redhat6' || this.state.selectedVersion == 'redhat7' || this.state.selectedVersion == 'amazonlinux2022' || this.state.selectedVersion == 'debian7' || this.state.selectedVersion == 'debian8' || this.state.selectedVersion == 'ubuntu14' || this.state.selectedVersion == 'ubuntu15' || this.state.selectedVersion == 'ubuntu16' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtons, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'centos7' || this.state.selectedVersion == 'amazonlinux2' || this.state.selectedVersion == 'suse12' || this.state.selectedVersion == '22' || this.state.selectedVersion == 'debian9' || this.state.selectedVersion == 'debian10' || this.state.selectedVersion == 'busterorgreater' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsWithPPC64LE, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'windowsxp' || this.state.selectedVersion == 'windows8' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsi386, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'sierra' || this.state.selectedVersion == 'highSierra' || this.state.selectedVersion == 'mojave' || this.state.selectedVersion == 'catalina' || this.state.selectedVersion == 'bigSur' || this.state.selectedVersion == 'monterrey' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsMacos, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsSolaris, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == '6.1 TL9' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsAix, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + ), + }, + ] + : []), + ...(this.state.selectedVersion == '11.31' + ? [ + { + title: 'Choose the architecture', + children: ( + buttonGroup("Choose the architecture", architectureButtonsHpUx, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) ), }, ] @@ -716,7 +1353,7 @@ export const RegisterAgent = withErrorBoundary(
{guide}
), }, - ...(this.state.selectedOS == 'rpm' || this.state.selectedOS == 'deb' + ...(this.state.selectedOS == 'rpm' || this.state.selectedOS == 'cent' || this.state.selectedOS == 'suse' || this.state.selectedOS == 'fedora' || this.state.selectedOS == 'oraclelinux' || this.state.selectedOS == 'amazonlinux' || this.state.selectedOS == 'deb' || this.state.selectedOS == 'raspbian' || this.state.selectedOS == 'ubu' || this.state.selectedOS == 'win' || this.state.selectedOS == 'macos' || this.state.selectedOS == 'open' || this.state.selectedOS == 'sol' || this.state.selectedOS == 'aix' || this.state.selectedOS == 'hp' ? [ { title: 'Start the agent', @@ -730,7 +1367,7 @@ export const RegisterAgent = withErrorBoundary( /> ) : ( @@ -742,6 +1379,19 @@ export const RegisterAgent = withErrorBoundary( ...(!missingOSSelection.length && this.state.selectedOS !== 'rpm' && this.state.selectedOS !== 'deb' && + this.state.selectedOS !== 'cent' && + this.state.selectedOS !== 'ubu' && + this.state.selectedOS !== 'win' && + this.state.selectedOS !== 'macos' && + this.state.selectedOS !== 'open' && + this.state.selectedOS !== 'sol' && + this.state.selectedOS !== 'aix' && + this.state.selectedOS !== 'hp' && + this.state.selectedOS !== 'amazonlinux' && + this.state.selectedOS !== 'fedora' && + this.state.selectedOS !== 'oraclelinux' && + this.state.selectedOS !== 'suse' && + this.state.selectedOS !== 'raspbian' && restartAgentCommand ? [ { @@ -827,4 +1477,4 @@ export const RegisterAgent = withErrorBoundary( ); } } -); \ No newline at end of file +); From a7acd57971d7127c6a4e0c1aaac33869240f44e1 Mon Sep 17 00:00:00 2001 From: "chantal.kelm" Date: Tue, 25 Oct 2022 09:18:37 -0300 Subject: [PATCH 2/4] merge 4.4-7.10 --- .../agent/components/register-agent.js | 955 +++--------------- 1 file changed, 158 insertions(+), 797 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 2e02f8e19e..c345b6503c 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -31,9 +31,10 @@ import { EuiCallOut, EuiSpacer, EuiProgress, + EuiCode, + EuiLink, EuiIcon, - EuiSwitch, - EuiLink + EuiSwitch } from '@elastic/eui'; import { WzRequest } from '../../../react-services/wz-request'; import { withErrorBoundary } from '../../../components/common/hocs'; @@ -41,7 +42,84 @@ import { UI_LOGGER_LEVELS } from '../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../react-services/common-services'; import { webDocumentationLink } from '../../../../common/services/web_documentation'; -import { architectureButtons, architectureButtonsi386, architecturei386Andx86_64, versionButtonsRaspbian, versionButtonsSuse, versionButtonsOracleLinux, versionButtonFedora, architectureButtonsSolaris, architectureButtonsWithPPC64LE, architectureButtonsOpenSuse, architectureButtonsAix, architectureButtonsHpUx, versionButtonAmazonLinux, versionButtonsRedHat, versionButtonsCentos, architectureButtonsMacos, osButtons, versionButtonsDebian, versionButtonsUbuntu, versionButtonsWindows, versionButtonsMacOS, versionButtonsOpenSuse, versionButtonsSolaris, versionButtonsAix, versionButtonsHPUX } from '../wazuh-config' + +const architectureButtons = [ + { + id: 'i386', + label: 'i386', + }, + { + id: 'x86_64', + label: 'x86_64', + }, + { + id: 'armhf', + label: 'armhf', + }, + { + id: 'aarch64', + label: 'aarch64', + }, +]; +const architectureCentos5OrRedHat5 = [ + { + id: 'i386', + label: 'i386', + }, + { + id: 'x86_64', + label: 'x86_64', + }, +]; + +const versionButtonsCentosOrRedHat = [ + { + id: 'centos5', + label: 'CentOS5', + }, + { + id: 'centos6', + label: 'CentOS6 or higher', + }, + { + id: 'redhat5', + label: 'Red Hat 5', + }, + { + id: 'redhat6', + label: 'Red Hat 6 or higher', + }, +]; + +const osButtons = [ + { + id: 'rpm', + label: 'Red Hat / CentOS', + }, + { + id: 'deb', + label: 'Debian / Ubuntu', + }, + { + id: 'win', + label: 'Windows', + }, + { + id: 'macos', + label: 'MacOS', + }, +]; + +const sysButtons = [ + { + id: 'systemd', + label: 'Systemd', + }, + { + id: 'sysV', + label: 'SysV Init', + }, +]; export const RegisterAgent = withErrorBoundary( @@ -68,10 +146,7 @@ export const RegisterAgent = withErrorBoundary( }; this.restartAgentCommand = { rpm: this.systemSelector(), - cent: this.systemSelector(), deb: this.systemSelector(), - ubu: this.systemSelector(), - oraclelinux: this.systemSelector(), macos: 'sudo /Library/Ossec/bin/wazuh-control start', win: 'NET START WazuhSvc' }; @@ -103,29 +178,9 @@ export const RegisterAgent = withErrorBoundary( serverAddress, needsPassword, hidePasswordInput, - versionButtonsRedHat, - versionButtonsCentos, - versionButtonsDebian, - versionButtonsUbuntu, - versionButtonsWindows, - versionButtonsMacOS, - versionButtonsOpenSuse, - versionButtonsSolaris, - versionButtonAmazonLinux, - versionButtonsSuse, - versionButtonsAix, - versionButtonsHPUX, - versionButtonsOracleLinux, - versionButtonsRaspbian, - versionButtonFedora, + versionButtonsCentosOrRedHat, architectureButtons, - architectureButtonsi386, - architecturei386Andx86_64, - architectureButtonsSolaris, - architectureButtonsAix, - architectureButtonsHpUx, - architectureButtonsMacos, - architectureButtonsWithPPC64LE, + architectureCentos5OrRedHat5, wazuhPassword, udpProtocol, wazuhVersion, @@ -169,7 +224,6 @@ export const RegisterAgent = withErrorBoundary( console.log(result, 'resultt+++') console.log('remoteee+') const remote = ((result.data || {}).data || {}).remote || {}; - // return (remote[0] || {}).protocol !== 'tcp' && (remote[0] || {}).protocol[0] !== 'TCP'; const remoteFiltered = remote.filter((item, key) => { if (item.connection === 'secure') { if(item.protocol.length === 1 && item.protocol[0] == 'UDP') { @@ -190,34 +244,20 @@ export const RegisterAgent = withErrorBoundary( selectedOS: os, selectedVersion: '', selectedArchitecture: '', - selectedSYS: '', + selectedSYS: 'systemd', }); } systemSelector() { - 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') - } - } - - systemSelectorNet() { - if (this.state.selectedVersion === 'windowsxp' || this.state.selectedVersion === 'windows8') { - 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') - } - } - - 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') - } + if (this.state.selectedOS === 'rpm') { + if (this.state.selectedSYS === 'systemd') { + return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent'; + } else return 'sudo chkconfig --add wazuh-agent\nsudo service wazuh-agent start'; + } else if (this.state.selectedOS === 'deb') { + if (this.state.selectedSYS === 'systemd') { + return 'sudo systemctl daemon-reload\nsudo systemctl enable wazuh-agent\nsudo systemctl start wazuh-agent'; + } else return 'sudo update-rc.d wazuh-agent defaults 95 10\nsudo service wazuh-agent start'; + } else return ''; } selectSYS(sys) { @@ -300,248 +340,47 @@ export const RegisterAgent = withErrorBoundary( 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 'redhat5-i386': return `https://packages.wazuh.com/4.x/yum5/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm`; case 'redhat5-x86_64': return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.el5.x86_64.rpm`; - case 'redhat6-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; - case 'redhat6-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; - case 'redhat6-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - case 'redhat6-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; - case 'redhat7-i386': + case 'centos6-i386': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; - case 'redhat7-aarch64': + case 'centos6-aarch64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; - case 'redhat7-x86_64': + case 'centos6-x86_64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - case 'redhat7-armhf': + case 'centos6-armhf': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - } - } - - resolveORACLELINUXPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'oraclelinux5-i386': + case 'redhat6-i386': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; - case 'oraclelinux5-aarch64': + case 'redhat6-aarch64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; - case 'oraclelinux5-x86_64': + case 'redhat6-x86_64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - case 'oraclelinux5-armhf': + case 'redhat6-armhf': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; - case 'oraclelinux5-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; - case 'oraclelinux6-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case 'oraclelinux6-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case 'oraclelinux6-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'oraclelinux6-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - } - } - - resolveCENTPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'centos5-i386': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.el5.i386.rpm`; - case 'centos5-x86_64': - return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}.el5.x86_64.rpm`; - case 'centos6-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case 'centos6-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case 'centos6-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'centos6-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case 'centos7-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case 'centos7-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case 'centos7-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'centos7-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case 'centos7-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - } - } - - resolveSUSEPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'suse11-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case 'suse11-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'suse12-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case 'suse12-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case 'suse12-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'suse12-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case 'suse12-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - } - } - - resolveFEDORAPachage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case '22-i386': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-1.el5.i386.rpm`; - case '22-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; - case '22-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case '22-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case '22-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - } - } - - resolveAMAZONLPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case '1-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case '1-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case '1-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case '1-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case '1-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; - case '2-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.i386.rpm`; - case '2-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.aarch64.rpm`; - case '2-x86_64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case '2-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm`; - case '2-powerpc': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.ppc64le.rpm`; - case 'amazonlinux2022-i386': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.i386.rpm`; - case 'amazonlinux2022-aarch64': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.aarch64.rpm`; - case 'amazonlinux2022-x86_64': return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; - case 'amazonlinux2022-armhf': - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.armv7hl.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.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}_i386.deb`; + 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}_amd64.deb`; + 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}_armhf.deb`; + 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}_arm64.deb`; - case 'powerpc': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}.ppc64le.rpm`; + 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}_amd64.deb`; - } - } - - resolveRASPBIANPackage() { - switch (`${this.state.selectedArchitecture}`) { - case 'busterorgreater-i386': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_i386.deb`; - case 'busterorgreater-aarch64': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; - case 'busterorgreater-armhf': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_armhf.deb`; - case 'busterorgreater-x86_64': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_arm64.deb`; - case 'busterorgreater-powerpc': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}.ppc64le.rpm`; - default: - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; - } - } - - resolveUBUNTUPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'i386': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_i386.deb`; - case 'aarch64': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; - case 'armhf': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_armhf.deb`; - case 'x86_64': - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_arm64.deb`; - default: - return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}_amd64.deb`; - } - } - - resolveOPENSUSEPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'leap15-i386': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - case 'leap15-x86_64': - return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}.armv7hl.rpm` - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}.x86_64.rpm`; - } - } - - resolveSOLARISPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case 'solaris10-i386': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol10-i386.pkg`; - case 'solaris10-spark': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol10-sparc.pkg`; - case 'solaris11-i386': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-sol11-i386.p5p`; - case 'solaris11-spark': - return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}-sol11-sparc.p5p` - default: - return `https://packages.wazuh.com/4.x/yum/wazuh-agent-${this.state.wazuhVersion}-sol11-sparc.p5p`; - } - } - - resolveAIXPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case '6.1 TL9-powerpc': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.aix.ppc.rpm`; - default: - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}.aix.ppc.rpm`; - } - } - - resolveHPPackage() { - switch (`${this.state.selectedVersion}-${this.state.selectedArchitecture}`) { - case '11.31-itanium2': - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-hpux-11v3-ia64.tar`; - default: - return `https://packages.wazuh.com/4.x/yum/i386/wazuh-agent-${this.state.wazuhVersion}-hpux-11v3-ia64.tar`; + return `https://packages.wazuh.com/4.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb`; } } @@ -549,32 +388,10 @@ export const RegisterAgent = withErrorBoundary( switch (this.state.selectedOS) { case 'rpm': return this.resolveRPMPackage(); - case 'cent': - return this.resolveCENTPackage(); case 'deb': return this.resolveDEBPackage(); - case 'ubu': - return this.resolveUBUNTUPackage(); - case 'open': - return this.resolveOPENSUSEPackage(); - case 'sol': - return this.resolveSOLARISPackage(); - case 'aix': - return this.resolveAIXPackage(); - case 'hp': - return this.resolveHPPackage(); - case 'amazonlinux': - return this.resolveAMAZONLPackage(); - case 'fedora': - return this.resolveFEDORAPachage(); - case 'oraclelinux': - return this.resolveORACLELINUXPackage(); - case 'suse': - return this.resolveSUSEPackage(); - case 'raspbian': - return this.resolveRASPBIANPackage(); default: - return `https://packages.wazuh.com/4.x/yum/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; + return `https://packages.wazuh.com/4.x/yum5/x86_64/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`; } } @@ -590,104 +407,8 @@ export const RegisterAgent = withErrorBoundary( ? ['OS architecture'] : []), ]; - case 'cent': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; case 'deb': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'ubu': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'win': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'macos': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'open': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'sol': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'aix': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'hp': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'amazonlinux': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'fedora': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'oraclelinux': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'suse': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; - case 'raspbian': - return [ - ...(!this.state.selectedVersion ? ['OS version'] : []), - ...(this.state.selectedVersion && !this.state.selectedArchitecture - ? ['OS architecture'] - : []), - ]; + return [...(!this.state.selectedArchitecture ? ['OS architecture'] : [])]; default: return []; } @@ -700,6 +421,7 @@ export const RegisterAgent = withErrorBoundary( return 'bash'; } } + render() { const appVersionMajorDotMinor = this.state.wazuhVersion.split('.').slice(0, 2).join('.'); const urlCheckConnectionDocumentation = webDocumentationLink('user-manual/agents/agent-connection.html', appVersionMajorDotMinor); @@ -766,32 +488,17 @@ export const RegisterAgent = withErrorBoundary( zIndex: '100', }; const customTexts = { - rpmText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`, - centText: `sudo ${this.optionalDeploymentVariables()}yum install -y ${this.optionalPackages()}`, + rpmText: `sudo ${this.optionalDeploymentVariables()}yum install ${this.optionalPackages()}`, debText: `curl -so wazuh-agent-${this.state.wazuhVersion }.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}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`, 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()}&& 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()}`, - raspbianText: `curl -so wazuh-agent-${this.state.wazuhVersion - }.deb ${this.optionalPackages()} && sudo ${this.optionalDeploymentVariables()}dpkg -i ./wazuh-agent-${this.state.wazuhVersion - }.deb`, }; const field = `${this.state.selectedOS}Text`; @@ -856,8 +563,8 @@ export const RegisterAgent = withErrorBoundary( {(copy) => ( -
-

Copy command

+
+

Copy command

)} @@ -875,35 +582,7 @@ export const RegisterAgent = withErrorBoundary(
); - const tabSysV = [ - { - id: 'sysV', - name: 'SysV Init', - content: ( - - - -
- - {this.systemSelector()} - - - {(copy) => ( -
-

Copy command

-
- )} -
-
- - {textAndLinkToCheckConnectionDocumentation} -
-
- ), - }, - ]; - - const tabSystemD = [ + const tabs = [ { id: 'systemd', name: 'Systemd', @@ -923,83 +602,24 @@ export const RegisterAgent = withErrorBoundary( )}
- - {textAndLinkToCheckConnectionDocumentation} - - - ), - }, - ]; - - const tabNet = [ - { - id: 'NET', - name: 'NET', - content: ( - - - -
- - {this.systemSelectorNet()} - - - {(copy) => ( -
-

Copy command

-
- )} -
-
- + {textAndLinkToCheckConnectionDocumentation}
), }, - ]; - - const tabWazuhControlMacos = [ { - id: 'Wazuh-control-macos', - name: 'Wazuh-control-macos', - content: ( - - - -
- - {this.systemSelectorWazuhControlMacos()} - - - {(copy) => ( -
-

Copy command

-
- )} -
-
- - {textAndLinkToCheckConnectionDocumentation} -
-
- ), - }, - ]; - - const tabWazuhControl = [ - { - id: 'Wazuh-control', - name: 'Wazuh-control', + id: 'sysV', + name: 'SysV Init', content: (
- {this.systemSelectorWazuhControl()} + {this.systemSelector()} - + {(copy) => (

Copy command

@@ -1007,7 +627,7 @@ export const RegisterAgent = withErrorBoundary( )}
- + {textAndLinkToCheckConnectionDocumentation} @@ -1015,71 +635,17 @@ export const RegisterAgent = withErrorBoundary( }, ]; - const buttonGroup = (legend, options, idSelected, onChange) => { - return ( - - ) - } - - const buttonGroupWithMessage = (legend, options, idSelected, onChange) => { - return ( - <> - - {this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' ? - Might require some extra installation steps. - - }> - : this.state.selectedVersion == '6.1 TL9' ? - Might require some extra installation steps. - - }> - : this.state.selectedVersion == '11.31' ? - Might require some extra installation steps. - - }> - : - The selected OS version reached its end of life (EOL). To install Wazuh follow our guide. - - }> - } - - ) - } - - const selectedVersionMac = (legend, options, idSelected, onChange) => { - return ( - - ) - } - const steps = [ { title: 'Choose the Operating system', children: ( - buttonGroup("Choose the Operating system", osButtons, this.state.selectedOS, (os) => this.selectOS(os)) + this.selectOS(os)} + /> ), }, ...(this.state.selectedOS == 'rpm' @@ -1087,238 +653,46 @@ export const RegisterAgent = withErrorBoundary( { title: 'Choose the version', children: ( - this.state.selectedVersion == 'redhat5' || this.state.selectedVersion == 'redhat6' ? buttonGroupWithMessage("Choose the version", versionButtonsRedHat, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsRedHat, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'oraclelinux' - ? [ - { - title: 'Choose the version', - children: ( - buttonGroup("Choose the version", versionButtonsOracleLinux, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'raspbian' - ? [ - { - title: 'Choose the version', - children: ( - buttonGroup("Choose the version", versionButtonsRaspbian, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'amazonlinux' - ? [ - { - title: 'Choose the version', - children: ( - buttonGroup("Choose the version", versionButtonAmazonLinux, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'cent' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'centos6' ? buttonGroupWithMessage("Choose the version", versionButtonsCentos, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsCentos, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'fedora' - ? [ - { - title: 'Choose the version', - children: ( - buttonGroup("Choose the version", versionButtonFedora, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'deb' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == 'debian7' || this.state.selectedVersion == 'debian8' ? buttonGroupWithMessage("Choose the version", versionButtonsDebian, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsDebian, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'ubu' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == 'ubuntu14' ? buttonGroupWithMessage("Choose the version", versionButtonsUbuntu, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsUbuntu, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'win' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == 'windowsxp' ? buttonGroupWithMessage("Choose the version", versionButtonsWindows, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsWindows, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'macos' - ? [ - { - title: 'Choose the version', - children: ( - selectedVersionMac("Choose the version", versionButtonsMacOS, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'suse' - ? [ - { - title: 'Choose the version', - children: ( - selectedVersionMac("Choose the version", versionButtonsSuse, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'open' - ? [ - { - title: 'Choose the version', - children: ( - buttonGroup("Choose the version", versionButtonsOpenSuse, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'sol' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' ? buttonGroupWithMessage("Choose the version", versionButtonsSolaris, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsSolaris, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'aix' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == '6.1 TL9' ? buttonGroupWithMessage("Choose the version", versionButtonsAix, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsAix, this.state.selectedVersion, (version) => this.setVersion(version)) - ), - }, - ] - : []), - ...(this.state.selectedOS == 'hp' - ? [ - { - title: 'Choose the version', - children: ( - this.state.selectedVersion == '11.31' ? buttonGroupWithMessage("Choose the version", versionButtonsHPUX, this.state.selectedVersion, (version) => this.setVersion(version)) : buttonGroup("Choose the version", versionButtonsHPUX, this.state.selectedVersion, (version) => this.setVersion(version)) - - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'redhat5' || this.state.selectedVersion == 'oraclelinux5' || this.state.selectedVersion == 'suse11' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architecturei386Andx86_64, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'leap15' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtonsOpenSuse, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'centos6' || this.state.selectedVersion == 'oraclelinux6' || this.state.selectedVersion == 'amazonlinux1' || this.state.selectedVersion == 'redhat6' || this.state.selectedVersion == 'redhat7' || this.state.selectedVersion == 'amazonlinux2022' || this.state.selectedVersion == 'debian7' || this.state.selectedVersion == 'debian8' || this.state.selectedVersion == 'ubuntu14' || this.state.selectedVersion == 'ubuntu15' || this.state.selectedVersion == 'ubuntu16' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtons, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'centos7' || this.state.selectedVersion == 'amazonlinux2' || this.state.selectedVersion == 'suse12' || this.state.selectedVersion == '22' || this.state.selectedVersion == 'debian9' || this.state.selectedVersion == 'debian10' || this.state.selectedVersion == 'busterorgreater' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtonsWithPPC64LE, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'windowsxp' || this.state.selectedVersion == 'windows8' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtonsi386, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'sierra' || this.state.selectedVersion == 'highSierra' || this.state.selectedVersion == 'mojave' || this.state.selectedVersion == 'catalina' || this.state.selectedVersion == 'bigSur' || this.state.selectedVersion == 'monterrey' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtonsMacos, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) - ), - }, - ] - : []), - ...(this.state.selectedVersion == 'solaris10' || this.state.selectedVersion == 'solaris11' - ? [ - { - title: 'Choose the architecture', - children: ( - buttonGroup("Choose the architecture", architectureButtonsSolaris, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + this.setVersion(version)} + /> ), }, ] : []), - ...(this.state.selectedVersion == '6.1 TL9' + ...(this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos5' || this.state.selectedVersion == 'redhat5' ? [ { title: 'Choose the architecture', children: ( - buttonGroup("Choose the architecture", architectureButtonsAix, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + this.setArchitecture(architecture)} + /> ), }, ] : []), - ...(this.state.selectedVersion == '11.31' + ...(this.state.selectedOS == 'deb' || + (this.state.selectedOS == 'rpm' && this.state.selectedVersion == 'centos6' || this.state.selectedVersion == 'redhat6') ? [ { title: 'Choose the architecture', children: ( - buttonGroup("Choose the architecture", architectureButtonsHpUx, this.state.selectedArchitecture, (architecture) => this.setArchitecture(architecture)) + this.setArchitecture(architecture)} + /> ), }, ] @@ -1353,7 +727,7 @@ export const RegisterAgent = withErrorBoundary(
{guide}
), }, - ...(this.state.selectedOS == 'rpm' || this.state.selectedOS == 'cent' || this.state.selectedOS == 'suse' || this.state.selectedOS == 'fedora' || this.state.selectedOS == 'oraclelinux' || this.state.selectedOS == 'amazonlinux' || this.state.selectedOS == 'deb' || this.state.selectedOS == 'raspbian' || this.state.selectedOS == 'ubu' || this.state.selectedOS == 'win' || this.state.selectedOS == 'macos' || this.state.selectedOS == 'open' || this.state.selectedOS == 'sol' || this.state.selectedOS == 'aix' || this.state.selectedOS == 'hp' + ...(this.state.selectedOS == 'rpm' || this.state.selectedOS == 'deb' ? [ { title: 'Start the agent', @@ -1367,7 +741,7 @@ export const RegisterAgent = withErrorBoundary( /> ) : ( @@ -1379,19 +753,6 @@ export const RegisterAgent = withErrorBoundary( ...(!missingOSSelection.length && this.state.selectedOS !== 'rpm' && this.state.selectedOS !== 'deb' && - this.state.selectedOS !== 'cent' && - this.state.selectedOS !== 'ubu' && - this.state.selectedOS !== 'win' && - this.state.selectedOS !== 'macos' && - this.state.selectedOS !== 'open' && - this.state.selectedOS !== 'sol' && - this.state.selectedOS !== 'aix' && - this.state.selectedOS !== 'hp' && - this.state.selectedOS !== 'amazonlinux' && - this.state.selectedOS !== 'fedora' && - this.state.selectedOS !== 'oraclelinux' && - this.state.selectedOS !== 'suse' && - this.state.selectedOS !== 'raspbian' && restartAgentCommand ? [ { @@ -1477,4 +838,4 @@ export const RegisterAgent = withErrorBoundary( ); } } -); +); \ No newline at end of file From ca38522ed6033543a20f5840fb316744461bf99c Mon Sep 17 00:00:00 2001 From: "chantal.kelm" Date: Thu, 27 Oct 2022 14:47:20 -0300 Subject: [PATCH 3/4] message + error handling --- .../agent/components/register-agent.js | 115 +++++++++++++++--- 1 file changed, 101 insertions(+), 14 deletions(-) diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index c345b6503c..520f1e1c16 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -143,6 +143,7 @@ export const RegisterAgent = withErrorBoundary( selectedGroup: [], udpProtocol: false, showPassword: false, + connectionSecure: true }; this.restartAgentCommand = { rpm: this.systemSelector(), @@ -172,7 +173,7 @@ export const RegisterAgent = withErrorBoundary( } } - const udpProtocol = await this.getRemoteInfo(); + await this.getRemoteInfo(); const groups = await this.getGroups(); this.setState({ serverAddress, @@ -182,7 +183,6 @@ export const RegisterAgent = withErrorBoundary( architectureButtons, architectureCentos5OrRedHat5, wazuhPassword, - udpProtocol, wazuhVersion, groups, loading: false, @@ -196,7 +196,7 @@ export const RegisterAgent = withErrorBoundary( context: `${RegisterAgent.name}.componentDidMount`, level: UI_LOGGER_LEVELS.ERROR, severity: UI_ERROR_SEVERITIES.BUSINESS, - display: false, + display: true, store: false, error: { error: error, @@ -221,19 +221,25 @@ export const RegisterAgent = withErrorBoundary( async getRemoteInfo() { try { const result = await WzRequest.apiReq('GET', '/agents/000/config/request/remote', {}); - console.log(result, 'resultt+++') - console.log('remoteee+') const remote = ((result.data || {}).data || {}).remote || {}; - const remoteFiltered = remote.filter((item, key) => { + const remoteFiltered = remote.filter((item) => { + return ( + item.connection === 'secure' + ) + }) + if (remoteFiltered.length === 0) { + this.setState({ connectionSecure: false }) + } else { + remoteFiltered.forEach((item) => { if (item.connection === 'secure') { if(item.protocol.length === 1 && item.protocol[0] == 'UDP') { - console.log('entre') - this.setState({ udpProtocol: true }); + this.setState({ udpProtocol: true, connectionSecure: true}); + } + if(item.protocol.length > 1 && item.protocol[0] == 'TCP') { + this.setState({ udpProtocol: false, connectionSecure: true}); } } - }) - console.log(remoteFiltered, 'remote filter') - console.log(udpProtocol, 'udp') + })} } catch (error) { throw new Error(error); } @@ -319,7 +325,6 @@ export const RegisterAgent = withErrorBoundary( if (this.state.needsPassword) { deployment += `WAZUH_REGISTRATION_PASSWORD='${this.state.wazuhPassword}' `; } - if (this.state.udpProtocol) { deployment += `WAZUH_PROTOCOL='UDP' `; } @@ -540,8 +545,90 @@ export const RegisterAgent = withErrorBoundary( 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) ? ( + +

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

+ + If the installer finds another Wazuh agent in the system, it will upgrade it preserving the configuration. + + } + iconType="iInCircle" + /> + + {windowsAdvice} +
+ + {this.state.wazuhPassword && !this.state.showPassword ? this.obfuscatePassword(text) : text} + + + {(copy) => ( +
+

Copy command

+
+ )} +
+
+ {this.state.needsPassword && ( + this.setShowPassword(active)} + /> + )} + +
) : (this.state.connectionSecure === false) ? + ( + +

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

+ + If the installer finds another Wazuh agent in the system, it will upgrade it preserving the configuration. + + } + iconType="iInCircle" + /> + + + Warning: there's no secure protocol configured and agents will not be able to communicate with the manager. + + } + iconType="iInCircle" + /> + + {windowsAdvice} +
+ + {this.state.wazuhPassword && !this.state.showPassword ? this.obfuscatePassword(text) : text} + + + {(copy) => ( +
+

Copy command

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

You can use this command to install and enroll the Wazuh agent in one or more hosts. From 6c84cf0cd82fc39598e71573ef4d660c61f267ec Mon Sep 17 00:00:00 2001 From: Maximiliano Ibarra Date: Thu, 27 Oct 2022 15:25:17 -0300 Subject: [PATCH 4/4] Detached getRemoteInfo request in service to ease unit testing --- .../components/register-agent-service.ts | 49 +++++++++++++++++++ .../agent/components/register-agent.js | 23 ++------- 2 files changed, 52 insertions(+), 20 deletions(-) create mode 100644 public/controllers/agent/components/register-agent-service.ts diff --git a/public/controllers/agent/components/register-agent-service.ts b/public/controllers/agent/components/register-agent-service.ts new file mode 100644 index 0000000000..e412191768 --- /dev/null +++ b/public/controllers/agent/components/register-agent-service.ts @@ -0,0 +1,49 @@ +import { WzRequest } from '../../../react-services/wz-request'; + +type RemoteConfig = { + udpProtocol: boolean | null; + connectionSecure: boolean | null; +}; + +type RemoteItem = { + connection: 'syslog' | 'secure'; + ipv6: 'yes' | 'no'; + protocol: 'TCP' | 'UDP'[]; +}; + +export const getRemoteConfiguration = async (): Promise => { + let config: RemoteConfig = { + udpProtocol: null, + connectionSecure: null, + }; + const result = await WzRequest.apiReq( + 'GET', + '/agents/000/config/request/remote', + {}, + ); + const remote = ((result.data || {}).data || {}).remote || {}; + const remoteFiltered = remote.filter((item: RemoteItem) => { + return item.connection === 'secure'; + }); + if (remoteFiltered.length === 0) { + config.connectionSecure = false; + } else { + remoteFiltered.forEach((item: RemoteItem) => { + if (item.connection === 'secure') { + if (item.protocol.length === 1 && item.protocol[0] == 'UDP') { + config = { + udpProtocol: true, + connectionSecure: true, + }; + } + if (item.protocol.length > 1 && item.protocol[0] == 'TCP') { + config = { + udpProtocol: false, + connectionSecure: true, + }; + } + } + }); + } + return config; +}; diff --git a/public/controllers/agent/components/register-agent.js b/public/controllers/agent/components/register-agent.js index 520f1e1c16..59f1657b9d 100644 --- a/public/controllers/agent/components/register-agent.js +++ b/public/controllers/agent/components/register-agent.js @@ -42,6 +42,7 @@ import { UI_LOGGER_LEVELS } from '../../../../common/constants'; import { UI_ERROR_SEVERITIES } from '../../../react-services/error-orchestrator/types'; import { getErrorOrchestrator } from '../../../react-services/common-services'; import { webDocumentationLink } from '../../../../common/services/web_documentation'; +import { getRemoteConfiguration } from './register-agent-service' const architectureButtons = [ { @@ -220,26 +221,8 @@ export const RegisterAgent = withErrorBoundary( async getRemoteInfo() { try { - const result = await WzRequest.apiReq('GET', '/agents/000/config/request/remote', {}); - const remote = ((result.data || {}).data || {}).remote || {}; - const remoteFiltered = remote.filter((item) => { - return ( - item.connection === 'secure' - ) - }) - if (remoteFiltered.length === 0) { - this.setState({ connectionSecure: false }) - } else { - remoteFiltered.forEach((item) => { - if (item.connection === 'secure') { - if(item.protocol.length === 1 && item.protocol[0] == 'UDP') { - this.setState({ udpProtocol: true, connectionSecure: true}); - } - if(item.protocol.length > 1 && item.protocol[0] == 'TCP') { - this.setState({ udpProtocol: false, connectionSecure: true}); - } - } - })} + let config = await getRemoteConfiguration(); + this.setState({ udpProtocol: config.udpProtocol, connectionSecure: config.connectionSecure }); } catch (error) { throw new Error(error); }