Class: WPScan::DB::DynamicFinders::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/wpscan/db/dynamic_finders/base.rb

Direct Known Subclasses

Plugin, Wordpress

Class Method Summary collapse

Class Method Details

.all_df_dataHash

Returns:

  • (Hash)


13
14
15
16
17
18
19
# File 'lib/wpscan/db/dynamic_finders/base.rb', line 13

def self.all_df_data
  @all_df_data ||= if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4.0.0')
                     YAML.safe_load(File.read(df_file), permitted_classes: [Regexp])
                   else
                     YAML.safe_load(File.read(df_file), [Regexp])
                   end
end

.allowed_classesArray<Symbol>

Returns:

  • (Array<Symbol>)


22
23
24
25
26
# File 'lib/wpscan/db/dynamic_finders/base.rb', line 22

def self.allowed_classes
  # The Readme is not put in there as it's not a Real DF, but rather using the DF system
  # to get the list of potential filenames for a given slug
  @allowed_classes ||= %i[Comment Xpath HeaderPattern BodyPattern JavascriptVar QueryParameter ConfigParser]
end

.df_fileString

Returns:

  • (String)


8
9
10
# File 'lib/wpscan/db/dynamic_finders/base.rb', line 8

def self.df_file
  @df_file ||= DB_DIR.join('dynamic_finders.yml').to_s
end

.method_missing(sym) ⇒ Object

Parameters:

  • sym (Symbol)


29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/wpscan/db/dynamic_finders/base.rb', line 29

def self.method_missing(sym)
  super unless sym =~ /\A(passive|aggressive)_(.*)_finder_configs\z/i

  finder_class = Regexp.last_match[2].camelize.to_sym

  raise "#{finder_class} is not allowed as a Dynamic Finder" unless allowed_classes.include?(finder_class)

  finder_configs(
    finder_class,
    aggressive: Regexp.last_match[1] == 'aggressive'
  )
end

.respond_to_missing?(sym, *_args) ⇒ Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/wpscan/db/dynamic_finders/base.rb', line 42

def self.respond_to_missing?(sym, *_args)
  sym =~ /\A(passive|aggressive)_(.*)_finder_configs\z/i
end