From d81c0ab2696e30d031495168f1526265fa3a0272 Mon Sep 17 00:00:00 2001 From: mauromalara Date: Tue, 28 Mar 2023 17:32:41 +0200 Subject: [PATCH 1/4] feat(#4058): remove the default credentials from code. --- .../wazuh_testing/tools/migration_tool/__init__.py | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/__init__.py b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/__init__.py index f425b1045f..7fa83e98e9 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/__init__.py @@ -16,13 +16,7 @@ SNAPSHOTS_DIR = f"{GENERATED_FILES_DIR}/snapshots" DOWNLOADS_DIR = f"{GENERATED_FILES_DIR}/downloads" UNCOMPRESSED_DIR = f"{GENERATED_FILES_DIR}/uncompressed" -MYSQL_CREDENTIALS = { - 'user': None, - 'password': None, - 'host': None, - 'port': None, - 'database': None -} +MYSQL_CREDENTIALS = None # Callback messages CB_PROCESS_STARTED = r'.+\[info\]\[Orchestrator - start\]: Starting process' From 95a7ece0302522e88564ed5904eb7d10a201a90c Mon Sep 17 00:00:00 2001 From: mauromalara Date: Wed, 29 Mar 2023 17:01:23 +0200 Subject: [PATCH 2/4] fix(#4059): fix importing a symbol instead of real var. --- .../wazuh_testing/tools/migration_tool/utils.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py index 8d73e6f013..81c1e2c65c 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py +++ b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py @@ -12,9 +12,10 @@ from jsonschema.exceptions import ValidationError from mysql.connector import errorcode +import wazuh_testing.tools.migration_tool as migration_tool from wazuh_testing.tools.migration_tool import MIGRATION_TOOL_PATH, CVE5_SCHEMA_PATH, DELTA_SCHEMA_PATH, \ ERROR_MESSAGES, SNAPSHOTS_DIR, DOWNLOADS_DIR, MIGRATION_TOOL_LOG_PATH, \ - MYSQL_CREDENTIALS, UNCOMPRESSED_DIR + UNCOMPRESSED_DIR from wazuh_testing.tools.file import delete_all_files_in_folder, read_json_file, truncate_file from wazuh_testing.tools.logging import Logging @@ -149,10 +150,10 @@ def query_publisher_db(query): try: connection = mysql.connector.connect( - host=MYSQL_CREDENTIALS['host'], - user=MYSQL_CREDENTIALS['user'], - password=MYSQL_CREDENTIALS['password'], - database=MYSQL_CREDENTIALS['database'] + host=migration_tool.MYSQL_CREDENTIALS['host'], + user=migration_tool.MYSQL_CREDENTIALS['user'], + password=migration_tool.MYSQL_CREDENTIALS['password'], + database=migration_tool.MYSQL_CREDENTIALS['database'] ) except mysql.connector.Error as error: connection = None From 0f4b6eed8772fb8881d7db5f319f9b1c46de2fdb Mon Sep 17 00:00:00 2001 From: mauromalara Date: Wed, 29 Mar 2023 17:59:38 +0200 Subject: [PATCH 3/4] docs(#4059): add change to the changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5bf6da3c2..6c9df56ad5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file. - Update Authd force_insert tests ([#3379](https://github.com/wazuh/wazuh-qa/pull/3379)) \- (Tests) - Update cluster logs in reliability tests ([#2772](https://github.com/wazuh/wazuh-qa/pull/2772)) \- (Tests) - Use correct version format in agent_simulator tool ([#3198](https://github.com/wazuh/wazuh-qa/pull/3198)) \- (Tools) +- Improve the way that environment data is managed ([#4059](https://github.com/wazuh/wazuh-qa/pull/4059)) \- (Framework) ### Fixed From c949a465fa1732eb955eba1329811e20ec11bb2e Mon Sep 17 00:00:00 2001 From: mauromalara Date: Wed, 19 Apr 2023 10:45:16 +0000 Subject: [PATCH 4/4] style(#4059): remove unused imports and fix CHANGELOG --- CHANGELOG.md | 3 ++- .../wazuh_testing/tools/migration_tool/utils.py | 15 ++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c9df56ad5..3e27a53755 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,8 @@ All notable changes to this project will be documented in this file. - Add new module to support migration tool. ([#3837](https://github.com/wazuh/wazuh-qa/pull/3837)) ### Changed + +- Improve the way that environment data is managed ([#4059](https://github.com/wazuh/wazuh-qa/pull/4059)) \- (Framework) - Update FIM test_ambiguous_confs IT to new framework ([#4121](https://github.com/wazuh/wazuh-qa/pull/4121)) \- (Tests + Framework) - Update `test_logcollector` invalid configs log level ([#4094](https://github.com/wazuh/wazuh-qa/pull/4094)) \- (Tests) - Update `test_office365` to support the new tag `API_TYPE` ([#4065](https://github.com/wazuh/wazuh-qa/pull/4065)) \- (Framework + Tests) @@ -31,7 +33,6 @@ All notable changes to this project will be documented in this file. - Update Authd force_insert tests ([#3379](https://github.com/wazuh/wazuh-qa/pull/3379)) \- (Tests) - Update cluster logs in reliability tests ([#2772](https://github.com/wazuh/wazuh-qa/pull/2772)) \- (Tests) - Use correct version format in agent_simulator tool ([#3198](https://github.com/wazuh/wazuh-qa/pull/3198)) \- (Tools) -- Improve the way that environment data is managed ([#4059](https://github.com/wazuh/wazuh-qa/pull/4059)) \- (Framework) ### Fixed diff --git a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py index 81c1e2c65c..64f8f3f4b1 100644 --- a/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py +++ b/deps/wazuh_testing/wazuh_testing/tools/migration_tool/utils.py @@ -13,9 +13,6 @@ from mysql.connector import errorcode import wazuh_testing.tools.migration_tool as migration_tool -from wazuh_testing.tools.migration_tool import MIGRATION_TOOL_PATH, CVE5_SCHEMA_PATH, DELTA_SCHEMA_PATH, \ - ERROR_MESSAGES, SNAPSHOTS_DIR, DOWNLOADS_DIR, MIGRATION_TOOL_LOG_PATH, \ - UNCOMPRESSED_DIR from wazuh_testing.tools.file import delete_all_files_in_folder, read_json_file, truncate_file from wazuh_testing.tools.logging import Logging @@ -43,11 +40,11 @@ def run_tool(cmd): return out, err for file_path in config_files: - truncate_file(MIGRATION_TOOL_LOG_PATH) - command = ' '.join([MIGRATION_TOOL_PATH, '-i', file_path, args]) + truncate_file(migration_tool.MIGRATION_TOOL_LOG_PATH) + command = ' '.join([migration_tool.MIGRATION_TOOL_PATH, '-i', file_path, args]) output, _ = run_tool(command) output = output.decode() - error_checker = [True for msg in ERROR_MESSAGES if msg in output] + error_checker = [True for msg in migration_tool.ERROR_MESSAGES if msg in output] if len(error_checker) > 0: errors += f"\n{output}" @@ -114,7 +111,7 @@ def validate_against_delta_schema(_elements): _result = True _errors = [] for cve in _elements: - _result, _error = validate_json_against_schema(cve, DELTA_SCHEMA_PATH) + _result, _error = validate_json_against_schema(cve, migration_tool.DELTA_SCHEMA_PATH) if _result is False: _errors.append(_error) @@ -132,7 +129,7 @@ def validate_against_cve5_schema(_elements): for cves in _elements: data = json.loads(cves['data_blob']) - _result, _error = validate_json_against_schema(data, CVE5_SCHEMA_PATH) + _result, _error = validate_json_against_schema(data, migration_tool.CVE5_SCHEMA_PATH) if _result is False: _errors.append(_error) @@ -176,7 +173,7 @@ def query_publisher_db(query): def clean_migration_tool_output_files(): '''Remove all files generated by Content Migration Tool. ''' - output_folders = [SNAPSHOTS_DIR, DOWNLOADS_DIR, UNCOMPRESSED_DIR] + output_folders = [migration_tool.SNAPSHOTS_DIR, migration_tool.DOWNLOADS_DIR, migration_tool.UNCOMPRESSED_DIR] for output_folder in output_folders: for folder in vendors: