Deterministic protocol fuzzing core with native TCP/UDP execution and portable JSONL replay
///|
test "named request quick start" {
let request = @moon_boofuzz.CompiledRequest::compile(
@moon_boofuzz.Block::new("packet", [
Leaf("prefix", @moon_boofuzz.Field::simple(b"PING ", [])),
Leaf("value", @moon_boofuzz.Field::simple(b"ok", [b"", b"\x00\xff"])),
]),
)
assert_eq(request.render(), b"PING ok")
let cases = request.cases(limit=1)
assert_eq(cases.next().map(case => case.payload), Some(b"PING "))
assert_eq(cases.next(), None)
assert_eq(cases.state(), Limited)
let resumed = request.cases(start=cases.position())
assert_eq(resumed.next().map(case => case.payload), Some(b"PING \x00\xff"))
}///|
test "group field" {
let field = @moon_boofuzz.Field::group([b"GET", b"POST", b"GET"])
assert_eq(field.default_value(), b"GET")
assert_eq(field.num_mutations(), 2)
assert_eq(field.mutation(0), Some(b"POST"))
assert_eq(field.mutation(1), Some(b"GET"))
}///|
test "minimal byte request" {
let request = @moon_boofuzz.Request::new([
@moon_boofuzz.Static(b"PING "),
@moon_boofuzz.Choice(b"ok", [b"", b"long"]),
])
assert_eq(request.render(), b"PING ok")
assert_eq(request.mutations(), [b"PING ", b"PING long"])
}pub struct CaseStream {
request : CompiledRequest
limit : Int
skip : Int
ordinal : Int
emitted : Int
state : EnumerationState
stack : Array[StreamFrame]
combinatorial : Bool
units : Array[StreamUnit]
max_depth : Int?
depth : Int
depth_emitted : Int
frames : Array[CombFrame]
vars : Map[String, Bytes]?
}pub struct ChecksumSpec {
target : String
endian : Endian
mutations : Array[Bytes]
algorithm : ChecksumAlgorithm
}fn CompiledRequest::cases(self : CompiledRequest, start? : Int, limit? : Int, vars? : Map[String, Bytes]?) -> CaseStream raise ModelErrorfn CompiledRequest::cases_with_variables(self : CompiledRequest, vars : Map[String, Bytes]?, start? : Int, limit? : Int) -> CaseStream raise ModelErrorfn CompiledRequest::combinatorial_cases(self : CompiledRequest, start? : Int, limit? : Int, max_depth? : Int) -> CaseStream raise ModelErrorfn CompiledRequest::combinatorial_cases_with_variables(self : CompiledRequest, vars : Map[String, Bytes]?, start? : Int, limit? : Int, max_depth? : Int) -> CaseStream raise ModelErrorfn CompiledRequest::from_request(name : String, request : Request, max_bytes? : Int) -> CompiledRequest raise ModelErrorfn CompiledRequest::raw_prefix_before(self : CompiledRequest, path : String) -> Int64 raise ModelErrorfn CompiledRequest::render_case(self : CompiledRequest, parts : Array[(String, Int)], vars : Map[String, Bytes]?) -> Bytes raise ModelErrorfn CompiledRequest::render_with(self : CompiledRequest, vars : Map[String, Bytes]?) -> Bytes raise ModelErrorpub struct Field {
value : Bytes
count : Int
candidate : (Int) -> Bytes
candidate_length : (Int) -> Int64
}fn Field::binary(value : Bytes, size? : Int, max_len? : Int, padding? : Bytes, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorfn Field::float(default_value? : Double, s_format? : String, f_min? : Double, f_max? : Double, max_mutations? : Int, seed? : Int64, encode_as_ieee_754? : Bool, endian? : Endian, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorfn Field::from_lines(default_value? : Bytes, lines? : Array[Bytes], max_len? : Int, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorfn Field::group(values : Array[Bytes], default_value? : Bytes, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorfn Field::integer(value : UInt64, width? : Int, endian? : Endian, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorfn Field::random_data(default_value? : Bytes, min_length? : Int, max_length? : Int, max_mutations? : Int, step? : Int, fuzzable? : Bool, fuzz_values? : Array[Bytes]) -> Field raise ModelErrorpub(all) enum Node {
Leaf(String, Field)
Nested(Block)
Repeat(String, String, Int, Int, Int, String?)
Sized(String, SizeSpec)
Checksummed(String, ChecksumSpec)
Mirrored(String, String)
Dynamic(String, String, Field)
}fn Node::checksum(name : String, target : String, endian? : Endian, mutations? : Array[UInt], fuzzable? : Bool, algorithm? : ChecksumAlgorithm) -> Node raise ModelErrorpub struct SessionGraph {
requests : Array[CompiledRequest]
edges : Array[Array[Int]]
names : Map[String, Int]
edge_callbacks : Map[(Int, Int), (StepContext) -> Bytes?]
}fn SessionGraph::connect(self : SessionGraph, from : String, to : String, callback? : (StepContext) -> Bytes?) -> Unit raise ModelErrorfn SessionGraph::paths(self : SessionGraph, targets? : Array[String], max_paths? : Int) -> Array[SessionPath] raise ModelErrorpub struct SessionPath {
requests : Array[CompiledRequest]
transitions : Array[(StepContext) -> Bytes??]
}fn SessionPath::cases(self : SessionPath, start? : Int, limit? : Int, variables? : Map[String, Bytes]?) -> CaseStream raise ModelErrorfn SessionPath::cases_with_variables(self : SessionPath, vars : Map[String, Bytes]?, start? : Int, limit? : Int) -> CaseStream raise ModelErrorfn SessionPath::combinatorial_cases_with_variables(self : SessionPath, vars : Map[String, Bytes]?, start? : Int, limit? : Int, max_depth? : Int) -> CaseStream raise ModelErrorfn adler32(bytes : Bytes) -> UIntfn crc32(bytes : Bytes) -> UIntfn crc32c(bytes : Bytes) -> UIntfn ipv4_checksum(header : Bytes) -> UIntfn udp_checksum(source : Bytes, destination : Bytes, udp_bytes : Bytes) -> UIntInstall
Download zipDeterministic protocol fuzzing core with native TCP/UDP execution and portable JSONL replay