mirror of
https://github.com/gchq/CyberChef
synced 2025-12-15 15:53:30 +00:00
Compare commits
45 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1b3295ff59 | ||
|
|
e40e7a0e4e | ||
|
|
cf5fd7cbf2 | ||
|
|
ec37a676a8 | ||
|
|
f33193e122 | ||
|
|
7c40204e4f | ||
|
|
2b2ffb3346 | ||
|
|
c9d9730726 | ||
|
|
a380aed878 | ||
|
|
4dafa50799 | ||
|
|
53e69835ff | ||
|
|
939208903a | ||
|
|
616b38c6fb | ||
|
|
a302df8f91 | ||
|
|
093512a55a | ||
|
|
007224c92e | ||
|
|
738ee33959 | ||
|
|
d720a6b250 | ||
|
|
5ce3cc17bb | ||
|
|
5c35205315 | ||
|
|
10751934e4 | ||
|
|
d658f91106 | ||
|
|
4c3324aea1 | ||
|
|
ac2fcee90f | ||
|
|
94e00115fe | ||
|
|
29255d2338 | ||
|
|
39278cfce7 | ||
|
|
46cc48cfb9 | ||
|
|
eb4009949d | ||
|
|
57c48a4bd2 | ||
|
|
45011de494 | ||
|
|
5e51ed0a5f | ||
|
|
875802ef2a | ||
|
|
bbc255ef83 | ||
|
|
fc155ec3fc | ||
|
|
3a0c8a199a | ||
|
|
9c729c4490 | ||
|
|
19bdbd66e5 | ||
|
|
ea090f79ee | ||
|
|
1be6c54be2 | ||
|
|
9f4ef9cdad | ||
|
|
8a029e5147 | ||
|
|
4251089687 | ||
|
|
dbcd670ca8 | ||
|
|
462f619f43 |
@@ -2,6 +2,12 @@
|
||||
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
||||
|
||||
|
||||
### [9.21.0] - 2020-06-12
|
||||
- Node API now exports `magic` operation [@d98762625] | [#1049]
|
||||
|
||||
### [9.20.0] - 2020-03-27
|
||||
- 'Parse ObjectID Timestamp' operation added [@dmfj] | [#987]
|
||||
|
||||
### [9.19.0] - 2020-03-24
|
||||
- Improvements to the 'Magic' operation, allowing it to recognise more data formats and provide more accurate results [@n1073645] [@n1474335] | [#966] [b765534b](https://github.com/gchq/CyberChef/commit/b765534b8b2a0454a5132a0a52d1d8844bcbdaaa)
|
||||
|
||||
@@ -221,6 +227,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||
|
||||
|
||||
|
||||
[9.20.0]: https://github.com/gchq/CyberChef/releases/tag/v9.20.0
|
||||
[9.19.0]: https://github.com/gchq/CyberChef/releases/tag/v9.19.0
|
||||
[9.18.0]: https://github.com/gchq/CyberChef/releases/tag/v9.18.0
|
||||
[9.17.0]: https://github.com/gchq/CyberChef/releases/tag/v9.17.0
|
||||
@@ -318,6 +325,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||
[@Flavsditz]: https://github.com/Flavsditz
|
||||
[@pointhi]: https://github.com/pointhi
|
||||
[@MarvinJWendt]: https://github.com/MarvinJWendt
|
||||
[@dmfj]: https://github.com/dmfj
|
||||
|
||||
[#95]: https://github.com/gchq/CyberChef/pull/299
|
||||
[#173]: https://github.com/gchq/CyberChef/pull/173
|
||||
@@ -389,3 +397,4 @@ All major and minor version changes will be documented in this file. Details of
|
||||
[#952]: https://github.com/gchq/CyberChef/pull/952
|
||||
[#965]: https://github.com/gchq/CyberChef/pull/965
|
||||
[#966]: https://github.com/gchq/CyberChef/pull/966
|
||||
[#987]: https://github.com/gchq/CyberChef/pull/987
|
||||
|
||||
10
Gruntfile.js
10
Gruntfile.js
@@ -37,7 +37,7 @@ module.exports = function (grunt) {
|
||||
]);
|
||||
|
||||
grunt.registerTask("configTests",
|
||||
"A task which configures config files in preparation for tests to be run. Use `npm tests` to run tests.",
|
||||
"A task which configures config files in preparation for tests to be run. Use `npm test` to run tests.",
|
||||
[
|
||||
"clean:config", "clean:nodeConfig", "exec:generateConfig", "exec:generateNodeIndex"
|
||||
]);
|
||||
@@ -242,6 +242,10 @@ module.exports = function (grunt) {
|
||||
entry: Object.assign({
|
||||
main: "./src/web/index.js"
|
||||
}, moduleEntryPoints),
|
||||
output: {
|
||||
publicPath: "",
|
||||
globalObject: "this"
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
"./config/modules/OpModules.mjs": "./config/modules/Default.mjs"
|
||||
@@ -302,7 +306,7 @@ module.exports = function (grunt) {
|
||||
},
|
||||
files: [
|
||||
{
|
||||
src: "build/prod/index.html",
|
||||
src: ["build/prod/index.html"],
|
||||
dest: "build/prod/index.html"
|
||||
}
|
||||
]
|
||||
@@ -324,7 +328,7 @@ module.exports = function (grunt) {
|
||||
},
|
||||
files: [
|
||||
{
|
||||
src: "build/prod/index.html",
|
||||
src: ["build/prod/index.html"],
|
||||
dest: `build/prod/CyberChef_v${pkg.version}.html`
|
||||
}
|
||||
]
|
||||
|
||||
10011
package-lock.json
generated
10011
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
150
package.json
150
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "cyberchef",
|
||||
"version": "9.19.1",
|
||||
"version": "9.21.1",
|
||||
"description": "The Cyber Swiss Army Knife for encryption, encoding, compression and data analysis.",
|
||||
"author": "n1474335 <n1474335@gmail.com>",
|
||||
"homepage": "https://gchq.github.io/CyberChef",
|
||||
@@ -36,124 +36,131 @@
|
||||
"node >= 10"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.8.7",
|
||||
"@babel/plugin-transform-runtime": "^7.8.3",
|
||||
"@babel/preset-env": "^7.8.7",
|
||||
"autoprefixer": "^9.7.4",
|
||||
"@babel/core": "^7.12.10",
|
||||
"@babel/plugin-transform-runtime": "^7.12.10",
|
||||
"@babel/preset-env": "^7.12.10",
|
||||
"autoprefixer": "^10.1.0",
|
||||
"babel-eslint": "^10.1.0",
|
||||
"babel-loader": "^8.0.6",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.0",
|
||||
"chromedriver": "^80.0.1",
|
||||
"cli-progress": "^3.6.0",
|
||||
"babel-loader": "^8.2.2",
|
||||
"babel-plugin-dynamic-import-node": "^2.3.3",
|
||||
"chromedriver": "^87.0.4",
|
||||
"cli-progress": "^3.8.2",
|
||||
"colors": "^1.4.0",
|
||||
"copy-webpack-plugin": "^5.1.1",
|
||||
"css-loader": "^3.4.2",
|
||||
"eslint": "^6.8.0",
|
||||
"exports-loader": "^0.7.0",
|
||||
"file-loader": "^6.0.0",
|
||||
"grunt": "^1.1.0",
|
||||
"copy-webpack-plugin": "^7.0.0",
|
||||
"css-loader": "^5.0.1",
|
||||
"eslint": "^7.15.0",
|
||||
"exports-loader": "^1.1.1",
|
||||
"file-loader": "^6.2.0",
|
||||
"grunt": "^1.3.0",
|
||||
"grunt-accessibility": "~6.0.0",
|
||||
"grunt-chmod": "~1.1.1",
|
||||
"grunt-concurrent": "^3.0.0",
|
||||
"grunt-contrib-clean": "~2.0.0",
|
||||
"grunt-contrib-connect": "^2.1.0",
|
||||
"grunt-contrib-connect": "^3.0.0",
|
||||
"grunt-contrib-copy": "~1.0.0",
|
||||
"grunt-contrib-watch": "^1.1.0",
|
||||
"grunt-eslint": "^22.0.0",
|
||||
"grunt-eslint": "^23.0.0",
|
||||
"grunt-exec": "~3.0.0",
|
||||
"grunt-webpack": "^3.1.3",
|
||||
"grunt-webpack": "^4.0.2",
|
||||
"grunt-zip": "^0.18.2",
|
||||
"html-webpack-plugin": "^3.2.0",
|
||||
"imports-loader": "^0.8.0",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"nightwatch": "^1.3.4",
|
||||
"node-sass": "^4.13.1",
|
||||
"postcss-css-variables": "^0.14.0",
|
||||
"postcss-import": "^12.0.1",
|
||||
"postcss-loader": "^3.0.0",
|
||||
"html-webpack-plugin": "^4.5.0",
|
||||
"imports-loader": "^1.2.0",
|
||||
"mini-css-extract-plugin": "^1.3.3",
|
||||
"nightwatch": "^1.5.1",
|
||||
"node-sass": "^5.0.0",
|
||||
"postcss": "^8.2.1",
|
||||
"postcss-css-variables": "^0.17.0",
|
||||
"postcss-import": "^13.0.0",
|
||||
"postcss-loader": "^4.1.0",
|
||||
"prompt": "^1.0.0",
|
||||
"sass-loader": "^8.0.2",
|
||||
"sitemap": "^6.1.0",
|
||||
"style-loader": "^1.1.3",
|
||||
"svg-url-loader": "^5.0.0",
|
||||
"url-loader": "^4.0.0",
|
||||
"webpack": "^4.42.0",
|
||||
"webpack-bundle-analyzer": "^3.6.1",
|
||||
"webpack-dev-server": "^3.10.3",
|
||||
"webpack-node-externals": "^1.7.2",
|
||||
"worker-loader": "^2.0.0"
|
||||
"sass-loader": "^10.1.0",
|
||||
"sitemap": "^6.3.3",
|
||||
"style-loader": "^2.0.0",
|
||||
"svg-url-loader": "^7.1.1",
|
||||
"url-loader": "^4.1.1",
|
||||
"webpack": "^5.10.1",
|
||||
"webpack-bundle-analyzer": "^4.2.0",
|
||||
"webpack-dev-server": "^3.11.0",
|
||||
"webpack-node-externals": "^2.5.2",
|
||||
"worker-loader": "^3.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/polyfill": "^7.8.7",
|
||||
"@babel/runtime": "^7.8.7",
|
||||
"@babel/polyfill": "^7.12.1",
|
||||
"@babel/runtime": "^7.12.5",
|
||||
"arrive": "^2.4.1",
|
||||
"avsc": "^5.4.19",
|
||||
"avsc": "^5.5.3",
|
||||
"babel-plugin-transform-builtin-extend": "1.1.2",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"bignumber.js": "^9.0.0",
|
||||
"bignumber.js": "^9.0.1",
|
||||
"blakejs": "^1.1.0",
|
||||
"bootstrap": "4.4.1",
|
||||
"bootstrap": "4.5.3",
|
||||
"bootstrap-colorpicker": "^3.2.0",
|
||||
"bootstrap-material-design": "^4.1.2",
|
||||
"bson": "^4.0.3",
|
||||
"bootstrap-material-design": "^4.1.3",
|
||||
"browserify-zlib": "^0.2.0",
|
||||
"bson": "^4.2.2",
|
||||
"buffer": "^6.0.3",
|
||||
"chi-squared": "^1.1.0",
|
||||
"codepage": "^1.14.0",
|
||||
"core-js": "^3.6.4",
|
||||
"core-js": "^3.8.1",
|
||||
"crypto-api": "^0.8.5",
|
||||
"crypto-browserify": "^3.12.0",
|
||||
"crypto-js": "^4.0.0",
|
||||
"ctph.js": "0.0.5",
|
||||
"d3": "^5.15.0",
|
||||
"d3": "^6.3.1",
|
||||
"d3-hexbin": "^0.2.2",
|
||||
"diff": "^4.0.2",
|
||||
"es6-promisify": "^6.1.0",
|
||||
"escodegen": "^1.14.1",
|
||||
"diff": "^5.0.0",
|
||||
"es6-promisify": "^6.1.1",
|
||||
"escodegen": "^2.0.0",
|
||||
"esm": "^3.2.25",
|
||||
"esmangle": "^1.0.1",
|
||||
"esprima": "^4.0.1",
|
||||
"exif-parser": "^0.1.12",
|
||||
"file-saver": "^2.0.2",
|
||||
"file-saver": "^2.0.5",
|
||||
"geodesy": "^1.1.3",
|
||||
"highlight.js": "^9.18.1",
|
||||
"jimp": "^0.9.5",
|
||||
"jquery": "3.4.1",
|
||||
"highlight.js": "^10.4.1",
|
||||
"jimp": "^0.16.1",
|
||||
"jquery": "3.5.1",
|
||||
"js-crc": "^0.2.0",
|
||||
"js-sha3": "^0.8.0",
|
||||
"jsesc": "^2.5.2",
|
||||
"jsesc": "^3.0.2",
|
||||
"jsonpath": "^1.0.2",
|
||||
"jsonwebtoken": "^8.5.1",
|
||||
"jsqr": "^1.2.0",
|
||||
"jsrsasign": "8.0.12",
|
||||
"kbpgp": "2.1.13",
|
||||
"jsqr": "^1.3.1",
|
||||
"jsrsasign": "10.1.4",
|
||||
"kbpgp": "2.1.15",
|
||||
"libbzip2-wasm": "0.0.4",
|
||||
"libyara-wasm": "^1.0.1",
|
||||
"lodash": "^4.17.15",
|
||||
"loglevel": "^1.6.7",
|
||||
"libyara-wasm": "^1.1.0",
|
||||
"lodash": "^4.17.20",
|
||||
"loglevel": "^1.7.1",
|
||||
"loglevel-message-prefix": "^3.0.0",
|
||||
"markdown-it": "^10.0.0",
|
||||
"moment": "^2.24.0",
|
||||
"moment-timezone": "^0.5.28",
|
||||
"markdown-it": "^12.0.3",
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.32",
|
||||
"ngeohash": "^0.6.3",
|
||||
"node-forge": "^0.9.1",
|
||||
"node-forge": "^0.10.0",
|
||||
"node-md6": "^0.1.0",
|
||||
"nodom": "^2.4.0",
|
||||
"notepack.io": "^2.3.0",
|
||||
"nwmatcher": "^1.4.4",
|
||||
"otp": "^0.1.3",
|
||||
"path": "^0.12.7",
|
||||
"popper.js": "^1.16.1",
|
||||
"process": "^0.11.10",
|
||||
"qr-image": "^3.2.0",
|
||||
"scryptsy": "^2.1.0",
|
||||
"snackbarjs": "^1.1.0",
|
||||
"sortablejs": "^1.10.2",
|
||||
"split.js": "^1.5.11",
|
||||
"sortablejs": "^1.12.0",
|
||||
"split.js": "^1.6.2",
|
||||
"ssdeep.js": "0.0.2",
|
||||
"tesseract.js": "^2.0.2",
|
||||
"ua-parser-js": "^0.7.21",
|
||||
"stream-browserify": "^3.0.0",
|
||||
"terser": "^5.5.1",
|
||||
"tesseract.js": "^2.1.1",
|
||||
"ua-parser-js": "^0.7.23",
|
||||
"unorm": "^1.6.0",
|
||||
"utf8": "^3.0.0",
|
||||
"vkbeautify": "^0.99.3",
|
||||
"xmldom": "^0.3.0",
|
||||
"xpath": "0.0.27",
|
||||
"xregexp": "^4.3.0",
|
||||
"xmldom": "^0.4.0",
|
||||
"xpath": "0.0.32",
|
||||
"xregexp": "^4.4.1",
|
||||
"zlibjs": "^0.3.1"
|
||||
},
|
||||
"scripts": {
|
||||
@@ -165,6 +172,7 @@
|
||||
"testui": "grunt testui",
|
||||
"testuidev": "npx nightwatch --env=dev",
|
||||
"lint": "grunt lint",
|
||||
"postinstall": "find ./node_modules/crypto-api/src/ \\( -type d -name .git -prune \\) -o -type f -print0 | xargs -0 sed -i '' -e '/\\.mjs/!s/\\(from \"\\.[^\"]*\\)\";/\\1.mjs\";/g'",
|
||||
"newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -242,6 +242,7 @@
|
||||
"Convert co-ordinate format",
|
||||
"Show on map",
|
||||
"Parse UNIX file permissions",
|
||||
"Parse ObjectID timestamp",
|
||||
"Swap endianness",
|
||||
"Parse colour code",
|
||||
"Escape string",
|
||||
|
||||
@@ -17,7 +17,7 @@ class DishJSON extends DishType {
|
||||
*/
|
||||
static toArrayBuffer() {
|
||||
DishJSON.checkForValue(this.value);
|
||||
this.value = this.value ? Utils.strToArrayBuffer(JSON.stringify(this.value, null, 4)) : new ArrayBuffer;
|
||||
this.value = this.value !== undefined ? Utils.strToArrayBuffer(JSON.stringify(this.value, null, 4)) : new ArrayBuffer;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
|
||||
const crypto = {};
|
||||
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
|
||||
/* dojo-release-1.8.1/dojo/_base/lang.js.uncompressed.js */
|
||||
|
||||
@@ -468,6 +468,34 @@ export const FILE_SIGNATURES = {
|
||||
],
|
||||
extractor: null
|
||||
},
|
||||
{
|
||||
name: "Targa Image",
|
||||
extension: "tga",
|
||||
mime: "image/x-targa",
|
||||
description: "",
|
||||
signature: [
|
||||
{ // This signature is not at the beginning of the file. The extractor works backwards.
|
||||
0: 0x54,
|
||||
1: 0x52,
|
||||
2: 0x55,
|
||||
3: 0x45,
|
||||
4: 0x56,
|
||||
5: 0x49,
|
||||
6: 0x53,
|
||||
7: 0x49,
|
||||
8: 0x4f,
|
||||
9: 0x4e,
|
||||
10: 0x2d,
|
||||
11: 0x58,
|
||||
12: 0x46,
|
||||
13: 0x49,
|
||||
14: 0x4c,
|
||||
15: 0x45,
|
||||
16: 0x2e
|
||||
}
|
||||
],
|
||||
extractor: extractTARGA
|
||||
}
|
||||
],
|
||||
"Video": [
|
||||
{ // Place before webm
|
||||
@@ -3047,6 +3075,90 @@ export function extractICO(bytes, offset) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* TARGA extractor.
|
||||
*
|
||||
* @param {Uint8Array} bytes
|
||||
* @param {number} offset
|
||||
*/
|
||||
export function extractTARGA(bytes, offset) {
|
||||
// Need all the bytes since we do not know how far up the image goes.
|
||||
const stream = new Stream(bytes);
|
||||
stream.moveTo(offset - 8);
|
||||
|
||||
// Read in the offsets of the possible areas.
|
||||
const extensionOffset = stream.readInt(4, "le");
|
||||
const developerOffset = stream.readInt(4, "le");
|
||||
|
||||
stream.moveBackwardsBy(8);
|
||||
|
||||
/**
|
||||
* Moves backwards in the stream until it meet bytes that are the same as the amount of bytes moved.
|
||||
*
|
||||
* @param {number} sizeOfSize
|
||||
* @param {number} maxSize
|
||||
*/
|
||||
function moveBackwardsUntilSize(maxSize, sizeOfSize) {
|
||||
for (let i = 0; i < maxSize; i++) {
|
||||
stream.moveBackwardsBy(1);
|
||||
|
||||
// Read in sizeOfSize amount of bytes in.
|
||||
const size = stream.readInt(sizeOfSize, "le") - 1;
|
||||
stream.moveBackwardsBy(sizeOfSize);
|
||||
|
||||
// If the size matches.
|
||||
if (size === i)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Moves backwards in the stream until we meet bytes(when calculated) that are the same as the amount of bytes moved.
|
||||
*/
|
||||
function moveBackwardsUntilImageSize() {
|
||||
stream.moveBackwardsBy(5);
|
||||
|
||||
// The documentation said that 0x100000 was the largest the file could be.
|
||||
for (let i = 0; i < 0x100000; i++) {
|
||||
|
||||
// (Height * Width * pixel depth in bits)/8
|
||||
const total = (stream.readInt(2, "le") * stream.readInt(2, "le") * stream.readInt(1))/8;
|
||||
if (total === i-1)
|
||||
break;
|
||||
|
||||
stream.moveBackwardsBy(6);
|
||||
}
|
||||
}
|
||||
|
||||
if (extensionOffset || developerOffset) {
|
||||
if (extensionOffset) {
|
||||
// Size is stored in two bytes hence the maximum is 0xffff.
|
||||
moveBackwardsUntilSize(0xffff, 2);
|
||||
|
||||
// Move to where we think the start of the file is.
|
||||
stream.moveBackwardsBy(extensionOffset);
|
||||
} else if (developerOffset) {
|
||||
// Size is stored in 4 bytes hence the maxiumum is 0xffffffff.
|
||||
moveBackwardsUntilSize(0xffffffff, 4);
|
||||
|
||||
// Size is stored in byte position 6 so have to move back.
|
||||
stream.moveBackwardsBy(6);
|
||||
|
||||
// Move to where we think the start of the file is.
|
||||
stream.moveBackwardsBy(developerOffset);
|
||||
}
|
||||
} else {
|
||||
// Move backwards until size === number of bytes passed.
|
||||
moveBackwardsUntilImageSize();
|
||||
|
||||
// Move backwards over the reaminder of the header + the 5 we borrowed in moveBackwardsUntilImageSize().
|
||||
stream.moveBackwardsBy(0xc+5);
|
||||
}
|
||||
|
||||
return stream.carve(stream.position, offset+0x12);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WAV extractor.
|
||||
*
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import jsQR from "jsqr";
|
||||
import qr from "qr-image";
|
||||
import jimp from "jimp";
|
||||
import Utils from "../Utils.mjs";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Parses a QR code image from an image
|
||||
|
||||
@@ -303,11 +303,13 @@ export default class Stream {
|
||||
/**
|
||||
* Returns a slice of the stream up to the current position.
|
||||
*
|
||||
* @param {number} [start=0]
|
||||
* @param {number} [finish=this.position]
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
carve() {
|
||||
if (this.bitPos > 0) this.position++;
|
||||
return this.bytes.slice(0, this.position);
|
||||
carve(start=0, finish=this.position) {
|
||||
if (this.bitPos > 0) finish++;
|
||||
return this.bytes.slice(start, finish);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Add Text To Image operation
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import { Blowfish } from "../lib/Blowfish.mjs";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import { Blowfish } from "../lib/Blowfish.mjs";
|
||||
|
||||
|
||||
@@ -9,8 +9,9 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import jimp from "jimp";
|
||||
import { gaussianBlur } from "../lib/ImageManipulation.mjs";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Blur Image operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Contain Image operation
|
||||
|
||||
@@ -8,7 +8,8 @@ import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Convert Image Format operation
|
||||
@@ -88,7 +89,7 @@ class ConvertImageFormat extends Operation {
|
||||
"Sub": jimp.PNG_FILTER_SUB,
|
||||
"Up": jimp.PNG_FILTER_UP,
|
||||
"Average": jimp.PNG_FILTER_AVERAGE,
|
||||
"Paeth": jimp.PNG_FILTER_PATH // Incorrect spelling in Jimp library
|
||||
"Paeth": jimp.PNG_FILTER_PATH
|
||||
};
|
||||
|
||||
const mime = formatMap[format];
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Cover Image operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Crop Image operation
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* DES Decrypt operation
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* DES Encrypt operation
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* Derive PBKDF2 key operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Image Dither operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import { fromBinary } from "../lib/Binary.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Extract LSB operation
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
import {RGBA_DELIM_OPTIONS} from "../lib/Delim.mjs";
|
||||
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Flip Image operation
|
||||
|
||||
@@ -21,7 +21,7 @@ class GenerateHOTP extends Operation {
|
||||
|
||||
this.name = "Generate HOTP";
|
||||
this.module = "Default";
|
||||
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.";
|
||||
this.description = "The HMAC-based One-Time Password algorithm (HOTP) is an algorithm that computes a one-time password from a shared secret key and an incrementing counter. It has been adopted as Internet Engineering Task Force standard RFC 4226, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/HMAC-based_One-time_Password_algorithm";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
@@ -59,7 +59,7 @@ class GenerateHOTP extends Operation {
|
||||
name: args[0],
|
||||
keySize: args[1],
|
||||
codeLength: args[2],
|
||||
secret: (new ToBase32).run(input, []),
|
||||
secret: (new ToBase32).run(input, []).split("=")[0],
|
||||
});
|
||||
const counter = args[3];
|
||||
return `URI: ${otpObj.hotpURL}\n\nPassword: ${otpObj.hotp(counter)}`;
|
||||
|
||||
@@ -7,10 +7,11 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import {isImage} from "../lib/FileType";
|
||||
import {toBase64} from "../lib/Base64";
|
||||
import jimp from "jimp";
|
||||
import {isWorkerEnvironment} from "../Utils";
|
||||
import {isImage} from "../lib/FileType.mjs";
|
||||
import {toBase64} from "../lib/Base64.mjs";
|
||||
import {isWorkerEnvironment} from "../Utils.mjs";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Generate Image operation
|
||||
|
||||
@@ -21,7 +21,7 @@ class GenerateTOTP extends Operation {
|
||||
|
||||
this.name = "Generate TOTP";
|
||||
this.module = "Default";
|
||||
this.description = "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OATH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. T0 and T1 are in seconds.";
|
||||
this.description = "The Time-based One-Time Password algorithm (TOTP) is an algorithm that computes a one-time password from a shared secret key and the current time. It has been adopted as Internet Engineering Task Force standard RFC 6238, is the cornerstone of Initiative For Open Authentication (OAUTH), and is used in a number of two-factor authentication systems. A TOTP is an HOTP where the counter is the current time.<br><br>Enter the secret as the input or leave it blank for a random secret to be generated. T0 and T1 are in seconds.";
|
||||
this.infoURL = "https://wikipedia.org/wiki/Time-based_One-time_Password_algorithm";
|
||||
this.inputType = "ArrayBuffer";
|
||||
this.outputType = "string";
|
||||
@@ -64,7 +64,7 @@ class GenerateTOTP extends Operation {
|
||||
name: args[0],
|
||||
keySize: args[1],
|
||||
codeLength: args[2],
|
||||
secret: (new ToBase32).run(input, []),
|
||||
secret: (new ToBase32).run(input, []).split("=")[0],
|
||||
epoch: args[3],
|
||||
timeSlice: args[4]
|
||||
});
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Image Brightness / Contrast operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Image Filter operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Image Hue/Saturation/Lightness operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Image Opacity operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Invert Image operation
|
||||
|
||||
@@ -4,10 +4,9 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import Operation from "../Operation.mjs";
|
||||
import * as esprima from "esprima";
|
||||
import escodegen from "escodegen";
|
||||
import esmangle from "esmangle";
|
||||
import * as terser from "terser";
|
||||
|
||||
/**
|
||||
* JavaScript Minify operation
|
||||
@@ -33,23 +32,12 @@ class JavaScriptMinify extends Operation {
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
let result = "";
|
||||
const AST = esprima.parseScript(input),
|
||||
optimisedAST = esmangle.optimize(AST, null),
|
||||
mangledAST = esmangle.mangle(optimisedAST);
|
||||
|
||||
result = escodegen.generate(mangledAST, {
|
||||
format: {
|
||||
renumber: true,
|
||||
hexadecimal: true,
|
||||
escapeless: true,
|
||||
compact: true,
|
||||
semicolons: false,
|
||||
parentheses: false
|
||||
}
|
||||
});
|
||||
return result;
|
||||
async run(input, args) {
|
||||
const result = await terser.minify(input);
|
||||
if (result.error) {
|
||||
throw new OperationError(`Error minifying JavaScript. (${result.error})`);
|
||||
}
|
||||
return result.code;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Normalise Image operation
|
||||
|
||||
@@ -51,7 +51,7 @@ class NormaliseUnicode extends Operation {
|
||||
case "NFKD":
|
||||
return unorm.nfkd(input);
|
||||
case "NFKC":
|
||||
return unorm.nfc(input);
|
||||
return unorm.nfkc(input);
|
||||
default:
|
||||
throw new OperationError("Unknown Normalisation Form");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/**
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @author mshwed [m@ttshwed.com]
|
||||
* @author Matt C [me@mitt.dev]
|
||||
* @copyright Crown Copyright 2019
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
@@ -12,7 +13,7 @@ import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
|
||||
import Tesseract from "tesseract.js";
|
||||
const { TesseractWorker } = Tesseract;
|
||||
const { createWorker } = Tesseract;
|
||||
|
||||
import process from "process";
|
||||
|
||||
@@ -60,23 +61,30 @@ class OpticalCharacterRecognition extends Operation {
|
||||
const assetDir = isWorkerEnvironment() ? `${self.docURL}/assets/` : `${process.cwd()}/src/core/vendor/`;
|
||||
|
||||
try {
|
||||
self.sendStatusMessage("Spinning up Tesseract worker...");
|
||||
const image = `data:${type};base64,${toBase64(input)}`;
|
||||
const worker = new TesseractWorker({
|
||||
const worker = createWorker({
|
||||
workerPath: `${assetDir}tesseract/worker.min.js`,
|
||||
langPath: `${assetDir}tesseract/lang-data`,
|
||||
corePath: `${assetDir}tesseract/tesseract-core.wasm.js`,
|
||||
});
|
||||
const result = await worker.recognize(image)
|
||||
.progress(progress => {
|
||||
logger: progress => {
|
||||
if (isWorkerEnvironment()) {
|
||||
self.sendStatusMessage(`Status: ${progress.status} - ${(parseFloat(progress.progress)*100).toFixed(2)}%`);
|
||||
self.sendStatusMessage(`Status: ${progress.status}${progress.status === "recognizing text" ? ` - ${(parseFloat(progress.progress)*100).toFixed(2)}%`: "" }`);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
await worker.load();
|
||||
self.sendStatusMessage("Loading English language...");
|
||||
await worker.loadLanguage("eng");
|
||||
self.sendStatusMessage("Intialising Tesseract API...");
|
||||
await worker.initialize("eng");
|
||||
self.sendStatusMessage("Finding text...");
|
||||
const result = await worker.recognize(image);
|
||||
|
||||
if (showConfidence) {
|
||||
return `Confidence: ${result.confidence}%\n\n${result.text}`;
|
||||
return `Confidence: ${result.data.confidence}%\n\n${result.data.text}`;
|
||||
} else {
|
||||
return result.text;
|
||||
return result.data.text;
|
||||
}
|
||||
} catch (err) {
|
||||
throw new OperationError(`Error performing OCR on image. (${err})`);
|
||||
|
||||
47
src/core/operations/ParseObjectIDTimestamp.mjs
Normal file
47
src/core/operations/ParseObjectIDTimestamp.mjs
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @author dmfj [dominic@dmfj.io]
|
||||
* @copyright Crown Copyright 2020
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import BSON from "bson";
|
||||
|
||||
/**
|
||||
* Parse ObjectID timestamp operation
|
||||
*/
|
||||
class ParseObjectIDTimestamp extends Operation {
|
||||
|
||||
/**
|
||||
* ParseObjectIDTimestamp constructor
|
||||
*/
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.name = "Parse ObjectID timestamp";
|
||||
this.module = "Serialise";
|
||||
this.description = "Parse timestamp from MongoDB/BSON ObjectID hex string.";
|
||||
this.infoURL = "https://docs.mongodb.com/manual/reference/method/ObjectId.getTimestamp/";
|
||||
this.inputType = "string";
|
||||
this.outputType = "string";
|
||||
this.args = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} input
|
||||
* @param {Object[]} args
|
||||
* @returns {string}
|
||||
*/
|
||||
run(input, args) {
|
||||
try {
|
||||
const objectId = new BSON.ObjectID(input);
|
||||
return objectId.getTimestamp().toISOString();
|
||||
} catch (err) {
|
||||
throw new OperationError(err);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default ParseObjectIDTimestamp;
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
import BigNumber from "bignumber.js";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* RC2 Decrypt operation
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,8 @@ import Utils from "../Utils.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { runHash } from "../lib/Hash.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Randomize Colour Palette operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Resize Image operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Rotate Image operation
|
||||
|
||||
@@ -10,7 +10,8 @@ import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import { gaussianBlur } from "../lib/ImageManipulation.mjs";
|
||||
import { isWorkerEnvironment } from "../Utils.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Sharpen Image operation
|
||||
|
||||
@@ -8,8 +8,8 @@ import Operation from "../Operation.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import {isImage} from "../lib/FileType.mjs";
|
||||
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* Split Colour Channels operation
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* Triple DES Decrypt operation
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
import forge from "node-forge/dist/forge.min.js";
|
||||
import forge from "node-forge";
|
||||
|
||||
/**
|
||||
* Triple DES Encrypt operation
|
||||
|
||||
@@ -9,7 +9,8 @@ import OperationError from "../errors/OperationError.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import { isImage } from "../lib/FileType.mjs";
|
||||
import { toBase64 } from "../lib/Base64.mjs";
|
||||
import jimp from "jimp";
|
||||
import jimplib from "jimp/es/index.js";
|
||||
const jimp = jimplib.default ? jimplib.default : jimplib;
|
||||
|
||||
/**
|
||||
* View Bit Plane operation
|
||||
|
||||
@@ -50,7 +50,19 @@ class XPathExpression extends Operation {
|
||||
|
||||
let doc;
|
||||
try {
|
||||
doc = new xmldom.DOMParser().parseFromString(input, "application/xml");
|
||||
doc = new xmldom.DOMParser({
|
||||
errorHandler: {
|
||||
warning(w) {
|
||||
throw w;
|
||||
},
|
||||
error(e) {
|
||||
throw e;
|
||||
},
|
||||
fatalError(e) {
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}).parseFromString(input, "application/xml");
|
||||
} catch (err) {
|
||||
throw new OperationError("Invalid input XML.");
|
||||
}
|
||||
|
||||
24
src/core/vendor/tesseract/tesseract-core.wasm.js
vendored
24
src/core/vendor/tesseract/tesseract-core.wasm.js
vendored
File diff suppressed because one or more lines are too long
17
src/core/vendor/tesseract/worker.min.js
vendored
17
src/core/vendor/tesseract/worker.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -24,20 +24,30 @@ class NodeRecipe {
|
||||
|
||||
|
||||
/**
|
||||
* Validate an ingredient $ coerce to operation if necessary.
|
||||
* Validate an ingredient & coerce to operation if necessary.
|
||||
* @param {String | Function | Object} ing
|
||||
* @returns {Function || Object} The operation, or an object with the
|
||||
* operation and its arguments
|
||||
* @throws {TypeError} If it cannot find the operation in chef's list of operations.
|
||||
*/
|
||||
_validateIngredient(ing) {
|
||||
// CASE operation name given. Find operation and validate
|
||||
if (typeof ing === "string") {
|
||||
const op = operations.find((op) => {
|
||||
return sanitise(op.opName) === sanitise(ing);
|
||||
});
|
||||
if (op) {
|
||||
return op;
|
||||
// Need to validate against case 2
|
||||
return this._validateIngredient(op);
|
||||
} else {
|
||||
throw new TypeError(`Couldn't find an operation with name '${ing}'.`);
|
||||
}
|
||||
// CASE operation given. Check its a chef operation and check its not flowcontrol
|
||||
} else if (typeof ing === "function") {
|
||||
if (ing.flowControl) {
|
||||
throw new TypeError(`flowControl operations like ${ing.opName} are not currently allowed in recipes for chef.bake in the Node API`);
|
||||
}
|
||||
|
||||
if (operations.includes(ing)) {
|
||||
return ing;
|
||||
} else {
|
||||
@@ -57,7 +67,7 @@ class NodeRecipe {
|
||||
|
||||
|
||||
/**
|
||||
* Parse config for recipe.
|
||||
* Parse an opList from a recipeConfig and assign it to the recipe's opList.
|
||||
* @param {String | Function | String[] | Function[] | [String | Function]} recipeConfig
|
||||
*/
|
||||
_parseConfig(recipeConfig) {
|
||||
|
||||
@@ -177,6 +177,7 @@ export function _wrap(OpClass) {
|
||||
// Check to see if class's run function is async.
|
||||
const opInstance = new OpClass();
|
||||
const isAsync = opInstance.run.constructor.name === "AsyncFunction";
|
||||
const isFlowControl = opInstance.flowControl;
|
||||
|
||||
let wrapped;
|
||||
|
||||
@@ -191,7 +192,28 @@ export function _wrap(OpClass) {
|
||||
*/
|
||||
wrapped = async (input, args=null) => {
|
||||
const {transformedInput, transformedArgs} = prepareOp(opInstance, input, args);
|
||||
|
||||
// SPECIAL CASE for Magic. Other flowControl operations will
|
||||
// not work because the opList is not passed in.
|
||||
if (isFlowControl) {
|
||||
opInstance.ingValues = transformedArgs;
|
||||
|
||||
const state = {
|
||||
progress: 0,
|
||||
dish: ensureIsDish(transformedInput),
|
||||
opList: [opInstance],
|
||||
};
|
||||
|
||||
const updatedState = await opInstance.run(state);
|
||||
|
||||
return new NodeDish({
|
||||
value: updatedState.dish.value,
|
||||
type: opInstance.outputType,
|
||||
});
|
||||
}
|
||||
|
||||
const result = await opInstance.run(transformedInput, transformedArgs);
|
||||
|
||||
return new NodeDish({
|
||||
value: result,
|
||||
type: opInstance.outputType,
|
||||
@@ -218,6 +240,8 @@ export function _wrap(OpClass) {
|
||||
// used in chef.help
|
||||
wrapped.opName = OpClass.name;
|
||||
wrapped.args = createArgInfo(opInstance);
|
||||
// Used in NodeRecipe to check for flowControl ops
|
||||
wrapped.flowControl = isFlowControl;
|
||||
|
||||
return wrapped;
|
||||
}
|
||||
@@ -292,25 +316,18 @@ export function help(input) {
|
||||
|
||||
|
||||
/**
|
||||
* bake [Wrapped] - Perform an array of operations on some input.
|
||||
* @returns {Function}
|
||||
* bake
|
||||
*
|
||||
* @param {*} input - some input for a recipe.
|
||||
* @param {String | Function | String[] | Function[] | [String | Function]} recipeConfig -
|
||||
* An operation, operation name, or an array of either.
|
||||
* @returns {NodeDish} of the result
|
||||
* @throws {TypeError} if invalid recipe given.
|
||||
*/
|
||||
export function bake() {
|
||||
|
||||
/**
|
||||
* bake
|
||||
*
|
||||
* @param {*} input - some input for a recipe.
|
||||
* @param {String | Function | String[] | Function[] | [String | Function]} recipeConfig -
|
||||
* An operation, operation name, or an array of either.
|
||||
* @returns {SyncDish} of the result
|
||||
* @throws {TypeError} if invalid recipe given.
|
||||
*/
|
||||
return function(input, recipeConfig) {
|
||||
const recipe = new NodeRecipe(recipeConfig);
|
||||
const dish = ensureIsDish(input);
|
||||
return recipe.execute(dish);
|
||||
};
|
||||
export function bake(input, recipeConfig) {
|
||||
const recipe = new NodeRecipe(recipeConfig);
|
||||
const dish = ensureIsDish(input);
|
||||
return recipe.execute(dish);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -100,8 +100,7 @@ Object.keys(operations).forEach((op) => {
|
||||
|
||||
code += `];
|
||||
|
||||
const prebaked = bake(operations);
|
||||
chef.bake = prebaked;
|
||||
chef.bake = bake;
|
||||
export default chef;
|
||||
|
||||
// Operations as top level exports.
|
||||
@@ -114,7 +113,7 @@ Object.keys(operations).forEach((op) => {
|
||||
});
|
||||
|
||||
code += " NodeDish as Dish,\n";
|
||||
code += " prebaked as bake,\n";
|
||||
code += " bake,\n";
|
||||
code += " help,\n";
|
||||
code += " OperationError,\n";
|
||||
code += " ExcludedOperationError,\n";
|
||||
|
||||
@@ -4,11 +4,11 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import Utils, { debounce } from "../core/Utils";
|
||||
import {fromBase64} from "../core/lib/Base64";
|
||||
import Manager from "./Manager";
|
||||
import HTMLCategory from "./HTMLCategory";
|
||||
import HTMLOperation from "./HTMLOperation";
|
||||
import Utils, { debounce } from "../core/Utils.mjs";
|
||||
import {fromBase64} from "../core/lib/Base64.mjs";
|
||||
import Manager from "./Manager.mjs";
|
||||
import HTMLCategory from "./HTMLCategory.mjs";
|
||||
import HTMLOperation from "./HTMLOperation.mjs";
|
||||
import Split from "split.js";
|
||||
import moment from "moment-timezone";
|
||||
|
||||
|
||||
@@ -9,13 +9,13 @@
|
||||
<svg version="1.2" baseProfile="tiny" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
x="0px" y="0px" width="550px" height="350px" viewBox="0 0 550 350" xml:space="preserve" onload="setup(evt)">
|
||||
<script type="text/ecmascript">
|
||||
// <![CDATA[
|
||||
<![CDATA[
|
||||
function setup(evt) {
|
||||
const allRotors = evt.target.ownerDocument.querySelectorAll('.rotor');
|
||||
const rotors = [];
|
||||
const initTime = Date.now();
|
||||
const tick = 360/26;
|
||||
const speed = 1000; // Time for one full rotation of the fast rotor
|
||||
const speed = 1000; /* Time for one full rotation of the fast rotor */
|
||||
|
||||
for (const rotor of allRotors) {
|
||||
const row = parseInt(rotor.classList.value.match(/row(\d)/)[1], 10);
|
||||
@@ -46,13 +46,13 @@
|
||||
rotor.last = rotor.last + rotor.wait * numTicks;
|
||||
rotor.el.setAttribute("transform", "rotate(" + rotor.pos + ", " + rotor.x + ", " + rotor.y + ")");
|
||||
} else {
|
||||
// Don't bother looking at the rest
|
||||
/* Don't bother looking at the rest */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}, speed/26/1.5 - 5);
|
||||
}
|
||||
// ]]>
|
||||
]]>
|
||||
</script>
|
||||
<style>
|
||||
.row0 {--primary-color: #e5d41b;}
|
||||
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
@@ -4,7 +4,7 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import ChefWorker from "worker-loader?inline&fallback=false!../../core/ChefWorker.js";
|
||||
import ChefWorker from "worker-loader?inline=no-fallback!../../core/ChefWorker.js";
|
||||
|
||||
/**
|
||||
* Waiter to handle conversations with a ChefWorker in the background.
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import LoaderWorker from "worker-loader?inline&fallback=false!../workers/LoaderWorker.js";
|
||||
import InputWorker from "worker-loader?inline&fallback=false!../workers/InputWorker.mjs";
|
||||
import LoaderWorker from "worker-loader?inline=no-fallback!../workers/LoaderWorker.js";
|
||||
import InputWorker from "worker-loader?inline=no-fallback!../workers/InputWorker.mjs";
|
||||
import Utils, { debounce } from "../../core/Utils.mjs";
|
||||
import { toBase64 } from "../../core/lib/Base64.mjs";
|
||||
import { isImage } from "../../core/lib/FileType.mjs";
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import Utils, { debounce } from "../../core/Utils.mjs";
|
||||
import Dish from "../../core/Dish.mjs";
|
||||
import FileSaver from "file-saver";
|
||||
import ZipWorker from "worker-loader?inline&fallback=false!../workers/ZipWorker.mjs";
|
||||
import ZipWorker from "worker-loader?inline=no-fallback!../workers/ZipWorker.mjs";
|
||||
|
||||
/**
|
||||
* Waiter to handle events related to the output
|
||||
|
||||
@@ -51,7 +51,6 @@ class RecipeWaiter {
|
||||
}
|
||||
}.bind(this),
|
||||
onSort: function(evt) {
|
||||
this.updateZIndices();
|
||||
if (evt.from.id === "rec-list") {
|
||||
document.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
@@ -150,19 +149,6 @@ class RecipeWaiter {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the z-index property on each operation to make sure that operations higher in the list
|
||||
* have a higher index, meaning dropdowns are not hidden underneath subsequent operations.
|
||||
*/
|
||||
updateZIndices() {
|
||||
const operations = document.getElementById("rec-list").children;
|
||||
for (let i = 0; i < operations.length; i++) {
|
||||
const operation = operations[i];
|
||||
operation.style.zIndex = 100 + operations.length - i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for favourite dragover events.
|
||||
* If the element being dragged is an operation, displays a visual cue so that the user knows it can
|
||||
@@ -480,7 +466,6 @@ class RecipeWaiter {
|
||||
log.debug(`'${e.target.querySelector(".op-title").textContent}' added to recipe`);
|
||||
|
||||
this.triggerArgEvents(e.target);
|
||||
this.updateZIndices();
|
||||
window.dispatchEvent(this.manager.statechange);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
import ChefWorker from "worker-loader?inline&fallback=false!../../core/ChefWorker.js";
|
||||
import DishWorker from "worker-loader?inline&fallback=false!../workers/DishWorker.mjs";
|
||||
import ChefWorker from "worker-loader?inline=no-fallback!../../core/ChefWorker.js";
|
||||
import DishWorker from "worker-loader?inline=no-fallback!../workers/DishWorker.mjs";
|
||||
import { debounce } from "../../core/Utils.mjs";
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
before: browser => {
|
||||
browser
|
||||
|
||||
406
tests/browser/ops.js
Normal file
406
tests/browser/ops.js
Normal file
@@ -0,0 +1,406 @@
|
||||
/**
|
||||
* Tests for operations to ensure they output something sensible where expected
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2021
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
|
||||
module.exports = {
|
||||
before: browser => {
|
||||
browser
|
||||
.resizeWindow(1280, 800)
|
||||
.url(browser.launchUrl)
|
||||
.useCss()
|
||||
.waitForElementNotPresent("#preloader", 10000)
|
||||
.click("#auto-bake-label");
|
||||
},
|
||||
|
||||
"Sanity check operations": browser => {
|
||||
testOp(browser, "A1Z26 Cipher Decode", "20 5 19 20 15 21 20 16 21 20", "testoutput");
|
||||
testOp(browser, "A1Z26 Cipher Encode", "test input", "20 5 19 20 9 14 16 21 20");
|
||||
testOp(browser, "ADD", "test input", "Ê»ÉÊv¿ÄÆËÊ", [{ "option": "Hex", "string": "56" }]);
|
||||
testOp(browser, "AES Decrypt", "b443f7f7c16ac5396a34273f6f639caa", "test output", [{ "option": "Hex", "string": "00112233445566778899aabbccddeeff" }, { "option": "Hex", "string": "00000000000000000000000000000000" }, "CBC", "Hex", "Raw", { "option": "Hex", "string": "" }]);
|
||||
testOp(browser, "AES Encrypt", "test input", "e42eb8fbfb7a98fff061cd2c1a794d92", [{"option": "Hex", "string": "00112233445566778899aabbccddeeff"}, {"option": "Hex", "string": "00000000000000000000000000000000"}, "CBC", "Raw", "Hex"]);
|
||||
testOp(browser, "AND", "test input", "4$04 $044", [{ "option": "Hex", "string": "34" }]);
|
||||
testOp(browser, "Add line numbers", "test input", "1 test input");
|
||||
// testOp(browser, "Add Text To Image", "test input", "test_output");
|
||||
testOp(browser, "Adler-32 Checksum", "test input", "16160411");
|
||||
testOp(browser, "Affine Cipher Decode", "test input", "rcqr glnsr", [1, 2]);
|
||||
testOp(browser, "Affine Cipher Encode", "test input", "njln rbfpn", [2, 1]);
|
||||
testOp(browser, "Analyse hash", "0123456789abcdef", /CRC-64/);
|
||||
testOp(browser, "Atbash Cipher", "test input", "gvhg rmkfg");
|
||||
// testOp(browser, "Avro to JSON", "test input", "test_output");
|
||||
// testOp(browser, "BLAKE2b", "test input", "test_output");
|
||||
// testOp(browser, "BLAKE2s", "test input", "test_output");
|
||||
// testOp(browser, "BSON deserialise", "test input", "test_output");
|
||||
// testOp(browser, "BSON serialise", "test input", "test_output");
|
||||
// testOp(browser, "Bacon Cipher Decode", "test input", "test_output");
|
||||
// testOp(browser, "Bacon Cipher Encode", "test input", "test_output");
|
||||
// testOp(browser, "Bcrypt", "test input", "test_output");
|
||||
// testOp(browser, "Bcrypt compare", "test input", "test_output");
|
||||
// testOp(browser, "Bcrypt parse", "test input", "test_output");
|
||||
// testOp(browser, "Bifid Cipher Decode", "test input", "test_output");
|
||||
// testOp(browser, "Bifid Cipher Encode", "test input", "test_output");
|
||||
// testOp(browser, "Bit shift left", "test input", "test_output");
|
||||
// testOp(browser, "Bit shift right", "test input", "test_output");
|
||||
// testOp(browser, "Blowfish Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "Blowfish Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "Blur Image", "test input", "test_output");
|
||||
// testOp(browser, "Bombe", "test input", "test_output");
|
||||
// testOp(browser, "Bzip2 Compress", "test input", "test_output");
|
||||
// testOp(browser, "Bzip2 Decompress", "test input", "test_output");
|
||||
// testOp(browser, "CRC-16 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "CRC-32 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "CRC-8 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "CSS Beautify", "test input", "test_output");
|
||||
// testOp(browser, "CSS Minify", "test input", "test_output");
|
||||
// testOp(browser, "CSS selector", "test input", "test_output");
|
||||
// testOp(browser, "CSV to JSON", "test input", "test_output");
|
||||
// testOp(browser, "CTPH", "test input", "test_output");
|
||||
// testOp(browser, "Cartesian Product", "test input", "test_output");
|
||||
// testOp(browser, "Change IP format", "test input", "test_output");
|
||||
// testOp(browser, "Chi Square", "test input", "test_output");
|
||||
// testOp(browser, "CipherSaber2 Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "CipherSaber2 Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "Citrix CTX1 Decode", "test input", "test_output");
|
||||
// testOp(browser, "Citrix CTX1 Encode", "test input", "test_output");
|
||||
// testOp(browser, "Colossus", "test input", "test_output");
|
||||
// testOp(browser, "Comment", "test input", "test_output");
|
||||
// testOp(browser, "Compare CTPH hashes", "test input", "test_output");
|
||||
// testOp(browser, "Compare SSDEEP hashes", "test input", "test_output");
|
||||
// testOp(browser, "Conditional Jump", "test input", "test_output");
|
||||
// testOp(browser, "Contain Image", "test input", "test_output");
|
||||
// testOp(browser, "Convert area", "test input", "test_output");
|
||||
// testOp(browser, "Convert co-ordinate format", "test input", "test_output");
|
||||
// testOp(browser, "Convert data units", "test input", "test_output");
|
||||
// testOp(browser, "Convert distance", "test input", "test_output");
|
||||
// testOp(browser, "Convert Image Format", "test input", "test_output");
|
||||
// testOp(browser, "Convert mass", "test input", "test_output");
|
||||
// testOp(browser, "Convert speed", "test input", "test_output");
|
||||
// testOp(browser, "Convert to NATO alphabet", "test input", "test_output");
|
||||
// testOp(browser, "Count occurrences", "test input", "test_output");
|
||||
// testOp(browser, "Cover Image", "test input", "test_output");
|
||||
// testOp(browser, "Crop Image", "test input", "test_output");
|
||||
// testOp(browser, "DES Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "DES Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "DNS over HTTPS", "test input", "test_output");
|
||||
// testOp(browser, "Dechunk HTTP response", "test input", "test_output");
|
||||
// testOp(browser, "Decode NetBIOS Name", "test input", "test_output");
|
||||
// testOp(browser, "Decode text", "test input", "test_output");
|
||||
// testOp(browser, "Defang IP Addresses", "test input", "test_output");
|
||||
// testOp(browser, "Defang URL", "test input", "test_output");
|
||||
// testOp(browser, "Derive EVP key", "test input", "test_output");
|
||||
// testOp(browser, "Derive PBKDF2 key", "test input", "test_output");
|
||||
// testOp(browser, "Detect File Type", "test input", "test_output");
|
||||
// testOp(browser, "Diff", "test input", "test_output");
|
||||
// testOp(browser, "Disassemble x86", "test input", "test_output");
|
||||
// testOp(browser, "Dither Image", "test input", "test_output");
|
||||
// testOp(browser, "Divide", "test input", "test_output");
|
||||
// testOp(browser, "Drop bytes", "test input", "test_output");
|
||||
// testOp(browser, "Encode NetBIOS Name", "test input", "test_output");
|
||||
// testOp(browser, "Encode text", "test input", "test_output");
|
||||
// testOp(browser, "Enigma", "test input", "test_output");
|
||||
// testOp(browser, "Entropy", "test input", "test_output");
|
||||
// testOp(browser, "Escape string", "test input", "test_output");
|
||||
// testOp(browser, "Escape Unicode Characters", "test input", "test_output");
|
||||
// testOp(browser, "Expand alphabet range", "test input", "test_output");
|
||||
// testOp(browser, "Extract dates", "test input", "test_output");
|
||||
// testOp(browser, "Extract domains", "test input", "test_output");
|
||||
// testOp(browser, "Extract EXIF", "test input", "test_output");
|
||||
// testOp(browser, "Extract email addresses", "test input", "test_output");
|
||||
// testOp(browser, "Extract file paths", "test input", "test_output");
|
||||
// testOp(browser, "Extract Files", "test input", "test_output");
|
||||
// testOp(browser, "Extract IP addresses", "test input", "test_output");
|
||||
// testOp(browser, "Extract LSB", "test input", "test_output");
|
||||
// testOp(browser, "Extract MAC addresses", "test input", "test_output");
|
||||
// testOp(browser, "Extract RGBA", "test input", "test_output");
|
||||
// testOp(browser, "Extract URLs", "test input", "test_output");
|
||||
// testOp(browser, "Filter", "test input", "test_output");
|
||||
// testOp(browser, "Find / Replace", "test input", "test_output");
|
||||
// testOp(browser, "Fletcher-16 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "Fletcher-32 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "Fletcher-64 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "Fletcher-8 Checksum", "test input", "test_output");
|
||||
// testOp(browser, "Flip Image", "test input", "test_output");
|
||||
// testOp(browser, "Fork", "test input", "test_output");
|
||||
// testOp(browser, "Format MAC addresses", "test input", "test_output");
|
||||
// testOp(browser, "Frequency distribution", "test input", "test_output");
|
||||
// testOp(browser, "From BCD", "test input", "test_output");
|
||||
// testOp(browser, "From Base", "test input", "test_output");
|
||||
// testOp(browser, "From Base32", "test input", "test_output");
|
||||
// testOp(browser, "From Base58", "test input", "test_output");
|
||||
// testOp(browser, "From Base62", "test input", "test_output");
|
||||
// testOp(browser, "From Base64", "test input", "test_output");
|
||||
// testOp(browser, "From Base85", "test input", "test_output");
|
||||
// testOp(browser, "From Binary", "test input", "test_output");
|
||||
// testOp(browser, "From Braille", "test input", "test_output");
|
||||
// testOp(browser, "From Case Insensitive Regex", "test input", "test_output");
|
||||
// testOp(browser, "From Charcode", "test input", "test_output");
|
||||
// testOp(browser, "From Decimal", "test input", "test_output");
|
||||
// testOp(browser, "From HTML Entity", "test input", "test_output");
|
||||
// testOp(browser, "From Hex", "test input", "test_output");
|
||||
// testOp(browser, "From Hex Content", "test input", "test_output");
|
||||
// testOp(browser, "From Hexdump", "test input", "test_output");
|
||||
// testOp(browser, "From MessagePack", "test input", "test_output");
|
||||
// testOp(browser, "From Morse Code", "test input", "test_output");
|
||||
// testOp(browser, "From Octal", "test input", "test_output");
|
||||
// testOp(browser, "From Punycode", "test input", "test_output");
|
||||
// testOp(browser, "From Quoted Printable", "test input", "test_output");
|
||||
// testOp(browser, "From UNIX Timestamp", "test input", "test_output");
|
||||
// testOp(browser, "GOST hash", "test input", "test_output");
|
||||
// testOp(browser, "Generate all hashes", "test input", "test_output");
|
||||
// testOp(browser, "Generate HOTP", "test input", "test_output");
|
||||
// testOp(browser, "Generate Image", "test input", "test_output");
|
||||
// testOp(browser, "Generate Lorem Ipsum", "test input", "test_output");
|
||||
// testOp(browser, "Generate PGP Key Pair", "test input", "test_output");
|
||||
// testOp(browser, "Generate QR Code", "test input", "test_output");
|
||||
// testOp(browser, "Generate TOTP", "test input", "test_output");
|
||||
// testOp(browser, "Generate UUID", "test input", "test_output");
|
||||
// testOp(browser, "Generic Code Beautify", "test input", "test_output");
|
||||
// testOp(browser, "Group IP addresses", "test input", "test_output");
|
||||
// testOp(browser, "Gunzip", "test input", "test_output");
|
||||
// testOp(browser, "Gzip", "test input", "test_output");
|
||||
// testOp(browser, "HAS-160", "test input", "test_output");
|
||||
// testOp(browser, "HMAC", "test input", "test_output");
|
||||
// testOp(browser, "HTML To Text", "test input", "test_output");
|
||||
// testOp(browser, "HTTP request", "test input", "test_output");
|
||||
// testOp(browser, "Hamming Distance", "test input", "test_output");
|
||||
// testOp(browser, "Haversine distance", "test input", "test_output");
|
||||
// testOp(browser, "Head", "test input", "test_output");
|
||||
// testOp(browser, "Heatmap chart", "test input", "test_output");
|
||||
// testOp(browser, "Hex Density chart", "test input", "test_output");
|
||||
// testOp(browser, "Hex to Object Identifier", "test input", "test_output");
|
||||
// testOp(browser, "Hex to PEM", "test input", "test_output");
|
||||
// testOp(browser, "Image Brightness / Contrast", "test input", "test_output");
|
||||
// testOp(browser, "Image Filter", "test input", "test_output");
|
||||
// testOp(browser, "Image Hue/Saturation/Lightness", "test input", "test_output");
|
||||
// testOp(browser, "Image Opacity", "test input", "test_output");
|
||||
// testOp(browser, "Index of Coincidence", "test input", "test_output");
|
||||
// testOp(browser, "Invert Image", "test input", "test_output");
|
||||
// testOp(browser, "JPath expression", "test input", "test_output");
|
||||
// testOp(browser, "JSON Beautify", "test input", "test_output");
|
||||
// testOp(browser, "JSON Minify", "test input", "test_output");
|
||||
// testOp(browser, "JSON to CSV", "test input", "test_output");
|
||||
// testOp(browser, "JWT Decode", "test input", "test_output");
|
||||
// testOp(browser, "JWT Sign", "test input", "test_output");
|
||||
// testOp(browser, "JWT Verify", "test input", "test_output");
|
||||
// testOp(browser, "JavaScript Beautify", "test input", "test_output");
|
||||
// testOp(browser, "JavaScript Minify", "test input", "test_output");
|
||||
// testOp(browser, "JavaScript Parser", "test input", "test_output");
|
||||
// testOp(browser, "Jump", "test input", "test_output");
|
||||
// testOp(browser, "Keccak", "test input", "test_output");
|
||||
// testOp(browser, "Label", "test input", "test_output");
|
||||
// testOp(browser, "Lorenz", "test input", "test_output");
|
||||
// testOp(browser, "Luhn Checksum", "test input", "test_output");
|
||||
// testOp(browser, "MD2", "test input", "test_output");
|
||||
// testOp(browser, "MD4", "test input", "test_output");
|
||||
// testOp(browser, "MD5", "test input", "test_output");
|
||||
// testOp(browser, "MD6", "test input", "test_output");
|
||||
// testOp(browser, "Magic", "test input", "test_output");
|
||||
// testOp(browser, "Mean", "test input", "test_output");
|
||||
// testOp(browser, "Median", "test input", "test_output");
|
||||
// testOp(browser, "Merge", "test input", "test_output");
|
||||
// testOp(browser, "Microsoft Script Decoder", "test input", "test_output");
|
||||
// testOp(browser, "Multiple Bombe", "test input", "test_output");
|
||||
// testOp(browser, "Multiply", "test input", "test_output");
|
||||
// testOp(browser, "NOT", "test input", "test_output");
|
||||
// testOp(browser, "Normalise Image", "test input", "test_output");
|
||||
// testOp(browser, "Normalise Unicode", "test input", "test_output");
|
||||
// testOp(browser, "Numberwang", "test input", "test_output");
|
||||
// testOp(browser, "OR", "test input", "test_output");
|
||||
// testOp(browser, "Object Identifier to Hex", "test input", "test_output");
|
||||
// testOp(browser, "Offset checker", "test input", "test_output");
|
||||
// testOp(browser, "Optical Character Recognition", "test input", "test_output");
|
||||
// testOp(browser, "PEM to Hex", "test input", "test_output");
|
||||
// testOp(browser, "PGP Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "PGP Decrypt and Verify", "test input", "test_output");
|
||||
// testOp(browser, "PGP Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "PGP Encrypt and Sign", "test input", "test_output");
|
||||
// testOp(browser, "PGP Verify", "test input", "test_output");
|
||||
// testOp(browser, "PHP Deserialize", "test input", "test_output");
|
||||
// testOp(browser, "Pad lines", "test input", "test_output");
|
||||
// testOp(browser, "Parse ASN.1 hex string", "test input", "test_output");
|
||||
// testOp(browser, "Parse colour code", "test input", "test_output");
|
||||
// testOp(browser, "Parse DateTime", "test input", "test_output");
|
||||
// testOp(browser, "Parse IP range", "test input", "test_output");
|
||||
// testOp(browser, "Parse IPv4 header", "test input", "test_output");
|
||||
// testOp(browser, "Parse IPv6 address", "test input", "test_output");
|
||||
// testOp(browser, "Parse ObjectID timestamp", "test input", "test_output");
|
||||
// testOp(browser, "Parse QR Code", "test input", "test_output");
|
||||
// testOp(browser, "Parse SSH Host Key", "test input", "test_output");
|
||||
// testOp(browser, "Parse TLV", "test input", "test_output");
|
||||
// testOp(browser, "Parse UDP", "test input", "test_output");
|
||||
// testOp(browser, "Parse UNIX file permissions", "test input", "test_output");
|
||||
// testOp(browser, "Parse URI", "test input", "test_output");
|
||||
// testOp(browser, "Parse User Agent", "test input", "test_output");
|
||||
// testOp(browser, "Parse X.509 certificate", "test input", "test_output");
|
||||
// testOp(browser, "Play Media", "test input", "test_output");
|
||||
// testOp(browser, "Power Set", "test input", "test_output");
|
||||
// testOp(browser, "Protobuf Decode", "test input", "test_output");
|
||||
// testOp(browser, "Pseudo-Random Number Generator", "test input", "test_output");
|
||||
// testOp(browser, "RC2 Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "RC2 Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "RC4", "test input", "test_output");
|
||||
// testOp(browser, "RC4 Drop", "test input", "test_output");
|
||||
// testOp(browser, "RIPEMD", "test input", "test_output");
|
||||
// testOp(browser, "ROT13", "test input", "test_output");
|
||||
// testOp(browser, "ROT47", "test input", "test_output");
|
||||
// testOp(browser, "Rail Fence Cipher Decode", "test input", "test_output");
|
||||
// testOp(browser, "Rail Fence Cipher Encode", "test input", "test_output");
|
||||
// testOp(browser, "Randomize Colour Palette", "test input", "test_output");
|
||||
// testOp(browser, "Raw Deflate", "test input", "test_output");
|
||||
// testOp(browser, "Raw Inflate", "test input", "test_output");
|
||||
// testOp(browser, "Register", "test input", "test_output");
|
||||
// testOp(browser, "Regular expression", "test input", "test_output");
|
||||
// testOp(browser, "Remove Diacritics", "test input", "test_output");
|
||||
// testOp(browser, "Remove EXIF", "test input", "test_output");
|
||||
// testOp(browser, "Remove line numbers", "test input", "test_output");
|
||||
// testOp(browser, "Remove null bytes", "test input", "test_output");
|
||||
// testOp(browser, "Remove whitespace", "test input", "test_output");
|
||||
// testOp(browser, "Render Image", "test input", "test_output");
|
||||
// testOp(browser, "Render Markdown", "test input", "test_output");
|
||||
// testOp(browser, "Resize Image", "test input", "test_output");
|
||||
// testOp(browser, "Return", "test input", "test_output");
|
||||
// testOp(browser, "Reverse", "test input", "test_output");
|
||||
// testOp(browser, "Rotate Image", "test input", "test_output");
|
||||
// testOp(browser, "Rotate left", "test input", "test_output");
|
||||
// testOp(browser, "Rotate right", "test input", "test_output");
|
||||
// testOp(browser, "SHA0", "test input", "test_output");
|
||||
// testOp(browser, "SHA1", "test input", "test_output");
|
||||
// testOp(browser, "SHA2", "test input", "test_output");
|
||||
// testOp(browser, "SHA3", "test input", "test_output");
|
||||
// testOp(browser, "SQL Beautify", "test input", "test_output");
|
||||
// testOp(browser, "SQL Minify", "test input", "test_output");
|
||||
// testOp(browser, "SSDEEP", "test input", "test_output");
|
||||
// testOp(browser, "SUB", "test input", "test_output");
|
||||
// testOp(browser, "Scan for Embedded Files", "test input", "test_output");
|
||||
// testOp(browser, "Scatter chart", "test input", "test_output");
|
||||
// testOp(browser, "Scrypt", "test input", "test_output");
|
||||
// testOp(browser, "Series chart", "test input", "test_output");
|
||||
// testOp(browser, "Set Difference", "test input", "test_output");
|
||||
// testOp(browser, "Set Intersection", "test input", "test_output");
|
||||
// testOp(browser, "Set Union", "test input", "test_output");
|
||||
// testOp(browser, "Shake", "test input", "test_output");
|
||||
// testOp(browser, "Sharpen Image", "test input", "test_output");
|
||||
// testOp(browser, "Show Base64 offsets", "test input", "test_output");
|
||||
// testOp(browser, "Show on map", "test input", "test_output");
|
||||
// testOp(browser, "Sleep", "test input", "test_output");
|
||||
// testOp(browser, "Snefru", "test input", "test_output");
|
||||
// testOp(browser, "Sort", "test input", "test_output");
|
||||
// testOp(browser, "Split", "test input", "test_output");
|
||||
// testOp(browser, "Split Colour Channels", "test input", "test_output");
|
||||
// testOp(browser, "Standard Deviation", "test input", "test_output");
|
||||
// testOp(browser, "Streebog", "test input", "test_output");
|
||||
// testOp(browser, "Strings", "test input", "test_output");
|
||||
// testOp(browser, "Strip HTML tags", "test input", "test_output");
|
||||
// testOp(browser, "Strip HTTP headers", "test input", "test_output");
|
||||
// testOp(browser, "Subsection", "test input", "test_output");
|
||||
// testOp(browser, "Substitute", "test input", "test_output");
|
||||
// testOp(browser, "Subtract", "test input", "test_output");
|
||||
// testOp(browser, "Sum", "test input", "test_output");
|
||||
// testOp(browser, "Swap endianness", "test input", "test_output");
|
||||
// testOp(browser, "Symmetric Difference", "test input", "test_output");
|
||||
// testOp(browser, "Syntax highlighter", "test input", "test_output");
|
||||
// testOp(browser, "TCP/IP Checksum", "test input", "test_output");
|
||||
// testOp(browser, "Tail", "test input", "test_output");
|
||||
// testOp(browser, "Take bytes", "test input", "test_output");
|
||||
// testOp(browser, "Tar", "test input", "test_output");
|
||||
// testOp(browser, "Text Encoding Brute Force", "test input", "test_output");
|
||||
// testOp(browser, "To BCD", "test input", "test_output");
|
||||
// testOp(browser, "To Base", "test input", "test_output");
|
||||
// testOp(browser, "To Base32", "test input", "test_output");
|
||||
// testOp(browser, "To Base58", "test input", "test_output");
|
||||
// testOp(browser, "To Base62", "test input", "test_output");
|
||||
// testOp(browser, "To Base64", "test input", "test_output");
|
||||
// testOp(browser, "To Base85", "test input", "test_output");
|
||||
// testOp(browser, "To Binary", "test input", "test_output");
|
||||
// testOp(browser, "To Braille", "test input", "test_output");
|
||||
// testOp(browser, "To Camel case", "test input", "test_output");
|
||||
// testOp(browser, "To Case Insensitive Regex", "test input", "test_output");
|
||||
// testOp(browser, "To Charcode", "test input", "test_output");
|
||||
// testOp(browser, "To Decimal", "test input", "test_output");
|
||||
// testOp(browser, "To HTML Entity", "test input", "test_output");
|
||||
// testOp(browser, "To Hex", "test input", "test_output");
|
||||
// testOp(browser, "To Hex Content", "test input", "test_output");
|
||||
// testOp(browser, "To Hexdump", "test input", "test_output");
|
||||
// testOp(browser, "To Kebab case", "test input", "test_output");
|
||||
// testOp(browser, "To Lower case", "test input", "test_output");
|
||||
// testOp(browser, "To MessagePack", "test input", "test_output");
|
||||
// testOp(browser, "To Morse Code", "test input", "test_output");
|
||||
// testOp(browser, "To Octal", "test input", "test_output");
|
||||
// testOp(browser, "To Punycode", "test input", "test_output");
|
||||
// testOp(browser, "To Quoted Printable", "test input", "test_output");
|
||||
// testOp(browser, "To Snake case", "test input", "test_output");
|
||||
// testOp(browser, "To Table", "test input", "test_output");
|
||||
// testOp(browser, "To UNIX Timestamp", "test input", "test_output");
|
||||
// testOp(browser, "To Upper case", "test input", "test_output");
|
||||
// testOp(browser, "Translate DateTime Format", "test input", "test_output");
|
||||
// testOp(browser, "Triple DES Decrypt", "test input", "test_output");
|
||||
// testOp(browser, "Triple DES Encrypt", "test input", "test_output");
|
||||
// testOp(browser, "Typex", "test input", "test_output");
|
||||
// testOp(browser, "UNIX Timestamp to Windows Filetime", "test input", "test_output");
|
||||
// testOp(browser, "URL Decode", "test input", "test_output");
|
||||
// testOp(browser, "URL Encode", "test input", "test_output");
|
||||
// testOp(browser, "Unescape string", "test input", "test_output");
|
||||
// testOp(browser, "Unescape Unicode Characters", "test input", "test_output");
|
||||
// testOp(browser, "Unique", "test input", "test_output");
|
||||
// testOp(browser, "Untar", "test input", "test_output");
|
||||
// testOp(browser, "Unzip", "test input", "test_output");
|
||||
// testOp(browser, "VarInt Decode", "test input", "test_output");
|
||||
// testOp(browser, "VarInt Encode", "test input", "test_output");
|
||||
// testOp(browser, "View Bit Plane", "test input", "test_output");
|
||||
// testOp(browser, "Vigenère Decode", "test input", "test_output");
|
||||
// testOp(browser, "Vigenère Encode", "test input", "test_output");
|
||||
// testOp(browser, "Whirlpool", "test input", "test_output");
|
||||
// testOp(browser, "Windows Filetime to UNIX Timestamp", "test input", "test_output");
|
||||
// testOp(browser, "XKCD Random Number", "test input", "test_output");
|
||||
// testOp(browser, "XML Beautify", "test input", "test_output");
|
||||
// testOp(browser, "XML Minify", "test input", "test_output");
|
||||
// testOp(browser, "XOR", "test input", "test_output");
|
||||
// testOp(browser, "XOR Brute Force", "test input", "test_output");
|
||||
// testOp(browser, "XPath expression", "test input", "test_output");
|
||||
// testOp(browser, "YARA Rules", "test input", "test_output");
|
||||
// testOp(browser, "Zip", "test input", "test_output");
|
||||
// testOp(browser, "Zlib Deflate", "test input", "test_output");
|
||||
// testOp(browser, "Zlib Inflate", "test input", "test_output");
|
||||
},
|
||||
|
||||
|
||||
after: browser => {
|
||||
browser.end();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Clears the current recipe and tests a new operation.
|
||||
*
|
||||
* @param {string} opName
|
||||
* @param {Browser} browser
|
||||
*/
|
||||
function testOp(browser, opName, input, output, args=[]) {
|
||||
|
||||
const recipeConfig = JSON.stringify([{
|
||||
"op": opName,
|
||||
"args": args
|
||||
}]);
|
||||
|
||||
browser
|
||||
.perform(function() {
|
||||
console.log(opName);
|
||||
})
|
||||
.useCss()
|
||||
.click("#clr-recipe")
|
||||
.click("#clr-io")
|
||||
.urlHash("recipe=" + recipeConfig)
|
||||
.setValue("#input-text", input)
|
||||
.pause(100)
|
||||
.click("#bake")
|
||||
.waitForElementPresent("#stale-indicator.hidden", 1000);
|
||||
|
||||
if (typeof output === "string") {
|
||||
browser.expect.element("#output-text").to.have.value.that.equals(output);
|
||||
} else if (output instanceof RegExp) {
|
||||
browser.expect.element("#output-text").to.have.value.that.matches(output);
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class TestRegister {
|
||||
result.status = "passing";
|
||||
} catch (e) {
|
||||
result.status = "erroring";
|
||||
result.output = e.message;
|
||||
result.output = `${e.message}\nError: ${e.stack}`;
|
||||
}
|
||||
|
||||
testResults.push(result);
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
import assert from "assert";
|
||||
import it from "../assertionHandler.mjs";
|
||||
import chef from "../../../src/node/index.mjs";
|
||||
import OperationError from "../../../src/core/errors/OperationError.mjs";
|
||||
import { OperationError, ExcludedOperationError } from "../../../src/core/errors/index.mjs";
|
||||
import NodeDish from "../../../src/node/NodeDish.mjs";
|
||||
|
||||
import { toBase32} from "../../../src/node/index.mjs";
|
||||
import { toBase32, magic} from "../../../src/node/index.mjs";
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addApiTests([
|
||||
@@ -181,22 +181,17 @@ TestRegister.addApiTests([
|
||||
}),
|
||||
|
||||
it("chef.bake: should complain if recipe isnt a valid object", () => {
|
||||
try {
|
||||
chef.bake("some input", 3264);
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.name, "TypeError");
|
||||
assert.strictEqual(e.message, "Recipe can only contain function names or functions");
|
||||
}
|
||||
assert.throws(() => chef.bake("some input", 3264), {
|
||||
name: "TypeError",
|
||||
message: "Recipe can only contain function names or functions"
|
||||
});
|
||||
}),
|
||||
|
||||
it("chef.bake: Should complain if string op is invalid", () => {
|
||||
try {
|
||||
chef.bake("some input", "not a valid operation");
|
||||
assert.fail("Shouldn't be hit");
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.name, "TypeError");
|
||||
assert.strictEqual(e.message, "Couldn't find an operation with name 'not a valid operation'.");
|
||||
}
|
||||
assert.throws(() => chef.bake("some input", "not a valid operation"), {
|
||||
name: "TypeError",
|
||||
message: "Couldn't find an operation with name 'not a valid operation'."
|
||||
});
|
||||
}),
|
||||
|
||||
it("chef.bake: Should take an input and an operation and perform it", () => {
|
||||
@@ -205,13 +200,10 @@ TestRegister.addApiTests([
|
||||
}),
|
||||
|
||||
it("chef.bake: Should complain if an invalid operation is inputted", () => {
|
||||
try {
|
||||
chef.bake("https://google.com/search?q=help", () => {});
|
||||
assert.fail("Shouldn't be hit");
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.name, "TypeError");
|
||||
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
|
||||
}
|
||||
assert.throws(() => chef.bake("https://google.com/search?q=help", () => {}), {
|
||||
name: "TypeError",
|
||||
message: "Inputted function not a Chef operation."
|
||||
});
|
||||
}),
|
||||
|
||||
it("chef.bake: accepts an array of operation names and performs them all in order", () => {
|
||||
@@ -241,12 +233,10 @@ TestRegister.addApiTests([
|
||||
}),
|
||||
|
||||
it("should complain if an invalid operation is inputted as part of array", () => {
|
||||
try {
|
||||
chef.bake("something", [() => {}]);
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.name, "TypeError");
|
||||
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
|
||||
}
|
||||
assert.throws(() => chef.bake("something", [() => {}]), {
|
||||
name: "TypeError",
|
||||
message: "Inputted function not a Chef operation."
|
||||
});
|
||||
}),
|
||||
|
||||
it("chef.bake: should take single JSON object describing op and args OBJ", () => {
|
||||
@@ -275,15 +265,13 @@ TestRegister.addApiTests([
|
||||
}),
|
||||
|
||||
it("chef.bake: should error if op in JSON is not chef op", () => {
|
||||
try {
|
||||
chef.bake("some input", {
|
||||
op: () => {},
|
||||
args: ["Colon"],
|
||||
});
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.name, "TypeError");
|
||||
assert.strictEqual(e.message, "Inputted function not a Chef operation.");
|
||||
}
|
||||
assert.throws(() => chef.bake("some input", {
|
||||
op: () => {},
|
||||
args: ["Colon"],
|
||||
}), {
|
||||
name: "TypeError",
|
||||
message: "Inputted function not a Chef operation."
|
||||
});
|
||||
}),
|
||||
|
||||
it("chef.bake: should take multiple ops in JSON object form, some ops by string", () => {
|
||||
@@ -357,22 +345,38 @@ TestRegister.addApiTests([
|
||||
assert.strictEqual(result.toString(), "begin_something_aaaaaaaaaaaaaa_end_something");
|
||||
}),
|
||||
|
||||
it("Excluded operations: throw a sensible error when you try and call one", () => {
|
||||
try {
|
||||
chef.fork();
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.type, "ExcludedOperationError");
|
||||
assert.strictEqual(e.message, "Sorry, the Fork operation is not available in the Node.js version of CyberChef.");
|
||||
}
|
||||
it("chef.bake: cannot accept flowControl operations in recipe", () => {
|
||||
assert.throws(() => chef.bake("some input", "magic"), {
|
||||
name: "TypeError",
|
||||
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
|
||||
});
|
||||
assert.throws(() => chef.bake("some input", magic), {
|
||||
name: "TypeError",
|
||||
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
|
||||
});
|
||||
assert.throws(() => chef.bake("some input", ["to base 64", "magic"]), {
|
||||
name: "TypeError",
|
||||
message: "flowControl operations like Magic are not currently allowed in recipes for chef.bake in the Node API"
|
||||
});
|
||||
}),
|
||||
|
||||
it("Excluded operations: throw a sensible error when you try and call one", () => {
|
||||
try {
|
||||
chef.renderImage();
|
||||
} catch (e) {
|
||||
assert.strictEqual(e.type, "ExcludedOperationError");
|
||||
assert.strictEqual(e.message, "Sorry, the RenderImage operation is not available in the Node.js version of CyberChef.");
|
||||
}
|
||||
assert.throws(chef.fork,
|
||||
(err) => {
|
||||
assert(err instanceof ExcludedOperationError);
|
||||
assert.deepEqual(err.message, "Sorry, the Fork operation is not available in the Node.js version of CyberChef.");
|
||||
return true;
|
||||
},
|
||||
"Unexpected error type"
|
||||
);
|
||||
assert.throws(chef.javaScriptBeautify,
|
||||
(err) => {
|
||||
assert(err instanceof ExcludedOperationError);
|
||||
assert.deepEqual(err.message, "Sorry, the JavaScriptBeautify operation is not available in the Node.js version of CyberChef.");
|
||||
return true;
|
||||
},
|
||||
"Unexpected error type"
|
||||
);
|
||||
}),
|
||||
|
||||
it("Operation arguments: should be accessible from operation object if op has array arg", () => {
|
||||
@@ -405,4 +409,5 @@ TestRegister.addApiTests([
|
||||
assert.equal(chef.convertDistance.args.inputUnits.options[0], "Nanometres (nm)");
|
||||
assert.equal(chef.defangURL.args.process.options[1], "Only full URLs");
|
||||
}),
|
||||
|
||||
]);
|
||||
|
||||
@@ -640,7 +640,7 @@ WWFkYSBZYWRh\r
|
||||
}),
|
||||
|
||||
it("Parse ASN.1 Hex string", () => {
|
||||
assert.strictEqual(chef.parseASN1HexString(chef.toHex("Mouth-watering")).toString(), "UNKNOWN(4d) 7574682d7761746572696e67\n");
|
||||
assert.strictEqual(chef.parseASN1HexString(chef.toHex("Mouth-watering")).toString(), "UNKNOWN(77) 7574682d7761746572696e67\n");
|
||||
}),
|
||||
|
||||
it("Parse DateTime", () => {
|
||||
@@ -1075,6 +1075,60 @@ ExifImageHeight: 57`);
|
||||
assert.equal(output, res.value);
|
||||
}),
|
||||
|
||||
it("performs MAGIC", async () => {
|
||||
const input = "WUagwsiae6mP8gNtCCLUFpCpCB26RmBDoDD8PacdAmzAzBVjkK2QstFXaKhpC6iUS7RHqXrJtFisoRSgoJ4whjm1arm864qaNq4RcfUmLHrcsAaZc5TXCYifNdgS83gDeejGX46gaiMyuBV6EskHt1scgJ88x2tNSotQDwbGY1mmCob2ARGFvCKYNqiN9ipMq1ZU1mgkdbNuGcb76aRtYWhCGUc8g93UJudhb8htsheZnwTpgqhx83SVJSZXMXUjJT2zmpC7uXWtumqokbdSi88YtkWDAc1Toouh2oH4D4ddmNKJWUDpMwmngUmK14xwmomccPQE9hM172APnSqwxdKQ172RkcAsysnmj5gGtRmVNNh2s359wr6mS2QRP";
|
||||
const depth = 1;
|
||||
|
||||
const res = await chef.magic(input, {
|
||||
depth,
|
||||
});
|
||||
|
||||
// assert against the structure of the output, rather than the values.
|
||||
assert.strictEqual(res.value.length, depth + 1);
|
||||
res.value.forEach(row => {
|
||||
assert.ok(row.recipe);
|
||||
assert.ok(row.data);
|
||||
assert.ok(row.languageScores);
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(row, "fileType")); // Can be null, so cannot just use ok
|
||||
assert.ok(row.entropy);
|
||||
assert.ok(row.matchingOps);
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(row, "useful"));
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(row, "matchesCrib"));
|
||||
|
||||
row.recipe.forEach(item => {
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(item, "op"), `No 'op' property in item ${item}`);
|
||||
assert.strictEqual(typeof item.op, "string");
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(item, "args"), `No 'args' property in item ${item}`);
|
||||
assert.ok(Array.isArray(item.args));
|
||||
});
|
||||
|
||||
row.languageScores.forEach(score => {
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(score, "lang"), `No 'lang' property in languageScore ${score}`);
|
||||
assert.strictEqual(typeof score.lang, "string");
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(score, "score"), `No 'score' property in languageScore ${score}`);
|
||||
assert.strictEqual(typeof score.score, "number");
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(score, "probability"), `No 'probability' property in languageScore ${score}`);
|
||||
assert.strictEqual(typeof score.probability, "number");
|
||||
});
|
||||
|
||||
row.matchingOps.forEach(op => {
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "op"), `No 'op' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.strictEqual(typeof op.op, "string");
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "pattern"), `No 'pattern' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.ok(op.pattern instanceof RegExp);
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "args"), `No 'args' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.ok(Array.isArray(op.args));
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "useful"), `No 'useful' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.ifError(op.useful); // Expect this to be undefined
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "entropyRange"), `No 'entropyRange' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.ifError(op.entropyRange); // Expect this to be undefined
|
||||
assert.ok(Object.prototype.hasOwnProperty.call(op, "output"), `No 'output' property in matchingOp ${JSON.stringify(op)}`);
|
||||
assert.ifError(op.output); // Expect this to be undefined
|
||||
});
|
||||
});
|
||||
|
||||
}),
|
||||
|
||||
|
||||
]);
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ import "./tests/Lorenz.mjs";
|
||||
import "./tests/LuhnChecksum.mjs";
|
||||
import "./tests/CipherSaber2.mjs";
|
||||
import "./tests/Colossus.mjs";
|
||||
import "./tests/ParseObjectIDTimestamp.mjs";
|
||||
|
||||
|
||||
// Cannot test operations that use the File type yet
|
||||
@@ -120,4 +121,3 @@ const logOpsTestReport = logTestReport.bind(null, testStatus);
|
||||
const results = await TestRegister.runTests();
|
||||
logOpsTestReport(results);
|
||||
})();
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ TestRegister.addTests([
|
||||
}, {
|
||||
name: "Normalise Unicode - NFKC",
|
||||
input: "\u00c7\u0043\u0327\u2160",
|
||||
expectedMatch: /\u00C7\u00C7\u2160/,
|
||||
expectedMatch: /\u00C7\u00C7I/,
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Normalise Unicode",
|
||||
|
||||
24
tests/operations/tests/ParseObjectIDTimestamp.mjs
Normal file
24
tests/operations/tests/ParseObjectIDTimestamp.mjs
Normal file
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* Parse ObjectID timestamp tests
|
||||
*
|
||||
* @author dmfj [dominic@dmfj.io]
|
||||
*
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Parse ISO timestamp from ObjectId",
|
||||
input: "000000000000000000000000",
|
||||
expectedOutput: "1970-01-01T00:00:00.000Z",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Parse ObjectID timestamp",
|
||||
args: [],
|
||||
}
|
||||
],
|
||||
}
|
||||
]);
|
||||
@@ -38,7 +38,12 @@ module.exports = {
|
||||
new webpack.ProvidePlugin({
|
||||
$: "jquery",
|
||||
jQuery: "jquery",
|
||||
log: "loglevel"
|
||||
log: "loglevel",
|
||||
// process and Buffer are no longer polyfilled in webpack 5 but
|
||||
// many of our dependencies expect them, so it is easiest to just
|
||||
// provide them everywhere as was the case in webpack 4-
|
||||
process: "process",
|
||||
Buffer: ["buffer", "Buffer"]
|
||||
}),
|
||||
new webpack.BannerPlugin({
|
||||
banner: banner,
|
||||
@@ -46,29 +51,52 @@ module.exports = {
|
||||
entryOnly: true
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
// Required by Jimp to improve loading speed in browsers
|
||||
"process.browser": "true"
|
||||
}),
|
||||
new MiniCssExtractPlugin({
|
||||
filename: "assets/[name].css"
|
||||
}),
|
||||
new CopyWebpackPlugin([
|
||||
{
|
||||
context: "src/core/vendor/",
|
||||
from: "tesseract/**/*",
|
||||
to: "assets/"
|
||||
}
|
||||
])
|
||||
new CopyWebpackPlugin({
|
||||
patterns: [
|
||||
{
|
||||
context: "src/core/vendor/",
|
||||
from: "tesseract/**/*",
|
||||
to: "assets/"
|
||||
}, {
|
||||
context: "node_modules/tesseract.js/",
|
||||
from: "dist/worker.min.js",
|
||||
to: "assets/tesseract"
|
||||
}, {
|
||||
context: "node_modules/tesseract.js-core/",
|
||||
from: "tesseract-core.wasm.js",
|
||||
to: "assets/tesseract"
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
resolve: {
|
||||
extensions: [".mjs", ".js", ".json"], // Allows importing files without extensions
|
||||
alias: {
|
||||
jquery: "jquery/src/jquery",
|
||||
},
|
||||
fallback: {
|
||||
"fs": false,
|
||||
"child_process": false,
|
||||
"net": false,
|
||||
"tls": false,
|
||||
"path": require.resolve("path/"),
|
||||
"buffer": require.resolve("buffer/"),
|
||||
"crypto": require.resolve("crypto-browserify"),
|
||||
"stream": require.resolve("stream-browserify"),
|
||||
"zlib": require.resolve("browserify-zlib")
|
||||
}
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.m?js$/,
|
||||
exclude: /node_modules\/(?!jsesc|crypto-api|bootstrap)/,
|
||||
exclude: /node_modules\/(?!crypto-api|bootstrap)/,
|
||||
options: {
|
||||
configFile: path.resolve(__dirname, "babel.config.js"),
|
||||
cacheDirectory: true,
|
||||
@@ -78,12 +106,26 @@ module.exports = {
|
||||
loader: "babel-loader"
|
||||
},
|
||||
{
|
||||
test: /forge.min.js$/,
|
||||
loader: "imports-loader?jQuery=>null"
|
||||
test: /node-forge/,
|
||||
loader: "imports-loader",
|
||||
options: {
|
||||
additionalCode: "var jQuery = false;"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /bootstrap-material-design/,
|
||||
loader: "imports-loader?Popper=popper.js/dist/umd/popper.js"
|
||||
loader: "imports-loader",
|
||||
options: {
|
||||
imports: "default popper.js/dist/umd/popper.js Popper"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /blueimp-load-image/,
|
||||
loader: "imports-loader",
|
||||
options: {
|
||||
type: "commonjs",
|
||||
imports: "single min-document document"
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
@@ -173,12 +215,6 @@ module.exports = {
|
||||
/Can't resolve 'sodium'/
|
||||
],
|
||||
},
|
||||
node: {
|
||||
fs: "empty",
|
||||
"child_process": "empty",
|
||||
net: "empty",
|
||||
tls: "empty"
|
||||
},
|
||||
performance: {
|
||||
hints: false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user