WIP: updating ref lookup based on code review comments

GSoC/Meterpreter_Web_Console
James Barnett 2019-01-02 15:42:38 -06:00
parent 5f43ec0a79
commit b875d391fc
No known key found for this signature in database
GPG Key ID: 647983861A4EC5EA
2 changed files with 10 additions and 5 deletions

View File

@ -4,11 +4,16 @@ module Msf::DBManager::Ref
#
def find_or_create_ref(opts)
ret = {}
ret[:ref] = get_ref(opts[:name])
ret[:ref] = Mdm::Ref.find_by_id(opts[:id]) if opts[:id]
return ret[:ref] if ret[:ref]
::ActiveRecord::Base.connection_pool.with_connection {
if opts[:id] && !opts[:id].to_s.empty?
return Array.wrap(Mdm::Ref.find(opts[:id]))
end
if opts[:ref]
return Array.wrap(get_ref(opts[:name]))
end
ref = ::Mdm::Ref.where(name: opts[:name]).first_or_initialize
begin
@ -21,7 +26,7 @@ module Msf::DBManager::Ref
if ref and ref.changed?
ref.save!
end
ret[:ref] = ref
Array.wrap(ref)
}
end

View File

@ -23,4 +23,4 @@
</div>
</body>
</html>
</html>