mirror of
https://github.com/gchq/CyberChef.git
synced 2026-10-12 02:13:56 +00:00
fix: show error when too many ingredient values are provided (#2711)
Co-authored-by: GCHQDeveloper581 <[email protected]> (added test)
This commit is contained in:
co-authored by
GCHQDeveloper581
parent
56ce40bf11
commit
e517cf52dc
@@ -242,6 +242,10 @@ class Operation {
|
||||
* @param {Object[]} ingValues
|
||||
*/
|
||||
set ingValues(ingValues) {
|
||||
if (ingValues.length > this._ingList.length) {
|
||||
throw new OperationError(`Failed to set ingredient values: more values provided than available ingredients (${ingValues.length} vs ${this._ingList.length})`);
|
||||
}
|
||||
|
||||
ingValues.forEach((val, i) => {
|
||||
try {
|
||||
const ingredient = this._ingList[i],
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "To Hex - too many ingredients",
|
||||
input: "aberystwyth",
|
||||
expectedError: true,
|
||||
expectedOutput: "Error: Failed to hydrate operation 'To Hex': Error: Failed to set ingredient values: more values provided than available ingredients (3 vs 2)",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Hex",
|
||||
"args": [
|
||||
"None",
|
||||
0,
|
||||
"extra"
|
||||
]
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "ASCII to Hex stream",
|
||||
input: "aberystwyth",
|
||||
|
||||
Reference in New Issue
Block a user