Skip to content
This repository was archived by the owner on Oct 14, 2020. It is now read-only.

Commit b74fd3d

Browse files
committed
#33 Add test for nmap scanning a port without a predefined port mapping
1 parent e52d845 commit b74fd3d

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE nmaprun>
3+
<?xml-stylesheet href="file:///usr/bin/../share/nmap/nmap.xsl" type="text/xsl"?>
4+
<!-- Nmap 7.80 scan initiated Sat Jun 27 19:40:19 2020 as: nmap -oX /home/securecodebox/nmap-results.xml &quot;-p 10250&quot; example.com -->
5+
<nmaprun scanner="nmap" args="nmap -oX /home/securecodebox/nmap-results.xml &quot;-p 10250&quot; example.com" start="1593286819" startstr="Sat Jun 27 19:40:19 2020" version="7.80" xmloutputversion="1.04">
6+
<scaninfo type="syn" protocol="tcp" numservices="1" services="10250"/>
7+
<verbose level="0"/>
8+
<debugging level="0"/>
9+
<host starttime="1593286819" endtime="1593286820"><status state="up" reason="reset" reason_ttl="37"/>
10+
<address addr="93.184.216.34" addrtype="ipv4"/>
11+
<hostnames>
12+
<hostname name="example.com" type="user"/>
13+
</hostnames>
14+
<ports><port protocol="tcp" portid="10250"><state state="filtered" reason="no-response" reason_ttl="0"/></port>
15+
</ports>
16+
<times srtt="301" rttvar="5000" to="100000"/>
17+
</host>
18+
<runstats><finished time="1593286820" timestr="Sat Jun 27 19:40:20 2020" elapsed="0.38" summary="Nmap done at Sat Jun 27 19:40:20 2020; 1 IP address (1 host up) scanned in 0.38 seconds" exit="success"/><hosts up="1" down="0" total="1"/>
19+
</runstats>
20+
</nmaprun>

scanners/nmap/parser/parser.test.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,55 @@ test("should properly parse a nmap xml without any host", async () => {
153153
expect(await parse(xmlContent)).toMatchInlineSnapshot(`Array []`);
154154
});
155155

156+
test("should properly parse a nmap xml with missing service information", async () => {
157+
const xmlContent = await readFile(
158+
__dirname + "/__testFiles__/no-service.xml",
159+
{
160+
encoding: "utf8"
161+
}
162+
);
163+
164+
expect(await parse(xmlContent)).toMatchInlineSnapshot(`
165+
Array [
166+
Object {
167+
"attributes": Object {
168+
"hostname": "example.com",
169+
"ip_address": "93.184.216.34",
170+
"mac_address": null,
171+
"method": undefined,
172+
"operating_system": null,
173+
"port": 10250,
174+
"protocol": "tcp",
175+
"scripts": null,
176+
"service": undefined,
177+
"serviceProduct": null,
178+
"serviceVersion": null,
179+
"state": "filtered",
180+
},
181+
"category": "Open Port",
182+
"description": "Port 10250 is filtered using tcp protocol.",
183+
"location": "tcp://93.184.216.34:10250",
184+
"name": undefined,
185+
"osi_layer": "NETWORK",
186+
"severity": "INFORMATIONAL",
187+
},
188+
Object {
189+
"attributes": Object {
190+
"hostname": "example.com",
191+
"ip_address": "93.184.216.34",
192+
"operating_system": null,
193+
},
194+
"category": "Host",
195+
"description": "Found a host",
196+
"location": "example.com",
197+
"name": "Host: example.com",
198+
"osi_layer": "NETWORK",
199+
"severity": "INFORMATIONAL",
200+
},
201+
]
202+
`);
203+
});
204+
156205
test("Should properly parse a nmap xml with script specific SMB findings", async () => {
157206
const xmlContent = await readFile(
158207
__dirname + "/__testFiles__/localhost-smb-script.xml",

0 commit comments

Comments
 (0)