Skip to content

Commit

Permalink
Merge pull request #1489 from wazuh/dev-1408-rework-test-scan-results
Browse files Browse the repository at this point in the history
Rework of test scan results
  • Loading branch information
DProvinciani authored Jun 24, 2021
2 parents e495da9 + 0bff1cc commit 3d784c4
Show file tree
Hide file tree
Showing 27 changed files with 925 additions and 158 deletions.
194 changes: 142 additions & 52 deletions deps/wazuh_testing/wazuh_testing/vulnerability_detector.py

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions deps/wazuh_testing/wazuh_testing/wazuh_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ def mock_agent_status(request, agent_id, agent_status):
@functools.wraps(func)
def magic(*args, **kwargs):
control_service('stop', daemon='wazuh-modulesd')
control_service('stop', daemon='wazuh-db')
func(*args, **kwargs)
control_service('start', daemon='wazuh-db')
control_service('start', daemon='wazuh-modulesd')

return magic
Expand All @@ -51,7 +49,7 @@ def mock_agent(
last_keepalive="253402300799", group="", sync_status="synced", connection_status="active",
client_key_secret=None):

create_agent_query = f'''INSERT INTO AGENT
create_agent_query = f'''global sql INSERT OR REPLACE INTO AGENT
(id, name, ip, register_ip, internal_key, os_name, os_version, os_major, os_minor,
os_codename, os_build, os_platform, os_uname, os_arch, version, config_sum, merged_sum,
manager_host, node_name, date_add, last_keepalive, "group", sync_status, connection_status)
Expand All @@ -62,7 +60,7 @@ def mock_agent(
"{date_add}", "{last_keepalive}", "{group}", "{sync_status}", "{connection_status}")
'''
try:
run_query(create_agent_query, GLOBAL_DB_PATH)
query_wdb(create_agent_query)
except sqlite3.IntegrityError:
logging.error("Failed to mock agent in database!")

Expand Down Expand Up @@ -151,7 +149,7 @@ def query_wdb(command):

# Remove response header and cast str to list of dictionaries
# From --> 'ok [ {data1}, {data2}...]' To--> [ {data1}, data2}...]
if len(data.split(' ')) > 1:
if len(data.split(' ')) > 1 and data.split(' ')[0] == 'ok':
data = json.loads(' '.join(data.split(' ')[1:]))
finally:
sock.close()
Expand Down
8 changes: 0 additions & 8 deletions tests/integration/test_vulnerability_detector/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,20 +55,12 @@ def mock_agent():
"""
Fixture to create a mocked agent in wazuh databases
"""
control_service('stop', daemon='wazuh-db')

agent_id = vd.create_mocked_agent(name="mocked_agent")

control_service('start', daemon='wazuh-db')

yield agent_id

control_service('stop', daemon='wazuh-db')

vd.delete_mocked_agent(agent_id)

control_service('start', daemon='wazuh-db')


@pytest.fixture(scope='module')
def check_cve_db():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"severity": "High",
"type": "multiple issues",
"affected": "75.0.3969.149-1",
"architecture": "x86_64",
"fixed": null,
"ticket": null,
"issues": [
Expand All @@ -28,6 +29,7 @@
"severity": "Medium",
"type": "arbitrary code execution",
"affected": "4.14.3-1",
"architecture": "x86_64",
"fixed": null,
"ticket": "70043",
"issues": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"package": {
"name": "postgresql-11",
"version": "0:11.6",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -23,6 +24,7 @@
"package": {
"name": "mariadb-10.3",
"version": "0:1:10.3.22",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -35,6 +37,7 @@
"package": {
"name": "python3.7",
"version": "0:3.7.0-6",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -47,6 +50,7 @@
"package": {
"name": "php7.3",
"version": "0:7.3.9",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -59,6 +63,7 @@
"package": {
"name": "bash",
"version": "0:4.3",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -81,6 +86,7 @@
"package": {
"name": "python3.5",
"version": "0:3.5.3",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -93,6 +99,7 @@
"package": {
"name": "ruby2.3",
"version": "0:2.3.3-1+deb9u5",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -105,6 +112,7 @@
"package": {
"name": "ansible",
"version": "0:2.2.1.0",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -117,6 +125,7 @@
"package": {
"name": "php7.0",
"version": "0:7.0.32",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand All @@ -129,6 +138,7 @@
"package": {
"name": "asterisk",
"version": "0:1:13.11.1",
"architecture": "x86_64",
"format": "deb"
},
"cve": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@
"os_major": "10",
"os_minor": "15",
"os_patch": "1",
"os_patch_fixed": "2",
"os_platform": "darwin",
"name": "macos_catalina",
"version": "Wazuh v4.1",
"architecture": "x86_64",
"release": "19.0.0",
"cve": "CVE-2018-14470",
"vulnerabilities": [
{
"package": {
"name": "safari",
"version": "13.0.3",
"architecture": "x86_64",
"format": "pkg",
"vendor": "Apple"
},
Expand All @@ -27,6 +30,7 @@
"package": {
"name": "sqlite",
"version": "3.26.0",
"architecture": "x86_64",
"format": "pkg",
"vendor": ""
},
Expand All @@ -43,16 +47,19 @@
"os_major": "10",
"os_minor": "6",
"os_patch": "8",
"os_patch_fixed": "9",
"os_platform": "darwin",
"name": "macos_server",
"version": "Wazuh v4.1",
"architecture": "x86_64",
"release": "10.0.0",
"cve": "CVE-2013-0984",
"vulnerabilities": [
{
"package": {
"name": "safari",
"version": "12.0.3",
"architecture": "x86_64",
"format": "pkg",
"vendor": "Apple"
},
Expand All @@ -64,6 +71,7 @@
"package": {
"name": "sqlite",
"version": "3.20.0",
"architecture": "x86_64",
"format": "pkg",
"vendor": ""
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"package": {
"name": "firefox-0",
"version": "68.1.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -23,6 +24,7 @@
"package": {
"name": "glibc-0",
"version": "2.27",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -36,6 +38,7 @@
"package": {
"name": "sqlite-0",
"version": "3.25.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -49,6 +52,7 @@
"package": {
"name": "git-0",
"version": "2.18.1",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -62,6 +66,7 @@
"package": {
"name": "haproxy-0",
"version": "2.0.12",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -84,6 +89,7 @@
"package": {
"name": "nodejs",
"version": "11.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -97,6 +103,7 @@
"package": {
"name": "firefox-0",
"version": "68.1",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -110,6 +117,7 @@
"package": {
"name": "ansible-0",
"version": "2.8.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -123,6 +131,7 @@
"package": {
"name": "php",
"version": "7.1",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -136,6 +145,7 @@
"package": {
"name": "samba-0",
"version": "4.10.3",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -158,6 +168,7 @@
"package": {
"name": "python-twisted-web-0",
"version": "8.1.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -171,6 +182,7 @@
"package": {
"name": "squid",
"version": "3",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -184,6 +196,7 @@
"package": {
"name": "vim-2",
"version": "7.3",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -197,6 +210,7 @@
"package": {
"name": "rh-java-common-xmlrpc-1",
"version": "3.1.2",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -210,6 +224,7 @@
"package": {
"name": "chromium-browser-0",
"version": "69.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -232,6 +247,7 @@
"package": {
"name": "pam-0",
"version": "0.98.0",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -245,6 +261,7 @@
"package": {
"name": "seamonkey-0",
"version": "1.0.8",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -258,6 +275,7 @@
"package": {
"name": "subversion",
"version": "1.9",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -271,6 +289,7 @@
"package": {
"name": "mariadb",
"version": "10.2",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand All @@ -284,6 +303,7 @@
"package": {
"name": "thunderbird-0",
"version": "3.1.5",
"architecture": "x86_64",
"format": "rpm",
"vendor": "Red Hat, Inc."
},
Expand Down
Loading

0 comments on commit 3d784c4

Please sign in to comment.