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

Vulnerability Detector integration tests for SUSE Linux Enterprise #2847

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
e84613a
add: Add custom feeds for suse
CamiRomero Apr 22, 2022
889dcbe
add: Add test case enable for SUSE Linux
CamiRomero Apr 22, 2022
aa5559e
add: Add test case disabled for SUSE Linux
CamiRomero Apr 22, 2022
a5bc7dd
add: Add test case 'missing OS' for SUSE Linux
CamiRomero Apr 22, 2022
a61ca6f
add: Add test cases to 'test_os'
CamiRomero Apr 22, 2022
59a3444
add: Add suse case to 'cases_update_from_year'
CamiRomero Apr 22, 2022
c1e62e2
fix: Fix typo in SUSE
CamiRomero Apr 22, 2022
6343950
add: Add case for suse to 'update_interval'
CamiRomero Apr 22, 2022
c0b316c
add: Add test documentation for SUSE
CamiRomero Apr 22, 2022
f4c4a0b
rm: Remove imports
CamiRomero Apr 22, 2022
18e8d1d
add: new mocking agent systems
Deblintrake09 Apr 22, 2022
54ff211
add: SUSE test cases for test_no_agent_data
Deblintrake09 Apr 22, 2022
e673ff0
docu: add tested SUSE systems - test_no_agent_data
Deblintrake09 Apr 22, 2022
233ff90
add: test cases and config for SUSE cases
Deblintrake09 Apr 22, 2022
901bec1
add: Add cases of download feeds in the yaml file.
damarisg Apr 25, 2022
1d7b62b
fix: Fix provider_os in 'cases_download_feeds'
CamiRomero Apr 27, 2022
2c29821
add: Add suse to cases_duplicated.yaml
CamiRomero Apr 27, 2022
44ddac9
Modify test in order to run suse cases
CamiRomero Apr 27, 2022
da49f4c
add: Add invalid case for SUSE
CamiRomero Apr 27, 2022
3f55c6b
add: Add configuration for suse
CamiRomero Apr 27, 2022
1cc8c15
add: add cases for suse in 'validate test'
CamiRomero Apr 27, 2022
7fea69e
add: Add test documentation for suse
CamiRomero Apr 27, 2022
ecba83a
rm: Remove unnecesary imports
CamiRomero Apr 27, 2022
ec3807c
add: Add custom_suse_oval_fedd variable
CamiRomero Apr 27, 2022
621dc52
Add: Add cases fot all OS - suse
CamiRomero Apr 27, 2022
e3ff6d5
add: Add test cases enableb for all OS - suse
CamiRomero Apr 27, 2022
c9d02cd
add: generate suse vulnerabilites json
Deblintrake09 Apr 27, 2022
fe95d2e
fix: modify execute_sqlite_query to return values
Deblintrake09 Apr 27, 2022
c237cd7
add: SUSE systems to mock SYSTEM_DATA array
Deblintrake09 Apr 27, 2022
c3fbc94
add: vendor tag to update_feed_path_configurations
Deblintrake09 Apr 27, 2022
7e8bba9
add: create suse_vulnerabilities yaml
Deblintrake09 Apr 27, 2022
ab671aa
create suse_vulnerabilities cases yaml
Deblintrake09 Apr 27, 2022
d0e0098
refac: remove unused imported functions
Deblintrake09 Apr 27, 2022
c9e3a57
test: add new test_scan_suse_vulnerabilites.py
Deblintrake09 Apr 27, 2022
369709c
fix: add deps_id param to insert_vulnerabilites
Deblintrake09 Apr 27, 2022
bb3e00d
add: new func insert_dependency & insert_pkg_dep
Deblintrake09 Apr 27, 2022
185c5c5
add: new fixture check_cve_db
Deblintrake09 Apr 27, 2022
7c57dbd
add: Add restart Wazuh
CamiRomero Apr 28, 2022
a4c50a2
add: Add OS to missing_os test
CamiRomero Apr 28, 2022
4dd0552
fix: Fix documentation about suse test
CamiRomero Apr 28, 2022
1128341
Add: add OS comments
CamiRomero Apr 28, 2022
f0ce9f7
fix: Fix copyright
CamiRomero Apr 28, 2022
05f9c07
Merge pull request #2820 from wazuh/2808-test-providers-for-suse-linu…
damarisg Apr 28, 2022
d72b366
fix: add more information SUSE mock systems
Deblintrake09 Apr 29, 2022
80c9abf
add: insert_suse_vulnerabilities function
Deblintrake09 Apr 29, 2022
9e6049a
add: check_suse_system_vulnerabilities function
Deblintrake09 Apr 29, 2022
355b906
add: fixture to prepare enviroment for suse scan
Deblintrake09 Apr 29, 2022
2401c38
refac: fix JSON format for suse vulnerabilities
Deblintrake09 Apr 29, 2022
58e0a18
fix: test_cases_suse_vulnerabilities yaml
Deblintrake09 Apr 29, 2022
ad2d8bf
rm: remove suse from test_scan_nvd test cases
Deblintrake09 Apr 29, 2022
36b96bd
fix: suse system configuration
Deblintrake09 Apr 29, 2022
5cfdb68
fix: refactor test_scan_suse_vulnerabilities v3
Deblintrake09 Apr 29, 2022
f32e4c8
Merge pull request #2833 from wazuh/2807-add-test-feeds-cases
damarisg Apr 29, 2022
f25834b
fix: create alternative vulnerabilities and feeds
Deblintrake09 May 2, 2022
8a85698
test: ne test_scam_suse_vulnerability_removal
Deblintrake09 May 3, 2022
3167d38
fix: change min_full_scan_interval suse_removal
Deblintrake09 May 3, 2022
3661158
fix: update custom_suse_oval_feed - apply to test
Deblintrake09 May 5, 2022
1fc7455
rm: delete unused variable
Deblintrake09 May 12, 2022
db1848b
refac: change name id var in insert_dependency
Deblintrake09 May 12, 2022
dc983b0
rm: remove unused variable and rollback changes
Deblintrake09 May 12, 2022
c18c121
refac: remove unneeded lines and fix some formatting
Deblintrake09 May 12, 2022
57ef39c
doc: add docu to functions in vdt.__init__
Deblintrake09 May 12, 2022
314f183
rm: remove changes check_vulnerability_affects_log
Deblintrake09 May 12, 2022
032c64b
refac: add complete SLES15 mock data
Deblintrake09 May 12, 2022
7cb3789
refac: modify suse mocked system data
Deblintrake09 May 16, 2022
3ad887d
add: suse_system_package and function to insert
Deblintrake09 May 16, 2022
e623236
docu: add suse to supported systems
Deblintrake09 May 16, 2022
1bfa866
add: suse case to scan_provider_vulns
Deblintrake09 May 16, 2022
3b1b53b
add: suse case to test_scan_provider_and_nvd vulns
Deblintrake09 May 16, 2022
38f6dfb
refac: modify custom_suse_oval_feed
Deblintrake09 May 16, 2022
d51c6b0
rm: test_scan_suse_vulnerabilities
Deblintrake09 May 16, 2022
83d1f69
refac: fix suse_feed import
Deblintrake09 May 16, 2022
e681d3e
refac: clean custom_suse_oval_feed
Deblintrake09 May 16, 2022
63d1423
rm: delete test_scan_suse_vuln_removal
Deblintrake09 May 17, 2022
044f864
refac: make test_scan_vuln_removal accept agent OS
Deblintrake09 May 17, 2022
21d517e
add: SUSE test case scan_vuln_removal
Deblintrake09 May 17, 2022
c0eefd4
rm: delete unused file
Deblintrake09 May 17, 2022
436366d
rm: delete unused functions
Deblintrake09 May 17, 2022
f032a95
docu: add supported SUSE systems
Deblintrake09 May 17, 2022
4162fe4
style: remove whitespaces
Deblintrake09 May 17, 2022
7618e08
rm: remove unused imports
Deblintrake09 May 17, 2022
7c6e263
docu: update docu
Deblintrake09 May 17, 2022
193155b
style: adjust files to pep8
Deblintrake09 May 17, 2022
6795e41
docu: update wazuh_min_version to 4.4.0
Deblintrake09 May 17, 2022
d8012bc
style: remove whitespace
Deblintrake09 May 17, 2022
42766a8
style: fix to comply to pep8
Deblintrake09 May 17, 2022
f97bd61
style: fix typo
Deblintrake09 May 17, 2022
6aadbb5
Update CHANGELOG.md
Deblintrake09 May 19, 2022
b40f070
rm: delete unused imports in conftest.py
Deblintrake09 May 19, 2022
bb8e8a0
Merge pull request #2902 from wazuh/2792-test-scan-results
damarisg May 19, 2022
5112962
Merge branch 'master' into 2792-add-support-for-SUSE-OVAL-in-Vulnerab…
Deblintrake09 May 19, 2022
edce167
rm: Update last SUSE version to test.
damarisg May 20, 2022
0b1c26c
rm: Update doc with wazuh_min_version and OS version supported.
damarisg May 20, 2022
b62a3f0
fix: add xfail for BIONIC test_download case
Deblintrake09 May 23, 2022
98b0de5
fix: modify threxhold_weeks for SLED11
Deblintrake09 May 23, 2022
9c12f40
Update update_threshol_weeks for SLES11
Deblintrake09 May 24, 2022
786117f
add: Add skip for windows
CamiRomero May 20, 2022
349274a
style: fix style errors
Deblintrake09 May 27, 2022
2a8b23b
fix: test_download_feeds always pass if Timeout
Deblintrake09 May 27, 2022
4e24082
docu: Fix test_scan_vulnerability_removal
Deblintrake09 May 27, 2022
b455449
fix: Remove unused data in test
Deblintrake09 May 27, 2022
022e2e3
style: Fix SUSE_SYSTEM_PACKAGE indentation
Deblintrake09 May 30, 2022
7119717
fix: add xfail to BIONIC test_download_feeds
Deblintrake09 May 30, 2022
70109ae
fix: test_download_feeds indentation error
Deblintrake09 May 30, 2022
d170c61
refac: Update xfail for bionic test download feed
jmv74211 May 30, 2022
5239aab
fix: Modify BIONIC xfail structure
Deblintrake09 May 31, 2022
4f9ee49
Merge branch 'master' into 2792-add-support-for-SUSE-OVAL-in-Vulnerab…
Deblintrake09 May 31, 2022
5748106
rm: Delete restart in test_multiple_providers
Deblintrake09 Jun 1, 2022
9c0739e
Merge branch '4.4' into 2792-add-support-for-SUSE-OVAL-in-Vulnerabili…
Deblintrake09 Jun 1, 2022
e8f42a9
fix: Add restart_wazuh_daemon_after_finishing
Deblintrake09 Jun 1, 2022
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 @@ -20,6 +20,7 @@ Release report: TBD

