Merge branch 'udp-header-parser' of https://github.com/h345983745/CyberChef into h345983745-udp-header-parser

This commit is contained in:
n1474335 2019-08-23 10:40:24 +01:00
commit 46fa7475cf
4 changed files with 160 additions and 0 deletions

View file

@ -0,0 +1,68 @@
/**
* Parse UDP tests.
*
* @author h345983745
*
* @copyright Crown Copyright 2019
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Parse UDP: No Data - JSON",
input: "04 89 00 35 00 2c 01 01",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x010x01\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
}, {
name: "Parse UDP: With Data - JSON",
input: "04 89 00 35 00 2c 01 01 02 02",
expectedOutput: "{\"Source port\":1161,\"Destination port\":53,\"Length\":44,\"Checksum\":\"0x010x01\",\"Data\":\"0x020x02\"}",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
},
{
name: "Parse UDP: Not Enough Bytes",
input: "04 89 00",
expectedOutput: "Need 8 bytes for a UDP Header",
recipeConfig: [
{
op: "From Hex",
args: ["Auto"],
},
{
op: "Parse UDP",
args: [],
},
{
op: "JSON Minify",
args: [],
},
],
}
]);