3166-T8-R2-e2e-juliamagan.html

Report generated on 29-Aug-2022 at 10:34:34 by pytest-html v3.1.1

Environment

Packages {"pluggy": "0.13.1", "py": "1.10.0", "pytest": "6.2.2"}
Platform Linux-5.18.10-76051810-generic-x86_64-with-glibc2.35
Plugins {"html": "3.1.1", "metadata": "2.0.1", "testinfra": "5.0.0"}
Python 3.9.7

Summary

1 tests ran in 143.95 seconds.

0 passed, 0 skipped, 1 failed, 0 errors, 0 expected failures, 0 unexpected passes

Results

Result Test Duration Links
Failed tests/end_to_end/test_basic_cases/test_suricata_integration/test_suricata_integration.py::test_suricata_integration[trigger_emerging_policy_rule] 143.82
configure_environment = None
metadata = {'description': 'Test the detection of threats by monitoring network traffic. The test generates a specific web reques...trigger_emerging_policy_rule', 'rule.description': 'Suricata: Alert - GPL ATTACK_RESPONSE id check returned root', ...}
get_dashboard_credentials = {'password': 'admin', 'user': 'admin'}, get_manager_ip = '172.31.2.132'
generate_events = None, clean_alerts_index = None

@pytest.mark.filterwarnings('ignore::urllib3.exceptions.InsecureRequestWarning')
@pytest.mark.parametrize('metadata', configuration_metadata, ids=cases_ids)
def test_suricata_integration(configure_environment, metadata, get_dashboard_credentials, get_manager_ip,
generate_events, clean_alerts_index):
'''
description: Check that an alert is generated when a specific web request is executed.

test_phases:
- Set a custom Wazuh configuration.
- Execute a web request known to trip NIDS rules to generate the event.
- Check in the alerts.json log that the expected alert has been triggered and get its timestamp.
- Check that the obtained alert from alerts.json has been indexed.

wazuh_min_version: 4.4.0

tier: 0

parameters:
- configurate_environment:
type: fixture
brief: Set the wazuh configuration according to the configuration playbook.
- metadata:
type: dict
brief: Wazuh configuration metadata.
- get_dashboard_credentials:
type: fixture
brief: Get the wazuh dashboard credentials.
- generate_events:
type: fixture
brief: Generate events that will trigger the alert according to the generate_events playbook.
- clean_alerts_index:
type: fixture
brief: Delete obtained alerts.json and alerts index.

assertions:
- Verify that the alert has been triggered.
- Verify that the same alert has been indexed.

input_description:
- The `configuration.yaml` file provides the module configuration for this test.
- The `generate_events.yaml`file provides the function configuration for this test.
'''
rule_level = metadata['rule.level']
rule_description = metadata['rule.description']
rule_id = metadata['rule.id']
data_hostname = metadata['extra']['data.hostname']
timestamp_regex = r'\d{4}-\d+-\d+T\d+:\d+:\d+\.\d+[+|-]\d+'

expected_alert_json = fr".*timestamp.+({timestamp_regex}).+level.+{rule_level}.+description.+{rule_description}.+" \
fr"id.+{rule_id}.+hostname.+{data_hostname}"
expected_indexed_alert = fr".*hostname.*{data_hostname}.+level.+{rule_level}.+description.+" \
fr"{rule_description}.+id.+{rule_id}"

# Check that alert has been raised and save timestamp
> raised_alert = evm.check_event(callback=expected_alert_json, file_to_monitor=alerts_json,
timeout=fw.T_5, error_message='The alert has not occurred').result()

