Skip to content

Commit 9f32cbd

Browse files
committed
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.
1 parent 13923a8 commit 9f32cbd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/msf/core/db_manager/import.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ def import_file(args={}, &block)
115115
else
116116
case data[0,4]
117117
when "PK\x03\x04"
118-
data = Zip::File.open(filename)
118+
# When Msf::DBManager::Import::MetasploitFramework is included, it's child namespace of
119+
# Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as Zip here, so need to use ::Zip so Zip
120+
# is resolved as one from rubyzip gem.
121+
data = ::Zip::File.open(filename)
119122
when "\xd4\xc3\xb2\xa1", "\xa1\xb2\xc3\xd4"
120123
data = PacketFu::PcapFile.new(:filename => filename)
121124
else
@@ -174,8 +177,10 @@ def import_file(args={}, &block)
174177
#
175178
# @raise [Msf::DBImportError] if the type can't be detected
176179
def import_filetype_detect(data)
177-
178-
if data and data.kind_of? Zip::File
180+
# When Msf::DBManager::Import::MetasploitFramework is included, it's child namespace of
181+
# Msf::DBManager::Import::MetasploitFramework::Zip becomes resolvable as Zip here, so need to use ::Zip so Zip
182+
# is resolved as one from rubyzip gem.
183+
if data and data.kind_of? ::Zip::File
179184
if data.entries.empty?
180185
raise Msf::DBImportError.new("The zip file provided is empty.")
181186
end

0 commit comments

Comments
 (0)