diff --git a/Gemfile b/Gemfile index 6934f1ef5e..49d5f82ea5 100644 --- a/Gemfile +++ b/Gemfile @@ -37,8 +37,8 @@ group :development, :test do # environment is development gem 'rspec-rails' gem 'rspec-rerun' - # Required during CI as well local development - pinned due to CI failure on: rubocop-1.73.2/lib/rubocop/config_loader.rb:272:in `read' - gem 'rubocop', '1.67.0' + # Required during CI as well local development + gem 'rubocop', '1.75.6' end group :test do diff --git a/Gemfile.lock b/Gemfile.lock index 0db2f1ac55..febbb2cef7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -170,7 +170,7 @@ GEM rspec-expectations (~> 3.12) arel-helpers (2.16.0) activerecord (>= 3.1.0, < 8.1) - ast (2.4.2) + ast (2.4.3) aws-eventstream (1.3.2) aws-partitions (1.1065.0) aws-sdk-core (3.220.1) @@ -293,7 +293,8 @@ GEM jsobfu (0.4.2) rkelly-remix json (2.10.2) - language_server-protocol (3.17.0.4) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) little-plugger (1.1.4) logger (1.6.6) logging (2.4.0) @@ -377,8 +378,8 @@ GEM ostruct (0.6.1) packetfu (2.0.0) pcaprub (~> 0.13.1) - parallel (1.26.3) - parser (3.3.7.1) + parallel (1.27.0) + parser (3.3.8.0) ast (~> 2.4.1) racc patch_finder (1.0.2) @@ -390,6 +391,7 @@ GEM ruby-rc4 ttfunk pg (1.5.9) + prism (1.4.0) pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) @@ -517,18 +519,20 @@ GEM rspec-rerun (1.1.0) rspec (~> 3.0) rspec-support (3.13.2) - rubocop (1.67.0) + rubocop (1.75.6) json (~> 2.3) - language_server-protocol (>= 3.17.0) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.44.0, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.38.1) - parser (>= 3.3.1.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.44.1) + parser (>= 3.3.7.2) + prism (~> 1.4) ruby-macho (4.1.0) ruby-mysql (4.2.0) ruby-prof (1.7.1) @@ -578,7 +582,9 @@ GEM concurrent-ruby (~> 1.0) tzinfo-data (1.2025.1) tzinfo (>= 1.0.0) - unicode-display_width (2.6.0) + unicode-display_width (3.1.4) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) unix-crypt (1.3.1) warden (1.2.9) rack (>= 2.0.9) @@ -623,7 +629,7 @@ DEPENDENCIES redcarpet rspec-rails rspec-rerun - rubocop (= 1.67.0) + rubocop (= 1.75.6) ruby-prof simplecov (= 0.18.2) test-prof diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 090cdc799f..3a79e88132 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -12,6 +12,23 @@ require 'rubocop' require 'rubocop/rspec/support' require 'faker' +# Monkey patch rubocop which fails to load the default rspec config due to encoding issues - https://github.com/rapid7/metasploit-framework/pull/20196 +# Caused by our global IO encoding being set to ASCII-8BIT - https://github.com/rapid7/metasploit-framework/blob/b251fc1b635dc07c66cc3848983bdcbeaa08a81f/lib/metasploit/framework/common_engine.rb#L25-L33 +# Original code: https://github.com/rubocop/rubocop/blob/b6c9b0ed31daf40be5a273714095e451aee10bcd/lib/rubocop/config_loader.rb#L275 +# Character which causes encoding failure: https://github.com/rubocop/rubocop/blob/b6c9b0ed31daf40be5a273714095e451aee10bcd/config/default.yml#L3298-L3305 +module RuboCop + class ConfigLoader + # Read the specified file, or exit with a friendly, concise message on + # stderr. Care is taken to use the standard OS exit code for a "file not + # found" error. + def self.read_file(absolute_path) + File.binread(absolute_path).force_encoding(Encoding::UTF_8) + rescue Errno::ENOENT + raise ConfigNotFoundError, "Configuration file not found: #{absolute_path}" + end + end +end + ENV['RAILS_ENV'] = 'test' load_metasploit = ENV.fetch('SPEC_HELPER_LOAD_METASPLOIT', 'true') == 'true'