mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-23 00:06:17 -04:00
Merge branch 'master' into feature-ebcdic
This commit is contained in:
commit
6bf06a9629
73 changed files with 1481 additions and 1003 deletions
132
test/tests/operations/Code.js
Normal file
132
test/tests/operations/Code.js
Normal file
|
@ -0,0 +1,132 @@
|
|||
/**
|
||||
* Code tests.
|
||||
*
|
||||
* @author tlwr [toby@toby.codes]
|
||||
*
|
||||
* @copyright Crown Copyright 2017
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../TestRegister.js";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "To Camel case (dumb)",
|
||||
input: "hello world",
|
||||
expectedOutput: "helloWorld",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Camel case",
|
||||
"args": [false]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "To Snake case (dumb)",
|
||||
input: "hello world",
|
||||
expectedOutput: "hello_world",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Snake case",
|
||||
"args": [false]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "To Kebab case (dumb)",
|
||||
input: "hello world",
|
||||
expectedOutput: "hello-world",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Kebab case",
|
||||
"args": [false]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "To Camel case (smart)",
|
||||
input: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"a_camel_case_function",
|
||||
"$a_camel_case_variable;",
|
||||
"function function_name() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"aCamelCaseFunction",
|
||||
"$aCamelCaseVariable;",
|
||||
"function functionName() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Camel case",
|
||||
"args": [true]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "To Snake case (smart)",
|
||||
input: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"aSnakeCaseFunction",
|
||||
"$aSnakeCaseVariable;",
|
||||
"function functionName() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"a_snake_case_function",
|
||||
"$a_snake_case_variable;",
|
||||
"function function_name() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Snake case",
|
||||
"args": [true]
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "To Kebab case (smart)",
|
||||
input: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"aKebabCaseFunction",
|
||||
"$aKebabCaseVariable;",
|
||||
"function functionName() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"test='hello'",
|
||||
"echo $test",
|
||||
"a-kebab-case-function",
|
||||
"$a-kebab-case-variable;",
|
||||
"function function-name() {",
|
||||
" console.log('things inside quotes do not get broken');",
|
||||
" console.log(\"things inside quotes do not get broken\");",
|
||||
"}",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "To Kebab case",
|
||||
"args": [true]
|
||||
}
|
||||
],
|
||||
},
|
||||
]);
|
|
@ -66,6 +66,62 @@ TestRegister.addTests([
|
|||
{"op":"To Base64", "args":["A-Za-z0-9+/="]}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Jump: skips 0",
|
||||
input: [
|
||||
"should be changed",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"should be changed was changed",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Jump",
|
||||
args: [0, 10],
|
||||
},
|
||||
{
|
||||
op: "Find / Replace",
|
||||
args: [
|
||||
{
|
||||
"option": "Regex",
|
||||
"string": "should be changed"
|
||||
},
|
||||
"should be changed was changed",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Jump: skips 1",
|
||||
input: [
|
||||
"shouldnt be changed",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"shouldnt be changed",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Jump",
|
||||
args: [1, 10],
|
||||
},
|
||||
{
|
||||
op: "Find / Replace",
|
||||
args: [
|
||||
{
|
||||
"option": "Regex",
|
||||
"string": "shouldnt be changed"
|
||||
},
|
||||
"shouldnt be changed was changed",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Conditional Jump: Skips 0",
|
||||
input: [
|
||||
|
@ -111,4 +167,111 @@ TestRegister.addTests([
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Comment: nothing",
|
||||
input: "",
|
||||
expectedOutput: "",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Comment",
|
||||
"args": [""]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Fork, Comment, Base64",
|
||||
input: "cat\nsat\nmat",
|
||||
expectedOutput: "Y2F0\nc2F0\nbWF0\n",
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "Fork",
|
||||
"args": ["\\n", "\\n", false]
|
||||
},
|
||||
{
|
||||
"op": "Comment",
|
||||
"args": ["Testing 123"]
|
||||
},
|
||||
{
|
||||
"op": "To Base64",
|
||||
"args": ["A-Za-z0-9+/="]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Conditional Jump: Skips 1",
|
||||
input: [
|
||||
"match",
|
||||
"should not be changed",
|
||||
"should be changed",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"match",
|
||||
"should not be changed",
|
||||
"should be changed was changed"
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Conditional Jump",
|
||||
args: ["match", 1, 10],
|
||||
},
|
||||
{
|
||||
op: "Find / Replace",
|
||||
args: [
|
||||
{
|
||||
"option": "Regex",
|
||||
"string": "should not be changed"
|
||||
},
|
||||
"should not be changed was changed",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
],
|
||||
},
|
||||
{
|
||||
op: "Find / Replace",
|
||||
args: [
|
||||
{
|
||||
"option": "Regex",
|
||||
"string": "should be changed"
|
||||
},
|
||||
"should be changed was changed",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Conditional Jump: Skips negatively",
|
||||
input: [
|
||||
"match",
|
||||
].join("\n"),
|
||||
expectedOutput: [
|
||||
"replaced",
|
||||
].join("\n"),
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Jump",
|
||||
args: [1],
|
||||
},
|
||||
{
|
||||
op: "Find / Replace",
|
||||
args: [
|
||||
{
|
||||
"option": "Regex",
|
||||
"string": "match"
|
||||
},
|
||||
"replaced",
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
],
|
||||
},
|
||||
{
|
||||
op: "Conditional Jump",
|
||||
args: ["match", -2, 10],
|
||||
},
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue