Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Rails 7.1 support #206

Merged
merged 1 commit into from
Jun 12, 2024
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
6 changes: 5 additions & 1 deletion app/models/mdm/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ class Mdm::Event < ApplicationRecord
# {#name}-specific information about this event.
#
# @return [Hash]
serialize :info, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :info, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :info, MetasploitDataModels::Base64Serializer.new
end

#
# Validations
Expand Down
6 changes: 5 additions & 1 deletion app/models/mdm/listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ class Mdm::Listener < ApplicationRecord
# Options used to spawn this listener.
#
# @return [Hash]
serialize :options, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :options, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :options, MetasploitDataModels::Base64Serializer.new
end

#
# Validations
Expand Down
6 changes: 5 additions & 1 deletion app/models/mdm/loot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ class Mdm::Loot < ApplicationRecord
# Serializations
#

serialize :data, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :data, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :data, MetasploitDataModels::Base64Serializer.new
end

private

Expand Down
12 changes: 10 additions & 2 deletions app/models/mdm/macro.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,20 @@ 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.
serialize :actions, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :actions, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :actions, MetasploitDataModels::Base64Serializer.new
end

# Preference for this macro, shared across all actions.
#
# @return [Hash]
serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :prefs, MetasploitDataModels::Base64Serializer.new
end

# The maximum number of seconds that this macro is allowed to run.
#
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/nexpose_console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ class Mdm::NexposeConsole < ApplicationRecord
# List of sites known to Nexpose.
#
# @return [Array<String>] Array of site names.
serialize :cached_sites, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :cached_sites, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :cached_sites, MetasploitDataModels::Base64Serializer.new
end

#
# Validations
Expand All @@ -113,7 +117,7 @@ class Mdm::NexposeConsole < ApplicationRecord
#
# @return [void]
def strip_protocol
self.address.gsub!(/^http(s)*:\/\//i,'') unless self.address.nil?
self.address.gsub!(/^http(s)*:\/\//i,'') unless self.address.nil?
end

Metasploit::Concern.run(self)
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/note.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Data gathered or derived from the {#host} or {#service} such as its {#ntype fingerprint}.
class Mdm::Note < ApplicationRecord

#
# Associations
#
Expand Down Expand Up @@ -107,7 +107,11 @@ class Mdm::Note < ApplicationRecord
# Serializations
#

serialize :data, coder: ::MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :data, coder: ::MetasploitDataModels::Base64Serializer.new
else
serialize :data, ::MetasploitDataModels::Base64Serializer.new
end

private

Expand Down
6 changes: 5 additions & 1 deletion app/models/mdm/profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ class Mdm::Profile < ApplicationRecord
# Global settings.
#
# @return [Hash]
serialize :settings, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :settings, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :settings, MetasploitDataModels::Base64Serializer.new
end

Metasploit::Concern.run(self)
end
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/session.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A session opened on a {#host} using an {#via_exploit exploit} and controlled through a {#via_payload payload} to
# connect back to the local host using meterpreter or a cmd shell.
class Mdm::Session < ApplicationRecord

#
# Associations
#
Expand Down Expand Up @@ -172,7 +172,11 @@ class Mdm::Session < ApplicationRecord
# Serializations
#

serialize :datastore, coder: ::MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :datastore, coder: ::MetasploitDataModels::Base64Serializer.new
else
serialize :datastore, ::MetasploitDataModels::Base64Serializer.new
end

# Returns whether the session can be upgraded to a meterpreter session from a shell session on Windows.
#
Expand Down
18 changes: 15 additions & 3 deletions app/models/mdm/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,29 @@ class Mdm::Task < ApplicationRecord
# Options passed to `#module`.
#
# @return [Hash]
serialize :options, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :options, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :options, MetasploitDataModels::Base64Serializer.new
end

# Result of task running.
#
# @return [Hash]
serialize :result, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :result, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :result, MetasploitDataModels::Base64Serializer.new
end

# Settings used to configure this task outside of the {#options module options}.
#
# @return [Hash]
serialize :settings, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :settings, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :settings, MetasploitDataModels::Base64Serializer.new
end

#
# Instance Methods
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/user.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# A user of metasploit-framework or metasploit-pro.
class Mdm::User < ApplicationRecord
extend MetasploitDataModels::SerializedPrefs

#
# Associations
#
Expand Down Expand Up @@ -109,7 +109,11 @@ class Mdm::User < ApplicationRecord
# Hash of user preferences
#
# @return [Hash]
serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :prefs, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :prefs, MetasploitDataModels::Base64Serializer.new
end

# @!attribute time_zone
# User's preferred time zone.
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/web_form.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A filled-in form on a {#web_site}.
class Mdm::WebForm < ApplicationRecord

#
# Associations
#
Expand Down Expand Up @@ -46,7 +46,11 @@ class Mdm::WebForm < ApplicationRecord
# Parameters submitted in this form.
#
# @return [Array<Array(String, String)>>]
serialize :params, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :params, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :params, MetasploitDataModels::Base64Serializer.new
end

Metasploit::Concern.run(self)
end
Expand Down
12 changes: 10 additions & 2 deletions app/models/mdm/web_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,20 @@ class Mdm::WebPage < ApplicationRecord
# Headers sent from server.
#
# @return [Hash{String => String}]
serialize :headers, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :headers, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :headers, MetasploitDataModels::Base64Serializer.new
end

# Cookies sent from server.
#
# @return [Hash{String => String}]
serialize :cookie, coder: MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :cookie, coder: MetasploitDataModels::Base64Serializer.new
else
serialize :cookie, MetasploitDataModels::Base64Serializer.new
end
Metasploit::Concern.run(self)
end

8 changes: 6 additions & 2 deletions app/models/mdm/web_site.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# A Web Site running on a {#service}.
class Mdm::WebSite < ApplicationRecord

#
# Associations
#
Expand Down Expand Up @@ -60,7 +60,11 @@ class Mdm::WebSite < ApplicationRecord

# @!attribute [rw] options
# @todo Determine format and purpose of Mdm::WebSite#options.
serialize :options, coder: ::MetasploitDataModels::Base64Serializer.new
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
serialize :options, coder: ::MetasploitDataModels::Base64Serializer.new
else
serialize :options, ::MetasploitDataModels::Base64Serializer.new
end

#
# Instance Methods
Expand Down
8 changes: 6 additions & 2 deletions app/models/mdm/web_vuln.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# end
# end
class Mdm::WebVuln < ApplicationRecord

#
# CONSTANTS
#
Expand Down Expand Up @@ -141,7 +141,11 @@ class Mdm::WebVuln < ApplicationRecord
# Parameters sent as part of request
#
# @return [Array<Array(String, String)>] Array of parameter key value pairs
serialize :params, coder: MetasploitDataModels::Base64Serializer.new(:default => DEFAULT_PARAMS)
if 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)
end

#
# Methods
Expand Down