app/models/wp_item.rb in wpscan-3.0.8 vs app/models/wp_item.rb in wpscan-3.1.0

- old
+ new

@@ -7,24 +7,26 @@ include CMSScanner::Target::Server::Generic READMES = %w[readme.txt README.txt README.md readme.md Readme.txt].freeze CHANGELOGS = %w[changelog.txt CHANGELOG.md changelog.md].freeze - attr_reader :uri, :name, :detection_opts, :version_detection_opts, :target, :db_data + attr_reader :uri, :slug, :detection_opts, :version_detection_opts, :blog, :db_data - # @param [ String ] name The plugin/theme name - # @param [ Target ] target The targeted blog + delegate :homepage_res, :xpath_pattern_from_page, :in_scope_urls, to: :blog + + # @param [ String ] slug The plugin/theme slug + # @param [ Target ] blog The targeted blog # @param [ Hash ] opts # @option opts [ Symbol ] :mode The detection mode to use # @option opts [ Hash ] :version_detection The options to use when looking for the version # @option opts [ String ] :url The URL of the item - def initialize(name, target, opts = {}) - @name = URI.decode(name) - @target = target - @uri = Addressable::URI.parse(opts[:url]) if opts[:url] + def initialize(slug, blog, opts = {}) + @slug = URI.decode(slug) + @blog = blog + @uri = Addressable::URI.parse(opts[:url]) if opts[:url] - @detection_opts = { mode: opts[:mode] } + @detection_opts = { mode: opts[:mode] } @version_detection_opts = opts[:version_detection] || {} parse_finding_options(opts) end @@ -93,21 +95,19 @@ @uri.join(URI.encode(path)).to_s end # @return [ Boolean ] def ==(other) - return false unless self.class == other.class - - name == other.name + self.class == other.class && slug == other.slug end def to_s - name + slug end - # @return [ Symbol ] The Class name associated to the item name - def classify_name - name.to_s.tr('-', '_').camelize.to_s.to_sym + # @return [ Symbol ] The Class symbol associated to the item + def classify + @classify ||= classify_slug(slug) end # @return [ String ] The readme url if found def readme_url return if detection_opts[:mode] == :passive