class Wpxf::Utility::ReferenceInflater

A URL inflater for module references.

Public Class Methods

new(type) click to toggle source

Initializes a new {ReferenceInflater}. @param type [String] the reference type identifier. @raise [ArgumentError] if the reference type identifier is not recognised.

# 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

Public Instance Methods

format_strings() click to toggle source

@return [Hash] the format strings for each reference type identifier.

# 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) click to toggle source

Generate the full reference URL from its identifier. @param id [Object] the reference ID. @return [String] the reference URL.

# File lib/wpxf/utility/reference_inflater.rb, line 18
def inflate(id)
  format(format_strings[@type], id.to_s)
end