Skip to content

Commit

Permalink
fix(#4275): modified year field in test_update_from_year
Browse files Browse the repository at this point in the history
  • Loading branch information
lsayanes authored and MarcelKemp committed Jul 20, 2023
1 parent 2ad0ac5 commit 0344a58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
4 changes: 2 additions & 2 deletions deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <update_from_year>.
"""
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.*')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 0344a58

Please sign in to comment.