mirror of
https://github.com/gchq/CyberChef
synced 2025-01-06 01:28:48 +00:00
Switched from uas_parser.js to ua-parser-js library to improve library management and remove ReDos vulnerabilities. Also improved performance of two native regexes. Thanks to James Davis for raising awareness.
This commit is contained in:
parent
a177e2ab7e
commit
da473de9f0
8 changed files with 27 additions and 25839 deletions
5
package-lock.json
generated
5
package-lock.json
generated
|
@ -10517,6 +10517,11 @@
|
||||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"ua-parser-js": {
|
||||||
|
"version": "0.7.17",
|
||||||
|
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.17.tgz",
|
||||||
|
"integrity": "sha512-uRdSdu1oA1rncCQL7sCj8vSyZkgtL7faaw9Tc9rZ3mGgraQ7+Pdx7w5mnOSF3gw9ZNG6oc+KXfkon3bKuROm0g=="
|
||||||
|
},
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
"version": "3.1.3",
|
"version": "3.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.1.3.tgz",
|
||||||
|
|
|
@ -101,6 +101,7 @@
|
||||||
"sladex-blowfish": "^0.8.1",
|
"sladex-blowfish": "^0.8.1",
|
||||||
"sortablejs": "^1.7.0",
|
"sortablejs": "^1.7.0",
|
||||||
"split.js": "^1.3.5",
|
"split.js": "^1.3.5",
|
||||||
|
"ua-parser-js": "^0.7.17",
|
||||||
"utf8": "^3.0.0",
|
"utf8": "^3.0.0",
|
||||||
"vkbeautify": "^0.99.3",
|
"vkbeautify": "^0.99.3",
|
||||||
"xmldom": "^0.1.27",
|
"xmldom": "^0.1.27",
|
||||||
|
|
|
@ -138,6 +138,7 @@ function loadRequiredModules(recipeConfig) {
|
||||||
log.info("Loading module " + module);
|
log.info("Loading module " + module);
|
||||||
self.sendStatusMessage("Loading module " + module);
|
self.sendStatusMessage("Loading module " + module);
|
||||||
self.importScripts(self.docURL + "/" + module + ".js");
|
self.importScripts(self.docURL + "/" + module + ".js");
|
||||||
|
self.sendStatusMessage("");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -952,7 +952,7 @@ const Utils = {
|
||||||
// Parse bespoke recipe format
|
// Parse bespoke recipe format
|
||||||
recipe = recipe.replace(/\n/g, "");
|
recipe = recipe.replace(/\n/g, "");
|
||||||
let m,
|
let m,
|
||||||
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/])*)(\/[^)]+)?\)/g,
|
recipeRegex = /([^(]+)\(((?:'[^'\\]*(?:\\.[^'\\]*)*'|[^)/'])*)(\/[^)]+)?\)/g,
|
||||||
recipeConfig = [],
|
recipeConfig = [],
|
||||||
args;
|
args;
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -207,7 +207,7 @@ const Extract = {
|
||||||
*/
|
*/
|
||||||
runEmail: function(input, args) {
|
runEmail: function(input, args) {
|
||||||
let displayTotal = args[0],
|
let displayTotal = args[0],
|
||||||
regex = /\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}/ig;
|
regex = /\b\w[-.\w]*@[-\w]+(?:\.[-\w]+)*\.[A-Z]{2,4}\b/ig;
|
||||||
|
|
||||||
return Extract._search(input, regex, null, displayTotal);
|
return Extract._search(input, regex, null, displayTotal);
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import {UAS_parser as UAParser} from "../lib/uas_parser.js";
|
import UAParser from "ua-parser-js";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,20 +46,22 @@ const HTTP = {
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
runParseUserAgent: function(input, args) {
|
runParseUserAgent: function(input, args) {
|
||||||
const ua = UAParser.parse(input);
|
const ua = UAParser(input);
|
||||||
|
return `Browser
|
||||||
return "Type: " + ua.type + "\n" +
|
Name: ${ua.browser.name || "unknown"}
|
||||||
"Family: " + ua.uaFamily + "\n" +
|
Version: ${ua.browser.version || "unknown"}
|
||||||
"Name: " + ua.uaName + "\n" +
|
Device
|
||||||
"URL: " + ua.uaUrl + "\n" +
|
Model: ${ua.device.model || "unknown"}
|
||||||
"Company: " + ua.uaCompany + "\n" +
|
Type: ${ua.device.type || "unknown"}
|
||||||
"Company URL: " + ua.uaCompanyUrl + "\n\n" +
|
Vendor: ${ua.device.vendor || "unknown"}
|
||||||
"OS Family: " + ua.osFamily + "\n" +
|
Engine
|
||||||
"OS Name: " + ua.osName + "\n" +
|
Name: ${ua.engine.name || "unknown"}
|
||||||
"OS URL: " + ua.osUrl + "\n" +
|
Version: ${ua.engine.version || "unknown"}
|
||||||
"OS Company: " + ua.osCompany + "\n" +
|
OS
|
||||||
"OS Company URL: " + ua.osCompanyUrl + "\n" +
|
Name: ${ua.os.name || "unknown"}
|
||||||
"Device Type: " + ua.deviceType + "\n";
|
Version: ${ua.os.version || "unknown"}
|
||||||
|
CPU
|
||||||
|
Architecture: ${ua.cpu.architecture || "unknown"}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ const Regex = {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "Email address",
|
name: "Email address",
|
||||||
value: "(\\w[-.\\w]*)@([-\\w]+(?:\\.[-\\w]+)*)\\.([A-Za-z]{2,4})"
|
value: "\\b(\\w[-.\\w]*)@([-\\w]+(?:\\.[-\\w]+)*)\\.([A-Za-z]{2,4})\\b"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "URL",
|
name: "URL",
|
||||||
|
|
Loading…
Reference in a new issue