From f7099dd4e1b4dde4d1087e0d3302c9cc1c970b70 Mon Sep 17 00:00:00 2001 From: Christopher Krah Date: Tue, 14 May 2024 15:32:08 +0400 Subject: [PATCH] feat: add simple fuzz testing for NMEA/RTCM parsers --- src/ntrip_client/nmea_fuzz_test.py | 17 +++++++++++++++++ src/ntrip_client/rtcm_fuzz_test.py | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 src/ntrip_client/nmea_fuzz_test.py create mode 100644 src/ntrip_client/rtcm_fuzz_test.py diff --git a/src/ntrip_client/nmea_fuzz_test.py b/src/ntrip_client/nmea_fuzz_test.py new file mode 100644 index 0000000..af82d86 --- /dev/null +++ b/src/ntrip_client/nmea_fuzz_test.py @@ -0,0 +1,17 @@ +try: + import atheris +except ImportError: + raise ImportError("You need to install atheris to run this script.") +import sys + +with atheris.instrument_imports(): + from nmea_parser import NMEAParser + + +def TestOneInput(data): + parser = NMEAParser() + parser.is_valid_sentence(data) + + +atheris.Setup(sys.argv, TestOneInput) +atheris.Fuzz() diff --git a/src/ntrip_client/rtcm_fuzz_test.py b/src/ntrip_client/rtcm_fuzz_test.py new file mode 100644 index 0000000..ab73336 --- /dev/null +++ b/src/ntrip_client/rtcm_fuzz_test.py @@ -0,0 +1,17 @@ +try: + import atheris +except ImportError: + raise ImportError("You need to install atheris to run this script.") +import sys + +with atheris.instrument_imports(): + from rtcm_parser import RTCMParser + + +def TestOneInput(data): + parser = RTCMParser() + parser.parse(data) + + +atheris.Setup(sys.argv, TestOneInput) +atheris.Fuzz()