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 48
 | 
#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 60
 | 
#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 70
 | 
Instance Method Details
#directory ⇒ void (private)
This method returns an undefined value.
Validates that either #directory? is true.
| 134 135 136 137 138 | # File 'lib/metasploit/model/module/path.rb', line 134 def directory unless directory? errors[:real_path] << 'must be a directory' end end | 
#directory? ⇒ true, false
Returns whether #real_path is a directory.
| 90 91 92 93 94 95 96 97 98 | # File 'lib/metasploit/model/module/path.rb', line 90 def directory? directory = false if real_path and File.directory?(real_path) directory = true end directory end | 
#gem_and_name ⇒ void (private)
| 143 144 145 146 147 148 149 150 151 | # File 'lib/metasploit/model/module/path.rb', line 143 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.
| 104 105 106 107 108 109 110 111 112 | # File 'lib/metasploit/model/module/path.rb', line 104 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.
| 157 158 159 160 161 | # File 'lib/metasploit/model/module/path.rb', line 157 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
| 119 120 121 122 123 124 125 126 127 | # File 'lib/metasploit/model/module/path.rb', line 119 def was_named? was_named = false if gem_was.present? and name_was.present? was_named = true end was_named end |