mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-22 07:46:16 -04:00
Added numeric validation for arguments in Binary and Hex operattions. Fixes #1178
This commit is contained in:
parent
95884d77cf
commit
1e0e7f16a7
5 changed files with 18 additions and 4 deletions
|
@ -35,7 +35,8 @@ class FromBinary extends Operation {
|
|||
{
|
||||
"name": "Byte Length",
|
||||
"type": "number",
|
||||
"value": 8
|
||||
"value": 8,
|
||||
"min": 1
|
||||
}
|
||||
];
|
||||
this.checks = [
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
import Operation from "../Operation.mjs";
|
||||
import Utils from "../Utils.mjs";
|
||||
import OperationError from "../errors/OperationError.mjs";
|
||||
|
||||
/**
|
||||
* To Hexdump operation
|
||||
|
@ -28,7 +29,8 @@ class ToHexdump extends Operation {
|
|||
{
|
||||
"name": "Width",
|
||||
"type": "number",
|
||||
"value": 16
|
||||
"value": 16,
|
||||
"min": 1
|
||||
},
|
||||
{
|
||||
"name": "Upper case hex",
|
||||
|
@ -58,6 +60,9 @@ class ToHexdump extends Operation {
|
|||
const [length, upperCase, includeFinalLength, unixFormat] = args;
|
||||
const padding = 2;
|
||||
|
||||
if (length < 1 || Math.round(length) !== length)
|
||||
throw new OperationError("Width must be a positive integer");
|
||||
|
||||
let output = "";
|
||||
for (let i = 0; i < data.length; i += length) {
|
||||
const buff = data.slice(i, i+length);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue