Extract Msf::DBManager::HostDetail

MSP-11124

Extract method related to `Mdm::HostDetail`s.
bug/bundler_fix
Luke Imhoff 2014-10-13 10:15:14 -05:00
parent 8026352433
commit f16b3f05b4
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8
2 changed files with 23 additions and 20 deletions

View File

@ -81,6 +81,7 @@ class DBManager
autoload :ExploitAttempt, 'msf/core/db_manager/exploit_attempt'
autoload :ExploitedHost, 'msf/core/db_manager/exploited_host'
autoload :Host, 'msf/core/db_manager/host'
autoload :HostDetail, 'msf/core/db_manager/host_detail'
autoload :Import, 'msf/core/db_manager/import'
autoload :IPAddress, 'msf/core/db_manager/ip_address'
autoload :Loot, 'msf/core/db_manager/loot'
@ -104,6 +105,7 @@ class DBManager
include Msf::DBManager::ExploitAttempt
include Msf::DBManager::ExploitedHost
include Msf::DBManager::Host
include Msf::DBManager::HostDetail
include Msf::DBManager::Import
include Msf::DBManager::ImportMsfXml
include Msf::DBManager::IPAddress
@ -753,26 +755,6 @@ class DBManager
}
end
#
# Populate the host_details table with additional
# information, matched by a specific criteria
#
def report_host_details(host, details)
::ActiveRecord::Base.connection_pool.with_connection {
detail = ::Mdm::HostDetail.where(( details.delete(:key) || {} ).merge(:host_id => host.id)).first
if detail
details.each_pair do |k,v|
detail[k] = v
end
detail.save! if detail.changed?
detail
else
detail = ::Mdm::HostDetail.create(details.merge(:host_id => host.id))
end
}
end
#
# WMAP
# Support methods

View File

@ -0,0 +1,21 @@
module Msf::DBManager::HostDetail
#
# Populate the host_details table with additional
# information, matched by a specific criteria
#
def report_host_details(host, details)
::ActiveRecord::Base.connection_pool.with_connection {
detail = ::Mdm::HostDetail.where(( details.delete(:key) || {} ).merge(:host_id => host.id)).first
if detail
details.each_pair do |k,v|
detail[k] = v
end
detail.save! if detail.changed?
detail
else
detail = ::Mdm::HostDetail.create(details.merge(:host_id => host.id))
end
}
end
end