From 1bbcc8d5421ccf51cfbc02858a90b63d10561586 Mon Sep 17 00:00:00 2001 From: n1073645 Date: Wed, 18 Dec 2019 10:55:16 +0000 Subject: [PATCH] Converted MagicObject to just dictionaries --- src/core/lib/MagicObject.mjs | 17 -- src/core/operations/A1Z26CipherDecode.mjs | 79 ++++---- src/core/operations/BaconCipherDecode.mjs | 101 +++++----- src/core/operations/Bzip2Decompress.mjs | 24 ++- src/core/operations/CSVToJSON.mjs | 31 ++-- src/core/operations/ChangeIPFormat.mjs | 43 ++--- src/core/operations/CitrixCTX1Decode.mjs | 19 +- src/core/operations/DechunkHTTPResponse.mjs | 19 +- src/core/operations/DecodeNetBIOSName.mjs | 19 +- src/core/operations/DefangIPAddresses.mjs | 38 ++-- src/core/operations/DefangURL.mjs | 121 ++++++------ .../operations/EscapeUnicodeCharacters.mjs | 43 ++--- src/core/operations/FormatMACAddresses.mjs | 19 +- src/core/operations/FromBCD.mjs | 24 ++- src/core/operations/FromBase32.mjs | 28 ++- src/core/operations/FromBase58.mjs | 31 ++-- src/core/operations/FromBase64.mjs | 173 +++++++++--------- src/core/operations/FromBase85.mjs | 43 ++--- src/core/operations/FromBinary.mjs | 96 +++++----- src/core/operations/FromDecimal.mjs | 88 +++++---- src/core/operations/FromHTMLEntity.mjs | 19 +- src/core/operations/FromHex.mjs | 124 ++++++------- src/core/operations/FromHexContent.mjs | 27 ++- src/core/operations/FromHexdump.mjs | 27 ++- src/core/operations/FromMorseCode.mjs | 27 ++- src/core/operations/FromOctal.mjs | 87 +++++---- src/core/operations/FromQuotedPrintable.mjs | 19 +- src/core/operations/FromUNIXTimestamp.mjs | 55 +++--- src/core/operations/Gunzip.mjs | 24 ++- src/core/operations/ObjectIdentifierToHex.mjs | 19 +- src/core/operations/ParseIPv6Address.mjs | 19 +- src/core/operations/ParseQRCode.mjs | 21 ++- src/core/operations/ParseSSHHostKey.mjs | 19 +- .../operations/ParseUNIXFilePermissions.mjs | 19 +- src/core/operations/ParseUserAgent.mjs | 19 +- src/core/operations/ParseX509Certificate.mjs | 23 +-- src/core/operations/RemoveLineNumbers.mjs | 19 +- src/core/operations/RenderImage.mjs | 27 ++- src/core/operations/StripHTMLTags.mjs | 19 +- src/core/operations/StripHTTPHeaders.mjs | 19 +- src/core/operations/URLDecode.mjs | 19 +- src/core/operations/Untar.mjs | 19 +- src/core/operations/Unzip.mjs | 24 ++- src/core/operations/ZlibInflate.mjs | 19 +- 44 files changed, 879 insertions(+), 890 deletions(-) delete mode 100644 src/core/lib/MagicObject.mjs diff --git a/src/core/lib/MagicObject.mjs b/src/core/lib/MagicObject.mjs deleted file mode 100644 index 7deea50f..00000000 --- a/src/core/lib/MagicObject.mjs +++ /dev/null @@ -1,17 +0,0 @@ -/** - * A class to make the input/output validation checks easier to define. - */ -class magicObject { - /** - * @param inRegexes - * @param outRegexes - * @param mimeCheck - */ - constructor (inRegexes = null, outRegexes = null, mimeCheck = null, entropyTests=null) { - this.inRegexes = inRegexes; - this.outRegexes = outRegexes; - this.mimeCheck = mimeCheck; - this.entropyTests = entropyTests; - } - -} export default magicObject; diff --git a/src/core/operations/A1Z26CipherDecode.mjs b/src/core/operations/A1Z26CipherDecode.mjs index 8bb140af..fffe3dba 100644 --- a/src/core/operations/A1Z26CipherDecode.mjs +++ b/src/core/operations/A1Z26CipherDecode.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import {DELIM_OPTIONS} from "../lib/Delim.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * A1Z26 Cipher Decode operation @@ -34,44 +33,46 @@ class A1Z26CipherDecode extends Operation { value: DELIM_OPTIONS } ]; - this.checks = new magicObject([ - { - match: "^\\s*([12]?[0-9] )+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["Space"] - }, - { - match: "^\\s*([12]?[0-9],)+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["Comma"] - }, - { - match: "^\\s*([12]?[0-9];)+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["Semi-colon"] - }, - { - match: "^\\s*([12]?[0-9]:)+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["Colon"] - }, - { - match: "^\\s*([12]?[0-9]\\n)+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["Line feed"] - }, - { - match: "^\\s*([12]?[0-9]\\r\\n)+[12]?[0-9]\\s*$", - flags: "", - magic: true, - args: ["CRLF"] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([12]?[0-9] )+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["Space"] + }, + { + match: "^\\s*([12]?[0-9],)+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["Comma"] + }, + { + match: "^\\s*([12]?[0-9];)+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["Semi-colon"] + }, + { + match: "^\\s*([12]?[0-9]:)+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["Colon"] + }, + { + match: "^\\s*([12]?[0-9]\\n)+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["Line feed"] + }, + { + match: "^\\s*([12]?[0-9]\\r\\n)+[12]?[0-9]\\s*$", + flags: "", + magic: true, + args: ["CRLF"] + }] + }; } /** diff --git a/src/core/operations/BaconCipherDecode.mjs b/src/core/operations/BaconCipherDecode.mjs index 7f0311a7..b9230501 100644 --- a/src/core/operations/BaconCipherDecode.mjs +++ b/src/core/operations/BaconCipherDecode.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import { BACON_ALPHABETS, BACON_TRANSLATION_CASE, BACON_TRANSLATION_AMNZ, BACON_TRANSLATIONS, BACON_CLEARER_MAP, BACON_NORMALIZE_MAP, @@ -45,56 +44,58 @@ class BaconCipherDecode extends Operation { "value": false } ]; - this.checks = new magicObject([ + this.checks = { - match: "^\\s*([01]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Standard (I=J and U=V)", "0/1", false] - }, - { - match: "^\\s*([01]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Standard (I=J and U=V)", "0/1", true] - }, - { - match: "^\\s*([AB]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Standard (I=J and U=V)", "A/B", false] - }, - { - match: "^\\s*([AB]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Standard (I=J and U=V)", "A/B", true] - }, - { - match: "^\\s*([01]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Complete", "0/1", false] - }, - { - match: "^\\s*([01]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Complete", "0/1", true] - }, - { - match: "^\\s*([AB]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Complete", "A/B", false] - }, - { - match: "^\\s*([AB]{5}\\s?)+$", - flags: "", - magic: true, - args: ["Complete", "A/B", true] - } - ]); + inRegexes: [ + { + match: "^\\s*([01]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Standard (I=J and U=V)", "0/1", false] + }, + { + match: "^\\s*([01]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Standard (I=J and U=V)", "0/1", true] + }, + { + match: "^\\s*([AB]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Standard (I=J and U=V)", "A/B", false] + }, + { + match: "^\\s*([AB]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Standard (I=J and U=V)", "A/B", true] + }, + { + match: "^\\s*([01]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Complete", "0/1", false] + }, + { + match: "^\\s*([01]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Complete", "0/1", true] + }, + { + match: "^\\s*([AB]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Complete", "A/B", false] + }, + { + match: "^\\s*([AB]{5}\\s?)+$", + flags: "", + magic: true, + args: ["Complete", "A/B", true] + }] + }; } /** diff --git a/src/core/operations/Bzip2Decompress.mjs b/src/core/operations/Bzip2Decompress.mjs index fdee7f98..82bc2b24 100644 --- a/src/core/operations/Bzip2Decompress.mjs +++ b/src/core/operations/Bzip2Decompress.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import Bzip2 from "libbzip2-wasm"; import { isWorkerEnvironment } from "../Utils.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; @@ -35,18 +34,17 @@ class Bzip2Decompress extends Operation { value: false } ]; - this.checks = new magicObject([ - { - match: "^\\x42\\x5a\\x68", - flags: "", - magic: true, - args: [] - } - ], - null, - null, - criteria.compressedToDecompressed - ); + this.checks = + { + inRegexes: [ + { + match: "^\\x42\\x5a\\x68", + flags: "", + magic: true, + args: [] + }], + entropyTests: criteria.compressedToDecompressed + }; } /** diff --git a/src/core/operations/CSVToJSON.mjs b/src/core/operations/CSVToJSON.mjs index 04ae143a..7c847fe1 100644 --- a/src/core/operations/CSVToJSON.mjs +++ b/src/core/operations/CSVToJSON.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import Utils from "../Utils.mjs"; /** @@ -43,20 +42,22 @@ class CSVToJSON extends Operation { value: ["Array of dictionaries", "Array of arrays"] } ]; - this.checks = new magicObject([ - { - match: "^\\s*([A-Z\\s]*,){5}", - flags: "i", - magic: true, - args: [",", "\r\n", "Array of dictionaries"] - }, - { - match: "^\\s*([A-Z\\s]*,){5}", - flags: "i", - magic: true, - args: [",", "\r\n", "Array of arrays"] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([A-Z\\s]*,){5}", + flags: "i", + magic: true, + args: [",", "\r\n", "Array of dictionaries"] + }, + { + match: "^\\s*([A-Z\\s]*,){5}", + flags: "i", + magic: true, + args: [",", "\r\n", "Array of arrays"] + }] + }; } /** diff --git a/src/core/operations/ChangeIPFormat.mjs b/src/core/operations/ChangeIPFormat.mjs index 33728b14..e8180719 100644 --- a/src/core/operations/ChangeIPFormat.mjs +++ b/src/core/operations/ChangeIPFormat.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import {fromHex} from "../lib/Hex.mjs"; /** @@ -38,26 +37,28 @@ class ChangeIPFormat extends Operation { "value": ["Dotted Decimal", "Decimal", "Octal", "Hex"] } ]; - this.checks = new magicObject([ - { - match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", - flags: "", - magic: false, - args: ["Dotted Decimal", "Decimal"] - }, - { - match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", - flags: "", - magic: false, - args: ["Dotted Decimal", "Octal"] - }, - { - match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", - flags: "", - magic: false, - args: ["Dotted Decimal", "Hex"] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", + flags: "", + magic: false, + args: ["Dotted Decimal", "Decimal"] + }, + { + match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", + flags: "", + magic: false, + args: ["Dotted Decimal", "Octal"] + }, + { + match: "^\\s*([0-9]{1,3}\\.){3}[0-9]{1,3}$", + flags: "", + magic: false, + args: ["Dotted Decimal", "Hex"] + }] + }; } /** diff --git a/src/core/operations/CitrixCTX1Decode.mjs b/src/core/operations/CitrixCTX1Decode.mjs index 582aae1e..67b1b04b 100644 --- a/src/core/operations/CitrixCTX1Decode.mjs +++ b/src/core/operations/CitrixCTX1Decode.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import cptable from "codepage"; /** @@ -27,14 +26,16 @@ class CitrixCTX1Decode extends Operation { this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "([A-Z]{4}){10,}", - flags: "", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "([A-Z]{4}){10,}", + flags: "", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/DechunkHTTPResponse.mjs b/src/core/operations/DechunkHTTPResponse.mjs index a19a2eaa..c3291ad7 100644 --- a/src/core/operations/DechunkHTTPResponse.mjs +++ b/src/core/operations/DechunkHTTPResponse.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Dechunk HTTP response operation @@ -25,14 +24,16 @@ class DechunkHTTPResponse extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*[0-9A-F]+\r\n", - flags: "i", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*[0-9A-F]+\r\n", + flags: "i", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/DecodeNetBIOSName.mjs b/src/core/operations/DecodeNetBIOSName.mjs index 4c3e2f07..8dd1ee8e 100644 --- a/src/core/operations/DecodeNetBIOSName.mjs +++ b/src/core/operations/DecodeNetBIOSName.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Decode NetBIOS Name operation @@ -31,14 +30,16 @@ class DecodeNetBIOSName extends Operation { "value": 65 } ]; - this.checks = new magicObject([ - { - match: "^\\s*\\S{32}$", - flags: "", - magic: true, - args: [65] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*\\S{32}$", + flags: "", + magic: true, + args: [65] + }] + }; } /** diff --git a/src/core/operations/DefangIPAddresses.mjs b/src/core/operations/DefangIPAddresses.mjs index b44f2d6e..819f90d2 100644 --- a/src/core/operations/DefangIPAddresses.mjs +++ b/src/core/operations/DefangIPAddresses.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** @@ -26,24 +25,25 @@ class DefangIPAddresses extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-f]{4}:){7}[0-9a-f]{4})\\s*$", - flags: "i", - magic: true, - args: [], - } - ], - [ - { - match: "^\\s*(([0-9]{1,3}\\[\\.\\]){3}[0-9]{1,3}|([0-9a-f]{4}\\[\\:\\]){7}[0-9a-f]{4})\\s*$", - flags: "i", - magic: true, - shouldMatch: true, - args: [] - } - ] - ); + this.checks = + { + inRegexes: [ + { + match: "^\\s*(([0-9]{1,3}\\.){3}[0-9]{1,3}|([0-9a-f]{4}:){7}[0-9a-f]{4})\\s*$", + flags: "i", + magic: true, + args: [], + } + ], + outRegexes: [ + { + match: "^\\s*(([0-9]{1,3}\\[\\.\\]){3}[0-9]{1,3}|([0-9a-f]{4}\\[\\:\\]){7}[0-9a-f]{4})\\s*$", + flags: "i", + magic: true, + shouldMatch: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/DefangURL.mjs b/src/core/operations/DefangURL.mjs index f5f92e79..7181bcb3 100644 --- a/src/core/operations/DefangURL.mjs +++ b/src/core/operations/DefangURL.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import {URL_REGEX, DOMAIN_REGEX} from "../lib/Extract.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * DefangURL operation @@ -48,65 +47,67 @@ class DefangURL extends Operation { value: ["Valid domains and full URLs", "Only full URLs", "Everything"] } ]; - this.checks = new magicObject([ - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [false, false, false, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [true, false, false, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [false, true, false, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [true, true, false, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [false, false, true, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [true, false, true, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [false, true, true, "Everything"], - }, - { - match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - args: [true, true, true, "Everything"], - } - ], - [ - { - match: "^\\s*(h(tt|xx)ps?|ftp)(://|\\[://\\])(-(\\.|\\[\\.\\]))?([^\\s/?\\.\\[\\]#-]+(\\.|\\[\\.\\])?)+(/\\S*)?\\s*$", - flags: "i", - magic: false, - shouldMatch: true, - args: [true, true, true, "Everything"], - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [false, false, false, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [true, false, false, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [false, true, false, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [true, true, false, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [false, false, true, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [true, false, true, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [false, true, true, "Everything"], + }, + { + match: "^\\s*(https?|ftp)://(-\\.)?([^\\s/?\\.#-]+\\.?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + args: [true, true, true, "Everything"], + } + ], + outRegexes: [ + { + match: "^\\s*(h(tt|xx)ps?|ftp)(://|\\[://\\])(-(\\.|\\[\\.\\]))?([^\\s/?\\.\\[\\]#-]+(\\.|\\[\\.\\])?)+(/\\S*)?\\s*$", + flags: "i", + magic: false, + shouldMatch: true, + args: [true, true, true, "Everything"], + }] + }; } /** diff --git a/src/core/operations/EscapeUnicodeCharacters.mjs b/src/core/operations/EscapeUnicodeCharacters.mjs index 41186e0a..3fb885ed 100644 --- a/src/core/operations/EscapeUnicodeCharacters.mjs +++ b/src/core/operations/EscapeUnicodeCharacters.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Escape Unicode Characters operation @@ -45,26 +44,28 @@ class EscapeUnicodeCharacters extends Operation { "value": true } ]; - this.checks = new magicObject([ - { - match: "\\\\u(?:[\\da-f]{4,6})", - flags: "i", - magic: true, - args: ["\\u"] - }, - { - match: "%u(?:[\\da-f]{4,6})", - flags: "i", - magic: true, - args: ["%u"] - }, - { - match: "U\\+(?:[\\da-f]{4,6})", - flags: "i", - magic: true, - args: ["U+"] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "\\\\u(?:[\\da-f]{4,6})", + flags: "i", + magic: true, + args: ["\\u"] + }, + { + match: "%u(?:[\\da-f]{4,6})", + flags: "i", + magic: true, + args: ["%u"] + }, + { + match: "U\\+(?:[\\da-f]{4,6})", + flags: "i", + magic: true, + args: ["U+"] + }] + }; } /** diff --git a/src/core/operations/FormatMACAddresses.mjs b/src/core/operations/FormatMACAddresses.mjs index 76bf7ae9..fed98537 100644 --- a/src/core/operations/FormatMACAddresses.mjs +++ b/src/core/operations/FormatMACAddresses.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Format MAC addresses operation @@ -56,14 +55,16 @@ class FormatMACAddresses extends Operation { "value": false } ]; - this.checks = new magicObject([ - { - match: "^\\s*([0-9a-f]{2}:){5}[0-9a-f]{2}$", - flags: "i", - magic: false, - args: ["Both", true, true, true, true, true] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([0-9a-f]{2}:){5}[0-9a-f]{2}$", + flags: "i", + magic: false, + args: ["Both", true, true, true, true, true] + }] + }; } /** diff --git a/src/core/operations/FromBCD.mjs b/src/core/operations/FromBCD.mjs index 894e6af4..e81fef45 100644 --- a/src/core/operations/FromBCD.mjs +++ b/src/core/operations/FromBCD.mjs @@ -9,7 +9,6 @@ import Utils from "../Utils.mjs"; import OperationError from "../errors/OperationError.mjs"; import {ENCODING_SCHEME, ENCODING_LOOKUP, FORMAT} from "../lib/BCD.mjs"; import BigNumber from "bignumber.js"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -51,18 +50,17 @@ class FromBCD extends Operation { "value": FORMAT } ]; - this.checks = new magicObject([ - { - match: "^(?:\\d{4} ){3,}\\d{4}$", - flags: "", - magic: true, - args: ["8 4 2 1", true, false, "Nibbles"] - } - ], - null, - null, - criteria.binary - ); + this.checks = + { + inRegexes: [ + { + match: "^(?:\\d{4} ){3,}\\d{4}$", + flags: "", + magic: true, + args: ["8 4 2 1", true, false, "Nibbles"] + }], + entropyTests: criteria.binary + }; } /** diff --git a/src/core/operations/FromBase32.mjs b/src/core/operations/FromBase32.mjs index b380edbc..4a566ae5 100644 --- a/src/core/operations/FromBase32.mjs +++ b/src/core/operations/FromBase32.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -38,21 +37,20 @@ class FromBase32 extends Operation { value: true } ]; - this.checks = new magicObject([ - { - match: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$", - flags: "", - magic: true, - args: ["A-Z2-7=", false] - }, - ], - null, - null, + this.checks = { - input: [4.2, 5], - output: criteria.entropyOfText - } - ); + inRegexes: [ + { + match: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$", + flags: "", + magic: true, + args: ["A-Z2-7=", false] + }], + entropyTests: { + input: [4.2, 5], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromBase58.mjs b/src/core/operations/FromBase58.mjs index 144ec28d..47f3923b 100644 --- a/src/core/operations/FromBase58.mjs +++ b/src/core/operations/FromBase58.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import OperationError from "../errors/OperationError.mjs"; import {ALPHABET_OPTIONS} from "../lib/Base58.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From Base58 operation @@ -39,20 +38,22 @@ class FromBase58 extends Operation { "value": true } ]; - this.checks = new magicObject([ - { - match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", - flags: "", - magic: true, - args: ["123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", false] - }, - { - match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", - flags: "", - magic: true, - args: ["rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", false] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", + flags: "", + magic: true, + args: ["123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", false] + }, + { + match: "^[1-9A-HJ-NP-Za-km-z]{20,}$", + flags: "", + magic: true, + args: ["rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", false] + }] + }; } /** diff --git a/src/core/operations/FromBase64.mjs b/src/core/operations/FromBase64.mjs index 9d84b77f..50cf8951 100644 --- a/src/core/operations/FromBase64.mjs +++ b/src/core/operations/FromBase64.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import {fromBase64, ALPHABET_OPTIONS} from "../lib/Base64.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -38,93 +37,93 @@ class FromBase64 extends Operation { value: true } ]; - this.checks = new magicObject([ - { - match: "^\\s*(?:[A-Z\\d+/]{4})+(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["A-Za-z0-9+/=", true] - }, - { - match: "^\\s*[A-Z\\d\\-_]{20,}\\s*$", - flags: "i", - magic: true, - args: ["A-Za-z0-9-_", true] - }, - { - match: "^\\s*(?:[A-Z\\d+\\-]{4}){5,}(?:[A-Z\\d+\\-]{2}==|[A-Z\\d+\\-]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["A-Za-z0-9+\\-=", true] - }, - { - match: "^\\s*(?:[A-Z\\d./]{4}){5,}(?:[A-Z\\d./]{2}==|[A-Z\\d./]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["./0-9A-Za-z=", true] - }, - { - match: "^\\s*[A-Z\\d_.]{20,}\\s*$", - flags: "i", - magic: true, - args: ["A-Za-z0-9_.", true] - }, - { - match: "^\\s*(?:[A-Z\\d._]{4}){5,}(?:[A-Z\\d._]{2}--|[A-Z\\d._]{3}-)?\\s*$", - flags: "i", - magic: true, - args: ["A-Za-z0-9._-", true] - }, - { - match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["0-9a-zA-Z+/=", true] - }, - { - match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["0-9A-Za-z+/=", true] - }, - { - match: "^[ !\"#$%&'()*+,\\-./\\d:;<=>?@A-Z[\\\\\\]^_]{20,}$", - flags: "", - magic: true, - args: [" -_", false] - }, - { - match: "^\\s*[A-Z\\d+\\-]{20,}\\s*$", - flags: "i", - magic: true, - args: ["+\\-0-9A-Za-z", true] - }, - { - match: "^\\s*[!\"#$%&'()*+,\\-0-689@A-NP-VX-Z[`a-fh-mp-r]{20,}\\s*$", - flags: "", - magic: true, - args: ["!-,-0-689@A-NP-VX-Z[`a-fh-mp-r", true] - }, - { - match: "^\\s*(?:[N-ZA-M\\d+/]{4}){5,}(?:[N-ZA-M\\d+/]{2}==|[N-ZA-M\\d+/]{3}=)?\\s*$", - flags: "i", - magic: true, - args: ["N-ZA-Mn-za-m0-9+/=", true] - }, - { - match: "^\\s*[A-Z\\d./]{20,}\\s*$", - flags: "i", - magic: true, - args: ["./0-9A-Za-z", true] - }, - ], - null, - null, + this.checks = { - input: [4, 5], - output: criteria.entropyOfText - } - ); + inRegexes: [ + { + match: "^\\s*(?:[A-Z\\d+/]{4})+(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["A-Za-z0-9+/=", true] + }, + { + match: "^\\s*[A-Z\\d\\-_]{20,}\\s*$", + flags: "i", + magic: true, + args: ["A-Za-z0-9-_", true] + }, + { + match: "^\\s*(?:[A-Z\\d+\\-]{4}){5,}(?:[A-Z\\d+\\-]{2}==|[A-Z\\d+\\-]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["A-Za-z0-9+\\-=", true] + }, + { + match: "^\\s*(?:[A-Z\\d./]{4}){5,}(?:[A-Z\\d./]{2}==|[A-Z\\d./]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["./0-9A-Za-z=", true] + }, + { + match: "^\\s*[A-Z\\d_.]{20,}\\s*$", + flags: "i", + magic: true, + args: ["A-Za-z0-9_.", true] + }, + { + match: "^\\s*(?:[A-Z\\d._]{4}){5,}(?:[A-Z\\d._]{2}--|[A-Z\\d._]{3}-)?\\s*$", + flags: "i", + magic: true, + args: ["A-Za-z0-9._-", true] + }, + { + match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["0-9a-zA-Z+/=", true] + }, + { + match: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["0-9A-Za-z+/=", true] + }, + { + match: "^[ !\"#$%&'()*+,\\-./\\d:;<=>?@A-Z[\\\\\\]^_]{20,}$", + flags: "", + magic: true, + args: [" -_", false] + }, + { + match: "^\\s*[A-Z\\d+\\-]{20,}\\s*$", + flags: "i", + magic: true, + args: ["+\\-0-9A-Za-z", true] + }, + { + match: "^\\s*[!\"#$%&'()*+,\\-0-689@A-NP-VX-Z[`a-fh-mp-r]{20,}\\s*$", + flags: "", + magic: true, + args: ["!-,-0-689@A-NP-VX-Z[`a-fh-mp-r", true] + }, + { + match: "^\\s*(?:[N-ZA-M\\d+/]{4}){5,}(?:[N-ZA-M\\d+/]{2}==|[N-ZA-M\\d+/]{3}=)?\\s*$", + flags: "i", + magic: true, + args: ["N-ZA-Mn-za-m0-9+/=", true] + }, + { + match: "^\\s*[A-Z\\d./]{20,}\\s*$", + flags: "i", + magic: true, + args: ["./0-9A-Za-z", true] + }, + ], + entropyTests: { + input: [4, 5], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromBase85.mjs b/src/core/operations/FromBase85.mjs index 1f40a8e5..f6b9d036 100644 --- a/src/core/operations/FromBase85.mjs +++ b/src/core/operations/FromBase85.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; import Utils from "../Utils.mjs"; import {alphabetName, ALPHABET_OPTIONS} from "../lib/Base85.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From Base85 operation @@ -34,26 +33,28 @@ class FromBase85 extends Operation { value: ALPHABET_OPTIONS }, ]; - this.checks = new magicObject([ - { - match: "^\\s*(<~)?([!-u]{4})+([!-u]{1,3})??(~>)?\\s*$", - flags: "", - magic: false, - args: ["!-u", true] - }, - { - match: "^\\s*(<~)?([0-9A-Z.-:+=^!/*?&<>()[]{}@%$#]{4})+([0-9A-Z.-:+=^!/*?&<>()[]{}@%$#]{1,3})??(~>)?\\s*$", - flags: "i", - magic: false, - args: ["0-9a-zA-Z.-:+=^!/*?&<>()[]{}@%$#", true] - }, - { - match: "^\\s*(<~)?([0-9A-Z.-:+=^!/*?&_<>()[]{}@%$#;`|~]{4})+([0-9A-Z.-:+=^!/*?&_<>()[]{}@%$#;`|~]{1,3})??(~>)?\\s*$", - flags: "i", - magic: false, - args: ["0-9A-Za-z!#$%&()*+-;<=>?@^_`{|~}", true] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*(<~)?([!-u]{4})+([!-u]{1,3})??(~>)?\\s*$", + flags: "", + magic: false, + args: ["!-u", true] + }, + { + match: "^\\s*(<~)?([0-9A-Z.-:+=^!/*?&<>()[]{}@%$#]{4})+([0-9A-Z.-:+=^!/*?&<>()[]{}@%$#]{1,3})??(~>)?\\s*$", + flags: "i", + magic: false, + args: ["0-9a-zA-Z.-:+=^!/*?&<>()[]{}@%$#", true] + }, + { + match: "^\\s*(<~)?([0-9A-Z.-:+=^!/*?&_<>()[]{}@%$#;`|~]{4})+([0-9A-Z.-:+=^!/*?&_<>()[]{}@%$#;`|~]{1,3})??(~>)?\\s*$", + flags: "i", + magic: false, + args: ["0-9A-Za-z!#$%&()*+-;<=>?@^_`{|~}", true] + }] + }; } /** diff --git a/src/core/operations/FromBinary.mjs b/src/core/operations/FromBinary.mjs index ed020714..0e37d5ff 100644 --- a/src/core/operations/FromBinary.mjs +++ b/src/core/operations/FromBinary.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import {BIN_DELIM_OPTIONS} from "../lib/Delim.mjs"; import {fromBinary} from "../lib/Binary.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -35,54 +34,53 @@ class FromBinary extends Operation { "value": BIN_DELIM_OPTIONS } ]; - this.checks = new magicObject([ - { - match: "^(?:[01]{8})+$", - flags: "", - magic: true, - args: ["None"] - }, - { - match: "^(?:[01]{8})(?: [01]{8})*$", - flags: "", - magic: true, - args: ["Space"] - }, - { - match: "^(?:[01]{8})(?:,[01]{8})*$", - flags: "", - magic: true, - args: ["Comma"] - }, - { - match: "^(?:[01]{8})(?:;[01]{8})*$", - flags: "", - magic: true, - args: ["Semi-colon"] - }, - { - match: "^(?:[01]{8})(?::[01]{8})*$", - flags: "", - magic: true, - args: ["Colon"] - }, - { - match: "^(?:[01]{8})(?:\\n[01]{8})*$", - flags: "", - magic: true, - args: ["Line feed"] - }, - { - match: "^(?:[01]{8})(?:\\r\\n[01]{8})*$", - flags: "", - magic: true, - args: ["CRLF"] - }, - ], - null, - null, - criteria.binary - ); + this.checks = + { + inRegexes: [ + { + match: "^(?:[01]{8})+$", + flags: "", + magic: true, + args: ["None"] + }, + { + match: "^(?:[01]{8})(?: [01]{8})*$", + flags: "", + magic: true, + args: ["Space"] + }, + { + match: "^(?:[01]{8})(?:,[01]{8})*$", + flags: "", + magic: true, + args: ["Comma"] + }, + { + match: "^(?:[01]{8})(?:;[01]{8})*$", + flags: "", + magic: true, + args: ["Semi-colon"] + }, + { + match: "^(?:[01]{8})(?::[01]{8})*$", + flags: "", + magic: true, + args: ["Colon"] + }, + { + match: "^(?:[01]{8})(?:\\n[01]{8})*$", + flags: "", + magic: true, + args: ["Line feed"] + }, + { + match: "^(?:[01]{8})(?:\\r\\n[01]{8})*$", + flags: "", + magic: true, + args: ["CRLF"] + }], + entropyTests: criteria.binary + }; } /** diff --git a/src/core/operations/FromDecimal.mjs b/src/core/operations/FromDecimal.mjs index 2539200b..d7ec0f29 100644 --- a/src/core/operations/FromDecimal.mjs +++ b/src/core/operations/FromDecimal.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import {DELIM_OPTIONS} from "../lib/Delim.mjs"; import {fromDecimal} from "../lib/Decimal.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -38,51 +37,50 @@ class FromDecimal extends Operation { "value": false } ]; - this.checks = new magicObject([ - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["Space", false] - }, - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["Comma", false] - }, - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["Semi-colon", false] - }, - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["Colon", false] - }, - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["Line feed", false] - }, - { - match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", - flags: "", - magic: true, - args: ["CRLF", false] - }, - ], - null, - null, + this.checks = { - input: [2.5, 3], - output: criteria.entropyOfText - } - ); + inRegexes: [ + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["Space", false] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["Comma", false] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["Semi-colon", false] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["Colon", false] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["Line feed", false] + }, + { + match: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", + flags: "", + magic: true, + args: ["CRLF", false] + }], + entropyTests: { + input: [2.5, 3], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromHTMLEntity.mjs b/src/core/operations/FromHTMLEntity.mjs index 1ef47128..1192bf93 100644 --- a/src/core/operations/FromHTMLEntity.mjs +++ b/src/core/operations/FromHTMLEntity.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From HTML Entity operation @@ -26,14 +25,16 @@ class FromHTMLEntity extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});", - flags: "i", - magic: true, - args: [] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});", + flags: "i", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/FromHex.mjs b/src/core/operations/FromHex.mjs index 8e2c722a..57d55c7b 100644 --- a/src/core/operations/FromHex.mjs +++ b/src/core/operations/FromHex.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import {fromHex, FROM_HEX_DELIM_OPTIONS} from "../lib/Hex.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -34,69 +33,68 @@ class FromHex extends Operation { value: FROM_HEX_DELIM_OPTIONS } ]; - this.checks = new magicObject([ - { - match: "^(?:[\\dA-F]{2})+$", - flags: "i", - magic: true, - args: ["None"] - }, - { - match: "^[\\dA-F]{2}(?: [\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["Space"] - }, - { - match: "^[\\dA-F]{2}(?:,[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["Comma"] - }, - { - match: "^[\\dA-F]{2}(?:;[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["Semi-colon"] - }, - { - match: "^[\\dA-F]{2}(?::[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["Colon"] - }, - { - match: "^[\\dA-F]{2}(?:\\n[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["Line feed"] - }, - { - match: "^[\\dA-F]{2}(?:\\r\\n[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["CRLF"] - }, - { - match: "^[\\dA-F]{2}(?:0x[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["0x"] - }, - { - match: "^[\\dA-F]{2}(?:\\\\x[\\dA-F]{2})*$", - flags: "i", - magic: true, - args: ["\\x"] - } - ], - null, - null, + this.checks = { - input: [2, 3], - output: criteria.entropyOfText - } - ); + inRegexes: [ + { + match: "^(?:[\\dA-F]{2})+$", + flags: "i", + magic: true, + args: ["None"] + }, + { + match: "^[\\dA-F]{2}(?: [\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["Space"] + }, + { + match: "^[\\dA-F]{2}(?:,[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["Comma"] + }, + { + match: "^[\\dA-F]{2}(?:;[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["Semi-colon"] + }, + { + match: "^[\\dA-F]{2}(?::[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["Colon"] + }, + { + match: "^[\\dA-F]{2}(?:\\n[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["Line feed"] + }, + { + match: "^[\\dA-F]{2}(?:\\r\\n[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["CRLF"] + }, + { + match: "^[\\dA-F]{2}(?:0x[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["0x"] + }, + { + match: "^[\\dA-F]{2}(?:\\\\x[\\dA-F]{2})*$", + flags: "i", + magic: true, + args: ["\\x"] + }], + entropyTests: { + input: [2, 3], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromHexContent.mjs b/src/core/operations/FromHexContent.mjs index 4ce83642..7e3b62fe 100644 --- a/src/core/operations/FromHexContent.mjs +++ b/src/core/operations/FromHexContent.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import {fromHex} from "../lib/Hex.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -28,20 +27,20 @@ class FromHexContent extends Operation { this.inputType = "string"; this.outputType = "byteArray"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*.*?\\|([0-9a-f]{2})+\\|.*$", - flags: "i", - magic: true, - args: [] - } - ], - null, - null, + this.checks = { - input: [3, 4], - output: criteria.entropyOfText - }); + inRegexes: [ + { + match: "^\\s*.*?\\|([0-9a-f]{2})+\\|.*$", + flags: "i", + magic: true, + args: [] + }], + entropyTests: { + input: [3, 4], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromHexdump.mjs b/src/core/operations/FromHexdump.mjs index 8d4e4af9..ab918c1c 100644 --- a/src/core/operations/FromHexdump.mjs +++ b/src/core/operations/FromHexdump.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import { fromHex } from "../lib/Hex.mjs"; import { isWorkerEnvironment } from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; @@ -29,20 +28,20 @@ class FromHexdump extends Operation { this.inputType = "string"; this.outputType = "byteArray"; this.args = []; - this.checks = new magicObject([ - { - match: "^(?:(?:[\\dA-F]{4,16}h?:?)?[ \\t]*((?:[\\dA-F]{2} ){1,8}(?:[ \\t]|[\\dA-F]{2}-)(?:[\\dA-F]{2} ){1,8}|(?:[\\dA-F]{4} )*[\\dA-F]{4}|(?:[\\dA-F]{2} )*[\\dA-F]{2})[^\\n]*\\n?){2,}$", - flags: "i", - magic: true, - args: [] - }, - ], - null, - null, + this.checks = { - input: [3, 4], - output: criteria.entropyOfText - }); + inRegexes: [ + { + match: "^(?:(?:[\\dA-F]{4,16}h?:?)?[ \\t]*((?:[\\dA-F]{2} ){1,8}(?:[ \\t]|[\\dA-F]{2}-)(?:[\\dA-F]{2} ){1,8}|(?:[\\dA-F]{4} )*[\\dA-F]{4}|(?:[\\dA-F]{2} )*[\\dA-F]{2})[^\\n]*\\n?){2,}$", + flags: "i", + magic: true, + args: [] + }], + entropyTests: { + input: [3, 4], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromMorseCode.mjs b/src/core/operations/FromMorseCode.mjs index 1f38ec1d..5bddba32 100644 --- a/src/core/operations/FromMorseCode.mjs +++ b/src/core/operations/FromMorseCode.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import {LETTER_DELIM_OPTIONS, WORD_DELIM_OPTIONS} from "../lib/Delim.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From Morse Code operation @@ -38,20 +37,20 @@ class FromMorseCode extends Operation { "value": WORD_DELIM_OPTIONS } ]; - this.checks = new magicObject([ - { - match: "(?:^[-. \\n]{5,}$|^[_. \\n]{5,}$|^(?:dash|dot| |\\n){5,}$)", - flags: "i", - magic: true, - args: ["Space", "Line feed"] - }, - ], - null, - null, + this.checks = { - input: [0, 2], - output: [3, 6] - }); + inRegexes: [ + { + match: "(?:^[-. \\n]{5,}$|^[_. \\n]{5,}$|^(?:dash|dot| |\\n){5,}$)", + flags: "i", + magic: true, + args: ["Space", "Line feed"] + }], + entropyTests: { + input: [0, 2], + output: [3, 6] + } + }; } /** diff --git a/src/core/operations/FromOctal.mjs b/src/core/operations/FromOctal.mjs index 06ed1be3..30bc3780 100644 --- a/src/core/operations/FromOctal.mjs +++ b/src/core/operations/FromOctal.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import {DELIM_OPTIONS} from "../lib/Delim.mjs"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; /** @@ -34,50 +33,50 @@ class FromOctal extends Operation { "value": DELIM_OPTIONS } ]; - this.checks = new magicObject([ - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["Space"] - }, - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["Comma"] - }, - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["Semi-colon"] - }, - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["Colon"] - }, - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["Line feed"] - }, - { - match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", - flags: "", - magic: true, - args: ["CRLF"] - }, - ], - null, - null, + this.checks = { - input: [2.5, 3], - output: criteria.entropyOfText - }); + inRegexes: [ + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["Space"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["Comma"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["Semi-colon"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["Colon"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["Line feed"] + }, + { + match: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", + flags: "", + magic: true, + args: ["CRLF"] + }], + entropyTests: { + input: [2.5, 3], + output: criteria.entropyOfText + } + }; } /** diff --git a/src/core/operations/FromQuotedPrintable.mjs b/src/core/operations/FromQuotedPrintable.mjs index f3702026..7981bb0e 100644 --- a/src/core/operations/FromQuotedPrintable.mjs +++ b/src/core/operations/FromQuotedPrintable.mjs @@ -9,7 +9,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From Quoted Printable operation @@ -29,14 +28,16 @@ class FromQuotedPrintable extends Operation { this.inputType = "string"; this.outputType = "byteArray"; this.args = []; - this.checks = new magicObject([ - { - match: "^[\\x21-\\x3d\\x3f-\\x7e \\t]{0,76}(?:=[\\da-f]{2}|=\\r?\\n)(?:[\\x21-\\x3d\\x3f-\\x7e \\t]|=[\\da-f]{2}|=\\r?\\n)*$", - flags: "i", - magic: true, - args: [] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "^[\\x21-\\x3d\\x3f-\\x7e \\t]{0,76}(?:=[\\da-f]{2}|=\\r?\\n)(?:[\\x21-\\x3d\\x3f-\\x7e \\t]|=[\\da-f]{2}|=\\r?\\n)*$", + flags: "i", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/FromUNIXTimestamp.mjs b/src/core/operations/FromUNIXTimestamp.mjs index 0790cc73..881bbbbd 100644 --- a/src/core/operations/FromUNIXTimestamp.mjs +++ b/src/core/operations/FromUNIXTimestamp.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import moment from "moment-timezone"; import {UNITS} from "../lib/DateTime.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * From UNIX Timestamp operation @@ -34,32 +33,34 @@ class FromUNIXTimestamp extends Operation { "value": UNITS } ]; - this.checks = new magicObject([ - { - match: "^1?\\d{9}$", - flags: "", - magic: true, - args: ["Seconds (s)"] - }, - { - match: "^1?\\d{12}$", - flags: "", - magic: true, - args: ["Milliseconds (ms)"] - }, - { - match: "^1?\\d{15}$", - flags: "", - magic: true, - args: ["Microseconds (μs)"] - }, - { - match: "^1?\\d{18}$", - flags: "", - magic: true, - args: ["Nanoseconds (ns)"] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "^1?\\d{9}$", + flags: "", + magic: true, + args: ["Seconds (s)"] + }, + { + match: "^1?\\d{12}$", + flags: "", + magic: true, + args: ["Milliseconds (ms)"] + }, + { + match: "^1?\\d{15}$", + flags: "", + magic: true, + args: ["Microseconds (μs)"] + }, + { + match: "^1?\\d{18}$", + flags: "", + magic: true, + args: ["Nanoseconds (ns)"] + }] + }; } /** diff --git a/src/core/operations/Gunzip.mjs b/src/core/operations/Gunzip.mjs index 58383eb6..32a6dd7c 100644 --- a/src/core/operations/Gunzip.mjs +++ b/src/core/operations/Gunzip.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; const Zlib = zlibAndGzip.Zlib; @@ -29,18 +28,17 @@ class Gunzip extends Operation { this.inputType = "ArrayBuffer"; this.outputType = "ArrayBuffer"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\x1f\\x8b\\x08", - flags: "", - magic: true, - args: [] - }, - ], - null, - null, - criteria.compressedToDecompressed - ); + this.checks = + { + inRegexes: [ + { + match: "^\\x1f\\x8b\\x08", + flags: "", + magic: true, + args: [] + }], + entropyTests: criteria.compressedToDecompressed + }; } /** diff --git a/src/core/operations/ObjectIdentifierToHex.mjs b/src/core/operations/ObjectIdentifierToHex.mjs index 0faf72e2..65700151 100644 --- a/src/core/operations/ObjectIdentifierToHex.mjs +++ b/src/core/operations/ObjectIdentifierToHex.mjs @@ -6,7 +6,6 @@ import r from "jsrsasign"; import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Object Identifier to Hex operation @@ -26,14 +25,16 @@ class ObjectIdentifierToHex extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*([0-9]{1,3}\\.)+[0-9]{1,3}\\s*$", - flags: "", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([0-9]{1,3}\\.)+[0-9]{1,3}\\s*$", + flags: "", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/ParseIPv6Address.mjs b/src/core/operations/ParseIPv6Address.mjs index 1479aa79..9d6ef6e2 100644 --- a/src/core/operations/ParseIPv6Address.mjs +++ b/src/core/operations/ParseIPv6Address.mjs @@ -9,7 +9,6 @@ import Utils from "../Utils.mjs"; import OperationError from "../errors/OperationError.mjs"; import {strToIpv6, ipv6ToStr, ipv4ToStr, IPV6_REGEX} from "../lib/IP.mjs"; import BigNumber from "bignumber.js"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse IPv6 address operation @@ -29,14 +28,16 @@ class ParseIPv6Address extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*([a-f\\d]{4}:?)+\\s*$", - flags: "i", - magic: false, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([a-f\\d]{4}:?)+\\s*$", + flags: "i", + magic: false, + args: [] + }] + }; } /** diff --git a/src/core/operations/ParseQRCode.mjs b/src/core/operations/ParseQRCode.mjs index eed6813f..41719914 100644 --- a/src/core/operations/ParseQRCode.mjs +++ b/src/core/operations/ParseQRCode.mjs @@ -8,7 +8,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; import { isImage } from "../lib/FileType.mjs"; import { parseQrCode } from "../lib/QRCode.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse QR Code operation @@ -34,15 +33,17 @@ class ParseQRCode extends Operation { "value": false } ]; - this.checks = new magicObject([ - { - match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", - flags: "", - args: [false], - magic: true, - useful: true - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", + flags: "", + args: [false], + magic: true, + useful: true + }] + }; } /** diff --git a/src/core/operations/ParseSSHHostKey.mjs b/src/core/operations/ParseSSHHostKey.mjs index 9cccdadd..b0b854d0 100644 --- a/src/core/operations/ParseSSHHostKey.mjs +++ b/src/core/operations/ParseSSHHostKey.mjs @@ -9,7 +9,6 @@ import OperationError from "../errors/OperationError.mjs"; import Utils from "../Utils.mjs"; import { fromBase64 } from "../lib/Base64.mjs"; import { fromHex, toHexFast } from "../lib/Hex.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse SSH Host Key operation @@ -39,14 +38,16 @@ class ParseSSHHostKey extends Operation { ] } ]; - this.checks = new magicObject([ - { - match: "^\\s*([A-F\\d]{2}[,;:]){15,}[A-F\\d]{2}\\s*$", - flags: "i", - magic: true, - args: ["Hex"] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([A-F\\d]{2}[,;:]){15,}[A-F\\d]{2}\\s*$", + flags: "i", + magic: true, + args: ["Hex"] + }] + }; } /** diff --git a/src/core/operations/ParseUNIXFilePermissions.mjs b/src/core/operations/ParseUNIXFilePermissions.mjs index dbba150a..31316013 100644 --- a/src/core/operations/ParseUNIXFilePermissions.mjs +++ b/src/core/operations/ParseUNIXFilePermissions.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse UNIX file permissions operation @@ -26,14 +25,16 @@ class ParseUNIXFilePermissions extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*d[rxw-]{9}\\s*$", - flags: "", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*d[rxw-]{9}\\s*$", + flags: "", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/ParseUserAgent.mjs b/src/core/operations/ParseUserAgent.mjs index a72b36d6..7b4ec0f7 100644 --- a/src/core/operations/ParseUserAgent.mjs +++ b/src/core/operations/ParseUserAgent.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import UAParser from "ua-parser-js"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse User Agent operation @@ -26,14 +25,16 @@ class ParseUserAgent extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^(User-Agent:|Mozilla\\/)[^\\n\\r]+\\s*$", - flags: "i", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^(User-Agent:|Mozilla\\/)[^\\n\\r]+\\s*$", + flags: "i", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/ParseX509Certificate.mjs b/src/core/operations/ParseX509Certificate.mjs index 69192853..ecb37001 100644 --- a/src/core/operations/ParseX509Certificate.mjs +++ b/src/core/operations/ParseX509Certificate.mjs @@ -10,7 +10,6 @@ import { toHex } from "../lib/Hex.mjs"; import { formatByteStr, formatDnStr } from "../lib/PublicKey.mjs"; import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Parse X.509 certificate operation @@ -36,16 +35,18 @@ class ParseX509Certificate extends Operation { value: ["PEM", "DER Hex", "Base64", "Raw"] } ]; - this.checks = new magicObject([ - { - match: "^-+BEGIN CERTIFICATE-+\\r?\\n[\\da-z+/\\n\\r]+-+END CERTIFICATE-+\\r?\\n?$", - flags: "i", - magic: true, - args: [ - "PEM" - ] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^-+BEGIN CERTIFICATE-+\\r?\\n[\\da-z+/\\n\\r]+-+END CERTIFICATE-+\\r?\\n?$", + flags: "i", + magic: true, + args: [ + "PEM" + ] + }] + }; } /** diff --git a/src/core/operations/RemoveLineNumbers.mjs b/src/core/operations/RemoveLineNumbers.mjs index 5b512873..58bafd08 100644 --- a/src/core/operations/RemoveLineNumbers.mjs +++ b/src/core/operations/RemoveLineNumbers.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Remove line numbers operation @@ -24,14 +23,16 @@ class RemoveLineNumbers extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*([0-9]+ .*?(\\n))+[0-9] .+$", - flags: "", - magic: false, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*([0-9]+ .*?(\\n))+[0-9] .+$", + flags: "", + magic: false, + args: [] + }] + }; } /** diff --git a/src/core/operations/RenderImage.mjs b/src/core/operations/RenderImage.mjs index 485f121d..ed6e56ec 100644 --- a/src/core/operations/RenderImage.mjs +++ b/src/core/operations/RenderImage.mjs @@ -10,7 +10,6 @@ import Operation from "../Operation.mjs"; import OperationError from "../errors/OperationError.mjs"; import Utils from "../Utils.mjs"; import {isImage} from "../lib/FileType.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Render Image operation @@ -36,20 +35,20 @@ class RenderImage extends Operation { "value": ["Raw", "Base64", "Hex"] } ]; - this.checks = new magicObject([ - { - match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", - flags: "", - magic: true, - args: ["Raw"], - useful: true - } - ], - null, + this.checks = { - type: "image" - } - ); + inRegexes: [ + { + match: "^(?:\\xff\\xd8\\xff|\\x89\\x50\\x4e\\x47|\\x47\\x49\\x46|.{8}\\x57\\x45\\x42\\x50|\\x42\\x4d)", + flags: "", + magic: true, + args: ["Raw"], + useful: true + }], + mimeCheck: { + type: "image" + } + }; } /** diff --git a/src/core/operations/StripHTMLTags.mjs b/src/core/operations/StripHTMLTags.mjs index c0ef6efc..28e19250 100644 --- a/src/core/operations/StripHTMLTags.mjs +++ b/src/core/operations/StripHTMLTags.mjs @@ -6,7 +6,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Strip HTML tags operation @@ -37,14 +36,16 @@ class StripHTMLTags extends Operation { } ]; - this.checks = new magicObject([ - { - match: "^(\\S|\\s)*$", - flags: "i", - magic: true, - args: [true, true] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^(\\S|\\s)*$", + flags: "i", + magic: true, + args: [true, true] + }] + }; } /** diff --git a/src/core/operations/StripHTTPHeaders.mjs b/src/core/operations/StripHTTPHeaders.mjs index b1cf96e8..3e613c3b 100644 --- a/src/core/operations/StripHTTPHeaders.mjs +++ b/src/core/operations/StripHTTPHeaders.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Strip HTTP headers operation @@ -25,14 +24,16 @@ class StripHTTPHeaders extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: "^\\s*HTTP(.|\\s)+?(\\r?\\n){2}", - flags: "", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\s*HTTP(.|\\s)+?(\\r?\\n){2}", + flags: "", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/URLDecode.mjs b/src/core/operations/URLDecode.mjs index b1b7afc0..09de2d1e 100644 --- a/src/core/operations/URLDecode.mjs +++ b/src/core/operations/URLDecode.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * URL Decode operation @@ -25,14 +24,16 @@ class URLDecode extends Operation { this.inputType = "string"; this.outputType = "string"; this.args = []; - this.checks = new magicObject([ - { - match: ".*(?:%[\\da-f]{2}.*){4}", - flags: "i", - magic: true, - args: [], - } - ]); + this.checks = + { + inRegexes: [ + { + match: ".*(?:%[\\da-f]{2}.*){4}", + flags: "i", + magic: true, + args: [], + }] + }; } /** diff --git a/src/core/operations/Untar.mjs b/src/core/operations/Untar.mjs index b81dbc1f..1e2b160d 100644 --- a/src/core/operations/Untar.mjs +++ b/src/core/operations/Untar.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import Stream from "../lib/Stream.mjs"; -import magicObject from "../lib/MagicObject.mjs"; /** * Untar operation @@ -28,14 +27,16 @@ class Untar extends Operation { this.outputType = "List"; this.presentType = "html"; this.args = []; - this.checks = new magicObject([ - { - match: "^.{257}\\x75\\x73\\x74\\x61\\x72", - flags: "", - magic: true, - args: [] - } - ]); + this.checks = + { + inRegexes: [ + { + match: "^.{257}\\x75\\x73\\x74\\x61\\x72", + flags: "", + magic: true, + args: [] + }] + }; } /** diff --git a/src/core/operations/Unzip.mjs b/src/core/operations/Unzip.mjs index 4f91be0a..41101c41 100644 --- a/src/core/operations/Unzip.mjs +++ b/src/core/operations/Unzip.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import Utils from "../Utils.mjs"; import unzip from "zlibjs/bin/unzip.min.js"; -import magicObject from "../lib/MagicObject.mjs"; import * as criteria from "../lib/MagicCriteria.mjs"; @@ -43,18 +42,17 @@ class Unzip extends Operation { value: false } ]; - this.checks = new magicObject([ - { - match: "^\\x50\\x4b(?:\\x03|\\x05|\\x07)(?:\\x04|\\x06|\\x08)", - flags: "", - magic: true, - args: ["", false] - }, - ], - null, - null, - criteria.compressedToDecompressed - ); + this.checks = + { + inRegexes: [ + { + match: "^\\x50\\x4b(?:\\x03|\\x05|\\x07)(?:\\x04|\\x06|\\x08)", + flags: "", + magic: true, + args: ["", false] + }], + entropyTests: criteria.compressedToDecompressed + }; } /** diff --git a/src/core/operations/ZlibInflate.mjs b/src/core/operations/ZlibInflate.mjs index 8fced020..df0cbbf2 100644 --- a/src/core/operations/ZlibInflate.mjs +++ b/src/core/operations/ZlibInflate.mjs @@ -7,7 +7,6 @@ import Operation from "../Operation.mjs"; import {INFLATE_BUFFER_TYPE} from "../lib/Zlib.mjs"; import zlibAndGzip from "zlibjs/bin/zlib_and_gzip.min.js"; -import magicObject from "../lib/MagicObject.mjs"; const Zlib = zlibAndGzip.Zlib; @@ -60,14 +59,16 @@ class ZlibInflate extends Operation { value: false } ]; - this.checks = new magicObject([ - { - match: "^\\x78(\\x01|\\x9c|\\xda|\\x5e)", - flags: "", - magic: true, - args: [0, 0, "Adaptive", false, false] - }, - ]); + this.checks = + { + inRegexes: [ + { + match: "^\\x78(\\x01|\\x9c|\\xda|\\x5e)", + flags: "", + magic: true, + args: [0, 0, "Adaptive", false, false] + }] + }; } /**