Module: Wpxf::Cli::ModuleCache
- Included in:
- Console
- Defined in:
- lib/wpxf/cli/module_cache.rb
Overview
A mixin to handle the database caching of module data.
Instance Attribute Summary collapse
-
#current_version_number ⇒ Object
Returns the value of attribute current_version_number.
Instance Method Summary collapse
- #cache_valid? ⇒ Boolean
- #create_module_models(type) ⇒ Object
- #initialize ⇒ Object
- #rebuild_cache ⇒ Object
- #refresh_version_log ⇒ Object
Instance Attribute Details
#current_version_number ⇒ Object
Returns the value of attribute current_version_number.
57 58 59 |
# File 'lib/wpxf/cli/module_cache.rb', line 57 def current_version_number @current_version_number end |
Instance Method Details
#cache_valid? ⇒ Boolean
12 13 14 15 16 17 18 19 20 |
# File 'lib/wpxf/cli/module_cache.rb', line 12 def cache_valid? last_version_log = Wpxf::Models::Log.first(key: 'version') return false if last_version_log.nil? current_version = Gem::Version.new(current_version_number) last_version = Gem::Version.new(last_version_log.value) current_version == last_version end |
#create_module_models(type) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/wpxf/cli/module_cache.rb', line 22 def create_module_models(type) namespace = type == 'exploit' ? Wpxf::Exploit : Wpxf::Auxiliary namespace.module_list.each do |mod| instance = mod[:class].new Wpxf::Models::Module.create( path: mod[:name], name: instance.module_name, type: type, class_name: mod[:class].to_s ) end end |
#initialize ⇒ Object
7 8 9 10 |
# File 'lib/wpxf/cli/module_cache.rb', line 7 def initialize super self.current_version_number = Wpxf.version end |
#rebuild_cache ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/wpxf/cli/module_cache.rb', line 44 def rebuild_cache print_warning 'Refreshing the module cache...' Wpxf::Models::Module.truncate Wpxf.load_custom_modules create_module_models 'exploit' create_module_models 'auxiliary' refresh_version_log reset_context_stack end |