Class: Metasploit::Credential::Importer::Multi
- Inherits:
-
Object
- Object
- Metasploit::Credential::Importer::Multi
- Includes:
- Base
- Defined in:
- lib/metasploit/credential/importer/multi.rb
Overview
Multi allows a single class to pass off a file to the correct importer as long as the file meets certain basic requirements. Each file type is identified, and if supported, another class in the Metasploit::Credential::Importer namespace is instantiated with the ‘#input` attribute passed in there.
Constant Summary
Constants included from Base
Base::LONG_FORM_ALLOWED_PRIVATE_TYPE_NAMES, Base::SHORT_FORM_ALLOWED_PRIVATE_TYPE_NAMES
Instance Attribute Summary collapse
-
#selected_importer ⇒ IO
An instance of the importer class which will handle the processing of input into the system.
Instance Method Summary collapse
-
#csv? ⇒ Boolean
True if the file has a “.csv” extension.
-
#import! ⇒ void
Perform the import.
-
#initialize(args = {}) ⇒ Multi
constructor
Instance Methods.
-
#zip? ⇒ Boolean
True if the file can be opened with ‘Zip::File::open`, false otherwise.
Constructor Details
#initialize(args = {}) ⇒ Multi
Instance Methods
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/metasploit/credential/importer/multi.rb', line 32 def initialize(args={}) @selected_importer = nil super(args) if zip? @selected_importer = Metasploit::Credential::Importer::Zip.new(input: input, origin: origin, workspace: workspace) elsif csv? @selected_importer = Metasploit::Credential::Importer::Core.new(input: input, origin: origin, workspace: workspace) end end |
Instance Attribute Details
#selected_importer ⇒ IO
An instance of the importer class which will handle the processing of input into the system.
20 21 22 |
# File 'lib/metasploit/credential/importer/multi.rb', line 20 def selected_importer @selected_importer end |
Instance Method Details
#csv? ⇒ Boolean
True if the file has a “.csv” extension
66 67 68 |
# File 'lib/metasploit/credential/importer/multi.rb', line 66 def csv? ::Pathname.new(input.path).extname == '.csv' end |
#import! ⇒ void
This method returns an undefined value.
Perform the import
46 47 48 |
# File 'lib/metasploit/credential/importer/multi.rb', line 46 def import! selected_importer.import! end |
#zip? ⇒ Boolean
True if the file can be opened with ‘Zip::File::open`, false otherwise
54 55 56 57 58 59 60 61 |
# File 'lib/metasploit/credential/importer/multi.rb', line 54 def zip? begin ::Zip::File.open input.path true rescue ::Zip::Error false end end |