Skip to content

Commit

Permalink
Add clusterfuzzlite to fuzz in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes authored and dagar committed Jan 7, 2022
1 parent 9eda5b3 commit 2cbc993
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .clusterfuzzlite/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/oss-fuzz-base/base-builder:v1
COPY . $SRC/PX4-Autopilot
RUN apt-get install -y libjpeg8-dev zlib1g-dev
RUN pip3 install --upgrade pip
RUN python3 -m pip install -r $SRC/PX4-Autopilot/Tools/setup/requirements.txt
WORKDIR $SRC/PX4-Autopilot
COPY ./.clusterfuzzlite/build.sh $SRC/
4 changes: 4 additions & 0 deletions .clusterfuzzlite/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash -eu

PX4_FUZZ=1 make px4_sitl
cp build/px4_sitl_default/bin/px4 $OUT/px4
1 change: 1 addition & 0 deletions .clusterfuzzlite/project.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
language: c++
43 changes: 43 additions & 0 deletions .github/workflows/cflite_pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ClusterFuzzLite PR fuzzing
on:
pull_request:
paths:
- '**'
permissions: read-all
jobs:
PR:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
sanitizer:
- address
- undefined
- memory
steps:
- name: Build Fuzzers (${{ matrix.sanitizer }})
id: build
uses: google/clusterfuzzlite/actions/build_fuzzers@v1
with:
sanitizer: ${{ matrix.sanitizer }}
# Optional but recommended: used to only run fuzzers that are affected
# by the PR.
# See later section on "Git repo for storage".
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git
# storage-repo-branch: main # Optional. Defaults to "main"
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".
- name: Run Fuzzers (${{ matrix.sanitizer }})
id: run
uses: google/clusterfuzzlite/actions/run_fuzzers@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
fuzz-seconds: 600
mode: 'code-change'
sanitizer: ${{ matrix.sanitizer }}
# Optional but recommended: used to download the corpus produced by
# batch fuzzing.
# See later section on "Git repo for storage".
# storage-repo: https://${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/OWNER/STORAGE-REPO-NAME.git
# storage-repo-branch: main # Optional. Defaults to "main"
# storage-repo-branch-coverage: gh-pages # Optional. Defaults to "gh-pages".

2 changes: 0 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ else

# Fuzz Testing
ifdef PX4_FUZZ
export CC=clang
export CXX=clang++
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=FuzzTesting
endif

Expand Down
8 changes: 7 additions & 1 deletion cmake/px4_add_common_flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,20 @@ function(px4_add_common_flags)
set(cxx_flags)
list(APPEND cxx_flags
-fno-exceptions
-fno-rtti
-fno-threadsafe-statics

-Wreorder

# disabled warnings
-Wno-overloaded-virtual # TODO: fix and remove
)

if(NOT CMAKE_BUILD_TYPE STREQUAL FuzzTesting)
list(APPEND cxx_flags
-fno-rtti
)
endif()

foreach(flag ${cxx_flags})
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:${flag}>)
endforeach()
Expand Down
9 changes: 5 additions & 4 deletions cmake/sanitizers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ elseif (CMAKE_BUILD_TYPE STREQUAL FuzzTesting)

add_compile_options(
-g3
-fsanitize=fuzzer,address,undefined
-fsanitize=fuzzer
-DFUZZTESTING
)

set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=fuzzer,address,undefined" CACHE INTERNAL "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=fuzzer $ENV{LIB_FUZZING_ENGINE}" CACHE INTERNAL "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=fuzzer $ENV{LIB_FUZZING_ENGINE}" CACHE INTERNAL "" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=fuzzer $ENV{LIB_FUZZING_ENGINE}" CACHE INTERNAL "" FORCE)


function(sanitizer_fail_test_on_error test_name)
# Not sure what to do here
Expand Down

0 comments on commit 2cbc993

Please sign in to comment.