From da601662d6225a704c21b424e40414ad62452ecc Mon Sep 17 00:00:00 2001 From: Shivam7-1 <55046031+Shivam7-1@users.noreply.github.com> Date: Sun, 29 Dec 2024 09:02:32 +0000 Subject: [PATCH] initial integration --- projects/grass-addons/Dockerfile | 4 +++ projects/grass-addons/build.sh | 9 +++++++ projects/grass-addons/fuzz_target.c | 39 +++++++++++++++++++++++++++++ projects/grass-addons/project.yaml | 8 ++++++ 4 files changed, 60 insertions(+) create mode 100644 projects/grass-addons/Dockerfile create mode 100644 projects/grass-addons/build.sh create mode 100644 projects/grass-addons/fuzz_target.c create mode 100644 projects/grass-addons/project.yaml diff --git a/projects/grass-addons/Dockerfile b/projects/grass-addons/Dockerfile new file mode 100644 index 000000000000..adbc5e2b8018 --- /dev/null +++ b/projects/grass-addons/Dockerfile @@ -0,0 +1,4 @@ +FROM gcr.io/oss-fuzz-base/base-builder +RUN git clone --depth 1 https://github.com/OSGeo/grass-addons.git /src/grass-addons +WORKDIR /src/grass-addons +COPY build.sh $SRC/ \ No newline at end of file diff --git a/projects/grass-addons/build.sh b/projects/grass-addons/build.sh new file mode 100644 index 000000000000..dbcbb4c86f5d --- /dev/null +++ b/projects/grass-addons/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash -eu + +mkdir build +cd build +cmake .. +make -j$(nproc) + +$CXX $CXXFLAGS -I /src/grass-addons/include /src/grass-addons/fuzz_target.c -o $OUT/fuzz_target \ + $LIB_FUZZING_ENGINE /src/grass-addons/src/*.o \ No newline at end of file diff --git a/projects/grass-addons/fuzz_target.c b/projects/grass-addons/fuzz_target.c new file mode 100644 index 000000000000..c77c35ca7f23 --- /dev/null +++ b/projects/grass-addons/fuzz_target.c @@ -0,0 +1,39 @@ +#include +#include +#include "pavl.h" +#include "sort.h" +#include "local_proto.h" +#include "test_simulation.cpp" +#include "test_treatments.cpp" + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) +{ + if (size < sizeof(int)) + return 0; + + int input = *(int *)data; + + // fuzz test for pavl_create function from pavl.h + struct pavl_table *table = pavl_create(NULL, NULL, NULL); + if (table) { + pavl_destroy(table, NULL); + } + + // fuzz test for Mergesort_increasing_smallest_azimuth function from sort.h + struct node head; + struct node tail; + Mergesort_increasing_smallest_azimuth(&head, &tail); + + // Fuzz test for functions from local_proto.h + float result = f_and(input, input, E); + result += f_or(input, input, E); + result += f_not(input, E); + + // Fuzz test for test_simulation.cpp + ret += test_calling_all_functions(); + + // Fuzz test for test_treatments.cpp + ret += test_steering(); + + return 0; +} \ No newline at end of file diff --git a/projects/grass-addons/project.yaml b/projects/grass-addons/project.yaml new file mode 100644 index 000000000000..3133458eb13e --- /dev/null +++ b/projects/grass-addons/project.yaml @@ -0,0 +1,8 @@ +name: grass-addons +path: OSGeo/grass-addons +homepage: "https://grass.osgeo.org/grass-stable/manuals/addons/" +language: c++ +primary_contact: "neteler@gmail.com" +fuzzing_engines: + - libfuzzer +main_repo: 'https://github.com/OSGeo/grass-addons' \ No newline at end of file