From 456d7db7571bc9e2e5af91d9bc05f71dd5fa272c Mon Sep 17 00:00:00 2001 From: Alexander Senier Date: Mon, 13 May 2024 23:29:58 +0200 Subject: [PATCH] Fix fuzzer fuzzing test --- examples/fuzz_cobrafuzz/fuzz.py | 17 +++++++++++++++++ tests/fuzz_fuzzer.py | 15 --------------- tests/integration/test_examples.py | 1 + 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100755 examples/fuzz_cobrafuzz/fuzz.py delete mode 100755 tests/fuzz_fuzzer.py diff --git a/examples/fuzz_cobrafuzz/fuzz.py b/examples/fuzz_cobrafuzz/fuzz.py new file mode 100755 index 00000000..8814c522 --- /dev/null +++ b/examples/fuzz_cobrafuzz/fuzz.py @@ -0,0 +1,17 @@ +#!/usr/bin/env -S python3 -O + +import contextlib + +from cobrafuzz.common import OutOfBoundsError +from cobrafuzz.main import CobraFuzz +from cobrafuzz.mutator import Mutator + + +@CobraFuzz +def fuzz(data: bytes) -> None: + with contextlib.suppress(OutOfBoundsError): + Mutator()._mutate(bytearray(data)) # noqa: SLF001 + + +if __name__ == "__main__": + fuzz() diff --git a/tests/fuzz_fuzzer.py b/tests/fuzz_fuzzer.py deleted file mode 100755 index fc87c633..00000000 --- a/tests/fuzz_fuzzer.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env -S python3 -O - -from cobrafuzz.main import CobraFuzz -from cobrafuzz.mutator import Corpus - -CORPUS = Corpus() - - -@CobraFuzz -def fuzz(data: bytes) -> None: - CORPUS.mutate(bytearray(data)) - - -if __name__ == "__main__": - fuzz() diff --git a/tests/integration/test_examples.py b/tests/integration/test_examples.py index 8275dc8e..b3bbdeec 100644 --- a/tests/integration/test_examples.py +++ b/tests/integration/test_examples.py @@ -11,6 +11,7 @@ "aifc", "bs", "charset_normalizer", + "cobrafuzz", "codeop", "furl", "htmlparser",