Files
metasploit-gs/lib/msf/core/db_manager/adapter.rb
T
Jeffrey Martin 07cbe426e2 Rails 5, all models inherit from ApplicationRecord
ApplicationRecord is a new superclass for all app models, analogous to app controllers subclassing ApplicationController instead of ActionController::Base. This gives apps a single spot to configure app-wide model behavior.
https://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#active-record-models-now-inherit-from-applicationrecord-by-default

Deprecated Relation#uniq use Relation#distinct instead.
https://edgeguides.rubyonrails.org/5_0_release_notes.html#active-record-deprecations
2020-07-31 11:56:49 -05:00

49 lines
1006 B
Ruby

module Msf::DBManager::Adapter
#
# CONSTANTS
#
# The adapter to use to establish database connection.
ADAPTER = 'postgresql'
#
# Attributes
#
# Returns the list of usable database drivers
def drivers
@drivers ||= []
end
attr_writer :drivers
# Returns the active driver
attr_accessor :driver
#
# Instance Methods
#
#
# Scan through available drivers
#
def initialize_adapter
ApplicationRecord.default_timezone = :utc
if connection_established? && ApplicationRecord.connection_config[:adapter] == ADAPTER
dlog("Already established connection to #{ADAPTER}, so reusing active connection.")
self.drivers << ADAPTER
self.driver = ADAPTER
else
begin
ApplicationRecord.establish_connection(adapter: ADAPTER)
ApplicationRecord.remove_connection
rescue Exception => error
@adapter_error = error
else
self.drivers << ADAPTER
self.driver = ADAPTER
end
end
end
end