mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-14 10:06:58 -04:00
Magic Sigs for DefangURL operation
This commit is contained in:
parent
0f4d1e70e0
commit
f2b596c638
3 changed files with 52 additions and 6 deletions
|
@ -245,7 +245,7 @@ class Magic {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses the checks to validate the input/output of potential operations.
|
* Uses the checks to validate the input//output of potential operations.
|
||||||
*
|
*
|
||||||
* @param {string} flag
|
* @param {string} flag
|
||||||
* @param {array} sensible
|
* @param {array} sensible
|
||||||
|
@ -264,9 +264,13 @@ class Magic {
|
||||||
const opConfig = {
|
const opConfig = {
|
||||||
op: op.op,
|
op: op.op,
|
||||||
args: op.args
|
args: op.args
|
||||||
},
|
};
|
||||||
|
let output;
|
||||||
|
try {
|
||||||
output = await this._runRecipe([opConfig]);
|
output = await this._runRecipe([opConfig]);
|
||||||
|
} catch(err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// If the recipe is repeating and returning the same data, do not continue
|
// If the recipe is repeating and returning the same data, do not continue
|
||||||
if (prevOp && op.op === prevOp.op && _buffersEqual(output, this.inputBuffer)) {
|
if (prevOp && op.op === prevOp.op && _buffersEqual(output, this.inputBuffer)) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
/**
|
/**
|
||||||
*
|
* A class to make the input/output validation checks easier to define.
|
||||||
*/
|
*/
|
||||||
class magicObject {
|
class magicObject {
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param inRegexes
|
* @param inRegexes
|
||||||
* @param outRegexes
|
* @param outRegexes
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import {URL_REGEX, DOMAIN_REGEX} from "../lib/Extract.mjs";
|
import {URL_REGEX, DOMAIN_REGEX} from "../lib/Extract.mjs";
|
||||||
|
import magicObject from "../lib/MagicObject.mjs";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DefangURL operation
|
* DefangURL operation
|
||||||
|
@ -47,6 +48,48 @@ class DefangURL extends Operation {
|
||||||
value: ["Valid domains and full URLs", "Only full URLs", "Everything"]
|
value: ["Valid domains and full URLs", "Only full URLs", "Everything"]
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
this.checks = new magicObject([
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [false, false, false, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [true, false, false, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [false, true, false, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [true, true, false, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [false, false, true, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [true, false, true, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [false, true, true, "Everything"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$",
|
||||||
|
flags: "i",
|
||||||
|
args: [true, true, true, "Everything"],
|
||||||
|
}
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue