fuzz-target-payload-codec: the §3.1 target — all five invariants in shared, thin fuzz_target wrapper, 97 committed seeds + gitignore negation + README row; placeholder bin replaced; serde (derive) added to shared
This commit is contained in:
1 parent
21ab6fe564
commit
1f6cc0970a
108 files changed
+583
-24
No files matched your search
+101
-1
@@ -24,8 +24,108 @@ def write_seed(target, i, data):
|
||||
f.write(data)
|
||||
|
||||
|
||||
def payload_codec_seeds():
|
||||
i = 0
|
||||
|
||||
# Valid JSON of every Value variant (numbers incl. bounds/floats,
|
||||
# strings incl. escapes/unicode, arrays, objects), plus whitespace
|
||||
# padding.
|
||||
valid_docs = [
|
||||
b"null",
|
||||
b"true",
|
||||
b"false",
|
||||
b"0",
|
||||
b"-1",
|
||||
b"-9223372036854775808",
|
||||
b"9223372036854775807",
|
||||
b"18446744073709551615",
|
||||
b"18446744073709551616",
|
||||
b"3.5",
|
||||
b"-2.25",
|
||||
b"1e10",
|
||||
b"1e309",
|
||||
b"-0",
|
||||
b'""',
|
||||
b'"hello world"',
|
||||
b'"unicode \\u00e9"',
|
||||
b'"emoji \\ud83d\\ude00"',
|
||||
b'"tab\\tnewline\\nquote\\"slash"',
|
||||
b'"null"',
|
||||
b"[]",
|
||||
b'[1, "two", null, true, {"three": 3}, []]',
|
||||
b"{}",
|
||||
b'{"a": 1}',
|
||||
b'{"a": 1, "nested": {"deep": [true, null, 3.5]}}',
|
||||
b'{"\\u00e9": "value"}',
|
||||
b' \t\r\n{"spaced": true}\t\n ',
|
||||
]
|
||||
for doc in valid_docs:
|
||||
write_seed("payload_codec", i, doc)
|
||||
i += 1
|
||||
|
||||
# Truncations at every prefix length of two representative docs.
|
||||
for doc in [b'{"a": 1, "b": [2, 3]}', b"[true, null, 1.5]"]:
|
||||
for n in range(1, len(doc)):
|
||||
write_seed("payload_codec", i, doc[:n])
|
||||
i += 1
|
||||
|
||||
# Deep nesting: shallow, at/near serde_json's 128 recursion limit,
|
||||
# and well past it. Arrays and objects both.
|
||||
for depth in [8, 127, 128, 129, 256, 1024]:
|
||||
write_seed("payload_codec", i, ("[" * depth + "0" + "]" * depth).encode())
|
||||
i += 1
|
||||
for depth in [8, 200]:
|
||||
write_seed("payload_codec", i, ('{"a":' * depth + "1" + "}" * depth).encode())
|
||||
i += 1
|
||||
|
||||
# Non-UTF-8 bytes inside and outside string positions.
|
||||
for raw in [b"\xff\xfe\xfd", b'{"a": "\xff"}', b"[1, 2\xff]"]:
|
||||
write_seed("payload_codec", i, raw)
|
||||
i += 1
|
||||
|
||||
# Trailing garbage after a valid document.
|
||||
for raw in [
|
||||
b"{} trailing",
|
||||
b"[1]x",
|
||||
b"1 2",
|
||||
b"null null",
|
||||
b'"first""second"',
|
||||
]:
|
||||
write_seed("payload_codec", i, raw)
|
||||
i += 1
|
||||
|
||||
# Duplicate keys (canonicalization is serde_json's).
|
||||
for raw in [b'{"a": 1, "a": 2}', b'{"o": {"k": 1, "k": 2}, "o": 3}']:
|
||||
write_seed("payload_codec", i, raw)
|
||||
i += 1
|
||||
|
||||
# The Null-decode shape: an empty byte store must never decode to
|
||||
# a silent Null (ADR-023 §1).
|
||||
for raw in [b"", b" ", b"null", b"nullx"]:
|
||||
write_seed("payload_codec", i, raw)
|
||||
i += 1
|
||||
|
||||
# Other loud-fail shapes (typed `Codec` partition coverage).
|
||||
for raw in [
|
||||
b"NaN",
|
||||
b"Infinity",
|
||||
b"+1",
|
||||
b"01",
|
||||
b".5",
|
||||
b"1.",
|
||||
b"--1",
|
||||
b"{,}",
|
||||
b"[1,]",
|
||||
b'{"a"}',
|
||||
b'{"missing": }',
|
||||
b"\x80\x81\x82",
|
||||
]:
|
||||
write_seed("payload_codec", i, raw)
|
||||
i += 1
|
||||
|
||||
|
||||
def main():
|
||||
pass
|
||||
payload_codec_seeds()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user