Class: WPScan::DB::DynamicFinders::Plugin
- Inherits:
-
Base
- Object
- Base
- WPScan::DB::DynamicFinders::Plugin
show all
- Defined in:
- lib/wpscan/db/dynamic_finders/plugin.rb
Class Method Summary
collapse
Methods inherited from Base
all_df_data, allowed_classes, df_file, method_missing, respond_to_missing?
Class Method Details
.create_versions_finders(slug) ⇒ Array<Class>
Create the dynamic finders related to the given slug, and return the created classes
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 81
def self.create_versions_finders(slug)
created = []
mod = maybe_create_module(slug)
versions_finders_configs[slug]&.each do |finder_class, config|
klass = config['class'] || finder_class
next unless allowed_classes.include?(klass.to_sym)
created << if mod.constants.include?(finder_class.to_sym)
mod.const_get(finder_class.to_sym)
else
version_finder_super_class(klass).create_child_class(mod, finder_class.to_sym, config)
end
end
created
end
|
.df_data ⇒ Hash
8
9
10
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 8
def self.df_data
@df_data ||= all_df_data['plugins'] || {}
end
|
.finder_configs(finder_class, aggressive: false) ⇒ Hash
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 19
def self.finder_configs(finder_class, aggressive: false)
configs = {}
return configs unless allowed_classes.include?(finder_class)
df_data.each do |slug, finders|
fs = if aggressive
finders.reject { |_f, c| c['path'].nil? }
else
finders.select { |_f, c| c['path'].nil? }
end
fs.each do |finder_name, config|
klass = config['class'] || finder_name
next unless klass.to_sym == finder_class
configs[slug] ||= {}
configs[slug][finder_name] = config
end
end
configs
end
|
.maybe_create_module(slug) ⇒ Constant
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 65
def self.maybe_create_module(slug)
constant_name = classify_slug(slug)
unless version_finder_module.constants.include?(constant_name)
version_finder_module.const_set(constant_name, Module.new)
end
version_finder_module.const_get(constant_name)
end
|
.version_finder_module ⇒ Object
12
13
14
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 12
def self.version_finder_module
Finders::PluginVersion
end
|
.version_finder_super_class(klass) ⇒ Constant
The idea here would be to check if the class exist in the Finders::DynamicFinders::Plugins/Themes::klass or WpItemVersion::klass and return the related constant when one has been found.
So far, the Finders::DynamicFinders::WPItemVersion is enought as nothing else is used
114
115
116
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 114
def self.version_finder_super_class(klass)
"WPScan::Finders::DynamicFinder::WpItemVersion::#{klass}".constantize
end
|
.versions_finders_configs ⇒ Hash
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/wpscan/db/dynamic_finders/plugin.rb', line 46
def self.versions_finders_configs
return @versions_finders_configs if @versions_finders_configs
@versions_finders_configs = {}
df_data.each do |slug, finders|
finders.each do |finder_name, config|
next unless config.key?('version')
@versions_finders_configs[slug] ||= {}
@versions_finders_configs[slug][finder_name] = config
end
end
@versions_finders_configs
end
|