1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-29 09:27:46 +00:00

Lagom: Add fuzz testing for LibJS using libFuzzer (#1692)

Note: clang only (see https://llvm.org/docs/LibFuzzer.html)

- add FuzzJs which will run the LibJS parser on random javascript inputs
- added a basic dictionary of javascript tokens

To use fuzzer:
CC=/usr/bin/clang CXX=/usr/bin/clang++ cmake -DENABLE_FUZZER_SANITIZER=1 ..
Fuzzers/FuzzJs -dict=../Fuzzers/FuzzJs.dict
This commit is contained in:
Paul Redmond 2020-04-08 04:40:02 -04:00 committed by GitHub
parent e91cb83a23
commit 7291d5c86f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 140 additions and 0 deletions

View file

@ -24,6 +24,12 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=undefined")
endif()
option(ENABLE_FUZZER_SANITIZER "Enable fuzzer sanitizer testing in clang" FALSE)
if (ENABLE_FUZZER_SANITIZER)
add_definitions(-fsanitize=fuzzer -fno-omit-frame-pointer)
set(LINKER_FLAGS "${LINKER_FLAGS} -fsanitize=fuzzer-no-link")
endif()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")
@ -57,3 +63,7 @@ add_executable(js ../../Userland/js.cpp)
target_link_libraries(js lagom)
target_link_libraries(js stdc++)
target_link_libraries(js pthread)
if (ENABLE_FUZZER_SANITIZER)
add_subdirectory(Fuzzers)
endif()