tests/end_to_end/test_basic_cases/test_suricata_integration/test_suricata_integration.py:119:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/root/.pyenv/versions/3.9.7/lib/python3.9/site-packages/wazuh_testing-4.3.0-py3.9.egg/wazuh_testing/event_monitor.py:36: in check_event
result = file_monitor.start(timeout=timeout, update_position=update_position, accum_results=accum_results,
/root/.pyenv/versions/3.9.7/lib/python3.9/site-packages/wazuh_testing-4.3.0-py3.9.egg/wazuh_testing/tools/monitoring.py:201: in start
self._result = monitor.start(timeout=timeout, callback=callback, accum_results=accum_results,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <wazuh_testing.tools.monitoring.QueueMonitor object at 0x7f98bf36a790>, timeout = 5
callback = <function make_callback.<locals>.<lambda> at 0x7f98bfd3b4c0>, accum_results = 1
update_position = True, timeout_extra = 0, error_message = 'The alert has not occurred'

def start(self, timeout=-1, callback=_callback_default, accum_results=1, update_position=True, timeout_extra=0,
error_message=''):
"""Start the queue monitoring until the stop method is called."""
if not self._continue:
self._continue = True
self._abort = False
result = None

while self._continue:
if self._abort:
self.stop()
if error_message:
logger.error(error_message)
logger.error(f"Results accumulated: "
f"{len(result) if isinstance(result, list) else 0}")
logger.error(f"Results expected: {accum_results}")
> raise TimeoutError(error_message)
E TimeoutError: The alert has not occurred

/root/.pyenv/versions/3.9.7/lib/python3.9/site-packages/wazuh_testing-4.3.0-py3.9.egg/wazuh_testing/tools/monitoring.py:469: TimeoutError
-----------------------------Captured stdout setup------------------------------
PLAY [localhost] *************************************************************** TASK [Gathering Facts] ********************************************************* ok: [localhost] TASK [Generate a general validation playbook] ********************************** changed: [localhost] PLAY RECAP ********************************************************************* localhost : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 PLAY [General validation phase] ************************************************ TASK [Gathering Facts] ********************************************************* ok: [centos-manager] ok: [ubuntu-agent] TASK [host_checker : Set flag and informative variable] ************************ ok: [centos-manager] ok: [ubuntu-agent] TASK [host_checker : Check default Python version (Linux)] ********************* skipping: [centos-manager] skipping: [ubuntu-agent] TASK [host_checker : Get Python version (Windows)] ***************************** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [host_checker : Check default Python version (Windows)] ******************* skipping: [centos-manager] skipping: [ubuntu-agent] TASK [host_checker : Check OS (Linux)] ***************************************** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [host_checker : Check OS (Windows)] *************************************** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [Get Wazuh installation] ************************************************** TASK [service_controller : Get installation type] ****************************** changed: [centos-manager] changed: [ubuntu-agent] TASK [host_checker : Populate services facts] ********************************** ok: [centos-manager] ok: [ubuntu-agent] TASK [host_checker : Check the status of Wazuh components (Manager)] *********** skipping: [centos-manager] => (item=wazuh-manager.service) skipping: [centos-manager] => (item=wazuh-indexer.service) skipping: [centos-manager] => (item=filebeat.service) skipping: [ubuntu-agent] => (item=wazuh-manager.service) skipping: [ubuntu-agent] => (item=wazuh-indexer.service) skipping: [ubuntu-agent] => (item=filebeat.service) TASK [host_checker : set_fact] ************************************************* skipping: [centos-manager] ok: [ubuntu-agent] TASK [host_checker : Check the status of Wazuh Agent] ************************** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [Get Wazuh installation] ************************************************** TASK [service_controller : Get installation type] ****************************** changed: [centos-manager] changed: [ubuntu-agent] TASK [host_checker : Run filebeat test] **************************************** skipping: [ubuntu-agent] changed: [centos-manager] TASK [host_checker : Check the connection between Filebeat and Wazuh Indexer] *** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [Get Wazuh installation] ************************************************** TASK [service_controller : Get installation type] ****************************** changed: [centos-manager] changed: [ubuntu-agent] TASK [host_checker : Test connection with Wazuh Indexer] *********************** skipping: [ubuntu-agent] fatal: [centos-manager -> localhost]: FAILED! => {"changed": false, "msg": "The shell action failed to execute in the expected time frame (3) and was terminated"} ...ignoring TASK [host_checker : Check the connection between Controller node and Wazuh Indexer] *** skipping: [centos-manager] skipping: [ubuntu-agent] TASK [host_checker : set_fact] ************************************************* ok: [centos-manager] ok: [ubuntu-agent] TASK [host_checker : Verify if any check have failed] ************************** skipping: [centos-manager] skipping: [ubuntu-agent] PLAY RECAP ********************************************************************* centos-manager : ok=9 changed=4 unreachable=0 failed=0 skipped=11 rescued=0 ignored=1 ubuntu-agent : ok=8 changed=3 unreachable=0 failed=0 skipped=12 rescued=0 ignored=0 PLAY [Configure Ubuntu agent environment] ************************************** TASK [Gathering Facts] ********************************************************* ok: [ubuntu-agent] TASK [Configure Wazuh to read Suricata logs file] ****************************** TASK [manage_wazuh_configurations : Configure ossec.conf linux] **************** ok: [ubuntu-agent] TASK [manage_wazuh_configurations : Configure ossec.conf windows] ************** skipping: [ubuntu-agent] TASK [Restart wazuh-agent to apply the change] ********************************* TASK [manage_wazuh : Get installation type] ************************************ changed: [ubuntu-agent] TASK [manage_wazuh : Restart manager service on linux] ************************* skipping: [ubuntu-agent] TASK [manage_wazuh : Restart agent service on linux] *************************** changed: [ubuntu-agent] TASK [manage_wazuh : Restart wazuh on Windows] ********************************* skipping: [ubuntu-agent] TASK [Check if Suricata is installed] ****************************************** fatal: [ubuntu-agent]: FAILED! => {"changed": true, "cmd": "dpkg -l suricata | grep suricata", "delta": "0:00:00.011772", "end": "2022-08-29 08:33:17.407337", "msg": "non-zero return code", "rc": 1, "start": "2022-08-29 08:33:17.395565", "stderr": "/bin/sh: dpkg: command not found", "stderr_lines": ["/bin/sh: dpkg: command not found"], "stdout": "", "stdout_lines": []} ...ignoring TASK [Add the repo to install Suricata] **************************************** skipping: [ubuntu-agent] TASK [Install Suricata] ******************************************************** skipping: [ubuntu-agent] TASK [Enable and stop Suricata] ************************************************ fatal: [ubuntu-agent]: FAILED! => {"changed": false, "msg": "Could not find the requested service suricata: host"} PLAY RECAP ********************************************************************* ubuntu-agent : ok=5 changed=3 unreachable=0 failed=1 skipped=5 rescued=0 ignored=1 { "ansible_connection": "ssh", "ansible_host": "172.31.2.132", "ansible_python_interpreter": "/usr/bin/python3", "ansible_ssh_private_key_file": "/home/juliamagan/Desktop/QA/imp/ephemeral_key", "ansible_user": "qa", "aws_access_key_id": "AKIA6B6B4XJHMKALDJGT", "aws_region": "us-east-1", "aws_secret_access_key": "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", "bucket_name": "aws-cloudtrail-logs-966237403726-09245154", "dashboard_password": "admin", "dashboard_user": "admin", "s3_url": "https://s3.amazonaws.com/ci.wazuh.com/qa/testing_files/end_to_end", "slack_channel": "C03EZKLR682", "slack_token": "xoxb-746532534132-3509688290194-ITgoGLhy542RzfE7p2FxVHVN", "virustotal_key": "3e4db70c621cd9dd9e3400254297eea03215987facca9931a42dcb86ffb8aa78", "web_hook_url": "https://hooks.slack.com/services/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" } { "ansible_connection": "ssh", "ansible_host": "172.31.2.132", "ansible_python_interpreter": "/usr/bin/python3", "ansible_ssh_private_key_file": "/home/juliamagan/Desktop/QA/imp/ephemeral_key", "ansible_user": "qa", "aws_access_key_id": "AKIA6B6B4XJHMKALDJGT", "aws_region": "us-east-1", "aws_secret_access_key": "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", "bucket_name": "aws-cloudtrail-logs-966237403726-09245154", "dashboard_password": "admin", "dashboard_user": "admin", "s3_url": "https://s3.amazonaws.com/ci.wazuh.com/qa/testing_files/end_to_end", "slack_channel": "C03EZKLR682", "slack_token": "xoxb-746532534132-3509688290194-ITgoGLhy542RzfE7p2FxVHVN", "virustotal_key": "3e4db70c621cd9dd9e3400254297eea03215987facca9931a42dcb86ffb8aa78", "web_hook_url": "https://hooks.slack.com/services/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" } PLAY [Clean alerts file] ******************************************************* TASK [Gathering Facts] ********************************************************* ok: [centos-manager] TASK [Truncate alert.json] ***************************************************** TASK [manage_alerts : Truncate file] ******************************************* changed: [centos-manager] PLAY [Generate events] ********************************************************* TASK [Gathering Facts] ********************************************************* ok: [ubuntu-agent] TASK [Run command to generate an alert] **************************************** changed: [ubuntu-agent] PLAY [Get alerts file] ********************************************************* TASK [Gathering Facts] ********************************************************* ok: [centos-manager] TASK [Wait for alerts to be generated] ***************************************** ok: [centos-manager] TASK [Get alert json] ********************************************************** TASK [manage_alerts : Get alerts.json] ***************************************** changed: [centos-manager] PLAY RECAP ********************************************************************* centos-manager : ok=5 changed=2 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 ubuntu-agent : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
------------------------------Captured stderr call------------------------------
2022-08-29 10:34:08,177 - wazuh_testing - ERROR - The alert has not occurred 2022-08-29 10:34:08,177 - wazuh_testing - ERROR - Results accumulated: 0 2022-08-29 10:34:08,177 - wazuh_testing - ERROR - Results expected: 1
-------------------------------Captured log call--------------------------------
ERROR wazuh_testing:monitoring.py:465 The alert has not occurred ERROR wazuh_testing:monitoring.py:466 Results accumulated: 0 ERROR wazuh_testing:monitoring.py:468 Results expected: 1
----------------------------Captured stdout teardown----------------------------
PLAY [Configure environment] *************************************************** TASK [Gathering Facts] ********************************************************* ok: [ubuntu-agent] TASK [Remove Wazuh logs configuration] ***************************************** ok: [ubuntu-agent] TASK [Restart wazuh-agent to apply the change] ********************************* TASK [manage_wazuh : Get installation type] ************************************ changed: [ubuntu-agent] TASK [manage_wazuh : Restart manager service on linux] ************************* skipping: [ubuntu-agent] TASK [manage_wazuh : Restart agent service on linux] *************************** changed: [ubuntu-agent] TASK [manage_wazuh : Restart wazuh on Windows] ********************************* skipping: [ubuntu-agent] PLAY RECAP ********************************************************************* ubuntu-agent : ok=4 changed=2 unreachable=0 failed=0 skipped=2 rescued=0 ignored=0