Skip to content

Commit d4ae241

Browse files
authored
Merge branch 'master' into rsa
2 parents fad163e + 616b38c commit d4ae241

File tree

9 files changed

+2154
-2505
lines changed

9 files changed

+2154
-2505
lines changed

package-lock.json

+2,114-2,428
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cyberchef",
3-
"version": "9.20.3",
3+
"version": "9.20.7",
44
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
55
"author": "n1474335 <[email protected]>",
66
"homepage": "https://gchq.github.io/CyberChef",
@@ -43,7 +43,7 @@
4343
"babel-eslint": "^10.1.0",
4444
"babel-loader": "^8.0.6",
4545
"babel-plugin-dynamic-import-node": "^2.3.0",
46-
"chromedriver": "^80.0.1",
46+
"chromedriver": "^83.0.0",
4747
"cli-progress": "^3.6.0",
4848
"colors": "^1.4.0",
4949
"copy-webpack-plugin": "^5.1.1",
@@ -66,7 +66,7 @@
6666
"html-webpack-plugin": "^3.2.0",
6767
"imports-loader": "^0.8.0",
6868
"mini-css-extract-plugin": "^0.9.0",
69-
"nightwatch": "^1.3.4",
69+
"nightwatch": "^1.3.5",
7070
"node-sass": "^4.13.1",
7171
"postcss-css-variables": "^0.14.0",
7272
"postcss-import": "^12.0.1",
@@ -92,7 +92,7 @@
9292
"bcryptjs": "^2.4.3",
9393
"bignumber.js": "^9.0.0",
9494
"blakejs": "^1.1.0",
95-
"bootstrap": "4.4.1",
95+
"bootstrap": "4.5.0",
9696
"bootstrap-colorpicker": "^3.2.0",
9797
"bootstrap-material-design": "^4.1.2",
9898
"bson": "^4.0.3",
@@ -108,14 +108,13 @@
108108
"es6-promisify": "^6.1.0",
109109
"escodegen": "^1.14.1",
110110
"esm": "^3.2.25",
111-
"esmangle": "^1.0.1",
112111
"esprima": "^4.0.1",
113112
"exif-parser": "^0.1.12",
114113
"file-saver": "^2.0.2",
115114
"geodesy": "^1.1.3",
116115
"highlight.js": "^9.18.1",
117116
"jimp": "^0.9.5",
118-
"jquery": "3.4.1",
117+
"jquery": "3.5.0",
119118
"js-crc": "^0.2.0",
120119
"js-sha3": "^0.8.0",
121120
"jsesc": "^2.5.2",
@@ -146,6 +145,7 @@
146145
"sortablejs": "^1.10.2",
147146
"split.js": "^1.5.11",
148147
"ssdeep.js": "0.0.2",
148+
"terser": "^4.3.9",
149149
"tesseract.js": "^2.0.2",
150150
"ua-parser-js": "^0.7.21",
151151
"unorm": "^1.6.0",

src/core/operations/JavaScriptMinify.mjs

+7-19
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* @license Apache-2.0
55
*/
66

7+
import OperationError from "../errors/OperationError.mjs";
78
import Operation from "../Operation.mjs";
8-
import * as esprima from "esprima";
9-
import escodegen from "escodegen";
10-
import esmangle from "esmangle";
9+
import Terser from "terser";
1110

1211
/**
1312
* JavaScript Minify operation
@@ -34,22 +33,11 @@ class JavaScriptMinify extends Operation {
3433
* @returns {string}
3534
*/
3635
run(input, args) {
37-
let result = "";
38-
const AST = esprima.parseScript(input),
39-
optimisedAST = esmangle.optimize(AST, null),
40-
mangledAST = esmangle.mangle(optimisedAST);
41-
42-
result = escodegen.generate(mangledAST, {
43-
format: {
44-
renumber: true,
45-
hexadecimal: true,
46-
escapeless: true,
47-
compact: true,
48-
semicolons: false,
49-
parentheses: false
50-
}
51-
});
52-
return result;
36+
const result = Terser.minify(input);
37+
if (result.error) {
38+
throw new OperationError(`Error minifying JavaScript. (${result.error})`);
39+
}
40+
return result.code;
5341
}
5442

