Sha256: 2719a171d481c35b1e2bc3b07201519e255e336ea11f862e66322e7f8bce9c5b

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module WPScan
  # WP Version
  class WpVersion < CMSScanner::Version
    include Vulnerable

    def initialize(number, opts = {})
      raise InvalidWordPressVersion unless WpVersion.valid?(number.to_s)

      super(number, opts)
    end

    # @param [ String ] number
    #
    # @return [ Boolean ] true if the number is a valid WP version, false otherwise
    def self.valid?(number)
      all.include?(number)
    end

    # @return [ Array<String> ] All the version numbers
    def self.all
      return @all_numbers if @all_numbers

      @all_numbers = []

      DB::Fingerprints.wp_fingerprints.each_value do |fp|
        fp.each_value do |versions|
          versions.each do |version|
            @all_numbers << version unless @all_numbers.include?(version)
          end
        end
      end

      @all_numbers.sort! { |a, b| Gem::Version.new(b) <=> Gem::Version.new(a) }
    end

    # @return [ JSON ]
    def db_data
      DB::Version.db_data(number)
    end

    # @return [ Array<Vulnerability> ]
    def vulnerabilities
      return @vulnerabilities if @vulnerabilities

      @vulnerabilities = []

      [*db_data['vulnerabilities']].each do |json_vuln|
        @vulnerabilities << Vulnerability.load_from_json(json_vuln)
      end

      @vulnerabilities
    end

    # @return [ String ]
    def release_date
      @release_date ||= db_data['release_date']
    end

    # @return [ String ]
    def status
      @status ||= db_data['status']
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wpscan-3.4.0 app/models/wp_version.rb