wazuh / qa-system-framework

GNU General Public License v2.0
1 stars 3 forks source link

Wazuh Handler: In infrastructures with more than one macOS host, certain methods fail due to IP address duplication #76

Closed pro-akim closed 2 months ago

pro-akim commented 9 months ago

Wazuh Handler: In infrastructures with more than one macOS host, certain methods fail due to IP address duplication.

Tested: https://ci.wazuh.info/job/Wazuh_QA_environment/725/

inventory example ``` manager: hosts: manager1: ip: 172.31.9.219 version: 4.6.0 revision: 1 repository: live type: master os: ubuntu_22 service: EC2 resources: cpu: 4 memory: 8192 ansible_host: 172.31.9.219 ansible_user: qa ansible_connection: ssh architecture: amd64 os_name: linux ansible_become: 'true' ansible_python_interpreter: python3 manager2: ip: 172.31.10.236 version: 4.6.0 revision: 1 repository: live type: worker os: ubuntu_22 service: EC2 resources: cpu: 2 memory: 4096 ansible_host: 172.31.10.236 ansible_user: qa ansible_connection: ssh architecture: amd64 os_name: linux ansible_become: 'true' ansible_python_interpreter: python3 vars: {} filebeat: hosts: manager1: ip: 172.31.9.219 os: ubuntu_22 service: EC2 resources: cpu: 4 memory: 8192 ansible_host: 172.31.9.219 ansible_user: qa ansible_connection: ssh architecture: amd64 os_name: linux ansible_become: 'true' ansible_python_interpreter: python3 manager2: ip: 172.31.10.236 os: ubuntu_22 service: EC2 resources: cpu: 2 memory: 4096 ansible_host: 172.31.10.236 ansible_user: qa ansible_connection: ssh architecture: amd64 os_name: linux ansible_become: 'true' ansible_python_interpreter: python3 vars: {} indexer: hosts: manager1: ip: 172.31.9.219 version: 4.6.0 revision: 1 repository: live os: ubuntu_22 service: EC2 resources: cpu: 4 memory: 8192 ansible_host: 172.31.9.219 ansible_user: qa ansible_connection: ssh architecture: amd64 os_name: linux ansible_become: 'true' ansible_python_interpreter: python3 indexer_user: admin indexer_password: changeme vars: {} agent: children: linux: hosts: {} macos: hosts: agent1: ip: 10.10.0.251 version: 4.6.0 revision: 1 repository: live manager: manager1 os: macos service: vagrant ansible_host: 10.10.0.251 ansible_port: 42086 ansible_password: vagrant ansible_user: vagrant ansible_connection: ssh os_name: macos architecture: amd64 ansible_become: 'true' ansible_python_interpreter: /usr/bin/python3 manager_ip: 172.31.9.219 agent2: ip: 10.10.0.251 version: 4.6.0 revision: 1 repository: live manager: manager2 os: macos service: vagrant ansible_host: 10.10.0.251 ansible_port: 3522 ansible_password: vagrant ansible_user: vagrant ansible_connection: ssh os_name: macos architecture: amd64 ansible_become: 'true' ansible_python_interpreter: /usr/bin/python3 manager_ip: 172.31.10.236 agent3: ip: 10.10.0.251 version: 4.6.0 revision: 1 repository: live manager: manager1 os: macos service: vagrant ansible_host: 10.10.0.251 ansible_port: 40718 ansible_password: vagrant ansible_user: vagrant ansible_connection: ssh os_name: macos architecture: amd64 ansible_become: 'true' ansible_python_interpreter: /usr/bin/python3 manager_ip: 172.31.9.219 solaris: hosts: {} windows: hosts: {} all: vars: ansible_ssh_common_args: -o StrictHostKeyChecking=no ansible_winrm_server_cert_validation: ignore ansible_ssh_private_key_file: xxx.pem ```

When in the infrastructure there are more than 2 macOS hosts, certain methods fails as: Examples:


wh.check_agent_group('manager1', 'agent1', 'default')
False 

Expected result: True


wh.get_agents_names_in_group('manager1', 'default')
2023-11-22 15:25:05,686 - INFO - Requesting agent info using API [WazuhEnvironmentHandler get_agents_names_in_group:1044]
[] 

Expected result agent1, agent2, agent3


wh.get_agents_id(['agent1', 'agent2'])
Traceback (most recent call last):
  File "/home/akim/Desktop/trash/test2.py", line 83, in <module>
    wh.get_agents_id(['agent1', 'agent2'])
  File "/home/akim/Desktop/venvs/qa-system-env/lib/python3.10/site-packages/wazuh_qa_framework/system/wazuh_handler.py", line 645, in get_agents_id
    return self.wazuh_api.get_agents_id(host_ip_list=hosts_ip_list)
  File "/home/akim/Desktop/venvs/qa-system-env/lib/python3.10/site-packages/wazuh_qa_framework/wazuh_components/api/wazuh_api_request.py", line 80, in wrapper
    return func(obj, *args, **kwargs)
  File "/home/akim/Desktop/venvs/qa-system-env/lib/python3.10/site-packages/wazuh_qa_framework/wazuh_components/api/wazuh_api.py", line 149, in get_agents_id
    raise Exception('Agent not registered')
Exception: Agent not registered

Expected result: 001, 002

All the methods should be double-checked and fixed.

davidjiglesias commented 2 months ago

To be evaluated as part of Wazuh packages redesign tier 2