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`.bug/bundler_fix
parent
e242bf914f
commit
13923a8ca5
|
@ -3,11 +3,11 @@ module Msf::DBManager::HostTag
|
|||
# conditions and return hash as well.
|
||||
def report_host_tag(opts)
|
||||
name = opts.delete(:name)
|
||||
raise DBImportError.new("Missing required option :name") unless name
|
||||
raise Msf::DBImportError.new("Missing required option :name") unless name
|
||||
addr = opts.delete(:addr)
|
||||
raise DBImportError.new("Missing required option :addr") unless addr
|
||||
raise Msf::DBImportError.new("Missing required option :addr") unless addr
|
||||
wspace = opts.delete(:wspace)
|
||||
raise DBImportError.new("Missing required option :wspace") unless wspace
|
||||
raise Msf::DBImportError.new("Missing required option :wspace") unless wspace
|
||||
::ActiveRecord::Base.connection_pool.with_connection {
|
||||
if wspace.kind_of? String
|
||||
wspace = find_workspace(wspace)
|
||||
|
|
|
@ -107,7 +107,7 @@ module Msf::DBManager::Import
|
|||
data = f.read(Metasploit::Credential::Exporter::Pwdump::FILE_ID_STRING.size)
|
||||
end
|
||||
if data.nil?
|
||||
raise DBImportError.new("Zero-length file")
|
||||
raise Msf::DBImportError.new("Zero-length file")
|
||||
end
|
||||
|
||||
if data.index(Metasploit::Credential::Exporter::Pwdump::FILE_ID_STRING)
|
||||
|
@ -172,12 +172,12 @@ module Msf::DBManager::Import
|
|||
#
|
||||
# If there is no match, an error is raised instead.
|
||||
#
|
||||
# @raise DBImportError if the type can't be detected
|
||||
# @raise [Msf::DBImportError] if the type can't be detected
|
||||
def import_filetype_detect(data)
|
||||
|
||||
if data and data.kind_of? Zip::File
|
||||
if data.entries.empty?
|
||||
raise DBImportError.new("The zip file provided is empty.")
|
||||
raise Msf::DBImportError.new("The zip file provided is empty.")
|
||||
end
|
||||
|
||||
@import_filedata ||= {}
|
||||
|
@ -194,7 +194,7 @@ module Msf::DBManager::Import
|
|||
|
||||
# TODO This check for our zip export should be more extensive
|
||||
if xml_files.empty?
|
||||
raise DBImportError.new("The zip file provided is not a Metasploit Zip Export")
|
||||
raise Msf::DBImportError.new("The zip file provided is not a Metasploit Zip Export")
|
||||
end
|
||||
|
||||
@import_filedata[:zip_xml] = xml_files.first
|
||||
|
@ -207,7 +207,7 @@ module Msf::DBManager::Import
|
|||
# Don't check for emptiness here because unlike other formats, we
|
||||
# haven't read any actual data in yet, only magic bytes to discover
|
||||
# that this is indeed a pcap file.
|
||||
#raise DBImportError.new("The pcap file provided is empty.") if data.body.empty?
|
||||
#raise Msf::DBImportError.new("The pcap file provided is empty.") if data.body.empty?
|
||||
@import_filedata ||= {}
|
||||
@import_filedata[:type] = "Libpcap Packet Capture"
|
||||
return :libpcap
|
||||
|
@ -222,7 +222,7 @@ module Msf::DBManager::Import
|
|||
# This is a text string, lets make sure its treated as binary
|
||||
data = data.unpack("C*").pack("C*")
|
||||
if data and data.to_s.strip.length == 0
|
||||
raise DBImportError.new("The data provided to the import function was empty")
|
||||
raise Msf::DBImportError.new("The data provided to the import function was empty")
|
||||
end
|
||||
|
||||
# Parse the first line or 4k of data from the file
|
||||
|
@ -354,7 +354,7 @@ module Msf::DBManager::Import
|
|||
return :msf_pwdump
|
||||
end
|
||||
|
||||
raise DBImportError.new("Could not automatically determine file type")
|
||||
raise Msf::DBImportError.new("Could not automatically determine file type")
|
||||
end
|
||||
|
||||
# Handles timestamps from Metasploit Express/Pro imports.
|
||||
|
@ -440,7 +440,7 @@ module Msf::DBManager::Import
|
|||
def validate_import_file(data)
|
||||
begin
|
||||
import_filetype_detect(data)
|
||||
rescue DBImportError
|
||||
rescue Msf::DBImportError
|
||||
return false
|
||||
end
|
||||
return true
|
||||
|
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::Acunetix
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ module Msf::DBManager::Import::Amap
|
|||
when :amap_mlog
|
||||
import_amap_mlog(args.merge(:data => data))
|
||||
else
|
||||
raise DBImportError.new("Could not determine file type")
|
||||
raise Msf::DBImportError.new("Could not determine file type")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::Appscan
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -28,7 +28,7 @@ module Msf::DBManager::Import::Burp
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::CI
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::Foundstone
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ module Msf::DBManager::Import::IP360::ASPL
|
|||
bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : []
|
||||
|
||||
if not data.index("<ontology")
|
||||
raise DBImportError.new("The ASPL file does not appear to be valid or may still be compressed")
|
||||
raise Msf::DBImportError.new("The ASPL file does not appear to be valid or may still be compressed")
|
||||
end
|
||||
|
||||
base = ::File.join(Msf::Config.config_directory, "data", "ncircle")
|
||||
|
|
|
@ -39,7 +39,7 @@ module Msf::DBManager::Import::IP360::V3
|
|||
end
|
||||
|
||||
if not aspl_path
|
||||
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")
|
||||
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")
|
||||
end
|
||||
|
||||
# parse nCircle ASPL file
|
||||
|
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::MBSA
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,7 +32,7 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
|
|||
m_ver = nil
|
||||
end
|
||||
unless m_ver and btag
|
||||
raise DBImportError.new("Unsupported Metasploit XML document format")
|
||||
raise Msf::DBImportError.new("Unsupported Metasploit XML document format")
|
||||
end
|
||||
|
||||
host_info = {}
|
||||
|
@ -70,7 +70,7 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
|
|||
loot_file = ::File.split(loot_info[:orig_path]).last
|
||||
if ::File.exists? loot_dir
|
||||
unless (::File.directory?(loot_dir) && ::File.writable?(loot_dir))
|
||||
raise DBImportError.new("Could not move files to #{loot_dir}")
|
||||
raise Msf::DBImportError.new("Could not move files to #{loot_dir}")
|
||||
end
|
||||
else
|
||||
::FileUtils.mkdir_p(loot_dir)
|
||||
|
@ -120,7 +120,7 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
|
|||
task_file = ::File.split(task_info[:orig_path]).last
|
||||
if ::File.exists? tasks_dir
|
||||
unless (::File.directory?(tasks_dir) && ::File.writable?(tasks_dir))
|
||||
raise DBImportError.new("Could not move files to #{tasks_dir}")
|
||||
raise Msf::DBImportError.new("Could not move files to #{tasks_dir}")
|
||||
end
|
||||
else
|
||||
::FileUtils.mkdir_p(tasks_dir)
|
||||
|
@ -158,7 +158,7 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
|
|||
new_tmp = ::File.join(Dir::tmpdir,"msf","imp_#{Rex::Text::rand_text_alphanumeric(4)}",@import_filedata[:zip_basename])
|
||||
if ::File.exists? new_tmp
|
||||
unless (::File.directory?(new_tmp) && ::File.writable?(new_tmp))
|
||||
raise DBImportError.new("Could not extract zip file to #{new_tmp}")
|
||||
raise Msf::DBImportError.new("Could not extract zip file to #{new_tmp}")
|
||||
end
|
||||
else
|
||||
FileUtils.mkdir_p(new_tmp)
|
||||
|
@ -175,7 +175,7 @@ module Msf::DBManager::Import::MetasploitFramework::Zip
|
|||
if File.exists? tmp_subdirs
|
||||
unless (::File.directory?(tmp_subdirs) && File.writable?(tmp_subdirs))
|
||||
# if it exists but we can't write to it, give up
|
||||
raise DBImportError.new("Could not extract zip file to #{tmp_subdirs}")
|
||||
raise Msf::DBImportError.new("Could not extract zip file to #{tmp_subdirs}")
|
||||
end
|
||||
else
|
||||
::FileUtils.mkdir(tmp_subdirs)
|
||||
|
|
|
@ -29,6 +29,6 @@ module Msf::DBManager::Import::OpenVAS
|
|||
filename = args[:filename]
|
||||
wspace = args[:wspace] || workspace
|
||||
|
||||
raise DBImportError.new("No OpenVAS XML support. Please submit a patch to msfdev[at]metasploit.com")
|
||||
raise Msf::DBImportError.new("No OpenVAS XML support. Please submit a patch to msfdev[at]metasploit.com")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -27,7 +27,7 @@ module Msf::DBManager::Import::Outpost24
|
|||
end
|
||||
return true
|
||||
else # Sorry
|
||||
raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
raise Msf::DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -24,11 +24,11 @@ module Msf::DBManager::Report
|
|||
updated = opts.delete(:updated_at)
|
||||
|
||||
unless File.exists? tmp_path
|
||||
raise DBImportError 'Report artifact file to be imported does not exist.'
|
||||
raise Msf::DBImportError 'Report artifact file to be imported does not exist.'
|
||||
end
|
||||
|
||||
unless (File.directory?(artifacts_dir) && File.writable?(artifacts_dir))
|
||||
raise DBImportError "Could not move report artifact file to #{artifacts_dir}."
|
||||
raise Msf::DBImportError "Could not move report artifact file to #{artifacts_dir}."
|
||||
end
|
||||
|
||||
if File.exists? new_path
|
||||
|
|
|
@ -1463,7 +1463,7 @@ class Db
|
|||
print_error("Please note that there were #{warnings} warnings") if warnings > 1
|
||||
print_error("Please note that there was one warning") if warnings == 1
|
||||
|
||||
rescue DBImportError
|
||||
rescue Msf::DBImportError
|
||||
print_error("Failed to import #{filename}: #{$!}")
|
||||
elog("Failed to import #{filename}: #{$!.class}: #{$!}")
|
||||
dlog("Call stack: #{$@.join("\n")}", LEV_3)
|
||||
|
|
|
@ -160,7 +160,7 @@ shared_examples_for 'Msf::DBManager::Import::MetasploitFramework::XML' do
|
|||
)
|
||||
|
||||
context 'with other' do
|
||||
it 'should raise DBImportError' do
|
||||
it 'should raise Msf::DBImportError' do
|
||||
expect {
|
||||
metadata
|
||||
}.to raise_error(
|
||||
|
|
Loading…
Reference in New Issue