diff options
author | AnotherTest <ali.mpfard@gmail.com> | 2020-11-29 16:19:13 +0330 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-29 16:22:44 +0100 |
commit | 1ecea2f10511ffac8478d00935500be416b5228b (patch) | |
tree | 2de4c23ac240acefca0fc10ca14a0f829f17fce9 /Meta/Lagom | |
parent | e4bd5a5d69e23c79fee71506eed4b866ea6e0dc3 (diff) | |
download | serenity-1ecea2f10511ffac8478d00935500be416b5228b.zip |
Lagom: Add a Shell parser fuzzer
Diffstat (limited to 'Meta/Lagom')
-rw-r--r-- | Meta/Lagom/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Meta/Lagom/Fuzzers/FuzzShell.cpp | 38 |
3 files changed, 46 insertions, 3 deletions
diff --git a/Meta/Lagom/CMakeLists.txt b/Meta/Lagom/CMakeLists.txt index a5a287177b..5eb301a53d 100644 --- a/Meta/Lagom/CMakeLists.txt +++ b/Meta/Lagom/CMakeLists.txt @@ -64,10 +64,14 @@ file(GLOB LIBCRYPTO_SUBDIR_SOURCES CONFIGURE_DEPENDS "../../Libraries/LibCrypto/ file(GLOB LIBTLS_SOURCES CONFIGURE_DEPENDS "../../Libraries/LibTLS/*.cpp") file(GLOB SHELL_SOURCES CONFIGURE_DEPENDS "../../Shell/*.cpp") file(GLOB SHELL_TESTS CONFIGURE_DEPENDS "../../Shell/Tests/*.sh") +set(SHELL_MAIN_CPP "../../Shell/main.cpp") +set(LIB_SHELL_SOURCES ${SHELL_SOURCES}) +list(REMOVE_ITEM LIB_SHELL_SOURCES ${SHELL_MAIN_CPP}) +set(SHELL_SOURCES ${SHELL_MAIN_CPP}) set(LAGOM_REGEX_SOURCES ${LIBREGEX_LIBC_SOURCES} ${LIBREGEX_SOURCES}) set(LAGOM_CORE_SOURCES ${AK_SOURCES} ${LIBCORE_SOURCES}) -set(LAGOM_MORE_SOURCES ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES}) +set(LAGOM_MORE_SOURCES ${LIBELF_SOURCES} ${LIBIPC_SOURCES} ${LIBLINE_SOURCES} ${LIBJS_SOURCES} ${LIBJS_SUBDIR_SOURCES} ${LIBX86_SOURCES} ${LIBCRYPTO_SOURCES} ${LIBCOMPRESS_SOURCES} ${LIBCRYPTO_SUBDIR_SOURCES} ${LIBTLS_SOURCES} ${LIBMARKDOWN_SOURCES} ${LIBGEMINI_SOURCES} ${LIBGFX_SOURCES} ${LIBHTTP_SOURCES} ${LAGOM_REGEX_SOURCES} ${LIB_SHELL_SOURCES}) include_directories (../../) include_directories (../../Libraries/) @@ -77,8 +81,8 @@ add_library(LagomCore ${LAGOM_CORE_SOURCES}) if (BUILD_LAGOM) add_library(Lagom $<TARGET_OBJECTS:LagomCore> ${LAGOM_MORE_SOURCES}) - - if (NOT ENABLE_OSS_FUZZ) + + if (NOT ENABLE_OSS_FUZZ) add_executable(TestApp TestApp.cpp) target_link_libraries(TestApp Lagom) target_link_libraries(TestApp stdc++) diff --git a/Meta/Lagom/Fuzzers/CMakeLists.txt b/Meta/Lagom/Fuzzers/CMakeLists.txt index 33be3357b1..c872ecb44a 100644 --- a/Meta/Lagom/Fuzzers/CMakeLists.txt +++ b/Meta/Lagom/Fuzzers/CMakeLists.txt @@ -29,6 +29,7 @@ add_simple_fuzzer(FuzzJs) add_simple_fuzzer(FuzzMarkdown) add_simple_fuzzer(FuzzRegexECMA262) add_simple_fuzzer(FuzzRegexPosixExtended) +add_simple_fuzzer(FuzzShell) if (NOT ENABLE_OSS_FUZZ) add_executable(FuzzilliJs FuzzilliJs.cpp) diff --git a/Meta/Lagom/Fuzzers/FuzzShell.cpp b/Meta/Lagom/Fuzzers/FuzzShell.cpp new file mode 100644 index 0000000000..abb02c2f68 --- /dev/null +++ b/Meta/Lagom/Fuzzers/FuzzShell.cpp @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020, the SerenityOS developers. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <AK/StringView.h> +#include <Shell/Shell.h> +#include <stddef.h> +#include <stdint.h> + +extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) +{ + auto source = AK::StringView(static_cast<const unsigned char*>(data), size); + Shell::Parser parser(source); + parser.parse(); + return 0; +} |