### Added

- Add support for SUSE systems in VDT tests ([#2902](https://github.com/wazuh/wazuh-qa/pull/2902))
- Test `global backup` WDB command ([#2637](https://github.com/wazuh/wazuh-qa/pull/2637)
- Test `sync-agens-groups-get` WDB command ([#2626](https://github.com/wazuh/wazuh-qa/pull/2626)
- Test `wazuhdb getconfig` WDB command ([2627#](https://github.com/wazuh/wazuh-qa/pull/2627))
Expand Down
5 changes: 3 additions & 2 deletions deps/wazuh_testing/wazuh_testing/db_interface/agent_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def insert_hotfix(agent_id='000', scan_id=int(time()), scan_time=datetime.dateti


def insert_os_info(agent_id='000', scan_id=int(time()), scan_time=datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
hostname='centos8', architecture='x64', os_name='CentOS Linux', os_version='8.4', os_codename= '',
hostname='centos8', architecture='x64', os_name='CentOS Linux', os_version='8.4', os_codename='',
os_major='8', os_minor='4', os_patch='', os_build='', os_platform='centos', sysname='Linux',
release='', version='', os_release='', checksum='dummychecksum', os_display_version='', triaged=0,
reference=''):
Expand Down Expand Up @@ -138,6 +138,7 @@ def insert_package(agent_id='000', scan_id=int(time()), format='rpm', name='cust
f"{arguments['description']}, {arguments['location']}, {arguments['triaged']}, {arguments['checksum']},"
f"{arguments['item_id']})")


def update_sync_info(agent_id='000', component='syscollector-packages', last_attempt=1, last_completion=1,
n_attempts=0, n_completions=0, last_agent_checksum=''):
"""Update the sync_info table of the specified agent for the selected component.
Expand Down Expand Up @@ -215,7 +216,7 @@ def delete_os_info(agent_id='000'):


def update_os_info(agent_id='000', scan_id=int(time()), scan_time=datetime.datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
hostname='centos8', architecture='x64', os_name='CentOS Linux', os_version='8.4', os_codename= '',
hostname='centos8', architecture='x64', os_name='CentOS Linux', os_version='8.4', os_codename='',
os_major='8', os_minor='4', os_patch='', os_build='', os_platform='centos', sysname='Linux',
release='', version='', os_release='', checksum='dummychecksum', os_display_version='', triaged=0,
reference=''):
Expand Down
7 changes: 4 additions & 3 deletions deps/wazuh_testing/wazuh_testing/db_interface/cve_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def insert_vulnerability(cveid='CVE-000', target='RHEL7', target_minor='',
reference='https://github.com/wazuh/wazuh-qa', target_v='REDHAT', cvss='10.000000',
cvss_vector='AV:N/AC:L/Au:N/C:C/I:C/A:C', rationale='Wazuh integration test vulnerability',
cvss3='', bugzilla_reference='https://github.com/wazuh/wazuh-qa', cwe='WVE-000 -> WVE-001',
advisory='RHSA-2010:0029', ref_target='RHEL'):
advisory='RHSA-2010:0029', ref_target='RHEL', deps_id='0'):
"""Insert a vulnerability in CVE database.

Args:
Expand All @@ -87,10 +87,11 @@ def insert_vulnerability(cveid='CVE-000', target='RHEL7', target_minor='',
cwe (str): CWE ID.
advisory (str): Advisory ID.
ref_target (str): OS target ID.
deps_id (str): id of the dependencies related to the vulnerability.
"""
queries = [
'INSERT INTO VULNERABILITIES (cveid, target, target_minor, package, operation, operation_value) VALUES '
f"('{cveid}', '{target}', '{target_minor}', '{package}', '{operation}', '{operation_value}')",
'INSERT INTO VULNERABILITIES (cveid, target, target_minor, package, operation, operation_value, deps_id) VALUES'
f" ('{cveid}', '{target}', '{target_minor}', '{package}', '{operation}', '{operation_value}', '{deps_id}')",

'INSERT INTO VULNERABILITIES_INFO (ID, title, severity, published, updated, target, rationale, cvss, '
f"cvss_vector, CVSS3, cwe) VALUES ('{cveid}', '{title}', '{severity}', '{published}', '{updated}', "
Expand Down
43 changes: 31 additions & 12 deletions deps/wazuh_testing/wazuh_testing/mocking/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,24 @@
'WINDOWS_SERVER_2019': {'os_name': 'Microsoft Windows Server 2019', 'os_major': '10', 'os_minor': '0',
'os_platform': 'windows', 'name': 'windows_server_2019', 'os_version': '1000'},
'WINDOWS_SERVER_2022_1': {'os_name': 'Microsoft Windows Server 2022', 'os_major': '10', 'os_minor': '0',
'os_platform': 'windows', 'name': 'windows_server_2022', 'os_version': '1000'},
'os_platform': 'windows', 'name': 'windows_server_2022', 'os_version': '1000'},
'WINDOWS_SERVER_2022_2': {'os_name': 'Microsoft Windows Server 2022', 'os_major': '10', 'os_minor': '0',
'os_platform': 'windows', 'name': 'windows_server', 'os_version': '1000'},
'os_platform': 'windows', 'name': 'windows_server', 'os_version': '1000'},
'MAC': {'os_name': 'Mac OS X', 'os_major': '10', 'os_minor': '15', 'os_platform': 'darwin',
'name': 'macos-catalina'},
'MACS': {'os_name': 'Mac OS X Server', 'os_major': '5', 'os_minor': '10', 'os_platform': 'darwin',
'name': 'macos-server'},
'ARCH': {'os_name': 'Arch Linux', 'os_major': '', 'os_minor': '', 'os_platform': '', 'name': 'archlinux'},
'ALAS': {'hostname': 'amz', 'architecture': 'x86_64', 'os_name': 'Amazon Linux AMI', 'os_version': '2018.03',
'os_codename': '', 'os_major': '2018', 'os_minor': '03', 'os_patch': '', 'os_build': '',
'os_platform': 'amzn', 'sysname': 'Linux', 'release': '4.14.97-74.72.amzn1.x86_64',
'version': 'Wazuh v4.3.0', 'os_release': '', 'checksum': '1645433796303855540', 'os_display_version': '',
'triaged': '0', 'reference': '0886f3023b131f5bf1ecbc33f651807114cb5a53', 'name': 'amz', 'ip': '127.0.0.1',
'register_ip': '127.0.0.1', 'internal_key': '',
'os_uname': 'Linux |amz |4.14.97-74.72.amzn1.x86_64 |#1 SMP Tue Feb 5 20:59:30 UTC 2019 |x86_64',
'os_arch': 'x86_64', 'config_sum': '', 'merged_sum': '', 'manager_host': 'amz', 'node_name': 'node01',
'date_add': '1645433793', 'last_keepalive': '253402300799', 'sync_status': 'synced',
'connection_status': 'active', 'disconnection_time': '0'},
'os_codename': '', 'os_major': '2018', 'os_minor': '03', 'os_patch': '', 'os_build': '',
'os_platform': 'amzn', 'sysname': 'Linux', 'release': '4.14.97-74.72.amzn1.x86_64',
'version': 'Wazuh v4.3.0', 'os_release': '', 'checksum': '1645433796303855540', 'os_display_version': '',
'triaged': '0', 'reference': '0886f3023b131f5bf1ecbc33f651807114cb5a53', 'name': 'amz', 'ip': '127.0.0.1',
'register_ip': '127.0.0.1', 'internal_key': '',
'os_uname': 'Linux |amz |4.14.97-74.72.amzn1.x86_64 |#1 SMP Tue Feb 5 20:59:30 UTC 2019 |x86_64',
'os_arch': 'x86_64', 'config_sum': '', 'merged_sum': '', 'manager_host': 'amz', 'node_name': 'node01',
'date_add': '1645433793', 'last_keepalive': '253402300799', 'sync_status': 'synced',
'connection_status': 'active', 'disconnection_time': '0'},
'ALAS2': {'hostname': 'alas2', 'architecture': 'x86_64', 'os_name': 'Amazon Linux', 'os_version': '2',
'os_codename': '', 'os_major': '2', 'os_minor': '', 'os_patch': '', 'os_build': '', 'os_platform': 'amzn',
'sysname': 'Linux', 'release': '4.14.198-152.320.amzn2.x86_64', 'version': 'Wazuh v4.3.0',
Expand Down Expand Up @@ -103,7 +103,26 @@
'BUSTER': {'os_name': 'Debian GNU/Linux', 'os_major': '10', 'os_minor': '0', 'os_platform': 'debian',
'name': 'debian10'},
'STRETCH': {'os_name': 'Debian GNU/Linux', 'os_major': '9', 'os_minor': '0', 'os_platform': 'debian',
'name': 'debian9'}
'name': 'debian9'},
'SLED11': {'hostname': 'sled', 'architecture': 'x86_64', 'os_name': 'SLED', 'os_major': '11', 'os_minor': '',
'os_platform': 'sled', 'name': 'Desktop11', 'os_codename': 'sled'},
'SLED12': {'hostname': 'sled', 'architecture': 'x86_64', 'os_name': 'SLED', 'os_major': '12', 'os_minor': '',
'os_platform': 'sled', 'name': 'Desktop12', 'os_codename': 'sled'},
'SLED15': {'hostname': 'sled', 'architecture': 'x86_64', 'os_name': 'SLED', 'os_major': '15', 'os_minor': '',
'os_platform': 'sled', 'name': 'Desktop15', 'os_codename': 'sled'},
'SLES11': {'hostname': 'sles', 'architecture': 'x86_64', 'os_name': 'SLES', 'os_major': '11', 'os_minor': '',
'os_platform': 'sles', 'name': 'Server11', 'os_codename': 'sles'},
'SLES12': {'hostname': 'sles', 'architecture': 'x86_64', 'os_name': 'SLES', 'os_major': '12', 'os_minor': '',
'os_platform': 'sles', 'name': 'Server12', 'os_codename': 'sles'},
'SLES15': {'hostname': 'localhost', 'architecture': 'x64', 'os_name': 'SLES', 'os_version': '15.2',
'os_codename': '', 'os_major': '15', 'os_minor': '', 'os_patch': '', 'os_build': '',
'os_platform': 'sles', 'sysname': 'Linux', 'release': '5.3.18-22-default', 'version': 'Wazuh v4.4.0',
'os_release': '', 'checksum': '1652388661375945607', 'name': 'SUSE15', 'ip': '127.0.0.1',
'register_ip': 'any', 'internal_key': '',
'os_uname': 'Linux |localhost|5.3.18-22-default |#1 SMP Wed Jun 3 12:16:43 UTC 2020 (720aeba)|x86_64',
'os_arch': 'x64', 'config_sum': '', 'merged_sum': '', 'manager_host': 'localhost.localdomain',
'node_name': 'node01', 'date_add': '1652381429', 'last_keepalive': '253402300799',
'sync_status': 'synced', 'connection_status': 'active'}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CUSTOM_ARCHLINUX_JSON_FEED = 'custom_archlinux_feed.json'
CUSTOM_ALAS_JSON_FEED = 'custom_alas_feed.json'
CUSTOM_ALAS2_JSON_FEED = 'custom_alas2_feed.json'
CUSTOM_SUSE_OVAL_FEED = 'custom_suse_oval_feed.xml'

VULNERABILITY_DETECTOR_PREFIX = r'.*wazuh-modulesd:vulnerability-detector.*'

Expand Down Expand Up @@ -67,6 +68,17 @@
}
]

SUSE_SYSTEM_PACKAGE = {
'SLES15': [
{
"name": "sle-module-basesystem-release",
"version": "15.2",
"format": "rpm",
"vendor": "SUSE LLC <https://www.suse.com/>"
}
]
}


def update_feed_path_configurations(configurations, metadata, feeds_path):
"""Replace feed path tags in the configuration template, using the metadata information.
Expand All @@ -83,17 +95,17 @@ def update_feed_path_configurations(configurations, metadata, feeds_path):

for index, _ in enumerate(configurations):
if 'json_feed' in metadata[index] and metadata[index]['json_feed'] is not None:
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).\
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).
replace(metadata[index]['json_feed_tag'], os.path.join(feeds_path, metadata[index]['provider_name'],
metadata[index]['json_feed'])))

if 'oval_feed' in metadata[index] and metadata[index]['oval_feed'] is not None:
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).\
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).
replace(metadata[index]['oval_feed_tag'], os.path.join(feeds_path, metadata[index]['provider_name'],
metadata[index]['oval_feed'])))

if 'nvd_feed_tag' in metadata[index] and 'nvd_feed' in metadata[index]:
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).\
new_configurations[index] = json.loads(json.dumps(new_configurations[index]).
replace(metadata[index]['nvd_feed_tag'], os.path.join(feeds_path, 'nvd', metadata[index]['nvd_feed'])))

return new_configurations
Expand Down Expand Up @@ -130,6 +142,24 @@ def insert_vulnerabilities_agent_inventory(agent_id='000', status='VALID'):
cve=package['cveid'], status=status)


def insert_suse_system_package(agent_id='000', version='SLES15'):
"""Insert suse OS package to an agent.

Args:
agent_id (str): Agent ID.
version (str): Package version.

Raises:
ValueError: If version parameter has an invalid value.
"""
if version not in SUSE_SYSTEM_PACKAGE:
raise ValueError('Suse system parameter invalid.')

for package in SUSE_SYSTEM_PACKAGE[version]:
agent_db.insert_package(name=package['name'], version=package['version'], source=package['name'],
agent_id=agent_id, vendor=package['vendor'])


def feed_is_recently_updated(provider_name, provider_os, threshold_weeks):
"""Check if the provider OS feed is recently updated according to a specified threshold.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check_vuln_detector_event(file_monitor=None, callback='', error_message=None
error_message

file_monitor.start(timeout=timeout, update_position=update_position, accum_results=accum_results,
callback=make_vuln_callback(callback, prefix), error_message=error_message)
callback=make_vuln_callback(callback, prefix), error_message=error_message)


def check_vulnerability_detector_disabled():
Expand Down
8 changes: 8 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ def restart_wazuh_daemon_function(daemon=None):
truncate_file(LOG_FILE_PATH)
control_service("restart", daemon=daemon)

@pytest.fixture(scope='module')
def restart_wazuh_daemon_after_finishing(daemon=None):
"""
Restart a Wazuh daemon
"""
yield
truncate_file(LOG_FILE_PATH)
control_service("restart", daemon=daemon)

@pytest.fixture(scope='module')
def reset_ossec_log(get_configuration, request):
Expand Down
4 changes: 4 additions & 0 deletions tests/integration/test_vulnerability_detector/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def prepare_full_scan_with_vuln_packages_and_custom_system(agent_system, mock_ag
# Insert vulnerable packages
package_vendor = 'Red Hat, Inc.' if 'RHEL' in agent_system else 'wazuh-mocking'

if 'SLES' in agent_system:
package_vendor = 'SUSE LLC <https://www.suse.com/>'
vd.insert_suse_system_package(agent_id=mock_agent_with_custom_system, version=agent_system)

vd.insert_vulnerable_packages(agent_id=mock_agent_with_custom_system, vendor=package_vendor)

# Update sync info for packages
Expand Down
Loading