yams/tools/fuzzing/fuzz_p2p_protocol.cpp
Trevon 9c19452e7d
test(p2p): add direct control fuzz harnesses (#74)
Add libFuzzer/AFL++ harnesses for the direct-P2P handshake/state/history and
delta/bootstrap control parsers. Fuzzers invoke the same production parser
seams as the live wire path, so coverage cannot drift from real validation. A
protocol-v3 seed exercises exact-version rejection after the v4 upgrade. Bound
noninteractive AFL++ campaigns with AFL_FUZZ_SECONDS and register focused
fuzz-smoke tests without duplicating broad protocol/delta registrations.
Clarify that peer/cycle status is local health telemetry rather than global
convergence, and document the remaining decision-grade live-performance gate.

Signed-off-by: trvon <git@trevon.dev>
2026-08-30 11:27:11 -06:00

20 lines
635 B
C++

// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright 2026 YAMS Contributors
#include "../../src/daemon/p2p/p2p_fuzz.h"
// pi-lens-ignore: fatal error
#include <yams/daemon/p2p/p2p_transport.h>
#include <cstddef>
#include <cstdint>
#include <span>
extern "C" int LLVMFuzzerTestOneInput(const std::uint8_t* data, std::size_t size) {
if (data == nullptr || size > yams::daemon::p2p::kP2pMaxControlFrameBytes) {
return 0;
}
const auto frame = std::span<const std::byte>(reinterpret_cast<const std::byte*>(data), size);
(void)yams::daemon::p2p::detail::validateHandshakeControlFrame(frame);
return 0;
}