Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Node API #291

Merged
merged 156 commits into from
Jul 5, 2019
Merged
Show file tree
Hide file tree
Changes from 153 commits
Commits
Show all changes
156 commits
Select commit Hold shift + click to select a range
59877b5
Exporing options with API.
d98762625 Apr 13, 2018
fca4ed7
simplified API
d98762625 Apr 20, 2018
b8b9835
function tidy, add comments
d98762625 Apr 20, 2018
d5b5443
update readme
d98762625 Apr 27, 2018
fbec0a1
The raw, unpresented dish is now returned to the app after baking, wh…
n1474335 Apr 21, 2018
b0a8ca5
Added File and JSON Dish types and updated types for compression ops.
n1474335 Apr 21, 2018
7e7e5e7
Merge branch 'op-errors' into node-lib
d98762625 Apr 27, 2018
c238862
in/out typing working. Added translateTo function
d98762625 Apr 27, 2018
3d67280
remove find Type - not used any more
d98762625 Apr 27, 2018
e50758f
Merge branch 'esm' of github.com:gchq/CyberChef into node-lib
d98762625 May 3, 2018
5fb50a1
OperationErrors now bubble up to the top of the API.
d98762625 May 3, 2018
5efc3f1
linting
d98762625 May 3, 2018
c96a1df
add namespaces to docas
d98762625 May 11, 2018
615cb56
add some chef.translateTo tests
d98762625 May 11, 2018
7e8f78a
dont decapitalise all-caps operation names
d98762625 May 11, 2018
0a0316a
Make optional args in operation call use named properties rather than…
d98762625 May 11, 2018
0977e82
Merge branch 'esm' into node-lib
d98762625 May 24, 2018
0a0240e
WIP: generate top level node exports - manually mock lib files
d98762625 May 24, 2018
9a471d2
remove extra preamble for grunt task. improve index script
d98762625 May 25, 2018
b45fc63
Merge branch 'esm' of github.com:gchq/CyberChef into top-export
d98762625 May 29, 2018
9d5e533
Merge branch 'esm' of github.com:gchq/CyberChef into top-export
d98762625 May 30, 2018
336810c
amend generateNodeIndex script
d98762625 May 30, 2018
6db9521
re-add translateTo call to chef export
d98762625 May 30, 2018
dcf6564
linting for generated node/index.mjs
d98762625 May 30, 2018
58a7f7b
Merge branch 'esm' of github.com:gchq/CyberChef into node-lib
d98762625 Jun 6, 2018
d00b9e0
generate node index needs to be without other generate scripts
d98762625 Jun 6, 2018
45d2fbc
create SyncDish and wrap results in it.
d98762625 Jun 6, 2018
33f2c89
update tests to reflect new API behaviour
d98762625 Jun 6, 2018
ec00413
add example usage file
d98762625 Jun 6, 2018
fc1b891
add node index to clean. generate node index before test
d98762625 Jun 7, 2018
a5d5807
WIP: start testing ops with various arg types. AESENCRYPT result enco…
d98762625 Jun 15, 2018
ffb65d8
add more wrapper tests for node api
d98762625 Jun 18, 2018
c90f30a
update editableOptions wrapper
d98762625 Jun 18, 2018
471009b
remove example and remove cap issues for SyncDish
d98762625 Jun 18, 2018
866b367
edit logging on gruntfile
d98762625 Jun 19, 2018
f95f01b
Add ability to exclude operations from Node API. Exclude flow control…
d98762625 Jun 19, 2018
27ee7f8
exclude File operations until File API can be mimicked
d98762625 Jun 19, 2018
e04f66f
export help function on chef object
d98762625 Jun 19, 2018
2ff7b59
fix args transformation for ops with editableOptions
d98762625 Jun 25, 2018
a4d7065
add operation input case to chef.search
d98762625 Jun 25, 2018
2027b64
Merge branch 'esm' of github.com:gchq/CyberChef into node-lib
d98762625 Jul 6, 2018
db7b52d
Merge branch 'node-lib' into help
d98762625 Jul 6, 2018
fa8736b
Make help function use OperationConfig.json file
d98762625 Jul 6, 2018
f101eef
'From Hexdump' now supports an alternative style of Wireshark hexdump…
n1474335 Jun 13, 2018
2480dca
Make help function use OperationConfig.json file
d98762625 Jul 6, 2018
9abaadf
Build chef.bake.
d98762625 Jul 6, 2018
91eb692
Merge branch 'bake' into node-lib
d98762625 Jul 20, 2018
20452fe
include crypto-api src into lib to get around mjs import issue. compi…
d98762625 Aug 10, 2018
7c1ac43
merge 8.0.1 release -> node-lib
d98762625 Aug 11, 2018
a2f4e34
need to inclide src/node/index for `module` use
d98762625 Aug 11, 2018
f100356
started on full op test suite
d98762625 Aug 13, 2018
50c9162
adding more tests
d98762625 Aug 14, 2018
1f634ed
add more tests
d98762625 Aug 14, 2018
8675d1a
add more tests
d98762625 Aug 15, 2018
a6c0db4
Finished first run through of tests
d98762625 Aug 16, 2018
7557f43
Wrap async ops in an async wrapper
d98762625 Aug 16, 2018
8f85e57
fix translatreDateTimeFormat args assignment error
d98762625 Aug 16, 2018
fbcb626
add test timer. Remove operations related to esprima
d98762625 Aug 16, 2018
223e2e0
add Buffer translation to Dish. Cannot work in SyncDish as typeEnums …
d98762625 Aug 17, 2018
1f771a9
fix scan embedded files, bson. Only RemoveExif remains
d98762625 Aug 17, 2018
20bb104
use utils.inspect.custom Rready for node v12
d98762625 Aug 19, 2018
55f7cac
Remove Buffer from Dish. Convert into ByteArray in api and then pass …
d98762625 Aug 19, 2018
f73452e
making SyncDish composable! we want to exclude certain ops from top l…
d98762625 Aug 20, 2018
f6c4b50
Expose Dish (SyncDish) in API and make it composable.
d98762625 Aug 23, 2018
7c9ebaf
toggleString args now additionally accept just input value, taking fi…
d98762625 Aug 31, 2018
96d5930
Throw ExcludedOperationError when excluded operation is called from API
d98762625 Aug 31, 2018
f51d924
Remove duplicate wiping of opconfig in node index config script
d98762625 Aug 31, 2018
c6a292b
rename node Recipe > NodeRecipe to avoid naming confusion
d98762625 Aug 31, 2018
b36e3ad
add assertions for chef.bake leniancy on op names
d98762625 Aug 31, 2018
3466f4e
add help, bake to top level export so theyre in the expected place in…
d98762625 Aug 31, 2018
63a23e4
make chef.help emulate search function in UI. Didnt extract search lo…
d98762625 Sep 4, 2018
5047619
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Sep 4, 2018
749a587
fix tests after merge; remove detectFileType as it behaves erratically
d98762625 Sep 4, 2018
e19d3d0
simplify repl-index - no longer needs its own config script. Just nee…
d98762625 Sep 4, 2018
cc840c0
Add header to repl. Use uppercase Dish in chef export. Fix SyncDish c…
d98762625 Sep 21, 2018
431f1d4
housekeeping & add repl command to package
d98762625 Sep 27, 2018
25e0585
Improve use of files as input. Add dish to repl
d98762625 Oct 5, 2018
48f3a3b
Do not mangle names on minification for Node prod build - property na…
d98762625 Oct 5, 2018
fa87fc8
replace operations on Dish with apply
d98762625 Oct 12, 2018
214d6c4
merge from upstream
d98762625 Oct 12, 2018
97255bb
merge upstream
d98762625 Nov 9, 2018
b19f8f6
update HMAC test after merge and add loader to allow external uglifyj…
d98762625 Nov 9, 2018
18f6ab4
pull from master
d98762625 Dec 7, 2018
19366e3
arg array options to wrapped func
d98762625 Dec 7, 2018
a010bba
add test and change name of property to argOptions
d98762625 Dec 21, 2018
6bc5f87
Merge branch 'master' of github.com:gchq/CyberChef into arg-options
d98762625 Dec 21, 2018
456b85e
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Dec 21, 2018
3efe930
Merge branch 'arg-options' into node-lib
d98762625 Dec 21, 2018
83fa50b
linting
d98762625 Dec 21, 2018
a4de937
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Jan 4, 2019
f22e9ce
refactor TestRegister and some test suite functions into common area
d98762625 Jan 4, 2019
9d674ce
move node test suite into its own grunt command
d98762625 Jan 4, 2019
4b7c927
remove old node tests from ops test suite
d98762625 Jan 4, 2019
6ca78ce
Merge branch 'node-lib-tests' into node-lib
d98762625 Jan 4, 2019
f7d4251
update test sample data
d98762625 Jan 4, 2019
dd4a7f9
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Jan 21, 2019
7522e5d
remove unnecessary operationConfig manipulation
d98762625 Jan 23, 2019
781ff95
add dev builds for node
d98762625 Jan 23, 2019
7679705
Merge branch 'dynamic-import' into node-lib-dynamic
d98762625 Feb 8, 2019
dd51b67
removed OpModules bodge from index generation scripts
d98762625 Feb 8, 2019
39c68ff
Merge branch 'dynamic-import' into node-lib-dynamic
d98762625 Feb 11, 2019
c76322c
force webpack to only emit one file when using dynamic import
d98762625 Feb 11, 2019
03e3ab5
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Feb 12, 2019
aafde89
tidy up gruntfile for node
d98762625 Feb 13, 2019
04b7f2f
WIP HAD to move NodeDish out - NONE of it is async!
d98762625 Feb 15, 2019
573a292
WIP dynamically define async functions in Dish, only if needed
d98762625 Feb 15, 2019
9094e8b
WIP tidy up. WHy is dish being passed back with chef.bake now?
d98762625 Feb 15, 2019
ff2521a
WIP Dish now working on dev with dynamically loaded _translate and ge…
d98762625 Feb 15, 2019
0a1ca18
refactor Dish get to handle sync and async
d98762625 Mar 1, 2019
b48c16b
Refactor Dish _translate to handle sync and async depending on enviro…
d98762625 Mar 1, 2019
6d219ad
remove legacy async api from NodeRecipe
d98762625 Mar 1, 2019
e4b688a
Make Frequency dist test more sensible
d98762625 Mar 1, 2019
14d591c
more debugging
d98762625 Mar 11, 2019
d080c5d
debugging File shim
d98762625 Mar 14, 2019
2019ae4
File shim now translates correctly
d98762625 Mar 14, 2019
b8cb7e9
add tests for File and test based operations. Only unzip to go
d98762625 Mar 14, 2019
76cc7f1
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Mar 14, 2019
e3cdf63
make unzip test accurate
d98762625 Mar 20, 2019
4bc3fc2
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Mar 20, 2019
f61e33a
update disassemble test after vendor code change
d98762625 Mar 20, 2019
8f5f3e5
prefer exact matches in help function
d98762625 Mar 20, 2019
8eed223
add immutable presentAs method to Dish for node REPL display. add tes…
d98762625 Mar 20, 2019
4add484
update TestRegister relative path in some tests
d98762625 Mar 20, 2019
aad1bc8
update file shim to use detectFileType.
d98762625 Mar 20, 2019
a1b116d
update travis build to include node tests. Minor refactor to grunt jo…
d98762625 Mar 20, 2019
b48a55b
add all options to argOptions. Add some extra test case for Zip
d98762625 Mar 20, 2019
8c48d73
debug why travis fails
d98762625 Mar 20, 2019
9e2aac0
update tests file name and linting
d98762625 Mar 20, 2019
656cf32
remove extra step from grunt test-node command
d98762625 Mar 20, 2019
b98cab7
pass full dish into NodeDish Apply to allow apply from ArrayBuffer ty…
d98762625 Mar 20, 2019
638093d
correct translation from node Buffer to byte array
d98762625 Mar 22, 2019
a7874cc
improve naming in API
d98762625 Apr 4, 2019
e4ee0fc
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 Apr 4, 2019
af50489
incorporate ArrayBuffer base Dish type. Add global file shim to node …
d98762625 Apr 4, 2019
d3e6200
remove babel-polyfill and update plugins to work with uplifted version
d98762625 Apr 5, 2019
367532c
linting and comment for readFileSync
d98762625 Apr 5, 2019
a210f95
more linting
d98762625 Apr 5, 2019
e764ddf
update TestRegister references
d98762625 Apr 5, 2019
de8c99e
merge init-dish & update tests
d98762625 Apr 8, 2019
aeb08ca
move NodeDish tests out into own file
d98762625 Apr 24, 2019
65a3897
add dish translation tests for node
d98762625 Apr 29, 2019
0a3d87d
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 May 3, 2019
6084759
Merge branch 'use-node-lts' into node-lib
d98762625 May 3, 2019
90dd703
update TestRegister location for new tests
d98762625 May 3, 2019
aa9bf08
amend comments, remove return type from Dish translate
d98762625 May 3, 2019
d51e8ec
Merge branch 'master' of github.com:gchq/CyberChef into node-lib
d98762625 May 23, 2019
1a9c9a5
Actually need to return the translation
d98762625 May 24, 2019
d22d22d
Try and include symlink at project root to make deep import specifier…
d98762625 May 24, 2019
79e2ca6
remove symlink
d98762625 May 24, 2019
c70f144
rename dishTranslationTypes
d98762625 Jul 5, 2019
1c24c05
swap ENVIRONMENT_IS_* functions for Utils named exports
d98762625 Jul 5, 2019
d2ff2ec
improve comments and re-add some excluded operations
d98762625 Jul 5, 2019
a1cf20b
gitignore fix
d98762625 Jul 5, 2019
368f508
Merge branch 'v9' of github.com:gchq/CyberChef into node-lib
d98762625 Jul 5, 2019
e03ff22
update more ENVIRONMENT_IS_* calls after merge, update some test path…
d98762625 Jul 5, 2019
0de89f3
Merge branch 'v9' of github.com:gchq/CyberChef into node-lib
d98762625 Jul 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@

