From 0344a58f4a413d9f07e6bf47654c4a24627f182a Mon Sep 17 00:00:00 2001 From: lsayanes Date: Wed, 5 Jul 2023 13:43:21 -0300 Subject: [PATCH] fix(#4275): modified year field in test_update_from_year --- .../wazuh_testing/db_interface/cve_db.py | 4 ++-- .../modules/vulnerability_detector/__init__.py | 3 +-- .../modules/vulnerability_detector/event_monitor.py | 13 +++++++++++-- .../test_providers/test_update_from_year.py | 3 +-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py b/deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py index 750f8c53b8..23e2a9c696 100644 --- a/deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py +++ b/deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py @@ -212,7 +212,7 @@ def get_metadata_timestamp(provider_os): return result[0] -def get_nvd_metadata_timestamp(year): +def get_nvd_metadata_timestamp(): """Get the NVD timestamp data for a specific year from nvd_metadata table. Args: @@ -221,7 +221,7 @@ def get_nvd_metadata_timestamp(year): Returns: str: Timestamp data. (example: 2022-03-03T03:00:01-05:00) """ - query_string = f"SELECT timestamp FROM nvd_metadata WHERE year={year}" + query_string = f"SELECT timestamp FROM nvd_metadata" result = get_sqlite_query_result(CVE_DB_PATH, query_string) if len(result) == 0: diff --git a/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/__init__.py b/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/__init__.py index 9cadb8d85b..ce0683c4d0 100644 --- a/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/__init__.py +++ b/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/__init__.py @@ -176,8 +176,7 @@ def feed_is_recently_updated(provider_name, provider_os, threshold_weeks): boolean: True if the feed is considered recently updated, False otherwise. """ if provider_name == 'National Vulnerability Database': - current_year = datetime.now().year - feed_update_timestamp = cve_db.get_nvd_metadata_timestamp(year=current_year) + feed_update_timestamp = cve_db.get_nvd_metadata_timestamp() else: feed_update_timestamp = cve_db.get_metadata_timestamp(provider_os=provider_os) diff --git a/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/event_monitor.py b/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/event_monitor.py index b918915a99..2737e06201 100644 --- a/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/event_monitor.py +++ b/deps/wazuh_testing/wazuh_testing/modules/vulnerability_detector/event_monitor.py @@ -240,13 +240,22 @@ def check_obtaining_software_failure_log(agent_id='000', num_attemps=5): f"{num_attemps} attempts. Skipping agent until the next scan.") -def check_nvd_download_log(update_year): +def check_nvd_download_log(): """Check that the NVD download has started. Args: update_year (int): Year specified in . """ - check_vuln_detector_event(timeout=vd.T_40, callback=fr".*Downloading .*nvdcve-\d.\d-{update_year}.meta.*", + + """ + leandro + - #define NVD_CVE_REPO_META "https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-%d.meta" + - #define NVD_CVE_REPO "https://nvd.nist.gov/feeds/json/cve/1.1/nvdcve-1.1-%d.json.gz" + + #define NVD_CVE_REPO_META "https://feed.wazuh.com/vulnerability-detector/nvd/generated-feeds/nvd_cve_single.meta" + + #define NVD_CVE_REPO "https://feed.wazuh.com/vulnerability-detector/nvd/generated-feeds/nvd_cve_single.json.gz + """ + + check_vuln_detector_event(timeout=vd.T_40, callback=fr".*Downloading .*nvd_cve_single.meta*", error_message='NVD feed download did not started', prefix=r'.*wazuh-modulesd:download.*') diff --git a/tests/integration/test_vulnerability_detector/test_providers/test_update_from_year.py b/tests/integration/test_vulnerability_detector/test_providers/test_update_from_year.py index f20734b7d6..5dbe266ea3 100644 --- a/tests/integration/test_vulnerability_detector/test_providers/test_update_from_year.py +++ b/tests/integration/test_vulnerability_detector/test_providers/test_update_from_year.py @@ -132,10 +132,9 @@ def test_update_from_year(configuration, metadata, set_wazuh_configuration_vdt, - "'update_from_year' option cannot be used for 'msu' provider." - f"Invalid option 'update_from_year' for '{provider}' provider at 'vulnerability-detector'" ''' - update_year = current_year provider = metadata['provider'] if provider == 'nvd': - evm.check_nvd_download_log(update_year) + evm.check_nvd_download_log() else: evm.check_invalid_provider_update_from_year_log(provider)