mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Removed V4 + V6 options
This commit is contained in:
parent
219469f24f
commit
bac2e8c014
2 changed files with 16 additions and 48 deletions
|
@ -24,18 +24,8 @@ class DefangIP extends Operation {
|
||||||
this.infoURL = "https://isc.sans.edu/forums/diary/Defang+all+the+things/22744/";
|
this.infoURL = "https://isc.sans.edu/forums/diary/Defang+all+the+things/22744/";
|
||||||
this.inputType = "string";
|
this.inputType = "string";
|
||||||
this.outputType = "string";
|
this.outputType = "string";
|
||||||
this.args = [
|
this.args = [];
|
||||||
{
|
|
||||||
name: "IPV4",
|
|
||||||
type: "boolean",
|
|
||||||
value: true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "IPV6",
|
|
||||||
type: "boolean",
|
|
||||||
value: true
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -44,18 +34,17 @@ class DefangIP extends Operation {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const [IPV4, IPV6] = args;
|
|
||||||
|
|
||||||
if (IPV4) {
|
|
||||||
input = input.replace(IPV4_REGEX, x => {
|
input = input.replace(IPV4_REGEX, x => {
|
||||||
return x.replace(/\./g, "[.]");
|
return x.replace(/\./g, "[.]");
|
||||||
});
|
});
|
||||||
}
|
|
||||||
if (IPV6) {
|
|
||||||
input = input.replace(IPV6_REGEX, x => {
|
input = input.replace(IPV6_REGEX, x => {
|
||||||
return x.replace(/:/g, "[:]");
|
return x.replace(/:/g, "[:]");
|
||||||
});
|
});
|
||||||
}
|
|
||||||
return input;
|
return input;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
*
|
*
|
||||||
* @author h345983745
|
* @author h345983745
|
||||||
*
|
*
|
||||||
* @copyright Crown Copyright 2017
|
* @copyright Crown Copyright 2019
|
||||||
* @license Apache-2.0
|
* @license Apache-2.0
|
||||||
*/
|
*/
|
||||||
import TestRegister from "../TestRegister";
|
import TestRegister from "../TestRegister";
|
||||||
|
@ -16,7 +16,7 @@ TestRegister.addTests([
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "Defang IP",
|
op: "Defang IP",
|
||||||
args: [true, true],
|
args: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}, {
|
}, {
|
||||||
|
@ -26,7 +26,7 @@ TestRegister.addTests([
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "Defang IP",
|
op: "Defang IP",
|
||||||
args: [true, true],
|
args: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}, {
|
}, {
|
||||||
|
@ -36,29 +36,8 @@ TestRegister.addTests([
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "Defang IP",
|
op: "Defang IP",
|
||||||
args: [true, true],
|
args: [],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "Defang IP: IPV4 Only",
|
|
||||||
input: "192.168.1.1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
|
|
||||||
expectedOutput: "192[.]168[.]1[.]1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
|
|
||||||
recipeConfig: [
|
|
||||||
{
|
|
||||||
op: "Defang IP",
|
|
||||||
args: [true, false],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}, {
|
|
||||||
name: "Defang IP: IPV6 Only",
|
|
||||||
input: "192.168.1.1 2001:0db8:85a3:0000:0000:8a2e:0370:7343",
|
|
||||||
expectedOutput: "192.168.1.1 2001[:]0db8[:]85a3[:]0000[:]0000[:]8a2e[:]0370[:]7343",
|
|
||||||
recipeConfig: [
|
|
||||||
{
|
|
||||||
op: "Defang IP",
|
|
||||||
args: [false, true],
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue