CodyKochmann / battle_tested

Fully automated python fuzzer built to test if code actually is production ready in seconds.
MIT License
103 stars 5 forks source link

Live render the fuzz result being built up. #45

Open CodyKochmann opened 5 years ago

CodyKochmann commented 5 years ago

Since everything is a pipeline, it would be easy to just live render the fuzz results being built up over time. Heres the base code to organize the display under pipeline logic.

from operator import itemgetter
from pprint import pprint

data = {
    (str, int): { # input types
        True: [],
        False: { # crash examples
            TypeError: [
                ('hi', 5),
                ('waffle', 0)
            ]
        }
    },
    (str, str): {
        True: [ # success examples
            [('waffle', 'syrup'), 'wafflesyrup'],
            [('exit()', 'break'), 'exit()break']
        ],
        False: {}
    },
    'success_combos': {
        (str, str)
    },
    'crash_combos': {
        (str, int)
    }
}

def organize_combos(success, crash):
    return success-crash, crash-success, success.intersection(crash)

def parse_result(pipe):
    success_crash = itemgetter('success_combos','crash_combos')
    for fuzz_result in pipe:
        successful, crash, iffy = organize_combos(
            *success_crash(fuzz_result)
        )
        pprint({'successful':successful,'crash':crash,'iffy':iffy})

if __name__ == '__main__':
    parse_result([data])