From fbedc55d5aa861c381701c9f913b34ee7ab57ec4 Mon Sep 17 00:00:00 2001 From: srdusr <99972264+srdusr@users.noreply.github.com> Date: Tue, 21 May 2024 22:24:00 +0200 Subject: Add GUI parity for -c/-a, mDNS/SSH dissectors, and two new fuzz harnesses GUI parity: checksum_status()/reassembled_http_status() moved out of main.cpp into a shared wireframe/packet_diagnostics.hpp so the GUI can show the same -c/-a diagnostics for the selected packet without duplicating the Ethernet/IPv4/TCP walk. Visually verified under Xvfb with the same split-segment scenario used to verify -a on the CLI. Two new L7 dissectors: mDNS (reuses parse_dns outright - RFC 6762 keeps DNS's wire format, just a different port) and SSH's cleartext identification banner. Live-verified against this machine's real sshd and a real DNS-wire-format packet sent to port 5353. Two new fuzz harnesses (fuzz_checksum, fuzz_tcp_reassembly) covering code added here that the original nine harnesses never touched. All 12 run clean across ~90M executions with no crashes. NAMES.md and PLAN.md updated with this round's decisions and naming candidates. --- tests/test_mdns.cpp | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/test_mdns.cpp (limited to 'tests/test_mdns.cpp') diff --git a/tests/test_mdns.cpp b/tests/test_mdns.cpp new file mode 100644 index 0000000..cad77e7 --- /dev/null +++ b/tests/test_mdns.cpp @@ -0,0 +1,60 @@ +#include + +#include + +#include "wireframe/l7/mdns.hpp" + +using namespace wireframe::net; + +namespace { + +// A typical mDNS query for a ".local" hostname, id=0 per RFC 6762 +// 18.1's convention for multicast queries. +std::vector mdns_query() { + return { + 0x00, 0x00, // id = 0 + 0x00, 0x00, // flags: query + 0x00, 0x01, // qdcount = 1 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 6, 'm', 'y', 'h', 'o', 's', 't', 5, 'l', 'o', 'c', 'a', 'l', 0, + 0x00, 0x01, // qtype = A + 0x00, 0x01, // qclass = IN + }; +} + +} // namespace + +TEST_CASE("MdnsDissector claims port 5353") { + MdnsDissector dissector; + CHECK(dissector.port() == kMdnsPort); +} + +TEST_CASE("MdnsDissector summarizes a query without an id= field") { + MdnsDissector dissector; + auto summary = dissector.summarize(mdns_query()); + REQUIRE(summary.has_value()); + CHECK(summary->substr(0, 10) == "mDNS query"); + CHECK(summary->find("myhost.local") != std::string::npos); + CHECK(summary->find("id=") == std::string::npos); +} + +TEST_CASE("MdnsDissector summarizes a response with ancount") { + MdnsDissector dissector; + std::vector bytes = { + 0x00, 0x00, + 0x84, 0x00, // flags: QR=1 (response), AA=1 + 0x00, 0x00, // qdcount = 0 (typical for an mDNS response) + 0x00, 0x01, // ancount = 1 + 0x00, 0x00, 0x00, 0x00, + }; + auto summary = dissector.summarize(bytes); + REQUIRE(summary.has_value()); + CHECK(summary->substr(0, 13) == "mDNS response"); + CHECK(summary->find("ancount=1") != std::string::npos); +} + +TEST_CASE("MdnsDissector::summarize returns nullopt for a truncated payload") { + MdnsDissector dissector; + std::vector bytes(5, 0); + CHECK_FALSE(dissector.summarize(bytes).has_value()); +} -- cgit v1.2.3