diff --git a/Rakefile b/Rakefile index 84f3a2b..ad73624 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,12 @@ -require "rake/testtask" -require "rake/extensiontask" +# frozen_string_literal: true + +require 'rake/testtask' +require 'rake/extensiontask' Rake::TestTask.new do |t| t.verbose = true end -Rake::ExtensionTask.new "cruzzy" do |ext| - ext.lib_dir = "lib/cruzzy" +Rake::ExtensionTask.new 'cruzzy' do |ext| + ext.lib_dir = 'lib/cruzzy' end diff --git a/bin/dummy.rb b/bin/dummy.rb index 4b227fb..9487c7d 100644 --- a/bin/dummy.rb +++ b/bin/dummy.rb @@ -1,5 +1,7 @@ -require "ruzzy" +# frozen_string_literal: true -dummy_test_one_input = lambda {|data| Ruzzy.c_dummy_test_one_input(data)} +require 'ruzzy' + +dummy_test_one_input = ->(data) { Ruzzy.c_dummy_test_one_input(data) } Ruzzy.fuzz(dummy_test_one_input) diff --git a/ext/cruzzy/extconf.rb b/ext/cruzzy/extconf.rb index 024e2d3..82cac56 100644 --- a/ext/cruzzy/extconf.rb +++ b/ext/cruzzy/extconf.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'mkmf' create_makefile('cruzzy/cruzzy') diff --git a/lib/ruzzy.rb b/lib/ruzzy.rb index d5ae95c..2d4cf17 100644 --- a/lib/ruzzy.rb +++ b/lib/ruzzy.rb @@ -1,11 +1,13 @@ +# frozen_string_literal: true + +# A Ruby C extension fuzzer module Ruzzy - require "cruzzy/cruzzy" + require 'cruzzy/cruzzy' - # $0 is the program name - DEFAULT_ARGS = [$0] + ARGV + DEFAULT_ARGS = [$PROGRAM_NAME] + ARGV def fuzz(test_one_input, args = DEFAULT_ARGS) - self.c_fuzz(test_one_input, args) + c_fuzz(test_one_input, args) end module_function :fuzz diff --git a/ruzzy.gemspec b/ruzzy.gemspec index 4c2233a..14c322b 100644 --- a/ruzzy.gemspec +++ b/ruzzy.gemspec @@ -1,16 +1,19 @@ -require "rake" +# frozen_string_literal: true + +require 'rake' Gem::Specification.new do |s| - s.name = "ruzzy" - s.version = "0.5.0" - s.summary = "A Ruby C extension fuzzer" - s.authors = ["Trail of Bits"] - s.email = "support@trailofbits.com" - s.files = FileList["lib/**/*.rb", "ext/**/*.{rb,c,h}"] - s.homepage = "https://rubygems.org/gems/ruzzy" - s.license = "AGPL-3.0" - s.extensions = %w[ext/cruzzy/extconf.rb] + s.name = 'ruzzy' + s.version = '0.5.0' + s.summary = 'A Ruby C extension fuzzer' + s.authors = ['Trail of Bits'] + s.email = 'support@trailofbits.com' + s.files = FileList['lib/**/*.rb', 'ext/**/*.{rb,c,h}'] + s.homepage = 'https://rubygems.org/gems/ruzzy' + s.license = 'AGPL-3.0' + s.extensions = %w[ext/cruzzy/extconf.rb] + s.required_ruby_version = '>= 3.1.0' - s.add_development_dependency "rake", '~> 13.0' - s.add_development_dependency "rake-compiler", '~> 1.2' + s.add_development_dependency 'rake', '~> 13.0' + s.add_development_dependency 'rake-compiler', '~> 1.2' end diff --git a/test/test_ruzzy.rb b/test/test_ruzzy.rb index 4ad57a6..de54a49 100644 --- a/test/test_ruzzy.rb +++ b/test/test_ruzzy.rb @@ -1,26 +1,28 @@ -require "ruzzy" -require "test/unit" +# frozen_string_literal: true + +require 'ruzzy' +require 'test/unit' class RuzzyTest < Test::Unit::TestCase def test_c_libfuzzer_is_loaded - result = Ruzzy.c_libfuzzer_is_loaded() + result = Ruzzy.c_libfuzzer_is_loaded assert_true(result) end def test_c_dummy_test_one_input_proc - dummy_test_one_input = proc {|data| Ruzzy.c_dummy_test_one_input(data)} + dummy_test_one_input = proc { |data| Ruzzy.c_dummy_test_one_input(data) } - result = dummy_test_one_input.call("test") + result = dummy_test_one_input.call('test') expected = 0 assert_equal(result, expected) end def test_c_dummy_test_one_input_lambda - dummy_test_one_input = lambda {|data| Ruzzy.c_dummy_test_one_input(data)} + dummy_test_one_input = ->(data) { Ruzzy.c_dummy_test_one_input(data) } - result = dummy_test_one_input.call("test") + result = dummy_test_one_input.call('test') expected = 0 assert_equal(result, expected) @@ -28,7 +30,7 @@ def test_c_dummy_test_one_input_lambda def test_fuzz_without_proc assert_raise(RuntimeError) do - Ruzzy.fuzz("not a proc") + Ruzzy.fuzz('not a proc') end end end