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

Commit e97bb3f

Browse files
committed
Change nmap parser to return an empty array if there are no hosts
1 parent 090306b commit e97bb3f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

integrations/nmap/parser/parser.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ function parseResultFile(fileContent) {
6464
} else {
6565
let tempHostList = [];
6666
if (!xmlInput.nmaprun.host) {
67-
reject(new Error("Nmap result file didn't contain a valid host. This probably means that the target was specified incorrectly."));
67+
resolve([]);
68+
return;
6869
}
6970

7071
xmlInput = xmlInput.nmaprun.host;

integrations/nmap/parser/parser.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,5 +150,5 @@ test("should properly parse a nmap xml without any host", async () => {
150150
encoding: "utf8"
151151
});
152152

153-
expect(parse(xmlContent)).rejects.toThrow("Nmap result file didn't contain a valid host. This probably means that the target was specified incorrectly.")
153+
expect(await parse(xmlContent)).toMatchInlineSnapshot(`Array []`);
154154
});

0 commit comments

Comments
 (0)