Skip to content

Commit aaf3b06

Browse files
committed
Move param to a named param in a object
Makes it easier to understand what this bool flag is doing from the tests Signed-off-by: Jannik Hollenbach <jannik.hollenbach@iteratec.com>
1 parent c98a88a commit aaf3b06

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

scanners/subfinder/parser/parser.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ const DOMAIN_FLAGS = ["-d", "-domain", "--domain"];
77
export async function parse(
88
fileContent,
99
scan,
10-
includeTargetDomain = process.env["INCLUDE_TARGET_DOMAIN"]?.toLowerCase() ==
11-
"true",
10+
options = {},
1211
) {
12+
const includeTargetDomain = options.includeTargetDomain ??
13+
(process.env["INCLUDE_TARGET_DOMAIN"]?.toLowerCase() === "true");
14+
1315
const targets = parseResultFile(fileContent);
1416
const findings = transformToFindings(targets);
1517

scanners/subfinder/parser/parser.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ test("should properly parse empty json file with includeTargetDomain=true", asyn
5959
const fileContent = await readFile(__dirname + "/__testFiles__/empty.jsonl", {
6060
encoding: "utf8",
6161
});
62-
const findings = await parse(fileContent, scan, "true");
62+
const findings = await parse(fileContent, scan, { includeTargetDomain: true });
6363
// validate findings
6464
expect(validateParser(findings)).toBeUndefined();
6565
expect(findings).toMatchSnapshot();
@@ -85,7 +85,7 @@ test("should properly parse subfinder json file and add target domain to finding
8585
encoding: "utf8",
8686
},
8787
);
88-
const findings = await parse(fileContent, scan, "true");
88+
const findings = await parse(fileContent, scan, { includeTargetDomain: true });
8989
// validate findings
9090
expect(validateParser(findings)).toBeUndefined();
9191
expect(findings).toMatchSnapshot();
@@ -111,7 +111,7 @@ test("should properly parse subfinder json file and add target domain to finding
111111
encoding: "utf8",
112112
},
113113
);
114-
const findings = await parse(fileContent, scan, "true");
114+
const findings = await parse(fileContent, scan, { includeTargetDomain: true });
115115
// validate findings
116116
expect(validateParser(findings)).toBeUndefined();
117117
expect(findings).toMatchSnapshot();
@@ -137,7 +137,7 @@ test("should properly parse subfinder json file and add target domain to finding
137137
encoding: "utf8",
138138
},
139139
);
140-
const findings = await parse(fileContent, scan, "true");
140+
const findings = await parse(fileContent, scan, { includeTargetDomain: true });
141141
// validate findings
142142
expect(validateParser(findings)).toBeUndefined();
143143
expect(findings).toMatchSnapshot();

0 commit comments

Comments
 (0)