Skip to content

Commit 10e8cbb

Browse files
authored
Merge pull request rapid7#19953 from dwelch-r7/rails-7.1-upgrade
Rails 7.1 upgrade
2 parents 3f161e0 + 47b5f86 commit 10e8cbb

File tree

16 files changed

+150
-149
lines changed

16 files changed

+150
-149
lines changed

Gemfile.lock

Lines changed: 47 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PATH
44
metasploit-framework (6.4.58)
55
aarch64
66
abbrev
7-
actionpack (~> 7.0.0)
8-
activerecord (~> 7.0.0)
9-
activesupport (~> 7.0.0)
7+
actionpack (~> 7.1.0)
8+
activerecord (~> 7.1.0)
9+
activesupport (~> 7.1.0)
1010
aws-sdk-ec2
1111
aws-sdk-ec2instanceconnect
1212
aws-sdk-iam
@@ -46,7 +46,7 @@ PATH
4646
metasploit-credential
4747
metasploit-model
4848
metasploit-payloads (= 2.0.189)
49-
metasploit_data_models
49+
metasploit_data_models (>= 6.0.7)
5050
metasploit_payloads-mettle (= 1.0.35)
5151
mqtt
5252
msgpack (~> 1.6.0)
@@ -123,28 +123,40 @@ GEM
123123
aarch64 (2.1.0)
124124
racc (~> 1.6)
125125
abbrev (0.1.2)
126-
actionpack (7.0.8.7)
127-
actionview (= 7.0.8.7)
128-
activesupport (= 7.0.8.7)
129-
rack (~> 2.0, >= 2.2.4)
126+
actionpack (7.1.5.1)
127+
actionview (= 7.1.5.1)
128+
activesupport (= 7.1.5.1)
129+
nokogiri (>= 1.8.5)
130+
racc
131+
rack (>= 2.2.4)
132+
rack-session (>= 1.0.1)
130133
rack-test (>= 0.6.3)
131-
rails-dom-testing (~> 2.0)
132-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
133-
actionview (7.0.8.7)
134-
activesupport (= 7.0.8.7)
134+
rails-dom-testing (~> 2.2)
135+
rails-html-sanitizer (~> 1.6)
136+
actionview (7.1.5.1)
137+
activesupport (= 7.1.5.1)
135138
builder (~> 3.1)
136-
erubi (~> 1.4)
137-
rails-dom-testing (~> 2.0)
138-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
139-
activemodel (7.0.8.7)
140-
activesupport (= 7.0.8.7)
141-
activerecord (7.0.8.7)
142-
activemodel (= 7.0.8.7)
143-
activesupport (= 7.0.8.7)
144-
activesupport (7.0.8.7)
139+
erubi (~> 1.11)
140+
rails-dom-testing (~> 2.2)
141+
rails-html-sanitizer (~> 1.6)
142+
activemodel (7.1.5.1)
143+
activesupport (= 7.1.5.1)
144+
activerecord (7.1.5.1)
145+
activemodel (= 7.1.5.1)
146+
activesupport (= 7.1.5.1)
147+
timeout (>= 0.4.0)
148+
activesupport (7.1.5.1)
149+
base64
150+
benchmark (>= 0.3)
151+
bigdecimal
145152
concurrent-ruby (~> 1.0, >= 1.0.2)
153+
connection_pool (>= 2.2.5)
154+
drb
146155
i18n (>= 1.6, < 2)
156+
logger (>= 1.4.2)
147157
minitest (>= 5.1)
158+
mutex_m
159+
securerandom (>= 0.3)
148160
tzinfo (~> 2.0)
149161
addressable (2.8.7)
150162
public_suffix (>= 2.0.2, < 7.0)
@@ -202,6 +214,7 @@ GEM
202214
chunky_png (1.4.0)
203215
coderay (1.1.3)
204216
concurrent-ruby (1.3.4)
217+
connection_pool (2.5.0)
205218
cookiejar (0.3.4)
206219
crass (1.0.6)
207220
csv (3.3.2)
@@ -391,22 +404,28 @@ GEM
391404
rack-protection (3.2.0)
392405
base64 (>= 0.1.0)
393406
rack (~> 2.2, >= 2.2.4)
407+
rack-session (1.0.2)
408+
rack (< 3)
394409
rack-test (2.2.0)
395410
rack (>= 1.3)
411+
rackup (1.0.1)
412+
rack (< 3)
413+
webrick
396414
rails-dom-testing (2.2.0)
397415
activesupport (>= 5.0.0)
398416
minitest
399417
nokogiri (>= 1.6)
400418
rails-html-sanitizer (1.6.2)
401419
loofah (~> 2.21)
402420
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
403-
railties (7.0.8.7)
404-
actionpack (= 7.0.8.7)
405-
activesupport (= 7.0.8.7)
406-
method_source
421+
railties (7.1.5.1)
422+
actionpack (= 7.1.5.1)
423+
activesupport (= 7.1.5.1)
424+
irb
425+
rackup (>= 1.0.0)
407426
rake (>= 12.2)
408-
thor (~> 1.0)
409-
zeitwerk (~> 2.5)
427+
thor (~> 1.0, >= 1.2.2)
428+
zeitwerk (~> 2.6)
410429
rainbow (3.1.1)
411430
rake (13.2.1)
412431
rasn1 (0.14.0)
@@ -527,6 +546,7 @@ GEM
527546
sawyer (0.9.2)
528547
addressable (>= 2.3.5)
529548
faraday (>= 0.17.3, < 3)
549+
securerandom (0.4.1)
530550
simplecov (0.18.2)
531551
docile (~> 1.1)
532552
simplecov-html (~> 0.11)