"COMPILE_TIME": false,
"COMPILE_MSG": false,
"PKG_VERSION": false,
"ENVIRONMENT_IS_WORKER": false,
"ENVIRONMENT_IS_NODE": false,
"ENVIRONMENT_IS_WEB": false
"PKG_VERSION": false
}
}
4 changes: 2 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ Before your contributions can be accepted, you must:
* Line endings: UNIX style (\n)


## Design Principals
## Design Principles

1. If at all possible, all operations and features should be client-side and not rely on connections to an external server. This increases the utility of CyberChef on closed networks and in virtual machines that are not connected to the Internet. Calls to external APIs may be accepted if there is no other option, but not for critical components.
2. Latency should be kept to a minimum to enhance the user experience. This means that all operation code should sit on the client, rather than being loaded dynamically from a server.
3. Use Vanilla JS if at all possible to reduce the number of libraries required and relied upon. Frameworks like jQuery, although included, should not be used unless absolutely necessary.
4. Minimise the use of large libraries, especially for niche operations that won't be used very often - these will be downloaded by everyone using the app, whether they use that operation or not (due to principal 2).


With these principals in mind, any changes or additions to CyberChef should keep it:
With these principles in mind, any changes or additions to CyberChef should keep it:

- Standalone
- Efficient
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ docs/*
src/core/config/modules/*
src/core/config/OperationConfig.json
src/core/operations/index.mjs
src/node/config/OperationConfig.json
src/node/index.mjs
**/*.DS_Store
tests/browser/output/*

4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
language: node_js
node_js:
- lts/*
cache: npm
addons:
chrome: stable
install: npm install
Expand All @@ -10,8 +11,9 @@ before_script:
script:
- grunt lint
- grunt test
- grunt test-node
- grunt docs
- grunt node
- npm run node-prod
- grunt prod --msg="$COMPILE_MSG"
- xvfb-run --server-args="-screen 0 1200x800x24" grunt testui
before_deploy:
Expand Down
69 changes: 49 additions & 20 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const path = require("path");
* @license Apache-2.0
*/

