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 inconsistencies in vulnerabilities for E2E Vulnerability tests #5710

Draft
wants to merge 8 commits into
base: 4.10.0
Choose a base branch
from
Draft
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ All notable changes to this project will be documented in this file.

### Added

- Adding jobflow templates ([#5680](https://github.com/wazuh/wazuh-qa/pull/5680/)) \- (Framework)
- Add RockyLinux 8.10 to Allocator module ([#5524](https://github.com/wazuh/wazuh-qa/pull/5524)) \- (Framework)
- Add Deployability testing tier 1 ([#5190](https://github.com/wazuh/wazuh-qa/pull/5190)) \- (Framework + Documentation + Tests)
- Add Workflow module to Wazuh-qa repository ([#4990](https://github.com/wazuh/wazuh-qa/pull/4990)) \- (Tests)
Expand All @@ -32,6 +33,7 @@ All notable changes to this project will be documented in this file.

### Fixed

- Fix playbook cleanup.yaml ([#5672](https://github.com/wazuh/wazuh-qa/pull/5672)) \- (Tests)
- Fixed unnecesary reference to debian file in dashboard provisioning task ([#5643](https://github.com/wazuh/wazuh-qa/pull/5643)) \- (Framework)
- Changed 'Ensure that the manager version is' expected warning to an agnostic version of regex ([#5630](https://github.com/wazuh/wazuh-qa/pull/5630)) \- (Tests)
- Adding fixed and dynamic waits to port status checks ([#5627](https://github.com/wazuh/wazuh-qa/pull/5627)) (Framework)
Expand Down
33 changes: 33 additions & 0 deletions deps/wazuh_testing/wazuh_testing/end_to_end/indexer_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,36 @@ def delete_index(host_manager: HostManager, credentials: dict = {'user': 'admin'

requests.delete(url=url, verify=False,
auth=requests.auth.HTTPBasicAuth(credentials['user'], credentials['password']), headers=headers)


def extend_result_window(host_manager: HostManager, credentials: dict = {'user': 'admin', 'password': 'changeme'},
index: str = 'wazuh-alerts*', new_max_result_window: int = 100000):
"""Extend the max_result_window setting for a Wazuh Indexer index.

Args:
host_manager: An instance of the HostManager class containing information about hosts.
credentials (Optional): A dictionary containing the Indexer credentials. Defaults to
{'user': 'admin', 'password': 'changeme'}.
index (Optional): The Indexer index name. Defaults to 'wazuh-alerts*'.
new_max_result_window (Optional): The new maximum result window size. Defaults to 100,000.
"""
logging.info(f"Extending max_result_window for {index} index to {new_max_result_window}")

url = f"https://{host_manager.get_master_ip()}:9200/{index}/_settings"
headers = {
'Content-Type': 'application/json',
}
data = {
"index": {
"max_result_window": new_max_result_window
}
}

response = requests.put(url=url, json=data, verify=False,
auth=requests.auth.HTTPBasicAuth(credentials['user'], credentials['password']),
headers=headers)

if response.status_code == 200:
logging.info(f"Successfully updated max_result_window for {index} index.")
else:
logging.error(f"Failed to update max_result_window for {index} index. Response: {response.text}")
7 changes: 6 additions & 1 deletion tests/end_to_end/test_vulnerability_detector/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def test_example(host_manager):
restore_configuration,
save_indexer_credentials_into_keystore)
from wazuh_testing.end_to_end.indexer_api import (
get_wazuh_states_vulnerabilities_indexname, delete_index)
get_wazuh_states_vulnerabilities_indexname, delete_index, extend_result_window)
from wazuh_testing.end_to_end.logs import (get_hosts_alerts, get_hosts_logs,
truncate_remote_host_group_files)
from wazuh_testing.end_to_end.remote_operations_handler import (
Expand Down Expand Up @@ -400,6 +400,11 @@ def enable_modulesd_debug(request, host_manager):
host_manager.modify_file_content(manager, '/var/ossec/etc/local_internal_options.conf', 'wazuh_modules.debug=0\n')
host_manager.control_environment('restart', ['manager'], parallel=True)

@pytest.fixture(scope='session', autouse=True)
def max_result_window(request, host_manager):
vuln_index = get_wazuh_states_vulnerabilities_indexname()
extend_result_window(host_manager, index=vuln_index)


@pytest.fixture(scope='session', autouse=True)
def handle_gather_evidence_when_passed(request):
Expand Down
2 changes: 1 addition & 1 deletion version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "4.9.0",
"revision": "40905"
"revision": "40906"
}