Modifications made.

This commit is contained in:
n1073645 2020-02-13 16:40:12 +00:00
parent 4247ddb0ce
commit 6373ad0bc3
6 changed files with 13 additions and 60 deletions

View file

@ -25,7 +25,6 @@ class Operation {
this._flowControl = false;
this._manualBake = false;
this._ingList = [];
// this._checks = [];
this._inputRegexes = [];
this._outputRegexes = [];

View file

@ -246,19 +246,6 @@ class Magic {
return results;
}
/**
* Checks the mime value of the data compared to the specified type.
*
* @param {ArrayBuffer} data
* @param {string} type
* @returns {boolean}
*/
async checkMime (data, type) {
if (isType(type, data)) {
return false;
}
return true;
}
/**
* Uses the checks to validate the input/output of potential operations.
@ -296,7 +283,7 @@ class Magic {
const mime = OperationConfig[op.op].mimeCheck;
if (mime)
if (await this.checkMime(output, mime.type))
if (!isType(output, mime.type))
return;
// If the recipe returned an empty buffer, do not continue
@ -390,7 +377,7 @@ class Magic {
const prevOp = recipeConfig[recipeConfig.length - 1];
results = results.concat(await this.regexesTests("Input", matchingOps, prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
results = results.concat(await this.regexesTests("Output", this.opPatterns.getOutputRegexes(), prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
results = results.concat(await this.regexesTests("Output", this.opPatterns.OutputRegexes, prevOp, depth, extLang, intensive, recipeConfig, crib, inputEntropy));
if (intensive) {
// Run brute forcing of various types on the data and create a new branch for each option
@ -488,7 +475,6 @@ class Magic {
* @returns {number[]}
*/
_freqDist(data=this.inputBuffer) {
// if (this.freqDist) return this.freqDist;
const len = data.length;
let i = len;

View file

@ -1,3 +1,4 @@
import OperationConfig from "../config/OperationConfig.json";
/**
* An object used by magic to store the input/output criteria for valid operation results.
*
@ -5,8 +6,6 @@
* @copyright Crown Copyright 2020
* @license Apache-2.0
*/
import OperationConfig from "../config/OperationConfig.json";
class potentialOps {
/**
@ -19,8 +18,8 @@ class potentialOps {
this.inputRegexes = this.generateInputOpPatterns();
this.outputRegexes = this.generateOutputOpPatterns();
} else {
this.inputRegexes = prevOp.getInputRegexes();
this.outputRegexes = prevOp.getOutputRegexes();
this.inputRegexes = prevOp.InputRegexes;
this.outputRegexes = prevOp.OutputRegexes;
}
}
@ -29,7 +28,7 @@ class potentialOps {
*
* @param outputRegexes
*/
setOutputRegexes (outputRegexes) {
set OutputRegexes (outputRegexes) {
this.outputRegexes = [...outputRegexes];
}
@ -38,7 +37,7 @@ class potentialOps {
*
* @param inputRegexes
*/
setInputRegexes (inputRegexes) {
set InputRegexes (inputRegexes) {
this.inputRegexes = [...inputRegexes];
}
@ -47,7 +46,7 @@ class potentialOps {
*
* @returns {Object[]}
*/
getInputRegexes () {
get InputRegexes () {
return this.inputRegexes;
}
@ -56,7 +55,7 @@ class potentialOps {
*
* @returns {Object[]}
*/
getOutputRegexes () {
get OutputRegexes () {
return this.outputRegexes;
}
@ -131,4 +130,5 @@ class potentialOps {
return opPatterns;
}
} export default potentialOps;
}
export default potentialOps;

View file

@ -37,28 +37,6 @@ class ChangeIPFormat extends Operation {
"value": ["Dotted Decimal", "Decimal", "Octal", "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"]
}]
};
}
/**

View file

@ -55,16 +55,6 @@ class FormatMACAddresses extends Operation {
"value": false
}
];
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]
}]
};
}
/**