Module: Metasploit::Framework::Database
- Defined in:
- lib/metasploit/framework/database.rb
Constant Summary collapse
- CONFIGURATIONS_PATHNAME_PRECEDENCE =
CONSTANTS
[ :environment_configurations_pathname, :user_configurations_pathname, :project_configurations_pathname ]
Class Method Summary collapse
-
.configurations_pathname(options = {}) ⇒ Pathname?
Returns first configuration pathname from configuration_pathnames or the overridding ‘:path`.
-
.configurations_pathnames ⇒ Array<Pathname>
Return configuration pathnames that exist.
-
.environment_configurations_pathname ⇒ Pathname?
Pathname to ‘database.yml` pointed to by `MSF_DATABASE_CONFIG` environment variable.
-
.project_configurations_pathname ⇒ Pathname
Pathname to ‘database.yml` for the metasploit-framework project in `config/database.yml`.
-
.user_configurations_pathname ⇒ Pathname?
Pathname to ‘database.yml` in the user’s config directory.
Class Method Details
.configurations_pathname(options = {}) ⇒ Pathname?
Returns first configuration pathname from configuration_pathnames or the overridding ‘:path`.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/metasploit/framework/database.rb', line 26 def self.configurations_pathname(={}) .assert_valid_keys(:path) path = [:path] if path.present? pathname = Pathname.new(path) else pathname = configurations_pathnames.first end if !pathname.nil? && pathname.exist? pathname else nil end end |
.configurations_pathnames ⇒ Array<Pathname>
Return configuration pathnames that exist.
Returns ‘Pathnames` in order of precedence
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/metasploit/framework/database.rb', line 53 def self.configurations_pathnames configurations_pathnames = [] CONFIGURATIONS_PATHNAME_PRECEDENCE.each do || configurations_pathname = public_send() if !configurations_pathname.nil? && configurations_pathname.exist? configurations_pathnames << configurations_pathname end end configurations_pathnames end |
.environment_configurations_pathname ⇒ Pathname?
Pathname to ‘database.yml` pointed to by `MSF_DATABASE_CONFIG` environment variable.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/metasploit/framework/database.rb', line 71 def self.environment_configurations_pathname msf_database_config = ENV['MSF_DATABASE_CONFIG'] if msf_database_config.blank? msf_database_config = nil else msf_database_config = Pathname.new(msf_database_config) end msf_database_config end |
.project_configurations_pathname ⇒ Pathname
Pathname to ‘database.yml` for the metasploit-framework project in `config/database.yml`.
86 87 88 89 |
# File 'lib/metasploit/framework/database.rb', line 86 def self.project_configurations_pathname root = Pathname.new(__FILE__).realpath.parent.parent.parent.parent root.join('config', 'database.yml') end |
.user_configurations_pathname ⇒ Pathname?
Pathname to ‘database.yml` in the user’s config directory.
95 96 97 |
# File 'lib/metasploit/framework/database.rb', line 95 def self.user_configurations_pathname Pathname.new(Msf::Config.config_directory).join('database.yml') end |