From 319ec9a2a0264c645755769e5e1d779612feed438bb6433e0db791550116603e Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Thu, 5 Dec 2024 12:57:38 +0300 Subject: [PATCH] Fuzzing related scripts --- pyac/fuzz.py | 17 +++++++++++++++++ tyac/mk-fuzz-inputs | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100755 pyac/fuzz.py create mode 100755 tyac/mk-fuzz-inputs diff --git a/pyac/fuzz.py b/pyac/fuzz.py new file mode 100755 index 0000000..603d696 --- /dev/null +++ b/pyac/fuzz.py @@ -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 index 0000000..a08bbf6 --- /dev/null +++ b/tyac/mk-fuzz-inputs @@ -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 -- 2.50.0