From bfb383b4fd4aa66d7b953e74138513253573d711 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 1 Aug 2024 14:05:26 +0000 Subject: [PATCH 1/2] ci: move the fuzz target from OSS-Fuzz as discussed in https://github.com/google/oss-fuzz/pull/12050 --- scapy/tools/pcap_fuzzer.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 scapy/tools/pcap_fuzzer.py diff --git a/scapy/tools/pcap_fuzzer.py b/scapy/tools/pcap_fuzzer.py new file mode 100755 index 00000000000..2fed1f490a8 --- /dev/null +++ b/scapy/tools/pcap_fuzzer.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +# SPDX-License-Identifier: GPL-2.0-only +# This file is part of Scapy +# See https://scapy.net/ for more information + +import sys +import atheris + +with atheris.instrument_imports(): + import io + import scapy + import scapy.error + import scapy.layers.all + import scapy.utils + + +def TestOneInput(input_bytes): + try: + for p in scapy.utils.rdpcap(io.BytesIO(input_bytes)): + p.summary() + except scapy.error.Scapy_Exception: + pass + + +def main(): + atheris.Setup(sys.argv, TestOneInput) + atheris.Fuzz() + + +if __name__ == "__main__": + main() From 475f96e25d66037567d1465e9635f5ea31629421 Mon Sep 17 00:00:00 2001 From: Evgeny Vereshchagin Date: Thu, 1 Aug 2024 14:06:02 +0000 Subject: [PATCH 2/2] fuzz: make it venv-friendly --- scapy/tools/pcap_fuzzer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scapy/tools/pcap_fuzzer.py b/scapy/tools/pcap_fuzzer.py index 2fed1f490a8..0e1417b673c 100755 --- a/scapy/tools/pcap_fuzzer.py +++ b/scapy/tools/pcap_fuzzer.py @@ -1,4 +1,4 @@ -#!/usr/bin/python3 +#!/usr/bin/env python # SPDX-License-Identifier: GPL-2.0-only # This file is part of Scapy