From a74d97f2a414b3f8532f4653e8725654ca1bc446 Mon Sep 17 00:00:00 2001 From: Windham Wong Date: Wed, 18 Oct 2017 13:22:32 +0100 Subject: [PATCH] Sync up to GCHQ master HEAD Fix syntax issues in multiple files --- prod_image_list.txt | 26 ++++++++++++++++ src/core/config/Categories.js | 4 +-- src/core/operations/ByteRepr.js | 38 +++++++++++------------ src/core/operations/Compress.js | 4 ++- src/core/operations/nTcpdump.js | 55 ++++++++++++++++----------------- 5 files changed, 76 insertions(+), 51 deletions(-) create mode 100644 prod_image_list.txt diff --git a/prod_image_list.txt b/prod_image_list.txt new file mode 100644 index 00000000..e3ab8d31 --- /dev/null +++ b/prod_image_list.txt @@ -0,0 +1,26 @@ +./src/web/static/images/bug-16x16.png +./src/web/static/images/clean-16x16.png +./src/web/static/images/cook_male-32x32.png +./src/web/static/images/cyberchef-128x128.png +./src/web/static/images/download-24x24.png +./src/web/static/images/erase-16x16.png +./src/web/static/images/favourite-16x16.png +./src/web/static/images/favourite-24x24.png +./src/web/static/images/fork_me.png +./src/web/static/images/gitter-badge.svg +./src/web/static/images/help-16x16.png +./src/web/static/images/help-22x22.png +./src/web/static/images/layout-16x16.png +./src/web/static/images/maximise-16x16.png +./src/web/static/images/open_yellow-16x16.png +./src/web/static/images/open_yellow-24x24.png +./src/web/static/images/recycle-16x16.png +./src/web/static/images/save-22x22.png +./src/web/static/images/save_as-16x16.png +./src/web/static/images/settings-22x22.png +./src/web/static/images/speech-16x16.png +./src/web/static/images/step-16x16.png +./src/web/static/images/switch-16x16.png +./src/web/static/images/thumb_down-16x16.png +./src/web/static/images/thumb_up-16x16.png +./src/web/static/images/undo-16x16.png \ No newline at end of file diff --git a/src/core/config/Categories.js b/src/core/config/Categories.js index 53ba0f91..b5912771 100755 --- a/src/core/config/Categories.js +++ b/src/core/config/Categories.js @@ -28,8 +28,8 @@ const Categories = [ "To Hexdump", "From Hexdump", "From nTcpdump", - "From 0x[Hex]", - "From Char(Hex)", + "From 0x[Hex]", + "From Char(Hex)", "To Hex", "From Hex", "To Charcode", diff --git a/src/core/operations/ByteRepr.js b/src/core/operations/ByteRepr.js index fabe8888..56d8bdf5 100755 --- a/src/core/operations/ByteRepr.js +++ b/src/core/operations/ByteRepr.js @@ -54,44 +54,44 @@ const ByteRepr = { }, - /** + /** * From 0xHex operation. * * @param {string} input (Starting with 0x only in the raw input) * @param {Object[]} args * @returns {byteArray} */ - runFrom0xHex: function(input, args) { - var data = input.replace(/0x([0-9a-f]{2,})/ig, - function(match, p1) { - if (p1) { - return Utils.byteArrayToChars(Utils.fromHex(p1)); - }; - }); - return data; + runFrom0xHex: function(input, args) { + let data = input.replace(/0x([0-9a-f]{2,})/ig, + function(match, p1) { + if (p1) { + return Utils.byteArrayToChars(Utils.fromHex(p1)); + } + }); + return data; }, - /** + /** * From char(hex) operation. * * @param {string} input (Starting with chr or char only in the raw input) * @param {Object[]} args * @returns {byteArray} */ - runFromCharHex: function(input, args) { - var re = /cha?r\((((\d{1,3})(,\s?)?)+)\)/ig; - var inner_re = /(\d{1,3}),?/g - var data = input.replace(re, + runFromCharHex: function(input, args) { + let re = /cha?r\((((\d{1,3})(,\s?)?)+)\)/ig; + let innerRe = /(\d{1,3}),?/g; + let data = input.replace(re, function(match, p1) { if (p1) { - var result = "", inner_match; - while ((inner_match = inner_re.exec(p1)) != null) { - result += Utils.byteArrayToChars([parseInt(inner_match[1])]); + let result = "", innerMatch; + while ((innerMatch = innerRe.exec(p1)) != null) { + result += Utils.byteArrayToChars([parseInt(innerMatch[1], 10)]); } return result; - } - }); + } + }); return data; }, diff --git a/src/core/operations/Compress.js b/src/core/operations/Compress.js index 527b04d6..2614c6f5 100755 --- a/src/core/operations/Compress.js +++ b/src/core/operations/Compress.js @@ -267,7 +267,9 @@ const Compress = { let regexStr = /1f8b080[0-8][0-9a-f]{12}/; let gzipPos = input.search(regexStr); - if (gzipPos == -1) {return Utils.hexToByteArray(input);} + if (gzipPos === -1) { + return Utils.hexToByteArray(input); + } let plainData = input.substr(0, gzipPos); let gzipData = input.substr(gzipPos); diff --git a/src/core/operations/nTcpdump.js b/src/core/operations/nTcpdump.js index bcdabaed..0e6f1f63 100644 --- a/src/core/operations/nTcpdump.js +++ b/src/core/operations/nTcpdump.js @@ -37,19 +37,19 @@ const nTcpdump = { * @returns {string} */ runTo: function(input, args) { - var length = args[0] || nTcpdump.WIDTH; - var upperCase = args[1]; - var includeFinalLength = args[2]; + let length = args[0] || nTcpdump.WIDTH; + let upperCase = args[1]; + let includeFinalLength = args[2]; - var output = "", padding = 2; - for (var i = 0; i < input.length; i += length) { - var buff = input.slice(i, i+length); - var hexa = ""; - for (var j = 0; j < buff.length; j++) { + let output = "", padding = 2; + for (let i = 0; i < input.length; i += length) { + let buff = input.slice(i, i+length); + let hexa = ""; + for (let j = 0; j < buff.length; j++) { hexa += Utils.hex(buff[j], padding) + " "; } - var lineNo = Utils.hex(i, 8); + let lineNo = Utils.hex(i, 8); if (upperCase) { hexa = hexa.toUpperCase(); @@ -77,21 +77,18 @@ const nTcpdump = { * @returns {byteArray} */ runFrom: function(input, args) { - var output = [], - regex = /^\s*(?:0x[\dA-F]{4}:?)?\s*((?:[\dA-F]{4}\s?){1,8})/igm, - regex_header = /^\s*(?:0x0000:){1}\s*((?:[\dA-F]{4}\s?){6})/igm, - block, line; - - while ((block = regex.exec(input))) { - // block[1].replace(regex_header, "0x0000:"); - line = Utils.fromHex(block[1].replace(/-/g, " ")); - for (var i = 0; i < line.length; i++) { + let output = []; + let regex = /^\s*(?:0x[\dA-F]{4}:?)?\s*((?:[\dA-F]{4}\s?){1,8})/igm; + let block = regex.exec(input); + while (block) { + let line = Utils.fromHex(block[1].replace(/-/g, " ")); + for (let i = 0; i < line.length; i++) { output.push(line[i]); } } // Is this a CyberChef hexdump or is it from a different tool? - var width = input.indexOf("\n"); - var w = (width - 13) / 4; + let width = input.indexOf("\n"); + let w = (width - 13) / 4; // w should be the specified width of the hexdump and therefore a round number if (Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1) { app.options.attemptHighlight = false; @@ -111,7 +108,7 @@ const nTcpdump = { */ highlightTo: function(pos, args) { // Calculate overall selection - var w = args[0] || 16, + let w = args[0] || 16, width = 14 + (w*4), line = Math.floor(pos[0].start / w), offset = pos[0].start % w, @@ -129,8 +126,8 @@ const nTcpdump = { pos[0].end = line*width + 10 + offset*3 - 1; // Set up multiple selections for bytes - var startLineNum = Math.floor(pos[0].start / width); - var endLineNum = Math.floor(pos[0].end / width); + let startLineNum = Math.floor(pos[0].start / width); + let endLineNum = Math.floor(pos[0].end / width); if (startLineNum === endLineNum) { pos.push(pos[0]); @@ -148,10 +145,10 @@ const nTcpdump = { } // Set up multiple selections for ASCII - var len = pos.length, lineNum = 0; + let len = pos.length, lineNum = 0; start = 0; end = 0; - for (var i = 1; i < len; i++) { + for (let i = 1; i < len; i++) { lineNum = Math.floor(pos[i].start / width); start = (((pos[i].start - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width); end = (((pos[i].end + 1 - (lineNum * width)) - 10) / 3) + (width - w -2) + (lineNum * width); @@ -171,11 +168,11 @@ const nTcpdump = { * @returns {Object[]} pos */ highlightFrom: function(pos, args) { - var w = args[0] || 16; - var width = 14 + (w*4); + let w = args[0] || 16; + let width = 14 + (w*4); - var line = Math.floor(pos[0].start / width); - var offset = pos[0].start % width; + let line = Math.floor(pos[0].start / width); + let offset = pos[0].start % width; if (offset < 10) { // In line number section pos[0].start = line*w;