Module: Metasploit::Framework::Require
- Included in:
- Msf::Auxiliary::Report, Msf::DBManager
- Defined in:
- lib/metasploit/framework/require.rb
Overview
Extension to ‘Kernel#require` behavior.
Class Method Summary collapse
-
.optionally(name, without_warning) { ... } ⇒ void
Tries to require ‘name`.
-
.optionally_active_record_railtie ⇒ void
Tries to ‘require ’active_record/railtie’‘ to define the activerecord Rails initializers and rake tasks.
-
.optionally_include_metasploit_credential_creation(including_module) ⇒ void
Tries to ‘require ’metasploit/credential’‘ and include `Metasploit::Credential::Creation` in the `including_module`.
-
.optionally_require_metasploit_db_gem_engines ⇒ void
Tries to require gems necessary for using a database with the framework.
Instance Method Summary collapse
-
#optionally_include_metasploit_credential_creation ⇒ void
Tries to ‘require ’metasploit/credential/creation’‘ and include it in this `Class` or `Module`.
Class Method Details
.optionally(name, without_warning) { ... } ⇒ void
This method returns an undefined value.
Tries to require ‘name`. If a `LoadError` occurs, then `without_warning` is printed to standard error using `Kernel#warn`, along with instructions for reinstalling the bundle. If a `LoadError` does not occur, then `with_block` is called.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/metasploit/framework/require.rb', line 20 def self.optionally(name, without_warning) begin require name rescue LoadError warn without_warning warn "Bundle installed '--without #{Bundler.settings.without.join(' ')}'" warn "To clear the without option do `bundle install --without ''` " \ "(the --without flag with an empty string) or " \ "`rm -rf .bundle` to remove the .bundle/config manually and " \ "then `bundle install`" else if block_given? yield end end end |
.optionally_active_record_railtie ⇒ void
This method returns an undefined value.
Tries to ‘require ’active_record/railtie’‘ to define the activerecord Rails initializers and rake tasks.
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/metasploit/framework/require.rb', line 51 def self.optionally_active_record_railtie if ::Rails.application.config.paths['config/database'].any? optionally( 'active_record/railtie', 'activerecord not in the bundle, so database support will be disabled.' ) else warn 'Could not find database.yml, so database support will be disabled.' end end |
.optionally_include_metasploit_credential_creation(including_module) ⇒ void
This method returns an undefined value.
Tries to ‘require ’metasploit/credential’‘ and include `Metasploit::Credential::Creation` in the `including_module`.
67 68 69 70 71 72 73 74 |
# File 'lib/metasploit/framework/require.rb', line 67 def self.(including_module) optionally( 'metasploit/credential', "metasploit-credential not in the bundle, so Metasploit::Credential creation will fail for #{including_module.name}" ) do including_module.send(:include, Metasploit::Credential::Creation) end end |
.optionally_require_metasploit_db_gem_engines ⇒ void
This method returns an undefined value.
Tries to require gems necessary for using a database with the framework.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/metasploit/framework/require.rb', line 82 def self. optionally( 'metasploit/credential', 'metasploit-credential not in the bundle', ) do require 'metasploit/credential/engine' end optionally( 'metasploit_data_models', 'metasploit_data_models not in the bundle' ) do require 'metasploit_data_models/engine' end end |
Instance Method Details
#optionally_include_metasploit_credential_creation ⇒ void
This method returns an undefined value.
Tries to ‘require ’metasploit/credential/creation’‘ and include it in this `Class` or `Module`.
114 115 116 |
# File 'lib/metasploit/framework/require.rb', line 114 def Metasploit::Framework::Require.(self) end |