mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-24 16:56:15 -04:00
Merge 9915ab7db5
into 7c8be12d52
This commit is contained in:
commit
aaff64fb10
6 changed files with 654 additions and 0 deletions
|
@ -176,6 +176,8 @@ import "./tests/JSONtoYAML.mjs";
|
|||
import "./tests/YARA.mjs";
|
||||
import "./tests/ParseCSR.mjs";
|
||||
import "./tests/XXTEA.mjs";
|
||||
import "./tests/NTPTimestampToUNIXTimestamp.mjs";
|
||||
import "./tests/UNIXTimestampToNTPTimestamp.mjs";
|
||||
|
||||
const testStatus = {
|
||||
allTestsPassing: true,
|
||||
|
|
211
tests/operations/tests/NTPTimestampToUNIXTimestamp.mjs
Normal file
211
tests/operations/tests/NTPTimestampToUNIXTimestamp.mjs
Normal file
|
@ -0,0 +1,211 @@
|
|||
/**
|
||||
* Set NTP timestamp to UNIX timestamp tests.
|
||||
*
|
||||
* @author kossithedon
|
||||
*
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Fixed-point decimal NTP Timestamp to Seconds UNIX Timestamp",
|
||||
input: "3923215437.1842400034",
|
||||
expectedOutput: "1714226637.4289672",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fixed-point decimal NTP Timestamp to Milliseconds UNIX Timestamp",
|
||||
input: "3923215437.1842400034",
|
||||
expectedOutput: "1714226637428.9673",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Milliseconds (ms)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fixed-point decimal NTP Timestamp to Microseconds UNIX Timestamp",
|
||||
input: "3923215437.1842400034",
|
||||
expectedOutput: "1714226637428967.2",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Microseconds (μs)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Fixed-point decimal NTP Timestamp to Nanoseconds UNIX Timestamp",
|
||||
input: "3923215437.1842400034",
|
||||
expectedOutput: "1714226637428967200",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Nanoseconds (ns)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Big-endian hexadecimal NTP Timestamp to Seconds UNIX Timestamp",
|
||||
input: "e9d784613df8dd8b",
|
||||
expectedOutput: "1714226657.2420785",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (big-endian)", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Big-endian hexadecimal NTP Timestamp to Milliseconds UNIX Timestamp",
|
||||
input: "e9d784613df8dd8b",
|
||||
expectedOutput: "1714226657242.0786",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (big-endian)", "Milliseconds (ms)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Big-endian hexadecimal NTP Timestamp to Microseconds UNIX Timestamp",
|
||||
input: "e9d784613df8dd8b",
|
||||
expectedOutput: "1714226657242078.5",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (big-endian)", "Microseconds (μs)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Big-endian hexadecimal NTP Timestamp to Nanoseconds UNIX Timestamp",
|
||||
input: "e9d784613df8dd8b",
|
||||
expectedOutput: "1714226657242078500",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (big-endian)", "Nanoseconds (ns)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Little-endian hexadecimal NTP Timestamp to Seconds UNIX Timestamp",
|
||||
input: "b8dd8fd316487d9e",
|
||||
expectedOutput: "1714226657.2420785",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (little-endian)", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Little-endian hexadecimal NTP Timestamp to Milliseconds UNIX Timestamp",
|
||||
input: "b8dd8fd316487d9e",
|
||||
expectedOutput: "1714226657242.0786",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (little-endian)", "Milliseconds (ms)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Little-endian hexadecimal NTP Timestamp to Microseconds UNIX Timestamp",
|
||||
input: "b8dd8fd316487d9e",
|
||||
expectedOutput: "1714226657242078.5",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (little-endian)", "Microseconds (μs)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Little-endian hexadecimal NTP Timestamp to Nanoseconds UNIX Timestamp",
|
||||
input: "b8dd8fd316487d9e",
|
||||
expectedOutput: "1714226657242078500",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (little-endian)", "Nanoseconds (ns)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Hexadecimal NTP Timestamp to UNIX Timestamp : too long hexadecimal NTP timestamp input",
|
||||
input: "e9d784613df8dd8bf",
|
||||
expectedOutput: "Error: NTP Timestamp should be 64 bits long",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (big-endian)", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Hexadecimal NTP Timestamp to UNIX Timestamp : too short hexadecimal NTP timestamp input",
|
||||
input: "b8dd8fd316487d9",
|
||||
expectedOutput: "Error: NTP Timestamp should be 64 bits long",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Hex (little-endian)", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "NTP Timestamp to UNIX Timestamp : NTP Timestamp input unrecognised format",
|
||||
input: "60954b2d-7151-45c7-99cc-aca4ab664a8e",
|
||||
expectedOutput: "Unrecognised format",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["uuid", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "NTP Timestamp to UNIX Timestamp : UNIX Timestamp output unrecognised unit",
|
||||
input: "3923215437.1842400034",
|
||||
expectedOutput: "Unrecognised unit",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Hours"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "NTP Timestamp to UNIX Timestamp : NTP timestamp seconds part is greater than the greatest 32 bits value 4294967296",
|
||||
input: "4294967297.1842400034",
|
||||
expectedOutput: "Error: Timestamp seconds part should be 32 bits long. The seconds part '4294967297' of the provided NTP timestamp exceeds the maximum positive integer representable in 32 bits '4294967296'",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "NTP Timestamp to UNIX Timestamp : NTP timestamp seconds fractions part is greater than the greatest 32 bits value 4294967296",
|
||||
input: "3923215437.4294967297",
|
||||
expectedOutput: "Error: Timestamp fractions seconds part should be 32 bits long. The fractions seconds part '4294967297' of the provided NTP timestamp exceeds the maximum positive integer representable in 32 bits '4294967296'",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "NTP Timestamp to UNIX Timestamp",
|
||||
args: ["Fixed-point decimal", "Seconds (s)"],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
]);
|
178
tests/operations/tests/UNIXTimestampToNTPTimestamp.mjs
Normal file
178
tests/operations/tests/UNIXTimestampToNTPTimestamp.mjs
Normal file
|
@ -0,0 +1,178 @@
|
|||
/**
|
||||
* Set UNIX Timestamp to NTP Timestamp tests.
|
||||
*
|
||||
* @author kossithedon
|
||||
*
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import TestRegister from "../../lib/TestRegister.mjs";
|
||||
|
||||
TestRegister.addTests([
|
||||
{
|
||||
name: "Seconds UNIX Timestamp to Fixed-point decimal NTP Timestamp",
|
||||
input: "1714226657.2420785",
|
||||
expectedOutput: "3923215457.1039719424",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Seconds (s)", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Milliseconds UNIX Timestamp to Fixed-point decimal NTP Timestamp ",
|
||||
input: "1714226657242.0786",
|
||||
expectedOutput: "3923215457.1039719424",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Milliseconds (ms)", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Microseconds UNIX Timestamp to Fixed-point decimal NTP Timestamp ",
|
||||
input: "1714226657242078.5",
|
||||
expectedOutput: "3923215457.1039719424",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Microseconds (μs)", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Nanoseconds UNIX Timestamp to Fixed-point decimal NTP Timestamp",
|
||||
input: "1714226657242078500",
|
||||
expectedOutput: "3923215457.1039719424",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Nanoseconds (ns)", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Seconds UNIX Timestamp to Big-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657.2420785",
|
||||
expectedOutput: "e9d784613df8dc00",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Seconds (s)", "Hex (big-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Milliseconds UNIX Timestamp to Big-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242.0786",
|
||||
expectedOutput: "e9d784613df8dc00",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Milliseconds (ms)", "Hex (big-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Microseconds UNIX Timestamp to Big-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242078.5",
|
||||
expectedOutput: "e9d784613df8dc00",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Microseconds (μs)", "Hex (big-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Nanoseconds UNIX Timestamp to Big-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242078500",
|
||||
expectedOutput: "e9d784613df8dc00",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Nanoseconds (ns)", "Hex (big-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Seconds UNIX Timestamp to Little-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657.2420785",
|
||||
expectedOutput: "00cd8fd316487d9e",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Seconds (s)", "Hex (little-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Milliseconds UNIX Timestamp to Little-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242.0786",
|
||||
expectedOutput: "00cd8fd316487d9e",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Milliseconds (ms)", "Hex (little-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Microseconds UNIX Timestamp to Little-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242078.5",
|
||||
expectedOutput: "00cd8fd316487d9e",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Microseconds (μs)", "Hex (little-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "Nanoseconds UNIX Timestamp to Little-endian hexadecimal NTP Timestamp",
|
||||
input: "1714226657242078500",
|
||||
expectedOutput: "00cd8fd316487d9e",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Nanoseconds (ns)", "Hex (little-endian)"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UNIX Timestamp to NTP Timestamp : UNIX Timestamp input unrecognised format",
|
||||
input: "60954b2d-7151-45c7-99cc-aca4ab664a8e",
|
||||
expectedOutput: "Unrecognised unit",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["uuid", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UNIX Timestamp to NTP Timestamp : UNIX Timestamp output unrecognised format",
|
||||
input: "1714226657.2420785",
|
||||
expectedOutput: "Unrecognised format",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Seconds (s)", "Floating-point"],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: "UNIX Timestamp to NTP Timestamp : NTP timestamp seconds part is greater than the greatest authorized value 2085978496",
|
||||
input: "2085978497",
|
||||
expectedOutput: "Error: The NTP Timestamp seconds part '2085978497' exceeds the greatest authorized seconds value '2085978496' due to an incorrect provided UNIX timestamp",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "UNIX Timestamp to NTP Timestamp",
|
||||
args: ["Seconds (s)", "Fixed-point decimal"],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
]);
|
Loading…
Add table
Add a link
Reference in a new issue