mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-11 00:31:31 -04:00
Delete ExtractFilePaths.mjs
This commit is contained in:
parent
05e65a74ce
commit
87f4257596
1 changed files with 0 additions and 78 deletions
|
@ -1,78 +0,0 @@
|
||||||
/**
|
|
||||||
* @author n1474335 [n1474335@gmail.com]
|
|
||||||
* @copyright Crown Copyright 2016
|
|
||||||
* @license Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
|
||||||
import { search } from "../lib/Extract.mjs";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Extract file paths operation
|
|
||||||
*/
|
|
||||||
class ExtractFilePaths extends Operation {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ExtractFilePaths constructor
|
|
||||||
*/
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.name = "Extract file paths";
|
|
||||||
this.module = "Regex";
|
|
||||||
this.description = "Extracts anything that looks like a Windows or UNIX file path.<br><br>Note that if UNIX is selected, there will likely be a lot of false positives.";
|
|
||||||
this.inputType = "string";
|
|
||||||
this.outputType = "string";
|
|
||||||
this.args = [
|
|
||||||
{
|
|
||||||
"name": "Windows",
|
|
||||||
"type": "boolean",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "UNIX",
|
|
||||||
"type": "boolean",
|
|
||||||
"value": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "Display total",
|
|
||||||
"type": "boolean",
|
|
||||||
"value": false
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param {string} input
|
|
||||||
* @param {Object[]} args
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
run(input, args) {
|
|
||||||
const [includeWinPath, includeUnixPath, displayTotal] = args,
|
|
||||||
winDrive = "[A-Z]:\\\\",
|
|
||||||
winName = "[A-Z\\d][A-Z\\d\\- '_\\(\\)~]{0,61}",
|
|
||||||
winExt = "[A-Z\\d]{1,6}",
|
|
||||||
winPath = winDrive + "(?:" + winName + "\\\\?)*" + winName +
|
|
||||||
"(?:\\." + winExt + ")?",
|
|
||||||
unixPath = "(?:/[A-Z\\d.][A-Z\\d\\-.]{0,61})+";
|
|
||||||
let filePaths = "";
|
|
||||||
|
|
||||||
if (includeWinPath && includeUnixPath) {
|
|
||||||
filePaths = winPath + "|" + unixPath;
|
|
||||||
} else if (includeWinPath) {
|
|
||||||
filePaths = winPath;
|
|
||||||
} else if (includeUnixPath) {
|
|
||||||
filePaths = unixPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filePaths) {
|
|
||||||
const regex = new RegExp(filePaths, "ig");
|
|
||||||
return search(input, regex, null, displayTotal);
|
|
||||||
} else {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export default ExtractFilePaths;
|
|
Loading…
Add table
Add a link
Reference in a new issue