From e9df6ba3045d25ad6cd549a256aef918ae89f6ab Mon Sep 17 00:00:00 2001 From: Deblintrake09 Date: Mon, 28 Nov 2022 14:21:33 -0300 Subject: [PATCH] refactor(#1915): refactor fim framework --- .../wazuh_testing/modules/fim/__init__.py | 1 - .../wazuh_testing/modules/fim/utils.py | 20 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/deps/wazuh_testing/wazuh_testing/modules/fim/__init__.py b/deps/wazuh_testing/wazuh_testing/modules/fim/__init__.py index 3635f9a115..62731fbd4b 100644 --- a/deps/wazuh_testing/wazuh_testing/modules/fim/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/modules/fim/__init__.py @@ -180,7 +180,6 @@ CB_REALTIME_MONITORED_FOLDERS = r'.*Folders monitored with real-time engine: (\d+)' CB_REALTIME_WHODATA_ENGINE_STARTED = 'File integrity monitoring real-time Whodata engine started' CB_INVALID_CONFIG_VALUE = r".*Invalid value for element '(.*)': (.*)." - CB_INTEGRITY_CONTROL_MESSAGE = r".*Sending integrity control message: (.+)$" CB_MAXIMUM_FILE_SIZE = r".*Maximum file size limit to generate diff information configured to \'(\d+) KB\'.*" CB_AGENT_CONNECT = r".* Connected to the server .*" diff --git a/deps/wazuh_testing/wazuh_testing/modules/fim/utils.py b/deps/wazuh_testing/wazuh_testing/modules/fim/utils.py index 941cffca23..d0db56322f 100644 --- a/deps/wazuh_testing/wazuh_testing/modules/fim/utils.py +++ b/deps/wazuh_testing/wazuh_testing/modules/fim/utils.py @@ -106,6 +106,26 @@ def create_registry(key, subkey, arch): logger.warning(f"Registry could not be created: {e}") +def modify_registry_value(key_h, value_name, type, value): + """ + Modify the content of a registry. If the value doesn't not exists, it will be created. + + Args: + key_h (pyHKEY): the key handle of the registry. + value_name (str): the value to be set. + type (int): type of the value. + value (str): the content that will be written to the registry value. + """ + if sys.platform == 'win32': + try: + logger.info(f"Modifying value '{value_name}' of type {fim.registry_value_type[type]} and value '{value}'") + win32api.RegSetValueEx(key_h, value_name, 0, type, value) + except OSError as e: + logger.warning(f"Could not modify registry value content: {e}") + except pywintypes.error as e: + logger.warning(f"Could not modify registry value content: {e}") + + def delete_registry(key, subkey, arch): """Delete a registry key.