Module: Metasploit::Model::Module::Path
- Extended by:
- ActiveModel::Naming, ActiveSupport::Concern
- Includes:
- NilifyBlanks, Translation
- Defined in:
- lib/metasploit/model/module/path.rb
Overview
Concern for sharing common code between Mdm::Module::Path
and Metasploit::Framework::Module::Path
. Define
#gem, #name, and #real_path by following the abstract instructions for each attribute.
Instance Attribute Summary collapse
-
#gem ⇒ String
abstract
The name of the gem that is adding this module path to metasploit-framework.
-
#name ⇒ String
abstract
The name of the module path scoped to #gem.
-
#real_path ⇒ String
abstract
be a text real_path column.
Instance Method Summary collapse
-
#directory ⇒ void
private
Validates that either #directory? is
true
. -
#directory? ⇒ true, false
Returns whether #real_path is a directory.
- #gem_and_name ⇒ void private
-
#named? ⇒ false, true
Returns whether is a named path.
-
#normalize_real_path ⇒ void
private
If #real_path is set and exists on disk, then converts it to a real path to eliminate any symlinks.
-
#was_named? ⇒ false, true
Returns whether was a named path.
Methods included from NilifyBlanks
Instance Attribute Details
#gem ⇒ String
In an ActiveModel, this should be an attr_accessor :gem
. In an ActiveRecord, this should be a
string gem column.
The name of the gem that is adding this module path to metasploit-framework. For paths normally added by
metasploit-framework itself, this would be 'metasploit-framework'
, while for Metasploit Pro this would be
'metasploit-pro'
. The name used for gem
does not have to be a gem on rubygems, it just functions as a
namespace for #name so that projects using metasploit-framework do not need to worry about collisions on
#name which could disrupt the cache behavior.
|
# File 'lib/metasploit/model/module/path.rb', line 51
|
#name ⇒ String
In an ActiveModel, this should be an attr_accessor :name
. In an ActiveRecord, this should be a
string name column.
The name of the module path scoped to #gem. #gem and #name uniquely identify this path so that if #real_path changes, the entire cache does not need to be invalidated because the change in #real_path will still be tied to the same (#gem, #name) tuple.
|
# File 'lib/metasploit/model/module/path.rb', line 63
|
#real_path ⇒ String
In an ActiveModel, this should be an attr_accesor :real_path
. In an ActiveRecord, this should
Non-real paths will be converted to real paths in a before validation callback, so take care to either pass real paths or pay attention when setting #real_path and then changing directories before validating.
be a text real_path column.
The real (absolute) path to module path.
|
# File 'lib/metasploit/model/module/path.rb', line 73
|
Instance Method Details
#directory ⇒ void (private)
This method returns an undefined value.
Validates that either #directory? is true
.
137 138 139 140 141 |
# File 'lib/metasploit/model/module/path.rb', line 137 def directory unless directory? errors[:real_path] << 'must be a directory' end end |
#directory? ⇒ true, false
Returns whether #real_path is a directory.
93 94 95 96 97 98 99 100 101 |
# File 'lib/metasploit/model/module/path.rb', line 93 def directory? directory = false if real_path and File.directory?(real_path) directory = true end directory end |
#gem_and_name ⇒ void (private)
146 147 148 149 150 151 152 153 154 |
# File 'lib/metasploit/model/module/path.rb', line 146 def gem_and_name if name.present? and gem.blank? errors[:gem] << "can't be blank if name is present" end if gem.present? and name.blank? errors[:name] << "can't be blank if gem is present" end end |
#named? ⇒ false, true
Returns whether is a named path.
107 108 109 110 111 112 113 114 115 |
# File 'lib/metasploit/model/module/path.rb', line 107 def named? named = false if gem.present? and name.present? named = true end named end |
#normalize_real_path ⇒ void (private)
This method returns an undefined value.
If #real_path is set and exists on disk, then converts it to a real path to eliminate any symlinks.
160 161 162 163 164 |
# File 'lib/metasploit/model/module/path.rb', line 160 def normalize_real_path if real_path and File.exist?(real_path) self.real_path = Metasploit::Model::File.realpath(real_path) end end |
#was_named? ⇒ false, true
122 123 124 125 126 127 128 129 130 |
# File 'lib/metasploit/model/module/path.rb', line 122 def was_named? was_named = false if gem_was.present? and name_was.present? was_named = true end was_named end |