From 1f0f87633bb8c65caec1e40eb47c5761f64de63b Mon Sep 17 00:00:00 2001 From: erwanlr Date: Thu, 21 Mar 2019 13:52:34 +0000 Subject: [PATCH] Reduces memory allocation with creating DFs --- lib/wpscan/db/dynamic_finders/plugin.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/wpscan/db/dynamic_finders/plugin.rb b/lib/wpscan/db/dynamic_finders/plugin.rb index 59e8de29..7500f7c2 100644 --- a/lib/wpscan/db/dynamic_finders/plugin.rb +++ b/lib/wpscan/db/dynamic_finders/plugin.rb @@ -64,18 +64,24 @@ module WPScan # What about slugs such as js_composer which will be done as JsComposer, just like js-composer constant_name = classify_slug(slug) - unless version_finder_module.constants.include?(constant_name) + # version_finder_module.constants.include? could be used here + # however, it increases the memory allocated doing so. + unless version_finder_modules.include?(constant_name) version_finder_module.const_set(constant_name, Module.new) + + version_finder_modules << constant_name end version_finder_module.const_get(constant_name) end + # @return [ Array ] + def self.version_finder_modules + @version_finder_modules ||= version_finder_module.constants + end + def self.create_versions_finders versions_finders_configs.each do |slug, finders| - # Kind of an issue here, module is created even if there is no valid classes - # Could put the #maybe_ directly in the #send() BUT it would be checked everytime, - # which is kind of a waste mod = maybe_create_module(slug) finders.each do |finder_class, config|