Skip to content
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

Fix AR tests and execd library. #4511

Merged
merged 2 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Release report: TBD

### Fixed

- Fix an error in AR library and test ([#4508](https://github.com/wazuh/wazuh-qa/pull/4390)) \- (Framework + Tests)
- Fix provisioned pytest failure fixed ([#4520](https://github.com/wazuh/wazuh-qa/pull/4520)) \- (Framework)
- Fix FIM framework to validate path in event correctly ([#4390](https://github.com/wazuh/wazuh-qa/pull/4390)) \- (Framework)
- Fix an error related to logs format in reliability test ([#4387](https://github.com/wazuh/wazuh-qa/pull/4387)) \- (Tests)
Expand Down
2 changes: 1 addition & 1 deletion deps/wazuh_testing/wazuh_testing/execd.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def wait_ended_message_line(line):

def wait_received_message_line(line):
"""Callback function to wait for the Received Active Response message."""
regex = r'.*wazuh-execd.+ExecdStart\(\): DEBUG: Received message: \S+'
regex = r'.*DEBUG: Received message: .+'
match = re.match(regex, line)

return None if not match else line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

os_platform:
- linux
- windows

os_version:
- Arch Linux
Expand All @@ -36,6 +37,9 @@
- Red Hat 8
- Ubuntu Focal
- Ubuntu Bionic
- Windows 10
- Windows Server 2019
- Windows Server 2016

references:
- https://documentation.wazuh.com/current/user-manual/capabilities/active-response/#active-response
Expand All @@ -57,7 +61,8 @@

pytestmark = [pytest.mark.linux, pytest.mark.win32, pytest.mark.tier(level=0), pytest.mark.agent]

CONF_FOLDER = '' if platform.system() == 'Windows' else 'etc'
CURRENT_PLATFORM = platform.system()
CONF_FOLDER = '' if CURRENT_PLATFORM == 'Windows' else 'etc'
CLIENT_KEYS_PATH = os.path.join(WAZUH_PATH, CONF_FOLDER, 'client.keys')
SERVER_KEY_PATH = os.path.join(WAZUH_PATH, CONF_FOLDER, 'manager.key')
SERVER_CERT_PATH = os.path.join(WAZUH_PATH, CONF_FOLDER, 'manager.cert')
Expand Down Expand Up @@ -126,7 +131,7 @@ def start_agent(request, get_configuration):
time.sleep(1)

control_service('stop')
agent_auth_pat = 'bin' if platform.system() == 'Linux' else ''
agent_auth_pat = 'bin' if CURRENT_PLATFORM == 'Linux' else ''
subprocess.call([f'{WAZUH_PATH}/{agent_auth_pat}/agent-auth', '-m',
SERVER_ADDRESS])
control_service('start')
Expand All @@ -145,7 +150,7 @@ def get_configuration(request):

def wait_message_line(line):
"""Callback function to wait for Active Response JSON message."""
if platform.system() == 'Windows' and "active-response/bin/restart-wazuh.exe: {\"version\"" in line:
if CURRENT_PLATFORM == 'Windows' and "active-response/bin/restart-wazuh.exe: {\"version\"" in line:
return True
elif "active-response/bin/restart-wazuh: {\"version\"" in line:
return True
Expand Down Expand Up @@ -238,15 +243,17 @@ def test_execd_restart(set_debug_mode, get_configuration, test_version,
# Checking AR in ossec logs
ossec_log_monitor.start(timeout=60, callback=execd.wait_received_message_line)

# Checking AR in active-response logs
ar_log_monitor.start(timeout=60, callback=execd.wait_start_message_line)
# Checking AR in active-response logs (only in Linux systems)
if CURRENT_PLATFORM == 'Linux':
ar_log_monitor.start(timeout=60, callback=execd.wait_start_message_line)

if expected['success']:
ar_log_monitor.start(timeout=60, callback=wait_message_line)

# Checking shutdown message in ossec logs
ossec_log_monitor.start(timeout=60, callback=wait_shutdown_message_line)

ar_log_monitor.start(timeout=60, callback=execd.wait_ended_message_line)
if CURRENT_PLATFORM == 'Linux':
ar_log_monitor.start(timeout=60, callback=execd.wait_ended_message_line)
else:
ar_log_monitor.start(timeout=60, callback=wait_invalid_input_message_line)