Class: Wpxf::Utility::ReferenceInflater

Inherits:
Object
  • Object
show all
Defined in:
lib/wpxf/utility/reference_inflater.rb

Overview

A URL inflater for module references.

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ ReferenceInflater

Parameters:

  • type (String)

    the reference type identifier.

Raises:

  • (ArgumentError)

    if the reference type identifier is not recognised.



10
11
12
13
# File 'lib/wpxf/utility/reference_inflater.rb', line 10

def initialize(type)
  raise ArgumentError, 'Unrecognised reference type' unless format_strings.key?(type)
  @type = type
end

Instance Method Details

#format_stringsHash

Returns the format strings for each reference type identifier.

Returns:

  • (Hash)

    the format strings for each reference type identifier.



23
24
25
26
27
28
29
30
31
# File 'lib/wpxf/utility/reference_inflater.rb', line 23

def format_strings
  {
    'WPVDB' => 'https://wpvulndb.com/vulnerabilities/%s',
    'OSVDB' => 'http://www.osvdb.org/%s',
    'CVE'   => 'http://www.cvedetails.com/cve/CVE-%s',
    'EDB'   => 'https://www.exploit-db.com/exploits/%s',
    'URL'   => '%s'
  }
end

#inflate(id) ⇒ String

Generate the full reference URL from its identifier.

Parameters:

  • id (Object)

    the reference ID.

Returns:

  • (String)

    the reference URL.



18
19
20
# File 'lib/wpxf/utility/reference_inflater.rb', line 18

def inflate(id)
  format(format_strings[@type], id.to_s)
end