Class: WPScan::Model::Plugin

Inherits:
WpItem
  • Object
show all
Defined in:
app/models/plugin.rb

Overview

WordPress Plugin

Constant Summary

Constants inherited from WpItem

WpItem::READMES

Instance Attribute Summary

Attributes inherited from WpItem

#blog, #detection_opts, #path_from_blog, #slug, #uri, #version_detection_opts

Instance Method Summary collapse

Methods inherited from WpItem

#==, #classify, #directory_listing?, #error_log?, #head_and_get, #last_updated, #latest_version, #outdated?, #popular?, #readme_url, #to_s, #url, #vulnerabilities, #vulnerable_to?

Methods included from Vulnerable

#vulnerable?

Constructor Details

#initialize(slug, blog, opts = {}) ⇒ Plugin

See WpItem



8
9
10
11
12
13
14
15
16
# File 'app/models/plugin.rb', line 8

def initialize(slug, blog, opts = {})
  super(slug, blog, opts)

  # To be used by #head_and_get
  # If custom wp-content, it will be replaced by blog#url
  @path_from_blog = "wp-content/plugins/#{slug}/"

  @uri = Addressable::URI.parse(blog.url(path_from_blog))
end

Instance Method Details

#db_dataHash

Returns:

  • (Hash)


26
27
28
# File 'app/models/plugin.rb', line 26

def db_data
  @db_data ||= DB::VulnApi.plugin_data(slug)
end

#metadataHash

Retrieve the metadata from the vuln API if available (and a valid token is given), or the local metadata db otherwise

Returns:

  • (Hash)


21
22
23
# File 'app/models/plugin.rb', line 21

def 
  @metadata ||= db_data.empty? ? DB::Plugin.(slug) : db_data
end

#potential_readme_filenamesArray<String>

Returns:

  • (Array<String>)


40
41
42
# File 'app/models/plugin.rb', line 40

def potential_readme_filenames
  @potential_readme_filenames ||= Array((DB::DynamicFinders::Plugin.df_data.dig(slug, 'Readme', 'path') || super))
end

#version(opts = {}) ⇒ Model::Version, false

Parameters:

  • opts (Hash) (defaults to: {})

Returns:

  • (Model::Version, false)


33
34
35
36
37
# File 'app/models/plugin.rb', line 33

def version(opts = {})
  @version = Finders::PluginVersion::Base.find(self, version_detection_opts.merge(opts)) if @version.nil?

  @version
end