Top Level Namespace

Defined Under Namespace

Modules: Typhoeus, WPScan

Instance Method Summary collapse

Instance Method Details

#classify_slug(slug) ⇒ Symbol

Note:

As a class can not start with a digit or underscore, a D_ is put as a prefix in such case. Ugly but well :x Not only used to classify slugs though, but Dynamic Finder names as well

Sanitize and classify a slug

Returns:

  • (Symbol)


15
16
17
18
19
20
21
22
23
# File 'lib/wpscan/helper.rb', line 15

def classify_slug(slug)
  classified = slug.to_s.gsub(/[^a-z\d\-]/i, '-').gsub(/-{1,}/, '_').camelize.to_s
  classified = "D_#{classified}" if /\d/.match?(classified[0])

  # Special case for slugs with all non-latin characters.
  classified = "HexSlug_#{slug.bytes.map { |i| i.to_s(16) }.join}" if classified.empty?

  classified.to_sym
end

#read_json_file(file) ⇒ Object



3
4
5
6
7
# File 'lib/wpscan/helper.rb', line 3

def read_json_file(file)
  JSON.parse(File.read(file))
rescue StandardError => e
  raise "JSON parsing error in #{file} #{e}"
end