Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApplicationRecord> pages
#gem 'yard-metasploit-erd'
end

# used by dummy application
group :development, :test do
# supplies factories for producing model instance for specs
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Copy link
Copy Markdown
Contributor

@adfoster-r7 adfoster-r7 Apr 13, 2026

Choose a reason for hiding this comment

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

Is this code change needed? 🤔

yes, to handle 8.0 - which would have the minor as 0 👍

serialize :info, coder: MetasploitDataModels::Base64Serializer.new(coerce: true)
else
serialize :info, MetasploitDataModels::Base64Serializer.new(coerce: true)
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/loot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/mdm/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Mdm::Macro < ApplicationRecord
#
# @return [Array<Hash{Symbol=>Object}>] 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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/nexpose_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class Mdm::NexposeConsole < ApplicationRecord
# List of sites known to Nexpose.
#
# @return [Array<String>] 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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/note.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/models/mdm/payload.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions app/models/mdm/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/web_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Mdm::WebForm < ApplicationRecord
# Parameters submitted in this form.
#
# @return [Array<Array(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 :params, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :params, MetasploitDataModels::Base64Serializer.new
Expand Down
4 changes: 2 additions & 2 deletions app/models/mdm/web_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/web_site.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/mdm/web_vuln.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class Mdm::WebVuln < ApplicationRecord
# Parameters sent as part of request
#
# @return [Array<Array(String, String)>] 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)
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20110317144932_add_session_table.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20110422000000_convert_binary.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ 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
end
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
Expand Down
11 changes: 7 additions & 4 deletions metasploit_data_models.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Loading