Use :: to force top-level constant resolution

MSP-11152

When `Msf::DBManager::Import::MetasploitFramework` is included in
`Msf::DBManager::Import`, it's child namespace of
`Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as
`Zip` in `Msf::DBManager::Import` methods, so need to use `::Zip` to
cause `Zip` to be resolved from rubyzip gem.
bug/bundler_fix
Luke Imhoff 2014-10-17 10:15:59 -05:00
parent 13923a8ca5
commit 9f32cbd476
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8
1 changed files with 8 additions and 3 deletions

View File

@ -115,7 +115,10 @@ module Msf::DBManager::Import
else
case data[0,4]
when "PK\x03\x04"
data = Zip::File.open(filename)
# When Msf::DBManager::Import::MetasploitFramework is included, it's child namespace of
# Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as Zip here, so need to use ::Zip so Zip
# is resolved as one from rubyzip gem.
data = ::Zip::File.open(filename)
when "\xd4\xc3\xb2\xa1", "\xa1\xb2\xc3\xd4"
data = PacketFu::PcapFile.new(:filename => filename)
else
@ -174,8 +177,10 @@ module Msf::DBManager::Import
#
# @raise [Msf::DBImportError] if the type can't be detected
def import_filetype_detect(data)
if data and data.kind_of? Zip::File
# When Msf::DBManager::Import::MetasploitFramework is included, it's child namespace of
# Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as Zip here, so need to use ::Zip so Zip
# is resolved as one from rubyzip gem.
if data and data.kind_of? ::Zip::File
if data.entries.empty?
raise Msf::DBImportError.new("The zip file provided is empty.")
end