5543
}

src/core/operations/NormaliseUnicode.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class NormaliseUnicode extends Operation {
5151
case "NFKD":
5252
return unorm.nfkd(input);
5353
case "NFKC":
54-
return unorm.nfc(input);
54+
return unorm.nfkc(input);
5555
default:
5656
throw new OperationError("Unknown Normalisation Form");
5757
}

src/core/operations/OpticalCharacterRecognition.mjs

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/**
22
* @author n1474335 [[email protected]]
33
* @author mshwed [[email protected]]
4+
* @author Matt C [[email protected]]
45
* @copyright Crown Copyright 2019
56
* @license Apache-2.0
67
*/
@@ -12,7 +13,7 @@ import { toBase64 } from "../lib/Base64.mjs";
1213
import { isWorkerEnvironment } from "../Utils.mjs";
1314

1415
import Tesseract from "tesseract.js";
15-
const { TesseractWorker } = Tesseract;
16+
const { createWorker } = Tesseract;
1617

1718
import process from "process";
1819

@@ -60,23 +61,30 @@ class OpticalCharacterRecognition extends Operation {
6061
const assetDir = isWorkerEnvironment() ? `${self.docURL}/assets/` : `${process.cwd()}/src/core/vendor/`;
6162

6263
try {
64+
self.sendStatusMessage("Spinning up Tesseract worker...");
6365
const image = `data:${type};base64,${toBase64(input)}`;
64-
const worker = new TesseractWorker({
66+
const worker = createWorker({
6567
workerPath: `${assetDir}tesseract/worker.min.js`,
6668
langPath: `${assetDir}tesseract/lang-data`,
6769
corePath: `${assetDir}tesseract/tesseract-core.wasm.js`,
68-
});
69-
const result = await worker.recognize(image)
70-
.progress(progress => {
70+
logger: progress => {
7171
if (isWorkerEnvironment()) {
72-
self.sendStatusMessage(`Status: ${progress.status} - ${(parseFloat(progress.progress)*100).toFixed(2)}%`);
72+
self.sendStatusMessage(`Status: ${progress.status}${progress.status === "recognizing text" ? ` - ${(parseFloat(progress.progress)*100).toFixed(2)}%`: "" }`);
7373
}
74-
});
74+
}
75+
});
76+
await worker.load();
77+
self.sendStatusMessage("Loading English language...");
78+
await worker.loadLanguage("eng");
79+
self.sendStatusMessage("Intialising Tesseract API...");
80+
await worker.initialize("eng");
81+
self.sendStatusMessage("Finding text...");
82+
const result = await worker.recognize(image);
7583

7684
if (showConfidence) {
77-
return `Confidence: ${result.confidence}%\n\n${result.text}`;
85+
return `Confidence: ${result.data.confidence}%\n\n${result.data.text}`;
7886
} else {
79-
return result.text;
87+
return result.data.text;
8088
}
8189
} catch (err) {
8290
throw new OperationError(`Error performing OCR on image. (${err})`);

src/core/vendor/tesseract/tesseract-core.wasm.js

-24
This file was deleted.

src/core/vendor/tesseract/worker.min.js

-17
This file was deleted.

tests/operations/tests/NormaliseUnicode.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ TestRegister.addTests([
4242
}, {
4343
name: "Normalise Unicode - NFKC",
4444
input: "\u00c7\u0043\u0327\u2160",
45-
expectedMatch: /\u00C7\u00C7\u2160/,
45+
expectedMatch: /\u00C7\u00C7I/,
4646
recipeConfig: [
4747
{
4848
op: "Normalise Unicode",

webpack.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ module.exports = {
6161
context: "node_modules/node-forge/dist",
6262
from: "prime.worker.min.js",
6363
to: "assets/forge/"
64+
}, {
65+
context: "node_modules/tesseract.js/",
66+
from: "dist/worker.min.js",
67+
to: "assets/tesseract"
68+
}, {
69+
context: "node_modules/tesseract.js-core/",
70+
from: "tesseract-core.wasm.js",
71+
to: "assets/tesseract"
6472
}
6573
])
6674
],

0 commit comments

Comments
 (0)