Parse IPv4 Header HTML formatting fix (#2401)

This commit is contained in:
GCHQ Developer 85297 2026-05-18 11:52:10 +01:00 committed by GitHub
parent cf6912f640
commit 1baef27e9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 25 additions and 1 deletions

View file

@ -138,7 +138,7 @@ class ParseIPv4Header extends Operation {
} else if (outputFormat === "Data (hex)") {
return toHex(data);
} else if (outputFormat === "Data (raw)") {
return Utils.byteArrayToChars(data);
return Utils.escapeHtml(Utils.byteArrayToChars(data));
}
}

View file

@ -126,6 +126,7 @@ import "./tests/NormaliseUnicode.mjs";
import "./tests/NTLM.mjs";
import "./tests/OTP.mjs";
import "./tests/ParseEthernetFrame.mjs";
import "./tests/ParseIPv4Header.mjs";
import "./tests/ParseIPRange.mjs";
import "./tests/ParseObjectIDTimestamp.mjs";
import "./tests/ParseQRCode.mjs";

View file

@ -0,0 +1,23 @@
/**
* Parse IPv4 header tests.
*
* @author C85297 [95289555+C85297@users.noreply.github.com]
* @copyright Crown Copyright 2026
* @license Apache-2.0
*/
import TestRegister from "../../lib/TestRegister.mjs";
TestRegister.addTests([
{
name: "Parse IPv4 header: Correctly formatted HTML output",
input: "45 00 00 3c 1c 46 40 00 40 06 b1 e6 c0 a8 00 01 c0 a8 00 02 3c 73 63 72 69 70 74 3e 61 6c 65 72 74 28 31 33 33 37 29 3c 2f 73 63 72 69 70 74 3e",
expectedOutput: "<script>alert(1337)</script>",
recipeConfig: [
{
op: "Parse IPv4 header",
args: ["Hex", "Data (raw)"]
}
]
}
]);