Skip to content

Commit 13923a8

Browse files
committed
Fully-qualify Msf::DBImportError
MSP-11152 Constant was unqualified in some of the reorganized Msf::DBManager code because that code was take advantage of the old nested lexical scope that included `Msf`.
1 parent e242bf9 commit 13923a8

File tree

17 files changed

+31
-31
lines changed

17 files changed

+31
-31
lines changed

lib/msf/core/db_manager/host_tag.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module Msf::DBManager::HostTag
33
# conditions and return hash as well.
44
def report_host_tag(opts)
55
name = opts.delete(:name)
6-
raise DBImportError.new("Missing required option :name") unless name
6+
raise Msf::DBImportError.new("Missing required option :name") unless name
77
addr = opts.delete(:addr)
8-
raise DBImportError.new("Missing required option :addr") unless addr
8+
raise Msf::DBImportError.new("Missing required option :addr") unless addr
99
wspace = opts.delete(:wspace)
10-
raise DBImportError.new("Missing required option :wspace") unless wspace
10+
raise Msf::DBImportError.new("Missing required option :wspace") unless wspace
1111
::ActiveRecord::Base.connection_pool.with_connection {
1212
if wspace.kind_of? String
1313
wspace = find_workspace(wspace)

lib/msf/core/db_manager/import.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def import_file(args={}, &block)
107107
data = f.read(Metasploit::Credential::Exporter::Pwdump::FILE_ID_STRING.size)
108108
end
109109
if data.nil?
110-
raise DBImportError.new("Zero-length file")
110+
raise Msf::DBImportError.new("Zero-length file")
111111
end
112112

113113
if data.index(Metasploit::Credential::Exporter::Pwdump::FILE_ID_STRING)
@@ -172,12 +172,12 @@ def import_file(args={}, &block)
172172
#
173173
# If there is no match, an error is raised instead.
174174
#
175-
# @raise DBImportError if the type can't be detected
175+
# @raise [Msf::DBImportError] if the type can't be detected
176176
def import_filetype_detect(data)
177177

178178
if data and data.kind_of? Zip::File
179179
if data.entries.empty?
180-
raise DBImportError.new("The zip file provided is empty.")
180+
raise Msf::DBImportError.new("The zip file provided is empty.")
181181
end
182182

183183
@import_filedata ||= {}
@@ -194,7 +194,7 @@ def import_filetype_detect(data)
194194

195195
# TODO This check for our zip export should be more extensive
196196
if xml_files.empty?
197-
raise DBImportError.new("The zip file provided is not a Metasploit Zip Export")
197+
raise Msf::DBImportError.new("The zip file provided is not a Metasploit Zip Export")
198198
end
199199

200200
@import_filedata[:zip_xml] = xml_files.first
@@ -207,7 +207,7 @@ def import_filetype_detect(data)
207207
# Don't check for emptiness here because unlike other formats, we
208208
# haven't read any actual data in yet, only magic bytes to discover
209209
# that this is indeed a pcap file.
210-
#raise DBImportError.new("The pcap file provided is empty.") if data.body.empty?
210+
#raise Msf::DBImportError.new("The pcap file provided is empty.") if data.body.empty?
211211
@import_filedata ||= {}
212212
@import_filedata[:type] = "Libpcap Packet Capture"
213213
return :libpcap
@@ -222,7 +222,7 @@ def import_filetype_detect(data)
222222
# This is a text string, lets make sure its treated as binary
223223
data = data.unpack("C*").pack("C*")
224224
if data and data.to_s.strip.length == 0
225-
raise DBImportError.new("The data provided to the import function was empty")
225+
raise Msf::DBImportError.new("The data provided to the import function was empty")
226226
end
227227

228228
# Parse the first line or 4k of data from the file
@@ -354,7 +354,7 @@ def import_filetype_detect(data)
354354
return :msf_pwdump
355355
end
356356

357-
raise DBImportError.new("Could not automatically determine file type")
357+
raise Msf::DBImportError.new("Could not automatically determine file type")
358358
end
359359

360360
# Handles timestamps from Metasploit Express/Pro imports.
@@ -440,7 +440,7 @@ def service_name_map(proto)
440440
def validate_import_file(data)
441441
begin
442442
import_filetype_detect(data)
443-
rescue DBImportError
443+
rescue Msf::DBImportError
444444
return false
445445
end
446446
return true

lib/msf/core/db_manager/import/acunetix.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def import_acunetix_xml(args={}, &block)
2727
end
2828
return true
2929
else # Sorry
30-
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
30+
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
3131
end
3232
end
3333

lib/msf/core/db_manager/import/amap.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def import_amap_log_file(args={})
4343
when :amap_mlog
4444
import_amap_mlog(args.merge(:data => data))
4545
else
46-
raise DBImportError.new("Could not determine file type")
46+
raise Msf::DBImportError.new("Could not determine file type")
4747
end
4848
end
4949

lib/msf/core/db_manager/import/appscan.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def import_appscan_xml(args={}, &block)
2727
end
2828
return true
2929
else # Sorry
30-
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
30+
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
3131
end
3232
end
3333
end

lib/msf/core/db_manager/import/burp.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def import_burp_session_xml(args={}, &block)
2828
end
2929
return true
3030
else # Sorry
31-
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
31+
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
3232
end
3333
end
3434
end

lib/msf/core/db_manager/import/ci.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def import_ci_xml(args={}, &block)
2727
end
2828
return true
2929
else # Sorry
30-
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
30+
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
3131
end
3232
end
3333
end

lib/msf/core/db_manager/import/foundstone.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def import_foundstone_xml(args={}, &block)
2727
end
2828
return true
2929
else # Sorry
30-
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
30+
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
3131
end
3232
end
3333
end

lib/msf/core/db_manager/import/ip360/aspl.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def import_ip360_aspl_xml(args={}, &block)
1010
bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
1111

1212
if not data.index("<ontology")
13-
raise DBImportError.new("The ASPL file does not appear to be valid or may still be compressed")
13+
raise Msf::DBImportError.new("The ASPL file does not appear to be valid or may still be compressed")
1414
end
1515

1616
base = ::File.join(Msf::Config.config_directory, "data", "ncircle")

lib/msf/core/db_manager/import/ip360/v3.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def import_ip360_xml_v3(args={}, &block)
3939
end
4040

4141
if not aspl_path
42-
raise DBImportError.new("The nCircle IP360 ASPL file is not present.\n Download ASPL from nCircle VNE | Administer | Support | Resources, unzip it, and import it first")
42+
raise Msf::DBImportError.new("The nCircle IP360 ASPL file is not present.\n Download ASPL from nCircle VNE | Administer | Support | Resources, unzip it, and import it first")
4343
end
4444

4545
# parse nCircle ASPL file

0 commit comments

Comments
 (0)