Skip to content

[WIP] Upgrade framework to rails 8.0#21308

Draft
dwelch-r7 wants to merge 3 commits intorapid7:masterfrom
dwelch-r7:rails-8.0-upgrade
Draft

[WIP] Upgrade framework to rails 8.0#21308
dwelch-r7 wants to merge 3 commits intorapid7:masterfrom
dwelch-r7:rails-8.0-upgrade

Conversation

@dwelch-r7
Copy link
Copy Markdown
Contributor

Upgrade framework to rails 8.0, initial PR to run through CI, do not merge

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR is an initial, WIP upgrade pass to move the metasploit-framework Rails stack to Rails 8.0 and unblock dependency resolution/CI on the new Rails + Rack versions.

Changes:

  • Bump Rails constraints to ~> 8.0.0 and refresh gem dependency constraints/lockfile for Rack 3 + Sinatra 4.
  • Update web service apps for Sinatra 4 defaults (host authorization) and Rack 3 header normalization.
  • Adjust JSON-RPC request specs to explicitly send JSON content type.

Reviewed changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
spec/api/json_rpc_spec.rb Adds JSON content-type headers to Rack::Test JSON-RPC requests.
metasploit-framework.gemspec Pins/adjusts runtime deps for Rails 8 compatibility (Rack 3, Sinatra 4, updated metasploit-* gems).
lib/msf/core/web_services/servlet_helper.rb Normalizes response header keys for Rack 3.
lib/msf/core/web_services/metasploit_api_app.rb Disables Sinatra 4 host authorization middleware behavior via settings.
lib/msf/core/web_services/json_rpc_exception_handling.rb Normalizes JSON error response header keys.
lib/msf/core/web_services/json_rpc_app.rb Disables Sinatra 4 host authorization middleware behavior via settings.
lib/msf/core/web_services/http_db_manager_service.rb Switches web service handler from Thin to Puma and rewrites SSL handling.
lib/metasploit/framework/rails_version_constraint.rb Updates Rails version constraint constant to ~> 8.0.0.
db/schema.rb Regenerates schema for ActiveRecord 8.0 output changes.
config/application.rb Updates Rails defaults to 8.0 and revises ActionView TagBuilder monkey patch for Rails 7 vs 8.
Gemfile.lock Updates locked gems for Rails 8 / Rack 3 / Sinatra 4 resolution.
.github/workflows/shared_gem_verify_rails.yml Adds ~> 8.0.0 to the Rails matrix used in shared gem verification.

Comment thread config/application.rb
Comment on lines +42 to +46
code_generator.class_eval do |batch|
batch << "\n" <<
"def #{method_name}(content = nil, escape: true, **options, &block)" <<
" tag_string(#{name.inspect}, content, options, escape: escape, &block)" <<
"end"
Comment on lines +46 to +56
if opts[:ssl]
print_good('SSL Enabled')
ssl_opts = opts[:ssl_opts] || {}
key = ssl_opts[:private_key_file]
cert = ssl_opts[:cert_chain_file]
verify = ssl_opts[:verify_peer] ? 'peer' : 'none'

ssl_uri = "ssl://#{host}:#{port}?key=#{key}&cert=#{cert}&verify_mode=#{verify}"
puma_opts[:Host] = ssl_uri
puma_opts.delete(:Port)
else
Comment thread Gemfile.lock
rubyntlm
rubyzip
sinatra (~> 3.2)
sinatra (~> 4.0)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to bump sinatra for rails 8, or is this worth splitting out?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rails 8 requires a minimum of Rack 3 which requires sinatra 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

4 participants