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

Feature: Run a recipe over multiple inputs #566

Merged
merged 180 commits into from
Jul 4, 2019
Merged
Show file tree
Hide file tree
Changes from 143 commits
Commits
Show all changes
180 commits
Select commit Hold shift + click to select a range
d09ab4a
Add new solarized light and dark themes.
j433866 Mar 19, 2019
2049e4e
Add image preview to input file overlay.
j433866 Mar 19, 2019
b195fc6
Remove old css file
j433866 Mar 19, 2019
674f879
Change file thumb to normal icon when file closed
j433866 Mar 19, 2019
e03e51c
Add styling of checkboxes.
j433866 Mar 20, 2019
4a84cf3
Add css styling option for banner URL
j433866 Mar 20, 2019
d9fdae9
Adjust css to keep aspect ratio of previewed image
j433866 Mar 20, 2019
7571767
Fix the aspect ratio fix
j433866 Mar 20, 2019
37218c1
Add UI for input tabs.
j433866 Mar 21, 2019
c0c83c5
Stores inputs in memory instead of in textareas.
j433866 Mar 22, 2019
9b86ed7
Fix input highlighter size
j433866 Mar 22, 2019
fbe1e2c
Show tab number on tab title.
j433866 Mar 22, 2019
37428fb
Bake all inputs, not just the active tab.
j433866 Mar 27, 2019
61bc543
Fix number of running workers not being correct.
j433866 Mar 27, 2019
3597aac
Add wrapper to output
j433866 Mar 27, 2019
90dd2b5
Add css for output tabs
j433866 Mar 27, 2019
a2cc7a8
Sync output tabs to input tabs.
j433866 Mar 27, 2019
c289e1b
Rewrite InputWaiter to be less messy.
j433866 Mar 29, 2019
0d8584f
Merge with ui-improvements
j433866 Mar 29, 2019
f6ab82f
Fix file preview not working
j433866 Mar 29, 2019
eb5809f
Fix tab info not being updated in refreshTabs()
j433866 Mar 29, 2019
7bf8467
Add maximum limit to the thumbnail image size
j433866 Apr 1, 2019
cd094d1
Change "input-tabs" id to be for the actual ul element.
j433866 Apr 1, 2019
6430129
Remove some inputNum stuff for now
j433866 Apr 2, 2019
2aad764
Add tab buttons (don't work yet).
j433866 Apr 2, 2019
2cb33bf
Bring up to date with master
j433866 Apr 2, 2019
e0c9aba
Improve WorkerWaiter and OutputWaiter.
j433866 Apr 2, 2019
9df26b8
Output tabs now (mostly) work.
j433866 Apr 3, 2019
1eadc08
Fix some weirdness with tabs.
j433866 Apr 3, 2019
b90cca7
Fix more tab weirdness.
j433866 Apr 4, 2019
de21f14
Move the tab buttons onto the tab bar
j433866 Apr 4, 2019
8739dd9
Change srcElement to target
j433866 Apr 4, 2019
76da287
Bake in the right order
j433866 Apr 4, 2019
0804647
Load in the right order
j433866 Apr 4, 2019
9690ccd
Fix being unable to go to tab 1
j433866 Apr 4, 2019
bd3777f
Change maximum file size in readme
j433866 Apr 5, 2019
f099a35
Change get input function calls
j433866 Apr 23, 2019
82186c8
Add search box for input tabs
j433866 Apr 23, 2019
6d8daac
Merge remote-tracking branch 'upstream/master' into multiple-input-files
j433866 Apr 23, 2019
406cbb0
Move input logic into a new worker (InputWorker)
j433866 Apr 25, 2019
7b169fb
Add css for search box
j433866 Apr 25, 2019
f638bd4
If sending arraybuffer back, use a transferable object
j433866 Apr 26, 2019
1cf83c2
Change baking to send all inputs individually.
j433866 Apr 26, 2019
6d98014
New max limit for files
j433866 Apr 26, 2019
8cb86c3
Increase file limit
j433866 Apr 26, 2019
145fba5
Input pasting now works
j433866 Apr 30, 2019
1f39a92
Reset bake button background when state changed
j433866 Apr 30, 2019
a96cb3f
Add clear all io button.
j433866 Apr 30, 2019
b4208ed
Add clear io button.
j433866 Apr 30, 2019
13ee79a
Add searching for inputs
j433866 Apr 30, 2019
6d8bf3a
Enable filter buttons in manager
j433866 Apr 30, 2019
2fff18c
Don't create a new loaderWorker until we need one.
j433866 Apr 30, 2019
55beb43
Go back to sending messages via the main thread.
j433866 May 1, 2019
f6f60e8
Update LoaderWorker to not use messagechannels
j433866 May 1, 2019
02bda32
Fix magic button.
j433866 May 1, 2019
1cedc94
Fix status messages for baking
j433866 May 1, 2019
ff9c68d
Update handling of bake errors.
j433866 May 1, 2019
1bdef97
Wait for stale indicator to disappear before clicking bake.
j433866 May 1, 2019
b2406b0
Run set() when a bake is cancelled.
j433866 May 2, 2019
82183bf
Improve queueing of inputs to avoid baking the same input twice.
j433866 May 2, 2019
8e97179
Improve autobake further to behave more like it did before.
j433866 May 2, 2019
e9d60f7
Fix some more autobake weirdness.
j433866 May 2, 2019
df20196
Fix magic not always working
j433866 May 3, 2019
07021b8
Add new worker for zipping outputs.
j433866 May 7, 2019
97c218c
Fix where zipworker was using output presented result.
j433866 May 7, 2019
ec4eb22
Don't include loading inputs in complete percentage
j433866 May 7, 2019
f1a2cf7
Add cancellation of zipping
j433866 May 7, 2019
35d6c7d
Bring highlighting back.
j433866 May 7, 2019
cbfde7d
Don't highlight if the input and output tab numbers are different
j433866 May 7, 2019
6268f09
Bring back moving the output into the input.
j433866 May 7, 2019
8190c7a
Add maximise output button
j433866 May 7, 2019
2818271
Fix showing slice of output not working.
j433866 May 8, 2019
689d084
Don't create more ChefWorkers than we need.
j433866 May 8, 2019
f727493
Improve handling of errors in operations.
j433866 May 8, 2019
3cffd93
Fix file slice not always being displayed
j433866 May 8, 2019
50f9bbe
Make set() asynchronous
j433866 May 8, 2019
43747ac
Change to add input tabs as inputs are added, instead of at the end.
j433866 May 8, 2019
3b8c365
Remove unused zip dependency
j433866 May 8, 2019
65bb7f3
Fix refreshTabs not always hiding the tab bar
j433866 May 8, 2019
cbf1d2f
Add specific handling for DOMExceptions
j433866 May 8, 2019
3c2e5c1
Set bake button to "Loading..." when an autobake is started
j433866 May 8, 2019
6d9a14f
Display when an input errors on load.
j433866 May 8, 2019
aff0416
Remove some comments
j433866 May 9, 2019
802879c
Merge pull request #2 from gchq/master
j433866 May 10, 2019
f5442c3
Only set the input of the active input if the progress has changed.
j433866 May 10, 2019
2c02900
Improve handling of errors.
j433866 May 10, 2019
e34d521
Improve UI for searching for input tabs
j433866 May 10, 2019
84cc3d1
Fix close tab buttons not working in old firefox.
j433866 May 10, 2019
392b96d
Commenting
j433866 May 14, 2019
04587a8
Merge branch 'multiple-input-files' of github.com:j433866/CyberChef i…
j433866 May 14, 2019
0855dc6
Add comments to inputWorker.
j433866 May 14, 2019
5d52f4a
Add searching for output tabs.
j433866 May 15, 2019
413e80e
Add clicking on output search result
j433866 May 15, 2019
0cff7bd
Improve handling of OperationErrors.
j433866 May 15, 2019
6237db9
Use detectFileType to autodetect file extensions in zip
j433866 May 16, 2019
2ddb9b8
Remove unecessary progress item
j433866 May 16, 2019
d326cad
Remove unused parameter
j433866 May 16, 2019
0e850b2
Fix stepping not working.
j433866 May 16, 2019
a750b0f
Use transferable objects to send arraybuffers back to the workerwaiter
j433866 May 16, 2019
6df9b64
Terminate zipworker when clearing all io
j433866 May 16, 2019
c50f576
Add key bindings for tabs
j433866 May 16, 2019
cb86cb1
Change baking to not send all inputs at once.
j433866 May 20, 2019
e95f92c
Bake inputs after clearing IO
j433866 May 21, 2019
4dcd60a
Improve handling of displaying large outputs.
j433866 May 23, 2019
0bced35
Fix stepping again
j433866 May 23, 2019
7528065
Fix stepping again.
j433866 May 28, 2019
6c711ec
Add and remove chefworkers when adding or removing inputs.
j433866 May 28, 2019
919c3fd
Fix display file slice displaying raw instead of presented data.
j433866 May 28, 2019
722edcc
Display file size in header
j433866 May 29, 2019
85809ef
Adjust number of tabs shown when resizing window.
j433866 May 29, 2019
476d9c8
Remove unused parameter
j433866 May 29, 2019
12e4fe4
Fix clear all button breaking everything.
j433866 May 29, 2019
9b2f44e
Turn extract click listener back on.
j433866 May 29, 2019
d94a431
Improve searching for tabs UI.
j433866 May 30, 2019
586e5a3
Further improvements to tab search UI
j433866 May 30, 2019
11d2a96
Pause for a second to allow autobake to finish.
j433866 May 30, 2019
b232069
If a tab can't be added, show the shadow on the...
j433866 May 30, 2019
7586c3e
Merge remote-tracking branch 'upstream/master' into multiple-input-files
j433866 May 30, 2019
1d20fe1
Reset displayed load progress when clearing IO
j433866 May 31, 2019
d6a80b4
Use toLocaleString for final bake stats
j433866 May 31, 2019
34b7c47
Fix highlighting not working
j433866 May 31, 2019
784b3b5
Fix to stop find tab CSS affecting operations
j433866 Jun 3, 2019
dc74a38
Add documentation for inputNum.
j433866 Jun 3, 2019
54bb17c
Remove getAllInput() function.
j433866 Jun 3, 2019
bcaefe3
Improve transferable object syntax.
j433866 Jun 3, 2019
4a0f62b
Change getLargest/getSmallest to use a for loop.
j433866 Jun 3, 2019
b3cb800
Default inputNum to -1 when one isn't sent.
j433866 Jun 3, 2019
89c4f54
Only show bake stats when theres more than 1 input
j433866 Jun 3, 2019
eb91dd7
Add documentation for getURIParams
j433866 Jun 3, 2019
87dc325
Move debouncer to App.
j433866 Jun 3, 2019
d3e8616
Add close all tabs button to input tab dropdown
j433866 Jun 3, 2019
f5cf7bb
Rename 'move output to input' to 'replace input with output'
j433866 Jun 3, 2019
2575a76
Make input and output tab areas scrollable
j433866 Jun 3, 2019
17b95f1
Add min / max inputNums on go to tab dialog
j433866 Jun 4, 2019
f551027
Add min / max tabs to go to tab dialog (output)
j433866 Jun 4, 2019
15b5cf7
Correctly handle clicking cancel on go to dialog
j433866 Jun 4, 2019
99e9df0
Holding down on tab change buttons will scroll.
j433866 Jun 4, 2019
0e5944e
Set URL input parameter when setting input.
j433866 Jun 4, 2019
31a3af1
Remove step and progress from Chef.
j433866 Jun 4, 2019
b77239f
Move waiters and workers into separate folders.
j433866 Jun 6, 2019
3910161
Scroll I/O areas to the top when switching tabs
j433866 Jun 6, 2019
98af95a
Change pasting to keep cursor position.
j433866 Jun 6, 2019
c2087f6
Move tab logic into a new TabWaiter
j433866 Jun 6, 2019
97f86af
Improve speed of changing input tabs.
j433866 Jun 6, 2019
8c2cc5b
Improve removing tabs experience
j433866 Jun 7, 2019
ad98274
Display recipe progress in status message
j433866 Jun 7, 2019
be0e125
Display preview of output in output tab headers.
j433866 Jun 10, 2019
d99cf9d
Use function in TabWaiter
j433866 Jun 10, 2019
5a52e5e
Remove new lines from input tab header
j433866 Jun 10, 2019
9d60ef5
Turn output tabs into progress bars!
j433866 Jun 10, 2019
713f10e
Turn input tabs into progress bars
j433866 Jun 10, 2019
749ffdd
Move input tab code
j433866 Jun 11, 2019
f497dc3
Handle progressMessage in background waiter.
j433866 Jun 11, 2019
6ee76e3
Add getDishTitle function
j433866 Jun 13, 2019
84204c1
Add mime type detection to tab title.
j433866 Jun 13, 2019
34d0397
Improve queueing for getDish... messages.
j433866 Jun 13, 2019
5731f5c
Add dishworker
j433866 Jun 13, 2019
370cae3
Fix incorrect value being sent to dishworker
j433866 Jun 13, 2019
05d81eb
Merge remote-tracking branch 'upstream/master' into multiple-input-files
j433866 Jun 14, 2019
c529a40
Fix switchClick not always being fired.
j433866 Jun 18, 2019
906ece0
Remove loading files modal
j433866 Jun 20, 2019
dd5038c
Bring up to date with master
j433866 Jul 1, 2019
86c37ba
Clone dish instead of using the current dish.
j433866 Jul 1, 2019
ba4740a
Correct documentation
j433866 Jul 1, 2019
3dc57c4
Update copyright year on solarized themes
j433866 Jul 2, 2019
a9f8dac
Fix stepping.
j433866 Jul 2, 2019
3a19737
Remove unused self.port variable
j433866 Jul 2, 2019
160e4a0
Change ZipWorker to use Dish.get()
j433866 Jul 3, 2019
7a01802
Update inputWorker description
j433866 Jul 3, 2019
cf500b7
Fix getInputValue not returning inputs that are arraybuffers
j433866 Jul 3, 2019
4312d39
Show or hide thumbnail when the option is changed.
j433866 Jul 3, 2019
0f87c70
Add comma to CSS rule
j433866 Jul 3, 2019
2d95092
Remove no file extension error
j433866 Jul 3, 2019
455b42a
Fix whitespace and comment typos.
j433866 Jul 3, 2019
a7eefa8
Merge remote-tracking branch 'upstream/master' into multiple-input-files
j433866 Jul 3, 2019
6d95cb0
Change tab element height using stylesheet.
j433866 Jul 3, 2019
b3fa1ea
Fix output heights being incorrect
j433866 Jul 3, 2019
30a66f1
Use reduce to find smallest and largest inputNums.
j433866 Jul 3, 2019
367d30e
Use reduce for finding previous and next inputNums
j433866 Jul 3, 2019
6964bbc
Improve layout of addInput parameters.
j433866 Jul 3, 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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ You can use as many operations as you like in simple or complex ways. Some examp

- Drag and drop
- Operations can be dragged in and out of the recipe list, or reorganised.
- Files up to 500MB can be dragged over the input box to load them directly into the browser.
- Files up to 2GB can be dragged over the input box to load them directly into the browser.
- Auto Bake
- Whenever you modify the input or the recipe, CyberChef will automatically "bake" for you and produce the output immediately.
- This can be turned off and operated manually if it is affecting performance (if the input is very large, for instance).
Expand All @@ -67,7 +67,7 @@ You can use as many operations as you like in simple or complex ways. Some examp
- Highlighting
- When you highlight text in the input or output, the offset and length values will be displayed and, if possible, the corresponding data will be highlighted in the output or input respectively (example: [highlight the word 'question' in the input to see where it appears in the output][11]).
- Save to file and load from file
- You can save the output to a file at any time or load a file by dragging and dropping it into the input field. Files up to around 500MB are supported (depending on your browser), however some operations may take a very long time to run over this much data.
- You can save the output to a file at any time or load a file by dragging and dropping it into the input field. Files up to around 2GB are supported (depending on your browser), however some operations may take a very long time to run over this much data.
- CyberChef is entirely client-side
- It should be noted that none of your recipe configuration or input (either text or files) is ever sent to the CyberChef web server - all processing is carried out within your browser, on your own computer.
- Due to this feature, CyberChef can be compiled into a single HTML file. You can download this file and drop it into a virtual machine, share it with other people, or use it independently on your local machine.
Expand Down
40 changes: 6 additions & 34 deletions src/core/Chef.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class Chef {
* @param {Object[]} recipeConfig - The recipe configuration object
* @param {Object} options - The options object storing various user choices
* @param {boolean} options.attempHighlight - Whether or not to attempt highlighting
* @param {number} progress - The position in the recipe to start from
* @param {number} [step] - Whether to only execute one operation in the recipe
*
* @returns {Object} response
* @returns {string} response.result - The output of the recipe
Expand All @@ -38,46 +36,20 @@ class Chef {
* @returns {number} response.duration - The number of ms it took to execute the recipe
* @returns {number} response.error - The error object thrown by a failed operation (false if no error)
*/
async bake(input, recipeConfig, options, progress, step) {
async bake(input, recipeConfig, options) {
log.debug("Chef baking");
const startTime = new Date().getTime(),
recipe = new Recipe(recipeConfig),
containsFc = recipe.containsFlowControl(),
notUTF8 = options && options.hasOwnProperty("treatAsUtf8") && !options.treatAsUtf8;
let error = false;

if (containsFc && ENVIRONMENT_IS_WORKER()) self.setOption("attemptHighlight", false);

// Clean up progress
if (progress >= recipeConfig.length) {
let error = false,
progress = 0;
}

if (step) {
// Unset breakpoint on this step
recipe.setBreakpoint(progress, false);
// Set breakpoint on next step
recipe.setBreakpoint(progress + 1, true);
}

// If the previously run operation presented a different value to its
// normal output, we need to recalculate it.
if (recipe.lastOpPresented(progress)) {
progress = 0;
}

// If stepping with flow control, we have to start from the beginning
// but still want to skip all previous breakpoints
if (progress > 0 && containsFc) {
recipe.removeBreaksUpTo(progress);
progress = 0;
}
if (containsFc && ENVIRONMENT_IS_WORKER()) self.setOption("attemptHighlight", false);

// If starting from scratch, load data
if (progress === 0) {
const type = input instanceof ArrayBuffer ? Dish.ARRAY_BUFFER : Dish.STRING;
this.dish.set(input, type);
}
// Load data
const type = input instanceof ArrayBuffer ? Dish.ARRAY_BUFFER : Dish.STRING;
this.dish.set(input, type);

try {
progress = await recipe.execute(this.dish, progress);
Expand Down
40 changes: 27 additions & 13 deletions src/core/ChefWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ self.chef = new Chef();

self.OpModules = OpModules;
self.OperationConfig = OperationConfig;
self.inputNum = -1;


// Tell the app that the worker has loaded and is ready to operate
self.postMessage({
Expand All @@ -35,6 +37,9 @@ self.postMessage({
/**
* Respond to message from parent thread.
*
* inputNum is optional and only used for baking multiple inputs.
* Defaults to -1 when one isn't sent with the bake message.
*
* Messages should have the following format:
* {
* action: "bake" | "silentBake",
Expand All @@ -43,7 +48,8 @@ self.postMessage({
* recipeConfig: {[Object]},
* options: {Object},
* progress: {number},
* step: {boolean}
* step: {boolean},
* inputNum: {number} | undefined
j433866 marked this conversation as resolved.
Show resolved Hide resolved
* } | undefined
* }
*/
Expand Down Expand Up @@ -91,30 +97,35 @@ self.addEventListener("message", function(e) {
async function bake(data) {
// Ensure the relevant modules are loaded
self.loadRequiredModules(data.recipeConfig);

try {
self.inputNum = (data.inputNum !== undefined) ? data.inputNum : -1;
const response = await self.chef.bake(
data.input, // The user's input
data.recipeConfig, // The configuration of the recipe
data.options, // Options set by the user
data.progress, // The current position in the recipe
data.step // Whether or not to take one step or execute the whole recipe
data.options // Options set by the user
j433866 marked this conversation as resolved.
Show resolved Hide resolved
);

const transferable = (data.input instanceof ArrayBuffer) ? [data.input] : undefined;
self.postMessage({
action: "bakeComplete",
data: Object.assign(response, {
id: data.id
id: data.id,
inputNum: data.inputNum,
bakeId: data.bakeId
})
});
}, transferable);

} catch (err) {
self.postMessage({
action: "bakeError",
data: Object.assign(err, {
id: data.id
})
data: {
error: err.message || err,
id: data.id,
inputNum: data.inputNum
}
});
}
self.inputNum = -1;
}


Expand All @@ -136,14 +147,14 @@ function silentBake(data) {
*/
async function getDishAs(data) {
const value = await self.chef.getDishAs(data.dish, data.type);

const transferable = (data.type === "ArrayBuffer") ? [value] : undefined;
self.postMessage({
action: "dishReturned",
data: {
value: value,
id: data.id
}
});
}, transferable);
}


Expand Down Expand Up @@ -193,7 +204,10 @@ self.loadRequiredModules = function(recipeConfig) {
self.sendStatusMessage = function(msg) {
self.postMessage({
action: "statusMessage",
data: msg
data: {
message: msg,
inputNum: self.inputNum
}
});
};

Expand Down
Loading