config/application.rb

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,9 @@ class Application < Rails::Application
4141
config.paths['config/database'] = [Metasploit::Framework::Database.configurations_pathname.try(:to_path)]
4242
config.autoloader = :zeitwerk
4343

44-
case Rails.env
45-
when "development"
46-
config.eager_load = false
47-
when "test"
48-
config.eager_load = false
49-
when "production"
50-
config.eager_load = false
51-
end
52-
53-
if ActiveRecord.respond_to?(:legacy_connection_handling=)
54-
ActiveRecord.legacy_connection_handling = false
55-
end
44+
config.load_defaults 7.1
45+
46+
config.eager_load = false
5647
end
5748
end
5849
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.0].define(version: 2025_02_04_172657) do
13+
ActiveRecord::Schema[7.1].define(version: 2025_02_04_172657) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

lib/metasploit/framework/common_engine.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ module Metasploit::Framework::CommonEngine
4040

4141
config.active_support.deprecation = :stderr
4242

43-
if ActiveRecord.respond_to?(:legacy_connection_handling=)
44-
ActiveRecord.legacy_connection_handling = false
45-
end
46-
4743
# @see https://github.com/rapid7/metasploit_data_models/blob/54a17149d5ccd0830db742d14c4987b48399ceb7/lib/metasploit_data_models/yaml.rb#L10
4844
# @see https://github.com/rapid7/metasploit_data_models/blob/54a17149d5ccd0830db742d14c4987b48399ceb7/lib/metasploit_data_models/base64_serializer.rb#L28-L31
4945
ActiveRecord.yaml_column_permitted_classes = (ActiveRecord.yaml_column_permitted_classes + MetasploitDataModels::YAML::PERMITTED_CLASSES).uniq

lib/metasploit/framework/rails_version_constraint.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Metasploit
44
module Framework
55
module RailsVersionConstraint
6-
RAILS_VERSION = '~> 7.0.0'
6+
RAILS_VERSION = '~> 7.1.0'
77
end
88
end
99
end

lib/msf/core/db_manager/connection.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,11 @@ def create_db(opts)
116116
def connection_established?
117117
begin
118118
# use with_connection so the connection doesn't stay pinned to the thread.
119-
ApplicationRecord.connection_pool.with_connection {
120-
ApplicationRecord.connection.active?
121-
}
119+
ApplicationRecord.connection_pool.with_connection do
120+
# There's a bug in Rails 7.1 where ApplicationRecord.connection.active? returns false even though we can get a connection
121+
# calling `verify!` instead will ensure we are connected even if `active?` incorrectly returns false
122+
ApplicationRecord.connection.verify!
123+
end
122124
rescue ActiveRecord::ConnectionNotEstablished, PG::ConnectionBad => error
123125
false
124126
end

lib/msf/core/db_manager/migration.rb

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ def with_migration_context
6969
yield ActiveRecord::MigrationContext.new(gather_engine_migration_paths)
7070
end
7171

72-
# @return [ActiveRecord::MigrationContext]
73-
def default_migration_context
74-
ActiveRecord::MigrationContext.new(gather_engine_migration_paths, ActiveRecord::SchemaMigration)
75-
end
76-
7772
# Loads gathers migration paths from all loaded Rails engines.
7873
#
7974
# @return Array[String]

lib/msf/core/thread_manager.rb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,6 @@ def spawn(name, crit, *args, &block)
111111
error: e
112112
)
113113
raise e
114-
ensure
115-
if framework.db && framework.db.active && framework.db.is_local?
116-
# NOTE: despite the Deprecation Warning's advice, this should *NOT*
117-
# be ApplicationRecord.connection.close which causes unrelated
118-
# threads to raise ActiveRecord::StatementInvalid exceptions at
119-
# some point in the future, presumably due to the pool manager
120-
# believing that the connection is still usable and handing it out
121-
# to another thread.
122-
::ApplicationRecord.connection_pool.release_connection
123-
end
124114
end
125115
end
126116
else

metasploit-framework.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ Gem::Specification.new do |spec|
6969
# Metasploit::Credential database models
7070
spec.add_runtime_dependency 'metasploit-credential'
7171
# Database models shared between framework and Pro.
72-
spec.add_runtime_dependency 'metasploit_data_models'
72+
spec.add_runtime_dependency 'metasploit_data_models', '>= 6.0.7'
7373
# Things that would normally be part of the database model, but which
7474
# are needed when there's no database
7575
spec.add_runtime_dependency 'metasploit-model'

spec/allure_config.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
require "allure-rspec"
2+
require "active_support"
3+
require "active_support/core_ext/object"
24

35
AllureRspec.configure do |config|
46
config.results_directory = "tmp/allure-raw-data"

0 commit comments

Comments
 (0)