mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:18:11 +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:
parent
e91cb83a23
commit
7291d5c86f
4 changed files with 140 additions and 0 deletions
14
Meta/Lagom/Fuzzers/FuzzJs.cpp
Normal file
14
Meta/Lagom/Fuzzers/FuzzJs.cpp
Normal file
|
@ -0,0 +1,14 @@
|
|||
#include <AK/StringView.h>
|
||||
#include <LibJS/Lexer.h>
|
||||
#include <LibJS/Parser.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
|
||||
{
|
||||
auto js = AK::StringView(static_cast<const unsigned char*>(data), size);
|
||||
auto lexer = JS::Lexer(js);
|
||||
auto parser = JS::Parser(lexer);
|
||||
parser.parse_program();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue