-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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 request: Multiple output types #233
Comments
Yeah, a very good idea. For the next big refactoring, I'd like to completely redesign how operations are defined and this could definitely play into it. Wouldn't it be nice if each operation looked something like this: class FromBase64 extends Operation {
constructor(input, args) {
super()
// handle args
}
run() {
...
}
toString() {
...
}
...
} It would then be possible to either run an entire recipe, or expose each class separately, allowing other people to use the operations in CyberChef in their projects: import { FromBase64 } from "cyberchef";
FromBase64.run("SGVsbG8sIFdvcmxkIQ=="); I haven't fully thought out the architecture yet, but I'm certainly aiming for something along these lines. |
That design seems quite elegant, if datatypes are defined nicely then operations would be quite composable. How would an operation communicate the datatypes it can accept, a class variable? e.g.
or something more complex, e.g. support for more complicated types, although that might end up like reimplemented some XML schema... |
Yes, datatypes are one of the areas I haven't quite worked out yet. We can define most of the operation config in the constructor and then generate a large config object for all operations dynamically at build time, so that the front end has all the information it requires (like operation names, descriptions and args). This dynamically built config object would replace class FromBase64 extends Operation {
constructor(input, ...) {
this.name = "From Base64";
this.description = "Blah blah blah";
this.categories = ["Data format"];
this.args = ...;
// Undecided whether args will just be the simple 'name', 'type', 'value' config used
// currently, or a more complex but powerful object oriented model
}
} The theory behind this is that when contributors submit a new operation, they only have to build this one class, rather than editing about four different config files just to get the operation to appear in the UI. Regarding datatypes... yeah. There are a number of options. We could continue having each operation support a single type which would keep this fairly simple. We could add more expressive types like We would then just need a good way of handling the output of the final operation in the recipe. How about there is a method in the This doesn't solve the problem of translating between types when importing individual operations in a script. Any bright ideas on this subject would be welcome. The naive way of solving it would be to just expose the |
Perhaps we should make a branch with a reduced operation set to start building this? I get the feeling that it's going to be a fair bit of work to get this on track. |
Yes, agreed. I'll set something up once I've finished working on my current PR (not pushed yet). It would be good to have some feedback on the new class model once the branch is set up. As you say, it's going to be a fair bit of work, so it's important we get the architecture as solid as possible from the beginning. |
This has been largely resolved by #284. Feel free to open a new issue if there are specifics that are outstanding. |
Summary
Creating complex recipes often ends up being much more complicated than it has to be because we lack expressive output types.
Example: files
Zipping and unzipping files produces HTML output, which is very useful as an end state but not good when it is in the middle of a recipe. What I usually end up doing is strip HTML and then a find replace.
Example: PGP encryption
For both testing internally, and composing operations in the UI, having structured output here would be really useful.
Proposed solution
Compound types
Operations could have an intrinsic
toString
orshowOperation
property in the case that the operation is the last operation in the recipe.An example recipe to hash first file in a zip file
An example with registers and a new unregister operation
This is still a little bit half-baked in my head, and I would love your thoughts and feedback.
The text was updated successfully, but these errors were encountered: