Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wpscanteam
GitHub Repository: wpscanteam/wpscan
Path: blob/master/app/models/plugin.rb
485 views
1
# frozen_string_literal: true
2
3
module WPScan
4
module Model
5
# WordPress Plugin
6
class Plugin < WpItem
7
# See WpItem
8
def initialize(slug, blog, opts = {})
9
super(slug, blog, opts)
10
11
# To be used by #head_and_get
12
# If custom wp-content, it will be replaced by blog#url
13
@path_from_blog = "wp-content/plugins/#{slug}/"
14
15
@uri = Addressable::URI.parse(blog.url(path_from_blog))
16
end
17
18
# Retrieve the metadata from the vuln API if available (and a valid token is given),
19
# or the local metadata db otherwise
20
# @return [ Hash ]
21
def metadata
22
@metadata ||= db_data.empty? ? DB::Plugin.metadata_at(slug) : db_data
23
end
24
25
# @return [ Hash ]
26
def db_data
27
@db_data ||= DB::VulnApi.plugin_data(slug)
28
end
29
30
# @param [ Hash ] opts
31
#
32
# @return [ Model::Version, false ]
33
def version(opts = {})
34
@version = Finders::PluginVersion::Base.find(self, version_detection_opts.merge(opts)) if @version.nil?
35
36
@version
37
end
38
39
# @return [ Array<String> ]
40
def potential_readme_filenames
41
@potential_readme_filenames ||= Array((DB::DynamicFinders::Plugin.df_data.dig(slug, 'Readme', 'path') || super))
42
end
43
end
44
end
45
end
46
47