Skip to content

Commit bac2e8c

Browse files
committed
Removed V4 + V6 options
1 parent 219469f commit bac2e8c

File tree

2 files changed

+17
-49
lines changed

2 files changed

+17
-49
lines changed

Diff for: src/core/operations/DefangIP.mjs

+13-24
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,8 @@ class DefangIP extends Operation {
2424
this.infoURL = "https://isc.sans.edu/forums/diary/Defang+all+the+things/22744/";
2525
this.inputType = "string";
2626
this.outputType = "string";
27-
this.args = [
28-
{
29-
name: "IPV4",
30-
type: "boolean",
31-
value: true
32-
},
33-
{
34-
name: "IPV6",
35-
type: "boolean",
36-
value: true
37-
}
38-
];
27+
this.args = [];
28+
3929
}
4030

4131
/**
@@ -44,18 +34,17 @@ class DefangIP extends Operation {
4434
* @returns {string}
4535
*/
4636
run(input, args) {
47-
const [IPV4, IPV6] = args;
48-
49-
if (IPV4) {
50-
input = input.replace(IPV4_REGEX, x => {
51-
return x.replace(/\./g, "[.]");
52-
});
53-
}
54-
if (IPV6) {
55-
input = input.replace(IPV6_REGEX, x => {
56-
return x.replace(/:/g, "[:]");
57-
});
58-
}
37+
38+
39+
input = input.replace(IPV4_REGEX, x => {
40+
return x.replace(/\./g, "[.]");
41+
});
42+
43+
44+
input = input.replace(IPV6_REGEX, x => {
45+
return x.replace(/:/g, "[:]");
46+
});
47+
5948
return input;
6049
}
6150
}

Diff for: tests/operations/tests/DefangIP.mjs

+4-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* @author h345983745
55
*
6-
* @copyright Crown Copyright 2017
6+
* @copyright Crown Copyright 2019
77
* @license Apache-2.0
88
*/
99
import TestRegister from "../TestRegister";
@@ -16,7 +16,7 @@ TestRegister.addTests([
1616
recipeConfig: [
1717
{
1818
op: "Defang IP",
19-
args: [true, true],
19+
args: [],
2020
},
2121
],
2222
}, {
@@ -26,7 +26,7 @@ TestRegister.addTests([
2626
recipeConfig: [
2727
{
2828
op: "Defang IP",
29-
args: [true, true],
29+
args: [],
3030
},
3131
],
3232
}, {
@@ -36,29 +36,8 @@ TestRegister.addTests([
3636
recipeConfig: [
3737
{
3838
op: "Defang IP",
39-
args: [true, true],
39+
args: [],
4040
},
4141
],
4242
},
43-
{
44-
name: "Defang IP: IPV4 Only",
45-
input: "192.168.1.1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
46-
expectedOutput: "192[.]168[.]1[.]1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
47-
recipeConfig: [
48-
{
49-
op: "Defang IP",
50-
args: [true, false],
51-
},
52-
],
53-
}, {
54-
name: "Defang IP: IPV6 Only",
55-
input: "192.168.1.1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
56-
expectedOutput: "192.168.1.1 2001[:]0db8[:]85a3[:]0000[:]0000[:]8a2e[:]0370[:]7343",
57-
recipeConfig: [
58-
{
59-
op: "Defang IP",
60-
args: [false, true],
61-
},
62-
],
63-
}
6443
]);

0 commit comments

Comments
 (0)