From 6d22b61d2fa44842d6afd33a6e21a6823d8caa56 Mon Sep 17 00:00:00 2001 From: Antonio Date: Mon, 22 Apr 2024 11:35:20 +0200 Subject: [PATCH] fix(#5229): Fixing connection check ostype --- .../modules/testing/tests/helpers/agent.py | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/deployability/modules/testing/tests/helpers/agent.py b/deployability/modules/testing/tests/helpers/agent.py index bcabfb114d..79ea11044d 100644 --- a/deployability/modules/testing/tests/helpers/agent.py +++ b/deployability/modules/testing/tests/helpers/agent.py @@ -313,10 +313,10 @@ def assert_results(result, agent_params) -> None: result (dict): result of comparison between pre and post action scan """ - os_name = HostInformation.get_os_name_from_inventory(agent_params) - if os_name == 'linux': + os_type = HostInformation.get_os_type(agent_params) + if os_type == 'linux': categories = ['/root', '/usr/bin', '/usr/sbin', '/boot'] - elif os_name == 'macos': + elif os_type == 'macos': categories = ['/usr/bin', '/usr/sbin'] actions = ['added', 'modified', 'removed'] @@ -337,21 +337,21 @@ def areAgent_processes_active(agent_params): """ return bool([int(numero) for numero in Executor.execute_command(agent_params, 'pgrep wazuh').splitlines()]) - def isAgent_port_open(agent_params): + def isAgent_port_open(inventory_path): """ Check if agent port is open Args: - agent_name (str): Agent name. + inventory_path (str): Agent inventory path. Returns: str: Os name. """ - os_name = HostInformation.get_os_name_from_inventory(agent_params) - if os_name == 'linux': - return 'ESTAB' in Executor.execute_command(agent_params, 'ss -t -a -n | grep ":1514" | grep ESTAB') - elif os_name == 'macos': - return 'ESTABLISHED' in Executor.execute_command(agent_params, 'netstat -an | grep ".1514 " | grep ESTABLISHED') + os_type = HostInformation.get_os_type(inventory_path) + if os_type == 'linux': + return 'ESTAB' in Executor.execute_command(inventory_path, 'ss -t -a -n | grep ":1514" | grep ESTAB') + elif os_type == 'macos': + return 'ESTABLISHED' in Executor.execute_command(inventory_path, 'netstat -an | grep ".1514 " | grep ESTABLISHED') def get_agents_information(wazuh_api: WazuhAPI) -> list: """