Implemented Ruby fuzzing (#3339)
This PR implements fuzzing for Ruby library using https://github.com/trailofbits/ruzzy, a coverage-guided fuzzer for pure Ruby code and Ruby C extensions based on libFuzzer. Implemented binary, compact, and JSON protocol fuzzers.
A separate PR will follow to address OOM and a crash caused by unchecked memory allocation in structs (Edit: #3340).
diff --git a/lib/rb/Rakefile b/lib/rb/Rakefile
index 7b51145..d1f0f7c 100644
--- a/lib/rb/Rakefile
+++ b/lib/rb/Rakefile
@@ -38,7 +38,7 @@
end
desc 'Compile the .thrift files for the specs'
-task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:namespaced_spec', :'gen-rb:flat_spec', :'gen-rb:benchmark', :'gen-rb:debug_proto', :'gen-rb:constants_demo']
+task :'gen-rb' => [:'gen-rb:spec', :'gen-rb:namespaced_spec', :'gen-rb:flat_spec', :'gen-rb:benchmark', :'gen-rb:debug_proto', :'gen-rb:constants_demo', :'gen-rb:fuzz']
namespace :'gen-rb' do
task :'spec' do
dir = File.dirname(__FILE__) + '/spec'
@@ -72,6 +72,12 @@
dir = File.dirname(__FILE__) + '/spec'
sh THRIFT, '--gen', 'rb:namespaced', '--recurse', '-o', dir, "../../test/ConstantsDemo.thrift"
end
+
+ task :'fuzz' do
+ dir = File.dirname(__FILE__) + '/test/fuzz'
+ sh "mkdir", "-p", dir
+ sh THRIFT, '--gen', 'rb', '-o', dir, "../../test/FuzzTest.thrift"
+ end
end
desc "Build the native library"