mirror of
https://github.com/gchq/CyberChef.git
synced 2025-05-10 08:15:00 -04:00
Add option to parse non-varint Protobuf fields as floats
This commit is contained in:
parent
c9d9730726
commit
6d2cacc30c
3 changed files with 149 additions and 8 deletions
|
@ -33,4 +33,106 @@ TestRegister.addTests([
|
|||
}
|
||||
]
|
||||
},
|
||||
/**
|
||||
* Input generated from:
|
||||
* ```
|
||||
$ cat test.proto
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
float a = 1;
|
||||
}
|
||||
|
||||
$ protoc --version
|
||||
libprotoc 3.11.1
|
||||
|
||||
$ echo a:1 | protoc --encode=Test test.proto | xxd -p
|
||||
0d0000803f
|
||||
```
|
||||
*/
|
||||
{
|
||||
name: "Protobuf Decode - parse fixed32 as integer",
|
||||
input: "0d0000803f",
|
||||
expectedOutput: JSON.stringify({
|
||||
"1": 32831,
|
||||
}, null, 4),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Auto"]
|
||||
},
|
||||
{
|
||||
"op": "Protobuf Decode",
|
||||
"args": [false]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Protobuf Decode - parse fixed32 as float32",
|
||||
input: "0d0000803f",
|
||||
expectedOutput: JSON.stringify({
|
||||
"1": 1,
|
||||
}, null, 4),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Auto"]
|
||||
},
|
||||
{
|
||||
"op": "Protobuf Decode",
|
||||
"args": [true]
|
||||
}
|
||||
]
|
||||
},
|
||||
/**
|
||||
* Input generated from:
|
||||
* ```
|
||||
$ cat test.proto
|
||||
syntax = "proto3";
|
||||
|
||||
message Test {
|
||||
double a = 1;
|
||||
}
|
||||
|
||||
$ protoc --version
|
||||
libprotoc 3.11.1
|
||||
|
||||
$ echo a:1 | protoc --encode=Test test.proto | xxd -p
|
||||
09000000000000f03f
|
||||
```
|
||||
*/
|
||||
{
|
||||
name: "Protobuf Decode - parse fixed64 as integer",
|
||||
input: "09000000000000f03f",
|
||||
expectedOutput: JSON.stringify({
|
||||
"1": 61503,
|
||||
}, null, 4),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Auto"]
|
||||
},
|
||||
{
|
||||
"op": "Protobuf Decode",
|
||||
"args": [false]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Protobuf Decode - parse fixed64 as float64",
|
||||
input: "09000000000000f03f",
|
||||
expectedOutput: JSON.stringify({
|
||||
"1": 1,
|
||||
}, null, 4),
|
||||
recipeConfig: [
|
||||
{
|
||||
"op": "From Hex",
|
||||
"args": ["Auto"]
|
||||
},
|
||||
{
|
||||
"op": "Protobuf Decode",
|
||||
"args": [true]
|
||||
}
|
||||
]
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue