Class: Msf::Modules::Metadata::Cache
- Inherits:
-
Object
- Object
- Msf::Modules::Metadata::Cache
- Defined in:
- lib/msf/core/modules/metadata/cache.rb
Constant Summary
Constants included from Store
Store::BaseMetaDataFile, Store::UserMetaDataFile
Constants included from Search
Search::MODULE_TYPE_SHORTHANDS, Search::VALID_PARAMS
Instance Method Summary collapse
-
#get_metadata ⇒ Object
Returns the module data cache, but first ensures all the metadata is loaded.
- #get_module_reference(type:, reference_name:) ⇒ Object
-
#refresh_metadata(module_sets) ⇒ Object
Checks for modules loaded that are not a part of the cache and updates the underlying store if there are changes.
-
#refresh_metadata_instance(module_instance) ⇒ Object
Refreshes cached module metadata as well as updating the store.
Methods included from Maps
Methods included from Store
Methods included from Search
Instance Method Details
#get_metadata ⇒ Object
Returns the module data cache, but first ensures all the metadata is loaded
30 31 32 33 34 35 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 30 def @mutex.synchronize { wait_for_load @module_metadata_cache.values } end |
#get_module_reference(type:, reference_name:) ⇒ Object
37 38 39 40 41 42 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 37 def get_module_reference(type:, reference_name:) @mutex.synchronize do wait_for_load @module_metadata_cache["#{type}_#{reference_name}"] end end |
#refresh_metadata(module_sets) ⇒ Object
Checks for modules loaded that are not a part of the cache and updates the underlying store if there are changes.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 47 def (module_sets) @mutex.synchronize { unchanged_module_references = get_unchanged_module_references has_changes = false module_sets.each do |mt| unchanged_reference_name_set = unchanged_module_references[mt[0]] mt[1].keys.sort.each do |mn| next if unchanged_reference_name_set.include? mn begin module_instance = mt[1].create(mn, cache_type: Msf::ModuleManager::Cache::MEMORY) rescue Exception => e elog "Unable to create module: #{mn}. #{e.}" end unless module_instance wlog "Removing invalid module reference from cache: #{mn}" existed = remove_from_cache(mn) if existed has_changes = true end next end begin (module_instance) has_changes = true rescue Exception => e elog("Error updating module details for #{module_instance.fullname}", error: e) end end end if has_changes update_store clear_maps end } end |
#refresh_metadata_instance(module_instance) ⇒ Object
Refreshes cached module metadata as well as updating the store
19 20 21 22 23 24 25 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 19 def (module_instance) @mutex.synchronize { dlog "Refreshing #{module_instance.refname} of type: #{module_instance.type}" (module_instance) update_store } end |