mirror of
https://github.com/gchq/CyberChef
synced 2025-12-31 07:33:28 +00:00
Added Magic operation with the ability to detect language, file type and some encoding types.
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user