Files
metasploit-gs/lib/msf/core/db_manager/ref.rb
T
Sliim 95e9707349 Call db event handlers
Implemented plugins handlers defined in
lib/msf/core/database_event.rb:
- on_db_client
- on_db_host
- on_db_service
- on_db_vuln
- on_db_host_state
- on_db_ref
- on_db_service_state
2018-01-21 19:35:55 +01:00

41 lines
914 B
Ruby

module Msf::DBManager::Ref
#
# Find or create a reference matching this name
#
def find_or_create_ref(opts)
ret = {}
ret[:ref] = get_ref(opts[:name])
return ret[:ref] if ret[:ref]
::ActiveRecord::Base.connection_pool.with_connection {
ref = ::Mdm::Ref.where(name: opts[:name]).first_or_initialize
begin
framework.events.on_db_ref(ref) if ref
rescue ::Exception => e
wlog("Exception in on_db_ref event handler: #{e.class}: #{e}")
wlog("Call Stack\n#{e.backtrace.join("\n")}")
end
if ref and ref.changed?
ref.save!
end
ret[:ref] = ref
}
end
def get_ref(name)
::ActiveRecord::Base.connection_pool.with_connection {
::Mdm::Ref.find_by_name(name)
}
end
#
# Find a reference matching this name
#
def has_ref?(name)
::ActiveRecord::Base.connection_pool.with_connection {
Mdm::Ref.find_by_name(name)
}
end
end