Merge branch 'john19696-nodejs16'

This commit is contained in:
n1474335 2022-03-25 18:33:22 +00:00
commit 78a1827af8
25 changed files with 20355 additions and 1720 deletions

View File

@ -1,5 +1,5 @@
{ {
"parser": "babel-eslint", "parser": "@babel/eslint-parser",
"parserOptions": { "parserOptions": {
"ecmaVersion": 9, "ecmaVersion": 9,
"ecmaFeatures": { "ecmaFeatures": {

View File

@ -1,6 +1,7 @@
name: "CodeQL Analysis" name: "CodeQL Analysis"
on: on:
workflow_dispatch:
push: push:
branches: [ master ] branches: [ master ]
pull_request: pull_request:

View File

@ -1,6 +1,7 @@
name: "Master Build, Test & Deploy" name: "Master Build, Test & Deploy"
on: on:
workflow_dispatch:
push: push:
branches: branches:
- master - master
@ -14,7 +15,7 @@ jobs:
- name: Set node version - name: Set node version
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.x' node-version: '17.x'
- name: Install - name: Install
run: | run: |

View File

@ -1,6 +1,7 @@
name: "Pull Requests" name: "Pull Requests"
on: on:
workflow_dispatch:
pull_request: pull_request:
types: [synchronize, opened, reopened] types: [synchronize, opened, reopened]
@ -13,7 +14,7 @@ jobs:
- name: Set node version - name: Set node version
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.x' node-version: '17.x'
- name: Install - name: Install
run: | run: |

View File

@ -1,6 +1,7 @@
name: "Releases" name: "Releases"
on: on:
workflow_dispatch:
push: push:
tags: tags:
- 'v*' - 'v*'
@ -14,7 +15,7 @@ jobs:
- name: Set node version - name: Set node version
uses: actions/setup-node@v1 uses: actions/setup-node@v1
with: with:
node-version: '10.x' node-version: '17.x'
- name: Install - name: Install
run: | run: |

2
.nvmrc
View File

@ -1 +1 @@
lts/dubnium 17

View File

@ -6,6 +6,8 @@ const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPl
const glob = require("glob"); const glob = require("glob");
const path = require("path"); const path = require("path");
const nodeFlags = "--experimental-modules --experimental-json-modules --experimental-specifier-resolution=node --no-warnings --no-deprecation";
/** /**
* Grunt configuration for building the app in various formats. * Grunt configuration for building the app in various formats.
* *
@ -187,9 +189,6 @@ module.exports = function (grunt) {
standalone: ["build/prod/CyberChef*.html"] standalone: ["build/prod/CyberChef*.html"]
}, },
eslint: { eslint: {
options: {
configFile: "./.eslintrc.json"
},
configs: ["*.{js,mjs}"], configs: ["*.{js,mjs}"],
core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*", "!src/core/operations/legacy/**/*"], core: ["src/core/**/*.{js,mjs}", "!src/core/vendor/**/*", "!src/core/operations/legacy/**/*"],
web: ["src/web/**/*.{js,mjs}", "!src/web/static/**/*"], web: ["src/web/**/*.{js,mjs}", "!src/web/static/**/*"],
@ -349,15 +348,15 @@ module.exports = function (grunt) {
command: "git gc --prune=now --aggressive" command: "git gc --prune=now --aggressive"
}, },
sitemap: { sitemap: {
command: "node --experimental-modules --no-warnings --no-deprecation src/web/static/sitemap.mjs > build/prod/sitemap.xml", command: `node ${nodeFlags} src/web/static/sitemap.mjs > build/prod/sitemap.xml`,
sync: true sync: true
}, },
generateConfig: { generateConfig: {
command: chainCommands([ command: chainCommands([
"echo '\n--- Regenerating config files. ---'", "echo '\n--- Regenerating config files. ---'",
"echo [] > src/core/config/OperationConfig.json", "echo [] > src/core/config/OperationConfig.json",
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateOpsIndex.mjs", `node ${nodeFlags} src/core/config/scripts/generateOpsIndex.mjs`,
"node --experimental-modules --no-warnings --no-deprecation src/core/config/scripts/generateConfig.mjs", `node ${nodeFlags} src/core/config/scripts/generateConfig.mjs`,
"echo '--- Config scripts finished. ---\n'" "echo '--- Config scripts finished. ---\n'"
]), ]),
sync: true sync: true
@ -365,7 +364,7 @@ module.exports = function (grunt) {
generateNodeIndex: { generateNodeIndex: {
command: chainCommands([ command: chainCommands([
"echo '\n--- Regenerating node index ---'", "echo '\n--- Regenerating node index ---'",
"node --experimental-modules --no-warnings --no-deprecation src/node/config/scripts/generateNodeIndex.mjs", `node ${nodeFlags} src/node/config/scripts/generateNodeIndex.mjs`,
"echo '--- Node index generated. ---\n'" "echo '--- Node index generated. ---\n'"
]), ]),
sync: true sync: true
@ -393,21 +392,21 @@ module.exports = function (grunt) {
testCJSNodeConsumer: { testCJSNodeConsumer: {
command: chainCommands([ command: chainCommands([
`cd ${nodeConsumerTestPath}`, `cd ${nodeConsumerTestPath}`,
"node --no-warnings cjs-consumer.js", `node ${nodeFlags} cjs-consumer.js`,
]), ]),
stdout: false, stdout: false,
}, },
testESMNodeConsumer: { testESMNodeConsumer: {
command: chainCommands([ command: chainCommands([
`cd ${nodeConsumerTestPath}`, `cd ${nodeConsumerTestPath}`,
"node --no-warnings --experimental-modules esm-consumer.mjs", `node ${nodeFlags} esm-consumer.mjs`,
]), ]),
stdout: false, stdout: false,
}, },
testESMDeepImportNodeConsumer: { testESMDeepImportNodeConsumer: {
command: chainCommands([ command: chainCommands([
`cd ${nodeConsumerTestPath}`, `cd ${nodeConsumerTestPath}`,
"node --no-warnings --experimental-modules esm-deep-import-consumer.mjs", `node ${nodeFlags} esm-deep-import-consumer.mjs`,
]), ]),
stdout: false, stdout: false,
}, },

View File

@ -11,6 +11,7 @@ module.exports = function(api) {
], ],
"plugins": [ "plugins": [
"dynamic-import-node", "dynamic-import-node",
"@babel/plugin-syntax-import-assertions",
[ [
"babel-plugin-transform-builtin-extend", { "babel-plugin-transform-builtin-extend", {
"globals": ["Error"] "globals": ["Error"]

21922
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -29,26 +29,35 @@
}, },
"main": "src/node/cjs.js", "main": "src/node/cjs.js",
"module": "src/node/index.mjs", "module": "src/node/index.mjs",
"exports": {
".": {
"require": "./src/node/cjs.js",
"import": "./src/node/index.mjs"
}
},
"bugs": "https://github.com/gchq/CyberChef/issues", "bugs": "https://github.com/gchq/CyberChef/issues",
"browserslist": [ "browserslist": [
"Chrome >= 50", "Chrome >= 50",
"Firefox >= 38", "Firefox >= 38",
"node >= 10" "node >= 16"
], ],
"devDependencies": { "devDependencies": {
"@babel/core": "^7.15.0", "@babel/core": "^7.17.8",
"@babel/plugin-transform-runtime": "^7.15.0", "@babel/eslint-parser": "^7.17.0",
"@babel/preset-env": "^7.15.0", "@babel/plugin-syntax-import-assertions": "^7.16.7",
"@babel/plugin-transform-runtime": "^7.17.0",
"@babel/preset-env": "^7.16.11",
"@babel/runtime": "^7.17.8",
"autoprefixer": "^10.3.1", "autoprefixer": "^10.3.1",
"babel-eslint": "^10.1.0", "babel-loader": "^8.2.4",
"babel-loader": "^8.2.2",
"babel-plugin-dynamic-import-node": "^2.3.3", "babel-plugin-dynamic-import-node": "^2.3.3",
"chromedriver": "^92.0.1", "chromedriver": "^99.0.0",
"cli-progress": "^3.9.0", "cli-progress": "^3.9.0",
"colors": "^1.4.0", "colors": "^1.4.0",
"copy-webpack-plugin": "^9.0.1", "copy-webpack-plugin": "^9.0.1",
"core-js": "^3.21.1",
"css-loader": "5.2.7", "css-loader": "5.2.7",
"eslint": "^7.32.0", "eslint": "^8.11.0",
"exports-loader": "^3.0.0", "exports-loader": "^3.0.0",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"grunt": "^1.4.1", "grunt": "^1.4.1",
@ -58,7 +67,7 @@
"grunt-contrib-connect": "^3.0.0", "grunt-contrib-connect": "^3.0.0",
"grunt-contrib-copy": "~1.0.0", "grunt-contrib-copy": "~1.0.0",
"grunt-contrib-watch": "^1.1.0", "grunt-contrib-watch": "^1.1.0",
"grunt-eslint": "^23.0.0", "grunt-eslint": "^24.0.0",
"grunt-exec": "~3.0.0", "grunt-exec": "~3.0.0",
"grunt-webpack": "^4.0.3", "grunt-webpack": "^4.0.3",
"grunt-zip": "^0.18.2", "grunt-zip": "^0.18.2",
@ -66,7 +75,6 @@
"imports-loader": "^3.0.0", "imports-loader": "^3.0.0",
"mini-css-extract-plugin": "1.3.7", "mini-css-extract-plugin": "1.3.7",
"nightwatch": "^1.7.8", "nightwatch": "^1.7.8",
"node-sass": "^5.0.0",
"postcss": "^8.3.6", "postcss": "^8.3.6",
"postcss-css-variables": "^0.18.0", "postcss-css-variables": "^0.18.0",
"postcss-import": "^14.0.2", "postcss-import": "^14.0.2",
@ -77,7 +85,7 @@
"style-loader": "^3.2.1", "style-loader": "^3.2.1",
"svg-url-loader": "^7.1.1", "svg-url-loader": "^7.1.1",
"url-loader": "^4.1.1", "url-loader": "^4.1.1",
"webpack": "^5.51.0", "webpack": "^5.70.0",
"webpack-bundle-analyzer": "^4.4.2", "webpack-bundle-analyzer": "^4.4.2",
"webpack-dev-server": "3.11.2", "webpack-dev-server": "3.11.2",
"webpack-node-externals": "^3.0.0", "webpack-node-externals": "^3.0.0",
@ -85,7 +93,6 @@
}, },
"dependencies": { "dependencies": {
"@babel/polyfill": "^7.12.1", "@babel/polyfill": "^7.12.1",
"@babel/runtime": "^7.15.3",
"arrive": "^2.4.1", "arrive": "^2.4.1",
"avsc": "^5.7.3", "avsc": "^5.7.3",
"babel-plugin-transform-builtin-extend": "1.1.2", "babel-plugin-transform-builtin-extend": "1.1.2",
@ -101,7 +108,6 @@
"cbor": "5.0.1", "cbor": "5.0.1",
"chi-squared": "^1.1.0", "chi-squared": "^1.1.0",
"codepage": "^1.15.0", "codepage": "^1.15.0",
"core-js": "^3.16.2",
"crypto-api": "^0.8.5", "crypto-api": "^0.8.5",
"crypto-browserify": "^3.12.0", "crypto-browserify": "^3.12.0",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
@ -111,7 +117,6 @@
"diff": "^5.0.0", "diff": "^5.0.0",
"es6-promisify": "^7.0.0", "es6-promisify": "^7.0.0",
"escodegen": "^2.0.0", "escodegen": "^2.0.0",
"esm": "^3.2.25",
"esprima": "^4.0.1", "esprima": "^4.0.1",
"exif-parser": "^0.1.12", "exif-parser": "^0.1.12",
"file-saver": "^2.0.5", "file-saver": "^2.0.5",
@ -139,6 +144,7 @@
"ngeohash": "^0.6.3", "ngeohash": "^0.6.3",
"node-forge": "^0.10.0", "node-forge": "^0.10.0",
"node-md6": "^0.1.0", "node-md6": "^0.1.0",
"node-sass": "^7.0.1",
"nodom": "^2.4.0", "nodom": "^2.4.0",
"notepack.io": "^2.3.0", "notepack.io": "^2.3.0",
"nwmatcher": "^1.4.4", "nwmatcher": "^1.4.4",
@ -169,13 +175,13 @@
"start": "npx grunt dev", "start": "npx grunt dev",
"build": "npx grunt prod", "build": "npx grunt prod",
"repl": "node src/node/repl.js", "repl": "node src/node/repl.js",
"test": "npx grunt configTests && node --experimental-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs", "test": "npx grunt configTests && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/node/index.mjs && node --experimental-modules --experimental-json-modules --no-warnings --no-deprecation tests/operations/index.mjs",
"test-node-consumer": "npx grunt testnodeconsumer", "test-node-consumer": "npx grunt testnodeconsumer",
"testui": "npx grunt testui", "testui": "npx grunt testui",
"testuidev": "npx nightwatch --env=dev", "testuidev": "npx nightwatch --env=dev",
"lint": "npx grunt lint", "lint": "npx grunt lint",
"postinstall": "npx grunt exec:fixCryptoApiImports", "postinstall": "npx grunt exec:fixCryptoApiImports",
"newop": "node --experimental-modules src/core/config/scripts/newOperation.mjs", "newop": "node --experimental-modules --experimental-json-modules src/core/config/scripts/newOperation.mjs",
"getheapsize": "node -e 'console.log(`node heap limit = ${require(\"v8\").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'", "getheapsize": "node -e 'console.log(`node heap limit = ${require(\"v8\").getHeapStatistics().heap_size_limit / (1024 * 1024)} Mb`)'",
"setheapsize": "export NODE_OPTIONS=--max_old_space_size=2048" "setheapsize": "export NODE_OPTIONS=--max_old_space_size=2048"
} }

View File

@ -7,7 +7,7 @@
*/ */
import Chef from "./Chef.mjs"; import Chef from "./Chef.mjs";
import OperationConfig from "./config/OperationConfig.json"; import OperationConfig from "./config/OperationConfig.json" assert {type: "json"};
import OpModules from "./config/modules/OpModules.mjs"; import OpModules from "./config/modules/OpModules.mjs";
// Add ">" to the start of all log messages in the Chef Worker // Add ">" to the start of all log messages in the Chef Worker

View File

@ -4,7 +4,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import OperationConfig from "./config/OperationConfig.json"; import OperationConfig from "./config/OperationConfig.json" assert {type: "json"};
import OperationError from "./errors/OperationError.mjs"; import OperationError from "./errors/OperationError.mjs";
import Operation from "./Operation.mjs"; import Operation from "./Operation.mjs";
import DishError from "./errors/DishError.mjs"; import DishError from "./errors/DishError.mjs";

View File

@ -1,6 +1,6 @@
import OperationError from "./OperationError.mjs"; import OperationError from "./OperationError.mjs";
import DishError from "./DishError.mjs"; import DishError from "./DishError.mjs";
import ExcludedOperationError from "./ExcludedOperationError"; import ExcludedOperationError from "./ExcludedOperationError.mjs";
export { export {
OperationError, OperationError,

View File

@ -1,4 +1,4 @@
import OperationConfig from "../config/OperationConfig.json"; import OperationConfig from "../config/OperationConfig.json" assert {type: "json"};
import Utils, { isWorkerEnvironment } from "../Utils.mjs"; import Utils, { isWorkerEnvironment } from "../Utils.mjs";
import Recipe from "../Recipe.mjs"; import Recipe from "../Recipe.mjs";
import Dish from "../Dish.mjs"; import Dish from "../Dish.mjs";

View File

@ -10,7 +10,7 @@
import NodeDish from "./NodeDish.mjs"; import NodeDish from "./NodeDish.mjs";
import NodeRecipe from "./NodeRecipe.mjs"; import NodeRecipe from "./NodeRecipe.mjs";
import OperationConfig from "../core/config/OperationConfig.json"; import OperationConfig from "../core/config/OperationConfig.json" assert {type: "json"};
import { sanitise, removeSubheadingsFromArray, sentenceToCamelCase } from "./apiUtils.mjs"; import { sanitise, removeSubheadingsFromArray, sentenceToCamelCase } from "./apiUtils.mjs";
import ExcludedOperationError from "../core/errors/ExcludedOperationError.mjs"; import ExcludedOperationError from "../core/errors/ExcludedOperationError.mjs";

View File

@ -7,7 +7,5 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
/* eslint no-global-assign: ["off"] */ module.exports = (async () => await import("./index.mjs"))();
require = require("esm")(module); module.exports.File = (async () => await import("./File.mjs"))();
module.exports = require("./index.mjs");
module.exports.File = require("./File.mjs");

View File

@ -41,7 +41,7 @@ let code = `/**
import NodeDish from "./NodeDish.mjs"; import NodeDish from "./NodeDish.mjs";
import { _wrap, help, bake, _explainExcludedFunction } from "./api.mjs"; import { _wrap, help, bake, _explainExcludedFunction } from "./api.mjs";
import File from "./File.mjs"; import File from "./File.mjs";
import { OperationError, DishError, ExcludedOperationError } from "../core/errors/index"; import { OperationError, DishError, ExcludedOperationError } from "../core/errors/index.mjs";
import { import {
// import as core_ to avoid name clashes after wrap. // import as core_ to avoid name clashes after wrap.
`; `;
@ -52,7 +52,7 @@ includedOperations.forEach((op) => {
}); });
code +=` code +=`
} from "../core/operations/index"; } from "../core/operations/index.mjs";
global.File = File; global.File = File;

View File

@ -17,8 +17,8 @@ import * as CanvasComponents from "../core/lib/CanvasComponents.mjs";
// CyberChef // CyberChef
import App from "./App.mjs"; import App from "./App.mjs";
import Categories from "../core/config/Categories.json"; import Categories from "../core/config/Categories.json" assert {type: "json"};
import OperationConfig from "../core/config/OperationConfig.json"; import OperationConfig from "../core/config/OperationConfig.json" assert {type: "json"};
/** /**

View File

@ -1,5 +1,5 @@
import sm from "sitemap"; import sm from "sitemap";
import OperationConfig from "../../core/config/OperationConfig.json"; import OperationConfig from "../../core/config/OperationConfig.json" assert {type: "json"};
/** /**

View File

@ -6,9 +6,10 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
const chef = require("cyberchef");
const assert = require("assert"); const assert = require("assert");
require("cyberchef").then(chef => {
const d = chef.bake("Testing, 1 2 3", [ const d = chef.bake("Testing, 1 2 3", [
chef.toHex, chef.toHex,
chef.reverse, chef.reverse,
@ -27,3 +28,5 @@ const d = chef.bake("Testing, 1 2 3", [
]); ]);
assert.equal(d.value, "630957449041920"); assert.equal(d.value, "630957449041920");
});

View File

@ -6,7 +6,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import assert from "assert"; import assert from "assert";
import { bake, toHex, reverse, unique, multiply } from "cyberchef/src/node/index.mjs"; import { bake, toHex, reverse, unique, multiply } from "cyberchef";
const d = bake("Testing, 1 2 3", [ const d = bake("Testing, 1 2 3", [
toHex, toHex,

View File

@ -1,6 +1,6 @@
import TestRegister from "../../lib/TestRegister.mjs"; import TestRegister from "../../lib/TestRegister.mjs";
import Categories from "../../../src/core/config/Categories.json"; import Categories from "../../../src/core/config/Categories.json" assert {type: "json"};
import OperationConfig from "../../../src/core/config/OperationConfig.json"; import OperationConfig from "../../../src/core/config/OperationConfig.json" assert {type: "json"};
import it from "../assertionHandler.mjs"; import it from "../assertionHandler.mjs";
import assert from "assert"; import assert from "assert";

View File

@ -32,7 +32,7 @@ import {
CSSMinify, CSSMinify,
toBase64, toBase64,
toHex toHex
} from "../../../src/node/index"; } from "../../../src/node/index.mjs";
import chef from "../../../src/node/index.mjs"; import chef from "../../../src/node/index.mjs";
import TestRegister from "../../lib/TestRegister.mjs"; import TestRegister from "../../lib/TestRegister.mjs";
import File from "../../../src/node/File.mjs"; import File from "../../../src/node/File.mjs";

View File

@ -6,7 +6,7 @@
* @license Apache-2.0 * @license Apache-2.0
*/ */
import TestRegister from "../../lib/TestRegister"; import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([ TestRegister.addTests([
{ {

View File

@ -5,8 +5,8 @@
* @copyright Karsten Silkenbäumer 2019 * @copyright Karsten Silkenbäumer 2019
* @license Apache-2.0 * @license Apache-2.0
*/ */
import TestRegister from "../../lib/TestRegister"; import TestRegister from "../../lib/TestRegister.mjs";
import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon"; import { BACON_ALPHABETS, BACON_TRANSLATIONS } from "../../../src/core/lib/Bacon.mjs";
const alphabets = Object.keys(BACON_ALPHABETS); const alphabets = Object.keys(BACON_ALPHABETS);
const translations = BACON_TRANSLATIONS; const translations = BACON_TRANSLATIONS;