const NODE_PROD = process.env.NODE_ENV === "production";

module.exports = function (grunt) {
grunt.file.defaultEncoding = "utf8";
grunt.file.preserveBOM = false;
Expand All @@ -26,16 +28,20 @@ module.exports = function (grunt) {

grunt.registerTask("node",
"Compiles CyberChef into a single NodeJS module.",
["clean:node", "clean:config", "exec:generateConfig", "webpack:node", "chmod:build"]);
["clean", "exec:generateConfig", "exec:generateNodeIndex", "webpack:node", "webpack:nodeRepl", "chmod:build"]);

grunt.registerTask("test",
"A task which runs all the operation tests in the tests directory.",
["exec:generateConfig", "exec:opTests"]);
["clean", "exec:generateConfig", "exec:opTests"]);

grunt.registerTask("testui",
"A task which runs all the UI tests in the tests directory. The prod task must already have been run.",
["connect:prod", "exec:browserTests"]);

grunt.registerTask("test-node",
"Run all the node tests in the tests directory",
["clean", "exec:generateConfig", "exec:generateNodeIndex", "exec:nodeTests"]);

grunt.registerTask("docs",
"Compiles documentation in the /docs directory.",
["clean:docs", "jsdoc", "chmod:docs"]);
Expand Down Expand Up @@ -80,15 +86,6 @@ module.exports = function (grunt) {
COMPILE_TIME: JSON.stringify(compileTime),
COMPILE_MSG: JSON.stringify(grunt.option("compile-msg") || grunt.option("msg") || ""),
PKG_VERSION: JSON.stringify(pkg.version),
ENVIRONMENT_IS_WORKER: function() {
return typeof importScripts === "function";
},
ENVIRONMENT_IS_NODE: function() {
return typeof process === "object" && typeof require === "function";
},
ENVIRONMENT_IS_WEB: function() {
return typeof window === "object";
}
},
moduleEntryPoints = listEntryModules();

