mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
eslint autofix
This commit is contained in:
parent
0d42541860
commit
ad730d806b
60 changed files with 13067 additions and 13014 deletions
|
@ -8,12 +8,12 @@
|
|||
* @class
|
||||
* @param {Object} recipe_config
|
||||
*/
|
||||
var Recipe = function(recipe_config) {
|
||||
this.op_list = [];
|
||||
|
||||
if (recipe_config) {
|
||||
this._parse_config(recipe_config);
|
||||
}
|
||||
const Recipe = function (recipe_config) {
|
||||
this.op_list = [];
|
||||
|
||||
if (recipe_config) {
|
||||
this._parse_config(recipe_config);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -23,16 +23,16 @@ var Recipe = function(recipe_config) {
|
|||
* @private
|
||||
* @param {Object} recipe_config
|
||||
*/
|
||||
Recipe.prototype._parse_config = function(recipe_config) {
|
||||
for (var c = 0; c < recipe_config.length; c++) {
|
||||
var operation_name = recipe_config[c].op;
|
||||
var operation_config = OperationConfig[operation_name];
|
||||
var operation = new Operation(operation_name, operation_config);
|
||||
operation.set_ing_values(recipe_config[c].args);
|
||||
operation.set_breakpoint(recipe_config[c].breakpoint);
|
||||
operation.set_disabled(recipe_config[c].disabled);
|
||||
this.add_operation(operation);
|
||||
}
|
||||
Recipe.prototype._parse_config = function (recipe_config) {
|
||||
for (let c = 0; c < recipe_config.length; c++) {
|
||||
const operation_name = recipe_config[c].op;
|
||||
const operation_config = OperationConfig[operation_name];
|
||||
const operation = new Operation(operation_name, operation_config);
|
||||
operation.set_ing_values(recipe_config[c].args);
|
||||
operation.set_breakpoint(recipe_config[c].breakpoint);
|
||||
operation.set_disabled(recipe_config[c].disabled);
|
||||
this.add_operation(operation);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -41,14 +41,14 @@ Recipe.prototype._parse_config = function(recipe_config) {
|
|||
*
|
||||
* @returns {*}
|
||||
*/
|
||||
Recipe.prototype.get_config = function() {
|
||||
var recipe_config = [];
|
||||
|
||||
for (var o = 0; o < this.op_list.length; o++) {
|
||||
recipe_config.push(this.op_list[o].get_config());
|
||||
}
|
||||
|
||||
return recipe_config;
|
||||
Recipe.prototype.get_config = function () {
|
||||
const recipe_config = [];
|
||||
|
||||
for (let o = 0; o < this.op_list.length; o++) {
|
||||
recipe_config.push(this.op_list[o].get_config());
|
||||
}
|
||||
|
||||
return recipe_config;
|
||||
};
|
||||
|
||||
|
||||
|
@ -57,8 +57,8 @@ Recipe.prototype.get_config = function() {
|
|||
*
|
||||
* @param {Operation} operation
|
||||
*/
|
||||
Recipe.prototype.add_operation = function(operation) {
|
||||
this.op_list.push(operation);
|
||||
Recipe.prototype.add_operation = function (operation) {
|
||||
this.op_list.push(operation);
|
||||
};
|
||||
|
||||
|
||||
|
@ -67,8 +67,8 @@ Recipe.prototype.add_operation = function(operation) {
|
|||
*
|
||||
* @param {Operation[]} operations
|
||||
*/
|
||||
Recipe.prototype.add_operations = function(operations) {
|
||||
this.op_list = this.op_list.concat(operations);
|
||||
Recipe.prototype.add_operations = function (operations) {
|
||||
this.op_list = this.op_list.concat(operations);
|
||||
};
|
||||
|
||||
|
||||
|
@ -78,12 +78,12 @@ Recipe.prototype.add_operations = function(operations) {
|
|||
* @param {number} position - The index of the Operation
|
||||
* @param {boolean} value
|
||||
*/
|
||||
Recipe.prototype.set_breakpoint = function(position, value) {
|
||||
try {
|
||||
this.op_list[position].set_breakpoint(value);
|
||||
} catch (err) {
|
||||
Recipe.prototype.set_breakpoint = function (position, value) {
|
||||
try {
|
||||
this.op_list[position].set_breakpoint(value);
|
||||
} catch (err) {
|
||||
// Ignore index error
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -93,10 +93,10 @@ Recipe.prototype.set_breakpoint = function(position, value) {
|
|||
*
|
||||
* @param {number} pos
|
||||
*/
|
||||
Recipe.prototype.remove_breaks_up_to = function(pos) {
|
||||
for (var i = 0; i < pos; i++) {
|
||||
this.op_list[i].set_breakpoint(false);
|
||||
}
|
||||
Recipe.prototype.remove_breaks_up_to = function (pos) {
|
||||
for (let i = 0; i < pos; i++) {
|
||||
this.op_list[i].set_breakpoint(false);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -105,11 +105,11 @@ Recipe.prototype.remove_breaks_up_to = function(pos) {
|
|||
*
|
||||
* @returns {boolean}
|
||||
*/
|
||||
Recipe.prototype.contains_flow_control = function() {
|
||||
for (var i = 0; i < this.op_list.length; i++) {
|
||||
if (this.op_list[i].is_flow_control()) return true;
|
||||
}
|
||||
return false;
|
||||
Recipe.prototype.contains_flow_control = function () {
|
||||
for (let i = 0; i < this.op_list.length; i++) {
|
||||
if (this.op_list[i].is_flow_control()) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
|
||||
|
@ -120,17 +120,17 @@ Recipe.prototype.contains_flow_control = function() {
|
|||
* @param {number} [start_index=0] - The index to start searching from
|
||||
* @returns (number}
|
||||
*/
|
||||
Recipe.prototype.last_op_index = function(start_index) {
|
||||
var i = start_index + 1 || 0,
|
||||
op;
|
||||
|
||||
for (; i < this.op_list.length; i++) {
|
||||
op = this.op_list[i];
|
||||
if (op.is_disabled()) return i-1;
|
||||
if (op.is_breakpoint()) return i-1;
|
||||
}
|
||||
|
||||
return i-1;
|
||||
Recipe.prototype.last_op_index = function (start_index) {
|
||||
let i = start_index + 1 || 0,
|
||||
op;
|
||||
|
||||
for (; i < this.op_list.length; i++) {
|
||||
op = this.op_list[i];
|
||||
if (op.is_disabled()) return i - 1;
|
||||
if (op.is_breakpoint()) return i - 1;
|
||||
}
|
||||
|
||||
return i - 1;
|
||||
};
|
||||
|
||||
|
||||
|
@ -141,56 +141,59 @@ Recipe.prototype.last_op_index = function(start_index) {
|
|||
* @param {number} [start_from=0] - The index of the Operation to start executing from
|
||||
* @returns {number} - The final progress through the recipe
|
||||
*/
|
||||
Recipe.prototype.execute = function(dish, start_from) {
|
||||
start_from = start_from || 0;
|
||||
var op, input, output, num_jumps = 0;
|
||||
|
||||
for (var i = start_from; i < this.op_list.length; i++) {
|
||||
op = this.op_list[i];
|
||||
if (op.is_disabled()) {
|
||||
continue;
|
||||
}
|
||||
if (op.is_breakpoint()) {
|
||||
return i;
|
||||
}
|
||||
|
||||
try {
|
||||
input = dish.get(op.input_type);
|
||||
|
||||
if (op.is_flow_control()) {
|
||||
// Package up the current state
|
||||
var state = {
|
||||
"progress" : i,
|
||||
"dish" : dish,
|
||||
"op_list" : this.op_list,
|
||||
"num_jumps" : num_jumps
|
||||
};
|
||||
|
||||
state = op.run(state);
|
||||
i = state.progress;
|
||||
num_jumps = state.num_jumps;
|
||||
} else {
|
||||
output = op.run(input, op.get_ing_values());
|
||||
dish.set(output, op.output_type);
|
||||
}
|
||||
} catch (err) {
|
||||
var e = typeof err == "string" ? { message: err } : err;
|
||||
Recipe.prototype.execute = function (dish, start_from) {
|
||||
start_from = start_from || 0;
|
||||
let op,
|
||||
input,
|
||||
output,
|
||||
num_jumps = 0;
|
||||
|
||||
e.progress = i;
|
||||
e.display_str = op.name + " - ";
|
||||
if (e.fileName) {
|
||||
e.display_str += e.name + " in " + e.fileName +
|
||||
" on line " + e.lineNumber +
|
||||
".<br><br>Message: " + e.message;
|
||||
} else {
|
||||
e.display_str += e.message;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
for (let i = start_from; i < this.op_list.length; i++) {
|
||||
op = this.op_list[i];
|
||||
if (op.is_disabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return this.op_list.length;
|
||||
if (op.is_breakpoint()) {
|
||||
return i;
|
||||
}
|
||||
|
||||
try {
|
||||
input = dish.get(op.input_type);
|
||||
|
||||
if (op.is_flow_control()) {
|
||||
// Package up the current state
|
||||
let state = {
|
||||
progress: i,
|
||||
dish,
|
||||
op_list: this.op_list,
|
||||
num_jumps,
|
||||
};
|
||||
|
||||
state = op.run(state);
|
||||
i = state.progress;
|
||||
num_jumps = state.num_jumps;
|
||||
} else {
|
||||
output = op.run(input, op.get_ing_values());
|
||||
dish.set(output, op.output_type);
|
||||
}
|
||||
} catch (err) {
|
||||
const e = typeof err === 'string' ? { message: err } : err;
|
||||
|
||||
e.progress = i;
|
||||
e.display_str = `${op.name} - `;
|
||||
if (e.fileName) {
|
||||
e.display_str += `${e.name} in ${e.fileName
|
||||
} on line ${e.lineNumber
|
||||
}.<br><br>Message: ${e.message}`;
|
||||
} else {
|
||||
e.display_str += e.message;
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
return this.op_list.length;
|
||||
};
|
||||
|
||||
|
||||
|
@ -199,8 +202,8 @@ Recipe.prototype.execute = function(dish, start_from) {
|
|||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
Recipe.prototype.to_string = function() {
|
||||
return JSON.stringify(this.get_config());
|
||||
Recipe.prototype.to_string = function () {
|
||||
return JSON.stringify(this.get_config());
|
||||
};
|
||||
|
||||
|
||||
|
@ -209,7 +212,7 @@ Recipe.prototype.to_string = function() {
|
|||
*
|
||||
* @param {string} recipe_str
|
||||
*/
|
||||
Recipe.prototype.from_string = function(recipe_str) {
|
||||
var recipe_config = JSON.parse(recipe_str);
|
||||
this._parse_config(recipe_config);
|
||||
Recipe.prototype.from_string = function (recipe_str) {
|
||||
const recipe_config = JSON.parse(recipe_str);
|
||||
this._parse_config(recipe_config);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue