Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed install macOS agent commands #5888

Merged
merged 6 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Loading