Skip to content

Commit fbf1057

Browse files
committed
#1833 Updated amass parser test and snapshot to fit the change to expect filecontent instead of path of database
Signed-off-by: Ilyes Ben Dlala <ilyes.bendlala@iteratec.com>
1 parent a46c5d1 commit fbf1057

3 files changed

Lines changed: 27 additions & 20 deletions

File tree

scanners/amass/parser/__snapshots__/parser.test.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
1616
},
1717
"category": "Subdomain",
1818
"description": "Found subdomain example.com",
19-
"identified_at": "2023-08-18T12:23:59.131Z",
19+
"identified_at": null,
2020
"location": "example.com",
2121
"name": "example.com",
2222
"osi_layer": "NETWORK",
@@ -36,7 +36,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
3636
},
3737
"category": "Subdomain",
3838
"description": "Found subdomain www.example.com",
39-
"identified_at": "2023-08-18T12:23:59.131Z",
39+
"identified_at": null,
4040
"location": "www.example.com",
4141
"name": "www.example.com",
4242
"osi_layer": "NETWORK",
@@ -56,7 +56,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
5656
},
5757
"category": "Subdomain",
5858
"description": "Found subdomain example.com",
59-
"identified_at": "2023-08-18T12:23:59.131Z",
59+
"identified_at": null,
6060
"location": "example.com",
6161
"name": "example.com",
6262
"osi_layer": "NETWORK",
@@ -76,7 +76,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
7676
},
7777
"category": "Subdomain",
7878
"description": "Found subdomain www.example.com",
79-
"identified_at": "2023-08-18T12:23:59.131Z",
79+
"identified_at": null,
8080
"location": "www.example.com",
8181
"name": "www.example.com",
8282
"osi_layer": "NETWORK",
@@ -96,7 +96,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
9696
},
9797
"category": "Subdomain",
9898
"description": "Found subdomain a.iana-servers.net",
99-
"identified_at": "2023-08-18T12:23:59.131Z",
99+
"identified_at": null,
100100
"location": "a.iana-servers.net",
101101
"name": "a.iana-servers.net",
102102
"osi_layer": "NETWORK",
@@ -116,7 +116,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
116116
},
117117
"category": "Subdomain",
118118
"description": "Found subdomain a.iana-servers.net",
119-
"identified_at": "2023-08-18T12:23:59.131Z",
119+
"identified_at": null,
120120
"location": "a.iana-servers.net",
121121
"name": "a.iana-servers.net",
122122
"osi_layer": "NETWORK",
@@ -136,7 +136,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
136136
},
137137
"category": "Subdomain",
138138
"description": "Found subdomain b.iana-servers.net",
139-
"identified_at": "2023-08-18T12:23:59.131Z",
139+
"identified_at": null,
140140
"location": "b.iana-servers.net",
141141
"name": "b.iana-servers.net",
142142
"osi_layer": "NETWORK",
@@ -156,7 +156,7 @@ exports[`parser parses example.com sqlite results database successfully 1`] = `
156156
},
157157
"category": "Subdomain",
158158
"description": "Found subdomain b.iana-servers.net",
159-
"identified_at": "2023-08-18T12:23:59.131Z",
159+
"identified_at": null,
160160
"location": "b.iana-servers.net",
161161
"name": "b.iana-servers.net",
162162
"osi_layer": "NETWORK",
0 Bytes
Binary file not shown.

scanners/amass/parser/parser.test.js

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,42 @@
22
//
33
// SPDX-License-Identifier: Apache-2.0
44

5-
const {
6-
validateParser,
7-
} = require("@securecodebox/parser-sdk-nodejs/parser-utils");
5+
const fs = require("fs");
6+
const util = require("util");
7+
const readFile = util.promisify(fs.readFile);
88

9-
// eslint-disable-next-line security/detect-non-literal-fs-filename
9+
const { parse } = require("./parser");
1010

1111
const {
12-
parse
13-
} = require("./parser");
12+
validateParser,
13+
} = require("@securecodebox/parser-sdk-nodejs/parser-utils");
1414

1515
test("parser parses example.com sqlite results database successfully", async () => {
16-
const databasePath = __dirname + "/__testFiles__/example.com.sqlite";
16+
const fileContent = await readFile(
17+
__dirname + "/__testFiles__/example.com.sqlite"
18+
);
1719

18-
const findings = await parse(databasePath);
20+
const findings = await parse(fileContent);
1921
await expect(validateParser(findings)).resolves.toBeUndefined();
2022
expect(findings).toMatchSnapshot();
2123
});
2224

2325
test("parser parses sqlite results database with empty tables successfully", async () => {
24-
const databasePath = __dirname + "/__testFiles__/emptyTables.sqlite";
25-
const findings = await parse(databasePath);
26+
const fileContent = await readFile(
27+
__dirname + "/__testFiles__/emptyTables.sqlite"
28+
);
29+
30+
const findings = await parse(fileContent);
2631
await expect(validateParser(findings)).resolves.toBeUndefined();
2732
expect(findings).toEqual([]);
2833
});
2934

3035
test("parser parses sqlite results database with no tables successfully", async () => {
31-
const databasePath = __dirname + "/__testFiles__/noTables.sqlite";
36+
const fileContent = await readFile(
37+
__dirname + "/__testFiles__/noTables.sqlite",
38+
);
3239

33-
const findings = await parse(databasePath);
40+
const findings = await parse(fileContent);
3441
await expect(validateParser(findings)).resolves.toBeUndefined();
3542
expect(findings).toEqual([]);
3643
});

0 commit comments

Comments
 (0)