Esempio n. 1
0
def _fuzztest_child(test_one_input, custom_setup, setup_kwargs, pipe, args,
                    enabled_hooks):
    """Fuzzing target to run as a separate process."""
    os.close(pipe[0])
    os.dup2(pipe[1], 1)
    os.dup2(pipe[1], 2)

    if not setup_kwargs:
        setup_kwargs = {}

    try:
        if enabled_hooks:
            for hook in enabled_hooks:
                atheris.enabled_hooks.add(hook)
        custom_setup([sys.argv[0]] + (args if args else []), test_one_input,
                     **setup_kwargs)
        atheris.Fuzz()

        # To avoid running tests multiple times due to fork(), never allow control
        # flow to proceed past here. Report that we're exiting gracefully so that
        # tests can verify that's what happened.
    except SystemExit as e:
        print("Exiting gracefully.")
        sys.stdout.flush()
        os._exit(e.code)
    finally:
        print("Exiting gracefully.")
        sys.stdout.flush()
        os._exit(0)
Esempio n. 2
0
def main():
    global runs_left
    max_runs = get_run_count_if_there()
    if max_runs is not None:
        runs_left = int(max_runs)

    t1 = ServerThread()
    t1.start()
    atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
    atheris.Fuzz()
Esempio n. 3
0
def _benchmark_child(test_one_input, num_runs, pipe, args, inst_all):
    os.close(pipe[0])
    os.dup2(pipe[1], 1)
    os.dup2(pipe[1], 2)

    if inst_all:
        instrument_all()

    counter = [0]
    start = time.time()

    def wrapped_test_one_input(data):
        counter[0] += 1
        if counter[0] == num_runs:
            print(f"\nbenchmark_duration={time.time() - start}")
            os._exit(0)
        test_one_input(data)

    atheris.Setup([sys.argv[0]] + args, wrapped_test_one_input)
    atheris.Fuzz()
    assert False  # Does not return
Esempio n. 4
0
def main():
    atheris.Setup(sys.argv, TestOneInput)
    atheris.Fuzz()
Esempio n. 5
0
def main():
  logging.disable(logging.CRITICAL)
  warnings.filterwarnings('ignore')
  atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
  atheris.Fuzz()
Esempio n. 6
0
def main():
    atheris.instrument_all()
    atheris.Setup(sys.argv, TestOneInput)
    atheris.Fuzz()
Esempio n. 7
0
 def test_bigNumbers_fuzzing(self):
     args = sys.argv
     args.append("-runs=10000")
     atheris.Setup(args, self.__setup_input_big_numbers)
     atheris.Fuzz()
Esempio n. 8
0
 def test_prime_generator_fuzzing(self):
     args = sys.argv
     args.append("-runs=100")
     atheris.Setup(args, self.__setup_input_prime_generator)
     atheris.Fuzz()
Esempio n. 9
0
def fuzz():
    test = deal.cases(decode)
    atheris.Setup(sys.argv, test)
    atheris.Fuzz()
Esempio n. 10
0
def main():
    fuzzers.enable_decompressionbomb_error()
    atheris.Setup(sys.argv, TestOneInput)
    atheris.Fuzz()
    fuzzers.disable_decompressionbomb_error()
Esempio n. 11
0
def fuzz(wsgi_app):
    atheris.Setup(sys.argv, lambda data: fuzz_request(data, wsgi_app), enable_python_coverage=True)
    atheris.Fuzz()
Esempio n. 12
0
 def test_random_curve_fuzzing(self):
     args = sys.argv
     args.append("-runs=10000")
     atheris.Setup(args, self.__setup_input_random_curve)
     atheris.Fuzz()
Esempio n. 13
0
 def test_point_arithmetic_affine_fuzzing(self):
     args = sys.argv
     args.append("-runs=10000")
     atheris.Setup(args, self.__setup_input_arithmetic_affine)
     atheris.Fuzz()
Esempio n. 14
0
import sys

import atheris

with atheris.instrument_imports():
    import fuzzers


def TestOneInput(data):
    fdp = atheris.FuzzedDataProvider(data)
    choice = fdp.ConsumeIntInRange(0, len(fuzzers.tests) - 1)
    func, data_type = fuzzers.tests[choice]

    if data_type == str:
        data = fdp.ConsumeUnicodeNoSurrogates(sys.maxsize)
    elif data_type == bytes:
        data = fdp.ConsumeBytes(sys.maxsize)
    elif data_type == int:
        data = fdp.ConsumeInt(sys.maxsize)

    try:
        func(data)
    except Exception:
        print(func, data_type, repr(data))
        raise


atheris.Setup(sys.argv, TestOneInput)
atheris.Fuzz()
Esempio n. 15
0
def main():
    ImageFile.LOAD_TRUNCATED_IMAGES = True
    warnings.filterwarnings("ignore")
    atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=False)
    atheris.Fuzz()
Esempio n. 16
0
def main():
    atheris.Setup(sys.argv, TestInput, enable_python_coverage=True)
    atheris.Fuzz()
Esempio n. 17
0
def main():
    # Since everything interesting in this fuzzer is in native code, we can
    # disable Python coverage to improve performance and reduce coverage noise.
    atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=False)
    atheris.Fuzz()
Esempio n. 18
0
def main():
    atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
    loop = asyncio.get_event_loop()
    asyncio.set_event_loop(loop)
    atheris.Fuzz()
Esempio n. 19
0
 def test_modularearithmetic_eff_fuzzing(self):
     args = sys.argv
     args.append("-runs=10000")
     atheris.Setup(args, self.__setup_input_modular_arithmetic)
     atheris.Fuzz()
Esempio n. 20
0
def main():
    atheris.instrument_all()
    atheris.Setup(sys.argv, TestOneInput, enable_python_coverage=True)
    atheris.Fuzz()
Esempio n. 21
0
def main():
    """Fuzz target with atheris."""
    atheris.Setup(sys.argv, TestOneInput)
    atheris.Fuzz()