diff --git a/.rubocop.yml b/.rubocop.yml index c713137..6aa13d1 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,9 @@ AllCops: Exclude: - lib/one_gadget/builds/*.rb +Gemspec/RequireMFA: + Enabled: false + Gemspec/RequiredRubyVersion: Enabled: false @@ -18,6 +21,12 @@ Layout/LineLength: Enabled: true Max: 120 +Lint/AmbiguousOperatorPrecedence: + Enabled: false + +Lint/AmbiguousRange: + Enabled: false + Metrics/AbcSize: Enabled: false diff --git a/Gemfile.lock b/Gemfile.lock index 31c3c53..5e62f7a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,16 +10,16 @@ GEM ast (2.4.2) bindata (2.4.10) diff-lcs (1.5.0) - docile (1.3.5) + docile (1.4.0) elftools (1.1.3) bindata (~> 2) - json (2.5.1) - parallel (1.20.1) - parser (3.0.0.0) + json (2.6.1) + parallel (1.21.0) + parser (3.1.1.0) ast (~> 2.4.1) - rainbow (3.0.0) + rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.1.1) + regexp_parser (2.2.1) rexml (3.2.5) rspec (3.11.0) rspec-core (~> 3.11.0) @@ -34,24 +34,24 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.11.0) rspec-support (3.11.0) - rubocop (1.12.1) + rubocop (1.26.0) parallel (~> 1.10) - parser (>= 3.0.0.0) + parser (>= 3.1.0.0) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml - rubocop-ast (>= 1.2.0, < 2.0) + rubocop-ast (>= 1.16.0, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.4.1) - parser (>= 2.7.1.5) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) ruby-progressbar (1.11.0) simplecov (0.17.1) docile (~> 1.1) json (>= 1.8, < 3) simplecov-html (~> 0.10.0) simplecov-html (0.10.2) - unicode-display_width (2.0.0) + unicode-display_width (2.1.0) webrick (1.7.0) yard (0.9.27) webrick (~> 1.7.0) diff --git a/lib/one_gadget/cli.rb b/lib/one_gadget/cli.rb index c097573..030ed6a 100644 --- a/lib/one_gadget/cli.rb +++ b/lib/one_gadget/cli.rb @@ -120,7 +120,7 @@ module OneGadget end opts.on('-n', '--near FUNCTIONS/FILE', 'Order gadgets by their distance to the given functions'\ - ' or to the GOT functions of the given file.') do |n| + ' or to the GOT functions of the given file.') do |n| @options[:near] = n end diff --git a/lib/one_gadget/fetchers/base.rb b/lib/one_gadget/fetchers/base.rb index bff5a85..9c65f44 100644 --- a/lib/one_gadget/fetchers/base.rb +++ b/lib/one_gadget/fetchers/base.rb @@ -192,7 +192,7 @@ module OneGadget end def str_offset(str) - IO.binread(file).index("#{str}\x00") || + File.binread(file).index("#{str}\x00") || raise(Error::ArgumentError, "File #{file.inspect} doesn't contain string #{str.inspect}, not glibc?") end diff --git a/lib/one_gadget/update.rb b/lib/one_gadget/update.rb index b2b68da..8206a31 100644 --- a/lib/one_gadget/update.rb +++ b/lib/one_gadget/update.rb @@ -42,7 +42,7 @@ module OneGadget # don't check if not CLI return false unless $stdout.tty? return false if cache.nil? # cache file fails, no update check. - return false if IO.binread(cache).strip == 'never' + return false if File.binread(cache).strip == 'never' Time.now >= last_check + FREQUENCY end @@ -57,7 +57,7 @@ module OneGadget def cache_file dir = File.dirname(CACHE_FILE) FileUtils.mkdir_p(dir) unless File.directory?(dir) - IO.binwrite(CACHE_FILE, '') unless File.exist?(CACHE_FILE) + File.binwrite(CACHE_FILE, '') unless File.exist?(CACHE_FILE) CACHE_FILE rescue Errno::EACCES # prevent dir is not writable nil diff --git a/spec/update_spec.rb b/spec/update_spec.rb index 82e779a..d38abb9 100644 --- a/spec/update_spec.rb +++ b/spec/update_spec.rb @@ -40,7 +40,7 @@ describe OneGadget::Update do allow(Time).to receive(:now).and_return(now + 30 * 24 * 3600) allow($stdout).to receive(:tty?).and_return(true) expect(described_class.__send__(:need_check?)).to be true - IO.binwrite(path, 'never') + File.binwrite(path, 'never') expect(described_class.__send__(:need_check?)).to be false end end diff --git a/tasks/builds/generate.rake b/tasks/builds/generate.rake index 8d77820..fd4a65c 100644 --- a/tasks/builds/generate.rake +++ b/tasks/builds/generate.rake @@ -47,11 +47,11 @@ namespace :builds do next failed('no gadgets found') if gadgets.empty? content = template(info, gadgets) - File.open(filename, 'w') { |f| f.write(content) } + File.write(filename, content) puts 'done' end puts "Total #{total} files, \e[32m#{total - @skipped - @failed}\e[0m succeeded, " \ - "\e[33m#{@skipped}\e[0m skipped, and \e[31m#{@failed}\e[0m failed." + "\e[33m#{@skipped}\e[0m skipped, and \e[31m#{@failed}\e[0m failed." end def template(info, gadgets) diff --git a/tasks/readme.rake b/tasks/readme.rake index 7d59a22..5b9b612 100644 --- a/tasks/readme.rake +++ b/tasks/readme.rake @@ -4,7 +4,7 @@ desc 'To auto generate README.md from README.tpl' task :readme do next if ENV['CI'] - @tpl = IO.binread('README.tpl.md') + @tpl = File.binread('README.tpl.md') def replace(prefix) @tpl.gsub!(/#{prefix}\(.*\)/) do |s| @@ -27,5 +27,5 @@ task :readme do "#{cmd}\n#=> #{res.inspect}\n" end - IO.binwrite('README.md', @tpl) + File.binwrite('README.md', @tpl) end