-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add configuration methods #56
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GJ! Some minor changes are required
DEFAULT_INSTALL_PATH = { | ||
'linux': '/var/ossec', | ||
'windows': 'C:\\Program Files\\ossec-agent', | ||
'windows': 'C:/Program Files (x86)/ossec-agent', | ||
'darwin': '/Library/Ossec' | ||
} | ||
|
||
DEFAULT_TEMPORAL_DIRECTORY = { | ||
'linux': '/tmp', | ||
'windows': 'C:/Users/qa/AppData/Local/Temp' | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These vars should be moved into a common variables module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the development can be long and goes out of the scope of this PR, the following issue has been created and will be worked on:
def configure_local_internal_options(new_conf): | ||
local_internal_configuration_string = '' | ||
for option_name, option_value in new_conf.items(): | ||
local_internal_configuration_string += f"{str(option_name)}={str(option_value)}\n" | ||
return local_internal_configuration_string | ||
|
||
|
||
def configure_ossec_conf(new_conf, template): | ||
new_configuration = ''.join(set_section_wazuh_conf(new_conf, template)) | ||
return new_configuration | ||
|
||
|
||
def configure_api_yaml(new_conf): | ||
new_configuration = yaml.dump(new_conf) | ||
return new_configuration | ||
|
||
|
||
conf_functions = { | ||
'local_internal_options.conf': configure_local_internal_options, | ||
'ossec.conf': configure_ossec_conf, | ||
'agent.conf': configure_ossec_conf, | ||
'api.yaml': configure_api_yaml | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move all these functions to the configuration module.
Functions to get the directory path should be moved to a separate module too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ecc6d4c
@@ -340,7 +371,7 @@ def get_ruleset_directory_path(self, host): | |||
|
|||
return ruleset_directory_path | |||
|
|||
def configure_host(self, host, configuration_host): | |||
def configure_host(self, host, configuration_file, configuration_values): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update the examples in the docstring
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8aa3f89
parameters = {'new_conf': configuration_values} | ||
|
||
# Get template for ossec.conf and agent.conf | ||
if configuration_file == 'ossec.conf' or configuration_file == 'agent.conf': |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if configuration_file == 'ossec.conf' or configuration_file == 'agent.conf': | |
if configuration_file in ['ossec.conf', 'agent.conf']: |
We can also move that list into a variable called xml_configuration_files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 1deaf31
LGTM! 🚀 |
LGTM! |
Description
In this PR, functions have been added that will be used for the configuration of Wazuh nodes. This configuration can be done either in parallel or not.
The following functions have been added which are responsible for modifying and restoring the configuration:
configure_host()
.change_agents_configured_manager()
.backup_host_configuration()
.restore_host_backup_configuration()
In addition, the following functions have been added, which are responsible for executing the above functions in parallel when desired:
configure_environment()
.backup_environment_configuration()
.restore_environment_backup_configuration()
.The configuration expected by these functions will have the following format:
The supported files are
ossec.conf
,agent.conf
,api.yaml
andagent.conf