Skip to content

Commit

Permalink
Fixed install macOS agent commands (#5888)
Browse files Browse the repository at this point in the history
### Description

Fix the macOS installation command
 
Closes #5886

## Evidence

## Intel (intel64)

![Captura de pantalla 2023-09-12 a la(s) 13 57
12](https://github.com/wazuh/wazuh-kibana-app/assets/6089438/fbdef941-d0c8-4d61-a1ec-922877132329)

![Captura de pantalla 2023-09-12 a la(s) 13 57
21](https://github.com/wazuh/wazuh-kibana-app/assets/6089438/d4c695d0-8ea2-4fc6-b6b2-7e0759aba6fa)

```bash
curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-4.6.0-1.intel64.pkg && echo "WAZUH_MANAGER='0.0.0.0' && WAZUH_AGENT_NAME='agent-name'" > /tmp/wazuh_envs && sudo installer -pkg ./wazuh-agent.pkg -target /
```

### Command output 

<img width="722" alt="Captura de pantalla 2023-09-12 a la(s) 13 50 56"
src="https://github.com/wazuh/wazuh-kibana-app/assets/6089438/9f8153be-dda7-4a6e-a016-949f61a0b53e">

### ossec.conf with parameters specified

<img width="521" alt="Captura de pantalla 2023-09-12 a la(s) 13 50 35"
src="https://github.com/wazuh/wazuh-kibana-app/assets/6089438/3c7ac29a-ad67-4407-962f-cf1d03967efd">



## Apple silicon (arm64)

![Captura de pantalla 2023-09-12 a la(s) 13 57
52](https://github.com/wazuh/wazuh-kibana-app/assets/6089438/767aedd3-9611-4462-b5e7-a25390f3f057)

![Captura de pantalla 2023-09-12 a la(s) 13 58
11](https://github.com/wazuh/wazuh-kibana-app/assets/6089438/3fe3d61d-6511-41a5-be80-dcdb24713bd3)

```bash
curl -so wazuh-agent.pkg https://packages.wazuh.com/4.x/macos/wazuh-agent-4.6.0-1.arm64.pkg && echo "WAZUH_MANAGER='0.0.0.0' && WAZUH_AGENT_NAME='agent-name'" > /tmp/wazuh_envs && sudo installer -pkg ./wazuh-agent.pkg -target /
```

### Command output 

<img width="682" alt="image"
src="https://github.com/wazuh/wazuh-kibana-app/assets/6089438/e9572921-cf1b-4151-ba42-fa8e321b67d3">

### ossec.conf with parameters specified

<img width="533" alt="image"
src="https://github.com/wazuh/wazuh-kibana-app/assets/6089438/eb0d4a5a-8495-4056-bc88-a101b6eab447">



### Test

1. Go to Agents section
2. Click Deploy new agent button
3. Select macOS operting system and complete the form
4. Check the installation and start commands

### Check List
- [x] All tests pass
  - [x] `yarn test:jest`
- [x] New functionality includes testing.
- [x] New functionality has been documented.
- [x] Update [CHANGELOG.md](./../CHANGELOG.md)
- [x] Commits are signed per the DCO using --signoff
  • Loading branch information
Tostti authored Sep 13, 2023
2 parents 153e81e + 6046d48 commit 03b6350
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ All notable changes to the Wazuh app project will be documented in this file.
- Fixed an error in the request body suggestions of API Console [#5521](https://github.com/wazuh/wazuh-kibana-app/pull/5521)
- Fixed some errors related to relative dirname of rule and decoder files [#5734](https://github.com/wazuh/wazuh-kibana-app/pull/5734)
- Fixed package URLs in aarch64 commands [#5879](https://github.com/wazuh/wazuh-kibana-app/pull/5879)
- Fixed install macOS agent commands [5888](https://github.com/wazuh/wazuh-kibana-app/pull/5888)

### Removed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ export class OptionalParametersManager<Params extends string> implements IOption
*/
getAllOptionalParams(paramsValues: IOptionalParameters<Params>){
// get keys for only the optional params with values !== ''
const optionalParams = Object.keys(paramsValues).filter(key => paramsValues[key as keyof typeof paramsValues] !== '') as Array<keyof typeof paramsValues>;
// when is array must have entries
const optionalParams = Object.keys(paramsValues).filter(
key => {
const value = paramsValues[key as keyof typeof paramsValues];
return Array.isArray(value) ? value.length > 0 : value !== ''
}) as Array<keyof typeof paramsValues>;
const resolvedOptionalParams: any = {};
for(const param of optionalParams){
if(!this.optionalParamsConfig[param]){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,20 @@ const getAllOptionalsMacos = (
['serverAddress', 'wazuhPassword', 'agentGroups', 'agentName', 'protocol'];

if (!optionals) return '';
return Object.entries(paramNameOrderList).reduce(
(acc, [key, value]) => {
if (optionals[value]) {
acc += `${optionals[value]}\\n`;
}
return acc;
},
'',
);

const paramsValueList = []

paramNameOrderList.forEach( paramName => {
if(optionals[paramName] && optionals[paramName] !== ''){
paramsValueList.push(optionals[paramName]);
}
})

if(paramsValueList.length){
return paramsValueList.join(' && ');
}

return '';
};

/******* DEB *******/
Expand Down Expand Up @@ -139,7 +144,7 @@ export const getMacOsInstallCommand = (

// If no variables are set, the echo will be empty
const macOSInstallationSetEnvVariablesScript = macOSInstallationOptions
? `echo -e "${macOSInstallationOptions}" > /tmp/wazuh_envs && `
? `echo "${macOSInstallationOptions}" > /tmp/wazuh_envs && `
: ``;

// Merge environment variables with installation script
Expand Down

0 comments on commit 03b6350

Please sign in to comment.