Class: Msf::ModuleDataStore
- Defined in:
- lib/msf/core/module_data_store.rb
Overview
DataStore wrapper for modules that will attempt to back values against the framework’s datastore if they aren’t found in the module’s datastore. This is done to simulate global data store values.
Instance Attribute Summary
Attributes inherited from DataStore
#aliases, #imported, #imported_by, #options
Class Method Summary collapse
-
.new(m) ⇒ Object
Temporary forking logic for conditionally using the ModuleDatastoreWithFallbacks implementation.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Same as fetch.
-
#copy ⇒ Object
Return a deep copy of this datastore.
-
#default?(key) ⇒ Boolean
Was this entry actually set or just using its default.
-
#fetch(key) ⇒ Object
Fetch the key from the local hash first, or from the framework datastore if we can’t directly find it.
-
#initialize(m) ⇒ ModuleDataStore
constructor
A new instance of ModuleDataStore.
Methods inherited from DataStore
#[]=, #clear, #clear_non_user_defined, #delete, #each, #find_key_case, #from_file, #import_option, #import_options, #import_options_from_hash, #import_options_from_s, #merge, #merge!, #store, #to_external_message_h, #to_file, #to_h, #to_s, #update_value, #user_defined
Constructor Details
#initialize(m) ⇒ ModuleDataStore
Returns a new instance of ModuleDataStore.
27 28 29 30 31 |
# File 'lib/msf/core/module_data_store.rb', line 27 def initialize(m) super() @_module = m end |
Class Method Details
.new(m) ⇒ Object
Temporary forking logic for conditionally using the Msf::ModuleDatastoreWithFallbacks implementation.
This method replaces the default ‘ModuleDataStore.new` with the ability to instantiate the `ModuleDataStoreWithFallbacks` class instead, if the feature is enabled
17 18 19 20 21 22 23 24 25 |
# File 'lib/msf/core/module_data_store.rb', line 17 def self.new(m) if Msf::FeatureManager.instance.enabled?(Msf::FeatureManager::DATASTORE_FALLBACKS) return Msf::ModuleDataStoreWithFallbacks.new(m) end instance = allocate instance.send(:initialize, m) instance end |
Instance Method Details
#[](key) ⇒ Object
Same as fetch
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/msf/core/module_data_store.rb', line 51 def [](key) key = find_key_case(key) val = nil val = super if(@imported_by[key] != 'self') if (val.nil? and @_module and @_module.framework) val = @_module.framework.datastore[key] end val = super if val.nil? val end |
#copy ⇒ Object
Return a deep copy of this datastore.
72 73 74 75 76 77 78 79 |
# File 'lib/msf/core/module_data_store.rb', line 72 def copy ds = self.class.new(@_module) self.keys.each do |k| ds.import_option(k, self[k].kind_of?(String) ? self[k].dup : self[k], @imported[k], @imported_by[k]) end ds.aliases = self.aliases.dup ds end |
#default?(key) ⇒ Boolean
Was this entry actually set or just using its default
65 66 67 |
# File 'lib/msf/core/module_data_store.rb', line 65 def default?(key) (@imported_by[key] == 'self') end |
#fetch(key) ⇒ Object
Fetch the key from the local hash first, or from the framework datastore if we can’t directly find it
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/msf/core/module_data_store.rb', line 37 def fetch(key) key = find_key_case(key) val = nil val = super if(@imported_by[key] != 'self') if (val.nil? and @_module and @_module.framework) val = @_module.framework.datastore[key] end val = super if val.nil? val end |