Skip to content

Commit 2a244a3

Browse files
committed
Modifications in results schema
1 parent 97173ac commit 2a244a3

File tree

5 files changed

+18
-18
lines changed

5 files changed

+18
-18
lines changed

deltascan/core/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class Config:
6060
-------------------------------------------------------
6161
- Scans in Db : {}
6262
- Profiles in Db : {}
63-
- Profiles : {}
63+
- Profile : {}
6464
- Configuration file : {}
6565
- Output file : {}
6666
-------------------------------------------------------

deltascan/core/parser.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def extract_port_scan_dict_results(cls, results):
9191
Exception: If an error occurs during the scan parser.
9292
9393
"""
94+
# TODO: We can add here as many fields as we want!
9495
try:
9596
scan_results = []
9697
for host in results.hosts:
@@ -107,22 +108,21 @@ def extract_port_scan_dict_results(cls, results):
107108
"servicefp": "none" if isinstance(s.servicefp, str) and s.servicefp == "" else s.servicefp,
108109
"service_product": "none" if isinstance(s.banner, str) and s.banner == "" else s.banner,
109110
})
110-
111-
scan["os"] = []
111+
112+
scan["os"] = {}
112113
try:
113-
for _idx in range(3):
114-
scan["os"].append(
115-
host._extras["os"]["osmatches"][_idx]["osmatch"]["name"])
114+
for _idx, _match in enumerate(host._extras["os"]["osmatches"][:3]):
115+
scan["os"][str(_idx+1)] = _match["osmatch"]["name"]
116116
except (KeyError, IndexError):
117117
if len(scan["os"]) == 0:
118118
scan["os"] = ["none"]
119119
else:
120120
pass
121121

122-
scan["hops"] = []
122+
scan["hops"] = {}
123123
try:
124-
for _hop in host._extras["trace"]["hops"]:
125-
scan["hops"].append({_k: _hop[_k] for _k in ["ipaddr", "host"]})
124+
for _idx, _hop in enumerate(host._extras["trace"]["hops"]):
125+
scan["hops"][str(_idx+1)] = _hop["ipaddr"]
126126
except (KeyError, IndexError):
127127
if len(scan["hops"]) == 0:
128128
scan["hops"] = ["none"]

deltascan/core/schemas.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Scan(Schema):
3838
host = fields.Str(required=True)
3939
status = fields.Str(required=True)
4040
ports = fields.Nested(ScanPorts, many=True, required=True)
41-
os = fields.List(fields.Str(), required=True)
41+
os = fields.Raw(required=True)
4242
hops = fields.Raw(required=True)
4343
osfingerprint = fields.Str(required=True)
4444
last_boot = fields.Str(required=True)

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"marshmallow==3.14.0",
2727
"jinja2==3.1.3",
2828
"getkey==0.6",
29-
"python-libnmap @ git+https://github.com/Logisek/python-libnmap.git@develop#egg=libnmap",
29+
"python-libnmap @ git+https://github.com/Logisek/python-libnmap.git@master#egg=libnmap",
3030
"pdfkit",
3131
"inputimeout"
3232
],

tests/unit/test_scanner.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ def test_scan(self):
5050
"service_product": "Nginx"
5151
}
5252
],
53-
"os": [
54-
"os_name"
55-
],
56-
"hops": [
57-
{"ipaddr": "10.0.0.0", "host": "host_1"},
58-
{"ipaddr": "10.0.0.1", "host": "host_2"},
59-
],
53+
"os": {
54+
"1": "os_name"
55+
},
56+
"hops": {
57+
"1": "10.0.0.0",
58+
"2": "10.0.0.1"
59+
},
6060
"osfingerprint": "os_fingerprint",
6161
"last_boot": "12345678"
6262
}

0 commit comments

Comments
 (0)