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::CacheMetaDataFile, Store::UserMetaDataFile
Constants included from Search
Search::MODULE_TYPE_SHORTHANDS, Search::VALID_PARAMS
Instance Attribute Summary
Attributes included from Stats
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
- #module_metadata(type) ⇒ 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 Stats
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
32 33 34 35 36 37 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 32 def @mutex.synchronize { wait_for_load @module_metadata_cache.values } end |
#get_module_reference(type:, reference_name:) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 39 def get_module_reference(type:, reference_name:) @mutex.synchronize do wait_for_load @module_metadata_cache["#{type}_#{reference_name}"] end end |
#module_metadata(type) ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 94 def (type) @mutex.synchronize do wait_for_load type_hash = @metadata_type_index[type] type_hash ? type_hash.dup : {} 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.
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 87 88 89 90 91 92 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 49 def (module_sets) has_changes = false @mutex.synchronize { wait_for_load unchanged_module_references = get_unchanged_module_references 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 rebuild_type_cache end } if has_changes update_store clear_maps update_stats end end |
#refresh_metadata_instance(module_instance) ⇒ Object
Refreshes cached module metadata as well as updating the store
20 21 22 23 24 25 26 27 |
# File 'lib/msf/core/modules/metadata/cache.rb', line 20 def (module_instance) @mutex.synchronize { wait_for_load dlog "Refreshing #{module_instance.refname} of type: #{module_instance.type}" (module_instance) update_store } end |