manual fixes

This commit is contained in:
Thomas Grainger 2017-04-13 18:31:26 +01:00
parent b33f73ac9a
commit d05543db30
No known key found for this signature in database
GPG key ID: 995EA0A029283160
16 changed files with 57 additions and 37 deletions

View file

@ -1,6 +1,5 @@
import Utils from "./Utils.js";
/**
* The data being operated on by each operation.
*
@ -12,10 +11,10 @@ import Utils from "./Utils.js";
* @param {byteArray|string|number} value - The value of the input data.
* @param {number} type - The data type of value, see Dish enums.
*/
var Dish = function(value, type) {
function Dish(value, type) {
this.value = value || typeof value == "string" ? value : null;
this.type = type || Dish.BYTE_ARRAY;
};
}
/**

View file

@ -48,14 +48,15 @@ const FlowControl = {
mergeDelim = ings[1],
ignoreErrors = ings[2],
subOpList = [],
inputs = [];
inputs = [],
i;
if (input)
inputs = input.split(splitDelim);
// Create subOpList for each tranche to operate on
// (all remaining operations unless we encounter a Merge)
for (var i = state.progress + 1; i < opList.length; i++) {
for (i = state.progress + 1; i < opList.length; i++) {
if (opList[i].name === "Merge" && !opList[i].isDisabled()) {
break;
} else {

View file

@ -63,6 +63,7 @@ Ingredient.prototype.setValue = function(value) {
* @param {string} type - The name of the data type.
*/
Ingredient.prepare = function(data, type) {
let number;
switch (type) {
case "binaryString":
case "binaryShortString":
@ -76,7 +77,7 @@ Ingredient.prepare = function(data, type) {
return data;
}
case "number":
var number = parseFloat(data);
number = parseFloat(data);
if (isNaN(number)) {
const sample = Utils.truncate(data.toString(), 10);
throw "Invalid ingredient value. Not a number: " + sample;

View file

@ -242,7 +242,8 @@ const Code = {
// Indent
let i = 0,
level = 0;
level = 0,
indent;
while (i < code.length) {
switch (code[i]) {
case "{":
@ -252,7 +253,7 @@ const Code = {
if (i+1 >= code.length) break;
if (code[i+1] === "}") level--;
var indent = (level >= 0) ? Array(level*4+1).join(" ") : "";
indent = (level >= 0) ? Array(level*4+1).join(" ") : "";
code = code.substring(0, i+1) + indent + code.substring(i+1);
if (level > 0) i += level*4;

View file

@ -91,10 +91,11 @@ const Entropy = {
let distrib = new Array(256),
percentages = new Array(256),
len = input.length,
showZeroes = args[0];
showZeroes = args[0],
i;
// Initialise distrib to 0
for (var i = 0; i < 256; i++) {
for (i = 0; i < 256; i++) {
distrib[i] = 0;
}
@ -149,9 +150,10 @@ const Entropy = {
_calcEntropy: function(data) {
let prob = [],
uniques = data.unique(),
str = Utils.byteArrayToChars(data);
str = Utils.byteArrayToChars(data),
i;
for (var i = 0; i < uniques.length; i++) {
for (i = 0; i < uniques.length; i++) {
prob.push(str.count(Utils.chr(uniques[i])) / data.length);
}

View file

@ -160,7 +160,7 @@ const HTML = {
* @returns {html}
*/
runParseColourCode: function(input, args) {
var m = null,
let m = null,
r = 0, g = 0, b = 0, a = 1;
// Read in the input
@ -198,15 +198,16 @@ const HTML = {
b = Math.round(255 * (1 - y_) * (1 - k_));
}
var hsl_ = HTML._rgbToHsl(r, g, b),
let hsl_ = HTML._rgbToHsl(r, g, b),
h = Math.round(hsl_[0] * 360),
s = Math.round(hsl_[1] * 100),
l = Math.round(hsl_[2] * 100),
k = 1 - Math.max(r/255, g/255, b/255),
c = (1 - r/255 - k) / (1 - k),
m = (1 - g/255 - k) / (1 - k), // eslint-disable-line no-redeclare
y = (1 - b/255 - k) / (1 - k);
m = (1 - g/255 - k) / (1 - k);
c = isNaN(c) ? "0" : c.toFixed(2);
m = isNaN(m) ? "0" : m.toFixed(2);
y = isNaN(y) ? "0" : y.toFixed(2);

View file

@ -259,6 +259,8 @@ const IP = {
for (let i = 0; i < lines.length; i++) {
if (lines[i] === "") continue;
let baIp = [];
let octets;
let decimal;
if (inFormat === outFormat) {
output += lines[i] + "\n";
@ -268,13 +270,13 @@ const IP = {
// Convert to byte array IP from input format
switch (inFormat) {
case "Dotted Decimal":
var octets = lines[i].split(".");
octets = lines[i].split(".");
for (j = 0; j < octets.length; j++) {
baIp.push(parseInt(octets[j], 10));
}
break;
case "Decimal":
var decimal = lines[i].toString();
decimal = lines[i].toString();
baIp.push(decimal >> 24 & 255);
baIp.push(decimal >> 16 & 255);
baIp.push(decimal >> 8 & 255);
@ -287,21 +289,25 @@ const IP = {
throw "Unsupported input IP format";
}
let ddIp;
let decIp;
let hexIp;
// Convert byte array IP to output format
switch (outFormat) {
case "Dotted Decimal":
var ddIp = "";
ddIp = "";
for (j = 0; j < baIp.length; j++) {
ddIp += baIp[j] + ".";
}
output += ddIp.slice(0, ddIp.length-1) + "\n";
break;
case "Decimal":
var decIp = ((baIp[0] << 24) | (baIp[1] << 16) | (baIp[2] << 8) | baIp[3]) >>> 0;
decIp = ((baIp[0] << 24) | (baIp[1] << 16) | (baIp[2] << 8) | baIp[3]) >>> 0;
output += decIp.toString() + "\n";
break;
case "Hex":
var hexIp = "";
hexIp = "";
for (j = 0; j < baIp.length; j++) {
hexIp += Utils.hex(baIp[j]);
}
@ -352,14 +358,15 @@ const IP = {
output = "",
ip = null,
network = null,
networkStr = "";
networkStr = "",
i;
if (cidr < 0 || cidr > 127) {
return "CIDR must be less than 32 for IPv4 or 128 for IPv6";
}
// Parse all IPs and add to network dictionary
for (var i = 0; i < ips.length; i++) {
for (i = 0; i < ips.length; i++) {
if ((match = IP.IPV4_REGEX.exec(ips[i]))) {
ip = IP._strToIpv4(match[1]) >>> 0;
network = ip & ipv4Mask;
@ -706,10 +713,11 @@ const IP = {
ip2 = IP._strToIpv6(range[14]);
let t = "",
total = new Array(128);
total = new Array(128),
i;
// Initialise total array to "0"
for (var i = 0; i < 128; i++)
for (i = 0; i < 128; i++)
total[i] = "0";
for (i = 0; i < 8; i++) {

View file

@ -267,9 +267,10 @@ const PublicKey = {
maxKeyLen = 0,
key,
value,
i,
str;
for (var i = 0; i < fields.length; i++) {
for (i = 0; i < fields.length; i++) {
if (!fields[i].length) continue;
key = fields[i].split("=")[0];

View file

@ -117,11 +117,12 @@ const SeqUtils = {
* @returns {byteArray}
*/
runReverse: function (input, args) {
let i;
if (args[0] === "Line") {
let lines = [],
line = [],
result = [];
for (var i = 0; i < input.length; i++) {
for (i = 0; i < input.length; i++) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];

View file

@ -275,10 +275,11 @@ const StrUtils = {
*/
runFilter: function(input, args) {
let delim = Utils.charRep[args[0]],
regex,
reverse = args[2];
try {
var regex = new RegExp(args[1]);
regex = new RegExp(args[1]);
} catch (err) {
return "Invalid regex. Details: " + err.message;
}

View file

@ -121,9 +121,10 @@ const Tidy = {
// Split input into lines
let lines = [],
line = [];
line = [],
i;
for (var i = 0; i < input.length; i++) {
for (i = 0; i < input.length; i++) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];
@ -174,8 +175,9 @@ const Tidy = {
// Split input into lines
let lines = [],
line = [];
let i;
for (var i = 0; i < input.length; i++) {
for (i = 0; i < input.length; i++) {
if (input[i] === 0x0a) {
lines.push(line);
line = [];

View file

@ -91,8 +91,8 @@ const URL_ = {
if (a.search && a.search !== window.location.search) {
output += "Arguments:\n";
const args_ = (a.search.slice(1, a.search.length)).split("&");
let splitArgs = [], padding = 0;
for (var i = 0; i < args_.length; i++) {
let splitArgs = [], padding = 0, i;
for (i = 0; i < args_.length; i++) {
splitArgs.push(args_[i].split("="));
padding = (splitArgs[i][0].length > padding) ? splitArgs[i][0].length : padding;
}

View file

@ -179,8 +179,9 @@ App.prototype.populateOperationsList = function() {
document.body.appendChild(document.getElementById("edit-favourites"));
let html = "";
let i;
for (var i = 0; i < this.categories.length; i++) {
for (i = 0; i < this.categories.length; i++) {
let catConf = this.categories[i],
selected = i === 0,
cat = new HTMLCategory(catConf.name, selected);

View file

@ -201,7 +201,7 @@ OperationsWaiter.prototype.editFavouritesClick = function(e) {
editFavouritesList.innerHTML = html;
this.removeIntent = false;
var editableList = Sortable.create(editFavouritesList, {
const editableList = Sortable.create(editFavouritesList, {
filter: ".remove-icon",
onFilter: function (evt) {
const el = editableList.closest(evt.item);

View file

@ -30,7 +30,8 @@ OptionsWaiter.prototype.load = function(options) {
// Set options to match object
const cboxes = document.querySelectorAll("#options-body input[type=checkbox]");
for (var i = 0; i < cboxes.length; i++) {
let i;
for (i = 0; i < cboxes.length; i++) {
$(cboxes[i]).bootstrapSwitch("state", this.app.options[cboxes[i].getAttribute("option")]);
}

View file

@ -23,7 +23,7 @@ import OperationConfig from "../core/config/OperationConfig.js";
/**
* Main function used to build the CyberChef web app.
*/
var main = function() {
function main() {
const defaultFavourites = [
"To Base64",
"From Base64",
@ -51,7 +51,7 @@ var main = function() {
document.removeEventListener("DOMContentLoaded", main, false);
window.app = new App(Categories, OperationConfig, defaultFavourites, defaultOptions);
window.app.setup();
};
}
// Fix issues with browsers that don't support console.log()
window.console = console || {log: function() {}, error: function() {}};