Expand All @@ -113,7 +110,7 @@ module.exports = function (grunt) {
dev: ["build/dev/*"],
prod: ["build/prod/*"],
node: ["build/node/*"],
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*", "src/code/operations/index.mjs"],
config: ["src/core/config/OperationConfig.json", "src/core/config/modules/*", "src/code/operations/index.mjs", "src/node/index.mjs", "src/node/config/OperationConfig.json"],
docs: ["docs/*", "!docs/*.conf.json", "!docs/*.ico", "!docs/*.png"],
standalone: ["build/prod/CyberChef*.html"]
},
Expand Down Expand Up @@ -201,19 +198,44 @@ module.exports = function (grunt) {
};
},
node: {
mode: "production",
mode: NODE_PROD ? "production" : "development",
target: "node",
entry: "./src/node/index.mjs",
externals: [NodeExternals()],
externals: [NodeExternals({
whitelist: ["crypto-api/src/crypto-api"]
})],
output: {
filename: "CyberChef.js",
path: __dirname + "/build/node",
library: "CyberChef",
libraryTarget: "commonjs2"
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS)
]
new webpack.DefinePlugin(BUILD_CONSTANTS),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
],
},
nodeRepl: {
mode: NODE_PROD ? "production" : "development",
target: "node",
entry: "./src/node/repl-index.mjs",
externals: [NodeExternals({
whitelist: ["crypto-api/src/crypto-api"]
})],
output: {
filename: "CyberChef-repl.js",
path: __dirname + "/build/node",
library: "CyberChef",
libraryTarget: "commonjs2"
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1
})
],
}
},
"webpack-dev-server": {
Expand Down Expand Up @@ -249,9 +271,6 @@ module.exports = function (grunt) {
"./config/modules/OpModules": "./config/modules/Default"
}
},
output: {
globalObject: "this",
},
plugins: [
new webpack.DefinePlugin(BUILD_CONSTANTS),
new HtmlWebpackPlugin({
Expand Down Expand Up @@ -358,7 +377,7 @@ module.exports = function (grunt) {
watch: {
config: {
files: ["src/core/operations/**/*", "!src/core/operations/index.mjs"],
tasks: ["exec:generateConfig"]
tasks: ["exec:generateNodeIndex", "exec:generateConfig"]
}
},
concurrent: {
Expand Down Expand Up @@ -390,11 +409,21 @@ module.exports = function (grunt) {
"echo '--- Config scripts finished. ---\n'"
].join(";")
},
generateNodeIndex: {
command: [
"echo '\n--- Regenerating node index ---'",
"node --experimental-modules src/node/config/scripts/generateNodeIndex.mjs",
"echo '--- Node index generated. ---\n'"
].join(";"),
},
opTests: {
command: "node --experimental-modules --no-warnings --no-deprecation tests/operations/index.mjs"
},
browserTests: {
command: "./node_modules/.bin/nightwatch --env prod"
},
nodeTests: {
command: "node --experimental-modules --no-warnings --no-deprecation tests/node/index.mjs"
}
},
});
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ module.exports = function(api) {
}]
],
"plugins": [
"babel-plugin-syntax-dynamic-import",
"dynamic-import-node",
[
"babel-plugin-transform-builtin-extend", {
"globals": ["Error"]
Expand Down
Loading