]> Cypherpunks repositories - keks.git/commitdiff
Fuzzing related scripts
authorSergey Matveev <stargrave@stargrave.org>
Thu, 5 Dec 2024 09:57:38 +0000 (12:57 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 5 Dec 2024 09:57:38 +0000 (12:57 +0300)
pyac/fuzz.py [new file with mode: 0755]
tyac/mk-fuzz-inputs [new file with mode: 0755]

diff --git a/pyac/fuzz.py b/pyac/fuzz.py
new file mode 100755 (executable)
index 0000000..603d696
--- /dev/null
@@ -0,0 +1,17 @@
+#!/usr/bin/env python3
+
+from sys import stdin
+from os import _exit
+
+import afl
+
+from pyac import loads
+from pyac import DecodeError
+
+afl.init()
+data = stdin.buffer.read()
+try:
+    loads(data)
+except DecodeError:
+    pass
+_exit(0)
diff --git a/tyac/mk-fuzz-inputs b/tyac/mk-fuzz-inputs
new file mode 100755 (executable)
index 0000000..a08bbf6
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh -e
+
+dump() {
+    args "$1" | xxd -r -p
+}
+
+dump 'BIN ""' >bin-empty
+dump 'BIN [binary decode hex "01020304"]' >bin-1234
+dump 'STR ""' >str-empty
+dump 'STR "foo"' >str-foo
+dump 'TRUE' >true
+dump 'FALSE' >false
+dump 'NIL' >nil
+dump 'INT 0' >int=0
+dump 'INT -1' >int=-1
+dump 'INT 10' >int=10
+dump 'INT -10' >int=-10
+dump 'INT 500' >int=500
+dump 'INT -500' >int=-500
+dump 'BLOB 2 ""' >blob-empty
+dump 'BLOB 2 "f"' >blob-f
+dump 'BLOB 2 "fo"' >blob-fo
+dump 'BLOB 2 "foo"' >blob-foo
+dump 'LIST {}' >list-empty
+dump 'LIST {NIL}' >list-nil
+dump 'LIST {TRUE FALSE}' >list-bool
+dump 'MAP {}' >map-empty
+dump 'MAP {a {LIST {NIL}}}' >map-foo
+dump 'TAI64 [UTCFromISO "1970-01-01 00:00:00"]' >tai-utc0
+dump 'TAI64 -11' >tai-before
+dump 'RAW [expr 0x18] [binary decode hex "40000000586846A4"]' >tai-leap
+dump 'TAI64 1234 1234' >tai-ns
+dump 'TAI64 1234 1234 1234' >tai-as