Skip to content

Commit

Permalink
Fixes formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dimeko committed Jun 25, 2024
1 parent b0097b9 commit ef869fd
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 79 deletions.
129 changes: 69 additions & 60 deletions tests/unit/test_data/mock_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,35 @@
"host": "0.0.0.0", "status": "up", "last_boot": "none", "os": ["unknown"], "osfingerprint": "none", "hops": [
"10.0.0.0",
"10.0.0.1"], "ports": {
"80": {"portid": "80", "protocol": "tcp", "state": {"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {"state": "closed"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
"80": {"portid": "80", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {
"state": "closed"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
}}, "result_hash": "d41d8cd98f00b204e9800998ecf8427e", "created_at": "2021-01-01 00:00:00"},

{"id": 2, "uuid": "uuid_2", "host_subnet": "0.0.0.0/24", "host": "0.0.0.0", "profile_name": "TEST_V1", "arguments": "-vv", "results": {
"host": "0.0.0.0", "status": "up", "last_boot": "none", "os": ["unknown"], "osfingerprint": "none", "hops": [
"10.0.0.0",
"10.0.0.1"], "ports": {
"80": {"portid": "80", "protocol": "tcp", "state": {"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {"state": "open"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
"80": {"portid": "80", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
}}, "result_hash": "d41d8cd98asw0b204e9800998ecf8427e", "created_at": "2021-01-01 00:00:00"},
{"id": 3, "uuid": "uuid_3", "host_subnet": "0.0.0.0/24", "host": "0.0.0.0", "profile_name": "TEST_V1", "arguments": "-vv", "results": {
"host": "0.0.0.0", "status": "up", "last_boot": "none", "os": ["unknown"], "osfingerprint": "none", "hops": [
"10.0.0.0",
"10.0.0.1"], "ports": {
"80": {"portid": "80", "protocol": "tcp", "state": {"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {"state": "closed"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
"80": {"portid": "80", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "http", "servicefp": "s_fp_test", "service_product": "Apache"},
"22": {"portid": "22", "protocol": "tcp", "state": {
"state": "closed"}, "service_name": "ssh", "servicefp": "s_fp_test", "service_product": "OpenSSH"},
"443": {"portid": "443", "protocol": "tcp", "state": {
"state": "open"}, "service_name": "https", "servicefp": "s_fp_test", "service_product": "Nginx"}
}}, "result_hash": "d41d8cd98f00b204e9800998ecf8427e", "created_at": "2021-01-01 00:00:00"},
]

Expand Down Expand Up @@ -237,13 +246,13 @@ def mock_data_with_real_hash(test_data):
},
"address": [
{
"addr": "0.0.0.0",
"addrtype": "ipv4"
"addr": "0.0.0.0",
"addrtype": "ipv4"
},
{
"addr": "D0:54:54:54:54:A4",
"addrtype": "mac",
"vendor": "NetApp"
"addr": "D0:54:54:54:54:A4",
"addrtype": "mac",
"vendor": "NetApp"
}
],
"ports": {
Expand Down Expand Up @@ -309,21 +318,21 @@ def mock_data_with_real_hash(test_data):
},
"os": {
"portused": [
{
"state": "open",
"proto": "tcp",
"portid": "22"
},
{
"state": "closed",
"proto": "tcp",
"portid": "666"
},
{
"state": "closed",
"proto": "udp",
"portid": "43268"
}
{
"state": "open",
"proto": "tcp",
"portid": "22"
},
{
"state": "closed",
"proto": "tcp",
"portid": "666"
},
{
"state": "closed",
"proto": "udp",
"portid": "43268"
}
],
"osmatch": [
{
Expand Down Expand Up @@ -354,51 +363,51 @@ def mock_data_with_real_hash(test_data):
"accuracy": "90",
"line": "26772",
"osclass": {
"type": "storage-misc",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "43.X",
"accuracy": "90",
"cpe": [
"cpe:/a:xxxxx:xxxxxx",
"cpe:/o:xxxxxx:xxxxxxxx:12.0"
]
"type": "storage-misc",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "43.X",
"accuracy": "90",
"cpe": [
"cpe:/a:xxxxx:xxxxxx",
"cpe:/o:xxxxxx:xxxxxxxx:12.0"
]
}
},
{
"name": "FreeBSD 54.0-RELEASE - 56.0-CURRENT",
"accuracy": "90",
"line": "26281",
"osclass": [
{
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "11.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxx:xxxxxxx:11"
},
{
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "43.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxxx:xxxxxxx:12"
}
{
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "11.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxx:xxxxxxx:11"
},
{
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "43.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxxx:xxxxxxx:12"
}
]
},
{
"name": "FreeBSD 43.2-RELEASE - 65.3 RELEASE or 65.2-STABLE",
"accuracy": "90",
"line": "26487",
"osclass": {
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "11.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxxx:xxxxxx:11"
"type": "general purpose",
"vendor": "FreeBSD",
"osfamily": "FreeBSD",
"osgen": "11.X",
"accuracy": "90",
"cpe": "cpe:/o:xxxxxxx:xxxxxx:11"
}
},
]
Expand Down
39 changes: 20 additions & 19 deletions tests/unit/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from deltascan.core.scanner import Scanner
import json


class TestScanner(unittest.TestCase):
@patch("deltascan.core.scanner.Parser.extract_port_scan_dict_results")
@patch("deltascan.core.scanner.LibNmapWrapper.scan")
Expand All @@ -46,13 +47,13 @@ def test_scan(self):
"host": "0.0.0.0",
"address": [
{
"addr": "0.0.0.0",
"addrtype": "ipv4"
"addr": "0.0.0.0",
"addrtype": "ipv4"
},
{
"addr": "D0:54:54:54:54:A4",
"addrtype": "mac",
"vendor": "NetApp"
"addr": "D0:54:54:54:54:A4",
"addrtype": "mac",
"vendor": "NetApp"
}
],
"status": "up",
Expand Down Expand Up @@ -130,16 +131,16 @@ def test_scan(self):
},
"trace": {
"hop": [
{
"ttl": "1",
"ipaddr": "10.0.0.1",
"rtt": "1.1"
},
{
"ttl": "2",
"ipaddr": "10.0.0.2",
"rtt": "1.1"
}
{
"ttl": "1",
"ipaddr": "10.0.0.1",
"rtt": "1.1"
},
{
"ttl": "2",
"ipaddr": "10.0.0.2",
"rtt": "1.1"
}
]
},
"os": [
Expand All @@ -153,7 +154,7 @@ def test_scan(self):
],
"osfingerprint": "none",
"last_boot": "12345678"
}
]
}
)
}
]
}
)

0 comments on commit ef869fd

Please sign in to comment.