mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Added Magic operation with the ability to detect language, file type and some encoding types.
This commit is contained in:
parent
aa6890432c
commit
fc2828fee3
7 changed files with 273 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
import Recipe from "./Recipe.js";
|
||||
import Dish from "./Dish.js";
|
||||
import Magic from "./lib/Magic.js";
|
||||
|
||||
|
||||
/**
|
||||
|
@ -253,6 +254,29 @@ const FlowControl = {
|
|||
},
|
||||
|
||||
|
||||
/**
|
||||
* Magic operation.
|
||||
*
|
||||
* @param {Object} state - The current state of the recipe.
|
||||
* @param {number} state.progress - The current position in the recipe.
|
||||
* @param {Dish} state.dish - The Dish being operated on.
|
||||
* @param {Operation[]} state.opList - The list of operations in the recipe.
|
||||
* @returns {Object} The updated state of the recipe.
|
||||
*/
|
||||
runMagic: function(state) {
|
||||
const dish = state.dish;
|
||||
|
||||
const magic = new Magic(dish.get(Dish.ARRAY_BUFFER));
|
||||
|
||||
const output = JSON.stringify(magic.detectLanguage(), null, 2) + "\n\n" +
|
||||
JSON.stringify(magic.detectFileType(), null, 2) + "\n\n" +
|
||||
JSON.stringify(magic.findMatchingOps(), null, 2);
|
||||
|
||||
dish.set(output, Dish.STRING);
|
||||
return state;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Returns the index of a label.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue