diff --git a/Gemfile b/Gemfile index 69cfbe3b..e299c383 100755 --- a/Gemfile +++ b/Gemfile @@ -3,12 +3,6 @@ source "https://rubygems.org" # Specify your gem's dependencies in metasploit_data_models.gemspec gemspec -group :development do - #gem 'metasploit-erd' - # embed ERDs on index, namespace Module and Class pages - #gem 'yard-metasploit-erd' -end - # used by dummy application group :development, :test do # supplies factories for producing model instance for specs @@ -17,8 +11,8 @@ group :development, :test do # auto-load factories from spec/factories gem 'factory_bot_rails' - # Enforce tests to run on 7.0.X - gem 'rails', '~> 7.0.0' + # Allow Rails 7.0 through 8.0 for upgrade compatibility + gem 'rails', '>= 7.0', '< 8.1' gem 'net-smtp', require: false # Used to create fake data diff --git a/app/models/mdm/event.rb b/app/models/mdm/event.rb index 805d68ce..fab47a22 100755 --- a/app/models/mdm/event.rb +++ b/app/models/mdm/event.rb @@ -72,7 +72,7 @@ class Mdm::Event < ApplicationRecord # {#name}-specific information about this event. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :info, coder: MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :info, MetasploitDataModels::Base64Serializer.new(coerce: true) diff --git a/app/models/mdm/listener.rb b/app/models/mdm/listener.rb index 981b2794..530dd003 100755 --- a/app/models/mdm/listener.rb +++ b/app/models/mdm/listener.rb @@ -69,7 +69,7 @@ class Mdm::Listener < ApplicationRecord # Options used to spawn this listener. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :options, coder: MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :options, MetasploitDataModels::Base64Serializer.new(coerce: true) diff --git a/app/models/mdm/loot.rb b/app/models/mdm/loot.rb index ce225278..8a7a1cf0 100755 --- a/app/models/mdm/loot.rb +++ b/app/models/mdm/loot.rb @@ -140,7 +140,7 @@ class Mdm::Loot < ApplicationRecord # Serializations # - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :data, coder: MetasploitDataModels::Base64Serializer.new else serialize :data, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/macro.rb b/app/models/mdm/macro.rb index f8e0cd46..08770d6e 100755 --- a/app/models/mdm/macro.rb +++ b/app/models/mdm/macro.rb @@ -39,7 +39,7 @@ class Mdm::Macro < ApplicationRecord # # @return [ArrayObject}>] Array of action hashes. Each action hash is have key :module with value # of an {Mdm::Module::Detail#fullname} and and key :options with value of options used to the run the module. - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :actions, coder: MetasploitDataModels::Base64Serializer.new else serialize :actions, MetasploitDataModels::Base64Serializer.new @@ -48,7 +48,7 @@ class Mdm::Macro < ApplicationRecord # Preference for this macro, shared across all actions. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new else serialize :prefs, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/nexpose_console.rb b/app/models/mdm/nexpose_console.rb index 7b61d4e2..a9777459 100755 --- a/app/models/mdm/nexpose_console.rb +++ b/app/models/mdm/nexpose_console.rb @@ -89,7 +89,7 @@ class Mdm::NexposeConsole < ApplicationRecord # List of sites known to Nexpose. # # @return [Array] Array of site names. - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :cached_sites, coder: MetasploitDataModels::Base64Serializer.new else serialize :cached_sites, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/note.rb b/app/models/mdm/note.rb index da4b1c29..0469a7d6 100755 --- a/app/models/mdm/note.rb +++ b/app/models/mdm/note.rb @@ -107,7 +107,7 @@ class Mdm::Note < ApplicationRecord # Serializations # - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :data, coder: ::MetasploitDataModels::Base64Serializer.new else serialize :data, ::MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/payload.rb b/app/models/mdm/payload.rb index 74d9bfa4..4efdaacd 100644 --- a/app/models/mdm/payload.rb +++ b/app/models/mdm/payload.rb @@ -93,13 +93,13 @@ class Mdm::Payload < ApplicationRecord # # Serializations - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :urls, coder: YAML else serialize :urls end - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :build_opts, coder: YAML else serialize :build_opts diff --git a/app/models/mdm/profile.rb b/app/models/mdm/profile.rb index 3e282229..3dd7044e 100755 --- a/app/models/mdm/profile.rb +++ b/app/models/mdm/profile.rb @@ -38,7 +38,7 @@ class Mdm::Profile < ApplicationRecord # Global settings. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :settings, coder: MetasploitDataModels::Base64Serializer.new else serialize :settings, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/session.rb b/app/models/mdm/session.rb index 6aa683a3..80d1da4e 100755 --- a/app/models/mdm/session.rb +++ b/app/models/mdm/session.rb @@ -198,7 +198,7 @@ class Mdm::Session < ApplicationRecord # Serializations # - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :datastore, coder: ::MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :datastore, ::MetasploitDataModels::Base64Serializer.new(coerce: true) diff --git a/app/models/mdm/task.rb b/app/models/mdm/task.rb index c884e5ec..9a7232e2 100755 --- a/app/models/mdm/task.rb +++ b/app/models/mdm/task.rb @@ -130,7 +130,7 @@ class Mdm::Task < ApplicationRecord # Options passed to `#module`. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :options, coder: MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :options, MetasploitDataModels::Base64Serializer.new(coerce: true) @@ -139,7 +139,7 @@ class Mdm::Task < ApplicationRecord # Result of task running. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :result, coder: MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :result, MetasploitDataModels::Base64Serializer.new(coerce: true) @@ -148,7 +148,7 @@ class Mdm::Task < ApplicationRecord # Settings used to configure this task outside of the {#options module options}. # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :settings, coder: MetasploitDataModels::Base64Serializer.new(coerce: true) else serialize :settings, MetasploitDataModels::Base64Serializer.new(coerce: true) diff --git a/app/models/mdm/user.rb b/app/models/mdm/user.rb index f97ec0dd..7be38fd5 100755 --- a/app/models/mdm/user.rb +++ b/app/models/mdm/user.rb @@ -114,7 +114,7 @@ class Mdm::User < ApplicationRecord # Hash of user preferences # # @return [Hash] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new else serialize :prefs, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/web_form.rb b/app/models/mdm/web_form.rb index 1c4cfef3..ce2f6976 100755 --- a/app/models/mdm/web_form.rb +++ b/app/models/mdm/web_form.rb @@ -46,7 +46,7 @@ class Mdm::WebForm < ApplicationRecord # Parameters submitted in this form. # # @return [Array>] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :params, coder: MetasploitDataModels::Base64Serializer.new else serialize :params, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/web_page.rb b/app/models/mdm/web_page.rb index 3159f76c..d6f6dcec 100755 --- a/app/models/mdm/web_page.rb +++ b/app/models/mdm/web_page.rb @@ -81,7 +81,7 @@ class Mdm::WebPage < ApplicationRecord # Headers sent from server. # # @return [Hash{String => String}] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :headers, coder: MetasploitDataModels::Base64Serializer.new else serialize :headers, MetasploitDataModels::Base64Serializer.new @@ -90,7 +90,7 @@ class Mdm::WebPage < ApplicationRecord # Cookies sent from server. # # @return [Hash{String => String}] - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :cookie, coder: MetasploitDataModels::Base64Serializer.new else serialize :cookie, MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/web_site.rb b/app/models/mdm/web_site.rb index 296065f3..f1bae4dc 100755 --- a/app/models/mdm/web_site.rb +++ b/app/models/mdm/web_site.rb @@ -60,7 +60,7 @@ class Mdm::WebSite < ApplicationRecord # @!attribute [rw] options # @todo Determine format and purpose of Mdm::WebSite#options. - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :options, coder: ::MetasploitDataModels::Base64Serializer.new else serialize :options, ::MetasploitDataModels::Base64Serializer.new diff --git a/app/models/mdm/web_vuln.rb b/app/models/mdm/web_vuln.rb index 3fb03ce5..e4ada762 100755 --- a/app/models/mdm/web_vuln.rb +++ b/app/models/mdm/web_vuln.rb @@ -141,7 +141,7 @@ class Mdm::WebVuln < ApplicationRecord # Parameters sent as part of request # # @return [Array] Array of parameter key value pairs - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :params, coder: MetasploitDataModels::Base64Serializer.new(default: DEFAULT_PARAMS) else serialize :params, MetasploitDataModels::Base64Serializer.new(default: DEFAULT_PARAMS) diff --git a/db/migrate/20110317144932_add_session_table.rb b/db/migrate/20110317144932_add_session_table.rb index 0db38b78..bb10c76c 100755 --- a/db/migrate/20110317144932_add_session_table.rb +++ b/db/migrate/20110317144932_add_session_table.rb @@ -1,7 +1,7 @@ class AddSessionTable < ActiveRecord::Migration[4.2] class Event < ApplicationRecord - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :info, coder: YAML else serialize :info @@ -14,7 +14,7 @@ class SessionEvent < ApplicationRecord class Session < ApplicationRecord has_many :events, :class_name => 'AddSessionTable::SessionEvent' - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :datastore, coder: YAML else serialize :datastore diff --git a/db/migrate/20110422000000_convert_binary.rb b/db/migrate/20110422000000_convert_binary.rb index 1d8ec923..2232717c 100755 --- a/db/migrate/20110422000000_convert_binary.rb +++ b/db/migrate/20110422000000_convert_binary.rb @@ -3,7 +3,7 @@ class ConvertBinary < ActiveRecord::Migration[4.2] class WebPage < ApplicationRecord - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :headers, coder: YAML else serialize :headers @@ -11,7 +11,7 @@ class WebPage < ApplicationRecord end class WebVuln < ApplicationRecord - if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1 + if ActiveRecord::VERSION::MAJOR > 7 || (ActiveRecord::VERSION::MAJOR == 7 && ActiveRecord::VERSION::MINOR >= 1) serialize :params, coder: YAML else serialize :params diff --git a/metasploit_data_models.gemspec b/metasploit_data_models.gemspec index 646cf502..77c22bcc 100644 --- a/metasploit_data_models.gemspec +++ b/metasploit_data_models.gemspec @@ -33,11 +33,14 @@ Gem::Specification.new do |s| s.add_development_dependency 'pry' - s.add_runtime_dependency 'activerecord', '~>7.0' - s.add_runtime_dependency 'activesupport', '~>7.0' + # Rails 8.0 upgrade: widened from '~> 7.0' (which means >= 7.0, < 8.0) to + # '>= 7.0', '< 8.1' so this gem resolves with both Rails 7.x and 8.0. + # The old pessimistic constraint hard-blocked Bundler from pulling Rails 8. + s.add_runtime_dependency 'activerecord', '>= 7.0', '< 8.1' + s.add_runtime_dependency 'activesupport', '>= 7.0', '< 8.1' s.add_runtime_dependency 'metasploit-concern' - s.add_runtime_dependency 'metasploit-model', '~>5.0.4' - s.add_runtime_dependency 'railties', '~>7.0' + s.add_runtime_dependency 'metasploit-model', '>= 5.0.4' + s.add_runtime_dependency 'railties', '>= 7.0', '< 8.1' s.add_runtime_dependency 'webrick' # os fingerprinting diff --git a/spec/dummy/config/application.rb b/spec/dummy/config/application.rb index 5a778087..e60fbc87 100644 --- a/spec/dummy/config/application.rb +++ b/spec/dummy/config/application.rb @@ -53,11 +53,6 @@ class Application < Rails::Application # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types config.active_record.schema_format = :sql - - # 5.x change to belongs_to - config.active_record.belongs_to_required_by_default = true - - config.autoloader = :zeitwerk end end