From 797ea356efad0ce6c168b72cc3c9ecdc11c291a8 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Sun, 19 Feb 2017 21:30:22 +0100 Subject: [PATCH] Fuzzing: Better seed corpus --- fuzzing/fuzz.sh | 1 + fuzzing/seed_corpus/ArduinoJson.json | 8 -------- fuzzing/seed_corpus/Comments.json | 10 ++++++++++ fuzzing/seed_corpus/EmptyArray.json | 1 + fuzzing/seed_corpus/EmptyObject.json | 1 + fuzzing/seed_corpus/ExcessiveNesting.json | 1 + fuzzing/seed_corpus/Numbers.json | 18 ++++++++++++++++++ fuzzing/seed_corpus/Strings.json | 8 ++++++++ scripts/oss-fuzz/Vagrantfile | 2 ++ 9 files changed, 42 insertions(+), 8 deletions(-) delete mode 100644 fuzzing/seed_corpus/ArduinoJson.json create mode 100644 fuzzing/seed_corpus/Comments.json create mode 100644 fuzzing/seed_corpus/EmptyArray.json create mode 100644 fuzzing/seed_corpus/EmptyObject.json create mode 100644 fuzzing/seed_corpus/ExcessiveNesting.json create mode 100644 fuzzing/seed_corpus/Numbers.json create mode 100644 fuzzing/seed_corpus/Strings.json diff --git a/fuzzing/fuzz.sh b/fuzzing/fuzz.sh index 0a7399c5..47af7553 100755 --- a/fuzzing/fuzz.sh +++ b/fuzzing/fuzz.sh @@ -1,6 +1,7 @@ #!/bin/bash # This script mimics an invocation from https://github.com/google/oss-fuzz +cd $(dirname $0) export CXX='clang++' export CXXFLAGS='-fsanitize-coverage=trace-pc-guard -fsanitize=address' export LIB_FUZZING_ENGINE=-lFuzzer diff --git a/fuzzing/seed_corpus/ArduinoJson.json b/fuzzing/seed_corpus/ArduinoJson.json deleted file mode 100644 index 0cd31670..00000000 --- a/fuzzing/seed_corpus/ArduinoJson.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "sensor": "gps", - "time": 1351824120, - "data": [ - 48.75608, - 2.302038 - ] -} diff --git a/fuzzing/seed_corpus/Comments.json b/fuzzing/seed_corpus/Comments.json new file mode 100644 index 00000000..bcc4cece --- /dev/null +++ b/fuzzing/seed_corpus/Comments.json @@ -0,0 +1,10 @@ +//comment +/*comment*/ +[ //comment +/*comment*/"comment"/*comment*/,//comment +/*comment*/{//comment +/* comment*/"key"//comment +: //comment +"value"//comment +}/*comment*/ +]//comment \ No newline at end of file diff --git a/fuzzing/seed_corpus/EmptyArray.json b/fuzzing/seed_corpus/EmptyArray.json new file mode 100644 index 00000000..0637a088 --- /dev/null +++ b/fuzzing/seed_corpus/EmptyArray.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/fuzzing/seed_corpus/EmptyObject.json b/fuzzing/seed_corpus/EmptyObject.json new file mode 100644 index 00000000..9e26dfee --- /dev/null +++ b/fuzzing/seed_corpus/EmptyObject.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/fuzzing/seed_corpus/ExcessiveNesting.json b/fuzzing/seed_corpus/ExcessiveNesting.json new file mode 100644 index 00000000..9285019a --- /dev/null +++ b/fuzzing/seed_corpus/ExcessiveNesting.json @@ -0,0 +1 @@ +[1,[2,[3,[4,[5,[6,[7,[8,[9,[10,[11,[12,[13,[14,[15,[16,[17,[18,[19,[20,[21,[22,[23,[24,[25,[26,[27,[28,[29,[30,[31,[32,[33,[34,[35,[36,[37,[38,[39,[40,[41,[42,[43,[44,[45,[46,[47,[48,[49,[50,[51,[52,[53,[54,[55,[56,[57,[58,[59,[60,[61,[62,[63,[64,[65,[66,[67,[68,[69,[70,[71,[72,[73,[74,[75,[76,[77,[78,[79,[80,[81,[82,[83,[84,[85,[86,[87,[88,[89,[90,[91,[92,[93,[94,[95,[96,[97,[98,[99,[100,[101,[102,[103,[104,[105,[106,[107,[108,[109,[110,[111,[112,[113,[114,[115,[116,[117,[118,[119,[120]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]] \ No newline at end of file diff --git a/fuzzing/seed_corpus/Numbers.json b/fuzzing/seed_corpus/Numbers.json new file mode 100644 index 00000000..7ce8ef62 --- /dev/null +++ b/fuzzing/seed_corpus/Numbers.json @@ -0,0 +1,18 @@ +[ + 123, + -123, + 123.456, + -123.456, + 12e34, + 12e-34, + 12e+34, + 12E34, + 12E-34, + 12E+34, + 12.34e56, + 12.34e-56, + 12.34e+56, + 12.34E56, + 12.34E-56, + 12.34E+56 +] \ No newline at end of file diff --git a/fuzzing/seed_corpus/Strings.json b/fuzzing/seed_corpus/Strings.json new file mode 100644 index 00000000..3ffa235e --- /dev/null +++ b/fuzzing/seed_corpus/Strings.json @@ -0,0 +1,8 @@ +[ + "hello", + 'hello', + hello, + {"hello":"world"}, + {'hello':'world'}, + {hello:world} +] \ No newline at end of file diff --git a/scripts/oss-fuzz/Vagrantfile b/scripts/oss-fuzz/Vagrantfile index e06c9f1f..ab44af43 100644 --- a/scripts/oss-fuzz/Vagrantfile +++ b/scripts/oss-fuzz/Vagrantfile @@ -26,5 +26,7 @@ Vagrant.configure(2) do |config| echo "export PROJECT_NAME='arduinojson'" >> $HOME/.profile echo "export CC='clang'" >> $HOME/.profile echo "export CXX='clang++'" >> $HOME/.profile + + echo "Run /host/ArduinoJson/fuzzing/fuzz.sh" | sudo tee /etc/motd SHELL end