Skip to content

Commit

Permalink
Revert "Merge branch 'extend-add-new-agent-1767' of https://github.co…
Browse files Browse the repository at this point in the history
…m/wazuh/wazuh-kibana-app"

This reverts commit 7e56d49, reversing
changes made to 7706a2e.
  • Loading branch information
juankaromo committed Sep 26, 2019
1 parent 09ef325 commit 6724d12
Show file tree
Hide file tree
Showing 8 changed files with 318 additions and 455 deletions.
44 changes: 3 additions & 41 deletions public/controllers/agent/agents-preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,9 @@ export class AgentsPreviewController {

this.registerAgentsProps = {
addNewAgent: flag => this.addNewAgent(flag),
getWazuhVersion: () => this.getWazuhVersion(),
getCurrentApiAddress: () => this.getCurrentApiAddress(),
needsPassword: () => this.needsPassword()
getWazuhVersion: () => this.getWazuhVersion()
};
this.hasAgents = true;

this.init = false;
//Load
this.load();
Expand Down Expand Up @@ -232,12 +230,7 @@ export class AgentsPreviewController {
this.lastAgent = unique.lastAgent;
this.summary = unique.summary;
if (!this.lastAgent || !this.lastAgent.id) {
if (this.addingNewAgent === undefined) {
this.addNewAgent(true);
}
this.hasAgents = false;
} else {
this.hasAgents = true;
this.addNewAgent(true);
}

if (agentsTop.data.data === '') {
Expand Down Expand Up @@ -292,37 +285,6 @@ export class AgentsPreviewController {
);
}

/**
* Returns if the password is neccesary to register a new agent
*/
async needsPassword() {
try {
const result = await this.apiReq.request('GET', '/agents/000/config/auth/auth', {});
const auth = ((result.data || {}).data || {}).auth || {};
const usePassword = auth.use_password === 'yes';
return usePassword;

} catch (error) {
return false;
}
}

/**
* Returns the current API address
*/
async getCurrentApiAddress() {
try {
const result = await this.genericReq.request('GET', '/elastic/apis');
const entries = result.data || [];
const host = entries.filter(e => {return e._id == this.api});
const url = host[0]._source.url;
const numToClean = url.startsWith('https://') ? 8 : 7;
return url.substr(numToClean);
} catch (error) {
return false;
}
}

/**
* Returns the Wazuh version as x.y.z
*/
Expand Down
61 changes: 11 additions & 50 deletions public/controllers/agent/components/register-agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,15 @@ export class RegisterAgent extends Component {
this.state = {
status: 'incomplete',
selectedOS: '',
serverAddress: '',
wazuhPassword: ''
serverAddress: ''
};
}

async componentDidMount() {
try {
const wazuhVersion = await this.props.getWazuhVersion();
const apiAddress = await this.props.getCurrentApiAddress();
const needsPassword = await this.props.needsPassword();
this.setState({
serverAddress: apiAddress,
needsPassword: needsPassword,
wazuhVersion: wazuhVersion
})
this.wazuhVersion = await this.props.getWazuhVersion();
} catch (error) {
this.setState({
wazuhVersion: version
})
this.wazuhVersion = version;
}
}

Expand All @@ -69,21 +59,6 @@ export class RegisterAgent extends Component {
this.setState({ serverAddress: event.target.value });
}

setWazuhPassword(event) {
this.setState({ wazuhPassword: event.target.value });
}

/**
* Checks if the password is not needed, in that case remove the input password step
* @param {Array} steps
*/
cleanSteps(steps) {
if (this.state.needsPassword) return steps;
steps.splice(2,1);
return steps;
}


render() {
const rpmButton = (
<EuiButtonToggle
Expand Down Expand Up @@ -125,14 +100,6 @@ export class RegisterAgent extends Component {
/>
);

const passwordInput = (
<EuiFieldText
placeholder="Wazuh password..."
value={this.state.wazuhPassword}
onChange={event => this.setWazuhPassword(event)}
/>
);

const copyButton = {
position: 'relative',
float: 'right',
Expand All @@ -145,10 +112,10 @@ export class RegisterAgent extends Component {
zIndex: '100'
};
const customTexts = {
rpmText: `sudo WAZUH_MANAGER_IP='${this.state.serverAddress}'${this.state.needsPassword ? ` WAZUH_PASSWORD='${this.state.wazuhPassword}' ` : ' '}yum install https://packages.wazuh.com/3.x/yum/wazuh-agent-${this.state.wazuhVersion}-1.x86_64.rpm`,
debText: `curl -so wazuh-agent.deb https://packages.wazuh.com/3.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.state.wazuhVersion}-1_amd64.deb && sudo WAZUH_MANAGER_IP='${this.state.serverAddress}'${this.state.needsPassword ? ` WAZUH_PASSWORD='${this.state.wazuhPassword}' ` : ' '} dpkg -i ./wazuh-agent.deb`,
macosText: `curl -so wazuh-agent.pkg https://packages.wazuh.com/3.x/osx/wazuh-agent-${this.state.wazuhVersion}-1.pkg && sudo launchctl setenv WAZUH_MANAGER_IP '${this.state.serverAddress}'${this.state.needsPassword ? ` setenv WAZUH_PASSWORD '${this.state.wazuhPassword}' ` : ' '} && sudo installer -pkg ./wazuh-agent.pkg -target /`,
winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/3.x/windows/wazuh-agent-${this.state.wazuhVersion}-1.msi -OutFile wazuh-agent.msi; wazuh-agent.msi /q ADDRESS='${this.state.serverAddress}' AUTHD_SERVER='${this.state.serverAddress}'${this.state.needsPassword ? ` PASSWORD='${this.state.wazuhPassword}' ` : ' '}`
rpmText: `sudo WAZUH_MANAGER_IP='${this.state.serverAddress}' yum install https://packages.wazuh.com/3.x/yum/wazuh-agent-${this.wazuhVersion}-1.x86_64.rpm`,
debText: `curl -so wazuh-agent.deb https://packages.wazuh.com/3.x/apt/pool/main/w/wazuh-agent/wazuh-agent_${this.wazuhVersion}-1_amd64.deb && sudo WAZUH_MANAGER_IP='${this.state.serverAddress}' dpkg -i ./wazuh-agent.deb`,
macosText: `curl -so wazuh-agent.pkg https://packages.wazuh.com/3.x/osx/wazuh-agent-${this.wazuhVersion}-1.pkg && sudo launchctl setenv WAZUH_MANAGER_IP '${this.state.serverAddress}' && sudo installer -pkg ./wazuh-agent.pkg -target /`,
winText: `Invoke-WebRequest -Uri https://packages.wazuh.com/3.x/windows/wazuh-agent-${this.wazuhVersion}-1.msi -OutFile wazuh-agent.msi; wazuh-agent.msi /q ADDRESS='${this.state.serverAddress}' AUTHD_SERVER='${this.state.serverAddress}'`
};

const field = `${this.state.selectedOS}Text`;
Expand Down Expand Up @@ -199,10 +166,6 @@ export class RegisterAgent extends Component {
title: 'Wazuh server address',
children: <Fragment>{ipInput}</Fragment>
},
{
title: 'Wazuh password',
children: <Fragment>{passwordInput}</Fragment>
},
{
title: 'Complete the installation',
children: (
Expand All @@ -217,12 +180,12 @@ export class RegisterAgent extends Component {

return (
<div>
<EuiPage restrictWidth="1000px" style={{background: "transparent"}} >
<EuiPage restrictWidth="1000px">
<EuiPageBody>
<EuiFlexGroup>
<EuiFlexItem>
<EuiTitle>
<h2>Deploy a new agent</h2>
<h2>Add a new agent</h2>
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -239,7 +202,7 @@ export class RegisterAgent extends Component {
<EuiFlexItem>
<EuiPanel>
<EuiFlexItem>
<EuiSteps steps={this.cleanSteps(steps)} />
<EuiSteps steps={steps} />
</EuiFlexItem>
</EuiPanel>
</EuiFlexItem>
Expand All @@ -253,7 +216,5 @@ export class RegisterAgent extends Component {

RegisterAgent.propTypes = {
addNewAgent: PropTypes.func,
getWazuhVersion: PropTypes.func,
getCurrentApiAddress: PropTypes.func,
needsPassword: PropTypes.func
getWazuhVersion: PropTypes.func
};
Loading

0 comments on commit 6724d12

Please sign in to comment.