mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 00:36:16 -04:00
Throw ExcludedOperationError when excluded operation is called from API
This commit is contained in:
parent
7c9ebafd00
commit
96d5930f05
6 changed files with 143 additions and 8 deletions
|
@ -22,7 +22,7 @@ export default [
|
|||
// esprima doesn't work in .mjs
|
||||
"JavaScriptBeautify",
|
||||
"JavaScriptMinify",
|
||||
"JavaScriptParse",
|
||||
"JavaScriptParser",
|
||||
|
||||
// Relies on state of recipe.
|
||||
// "Magic",
|
||||
|
|
|
@ -40,8 +40,9 @@ let code = `/**
|
|||
|
||||
import "babel-polyfill";
|
||||
import SyncDish from "./SyncDish";
|
||||
import { wrap, help, bake } from "./api";
|
||||
import { wrap, help, bake, explainExludedFunction } from "./api";
|
||||
import {
|
||||
// import as core_ to avoid name clashes after wrap.
|
||||
`;
|
||||
|
||||
includedOperations.forEach((op) => {
|
||||
|
@ -76,23 +77,32 @@ includedOperations.forEach((op) => {
|
|||
code += ` "${decapitalise(op)}": wrap(core_${op}),\n`;
|
||||
});
|
||||
|
||||
excludedOperations.forEach((op) => {
|
||||
code += ` "${decapitalise(op)}": explainExludedFunction("${op}"),\n`;
|
||||
});
|
||||
|
||||
code += ` };
|
||||
}
|
||||
|
||||
const chef = generateChef();
|
||||
// Add some additional features to chef object.
|
||||
chef.help = help;
|
||||
chef.dish = SyncDish;
|
||||
|
||||
// Define consts here so we can add to top-level export - wont allow
|
||||
// export of chef property.
|
||||
`;
|
||||
|
||||
includedOperations.forEach((op) => {
|
||||
Object.keys(operations).forEach((op) => {
|
||||
code += `const ${decapitalise(op)} = chef.${decapitalise(op)};\n`;
|
||||
});
|
||||
|
||||
code +=`
|
||||
|
||||
// Define array of all operations to create register for bake.
|
||||
const operations = [\n`;
|
||||
|
||||
includedOperations.forEach((op) => {
|
||||
Object.keys(operations).forEach((op) => {
|
||||
code += ` ${decapitalise(op)},\n`;
|
||||
});
|
||||
|
||||
|
@ -100,11 +110,13 @@ code += `];
|
|||
|
||||
chef.bake = bake(operations);
|
||||
export default chef;
|
||||
|
||||
// Operations as top level exports.
|
||||
export {
|
||||
operations,
|
||||
`;
|
||||
|
||||
includedOperations.forEach((op) => {
|
||||
Object.keys(operations).forEach((op) => {
|
||||
code += ` ${decapitalise(op)},\n`;
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue