Only do regex search if search_term is passed

GSoC/Meterpreter_Web_Console
James Barnett 2018-03-12 17:14:44 -05:00
parent 2e287135c4
commit e480b7dd2c
No known key found for this signature in database
GPG Key ID: 647983861A4EC5EA
2 changed files with 13 additions and 5 deletions

View File

@ -30,11 +30,15 @@ module Msf::DBManager::Loot
wspace = find_workspace(wspace)
end
opts[:workspace_id] = wspace.id
search_term = opts.delete(:search_term)
::ActiveRecord::Base.connection_pool.with_connection {
search_term = opts.delete(:search_term)
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Loot, search_term)
Mdm::Loot.includes(:host).where(opts).where(column_search_conditions)
if search_term && !search_term.empty?
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Loot, search_term)
Mdm::Loot.includes(:host).where(opts).where(column_search_conditions)
else
Mdm::Loot.includes(:host).where(opts)
end
}
end
alias_method :loot, :loots

View File

@ -147,8 +147,12 @@ module Msf::DBManager::Service
opts.compact!
::ActiveRecord::Base.connection_pool.with_connection {
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Service, search_term)
Mdm::Service.includes(:host).where(opts).where(column_search_conditions).order("hosts.address, port")
if search_term && !search_term.empty?
column_search_conditions = Msf::Util::DBManager.create_all_column_search_conditions(Mdm::Service, search_term)
Mdm::Service.includes(:host).where(opts).where(column_search_conditions).order("hosts.address, port")
else
Mdm::Service.includes(:host).where(opts).order("hosts.address, port")
end
}
end