class Bundler::Audit::Results::UnpatchedGem

Represents a gem version that has known vulnerabilities and needs to be upgraded.

Attributes

advisory[R]

The advisory documenting the vulnerability.

@return [Advisory]

gem[R]

The specification of the vulnerable gem.

@return [Gem::Specification]

Public Class Methods

new(gem,advisory) click to toggle source

Initializes the unpatched gem result.

@param [Gem::Specification] gem

The specification of the vulnerable gem.

@param [Advisory] advisory

The advisory documenting the vulnerability.
# File lib/bundler/audit/results/unpatched_gem.rb, line 50
def initialize(gem,advisory)
  @gem      = gem
  @advisory = advisory
end

Public Instance Methods

==(other) click to toggle source

Compares the unpatched gem to another result.

@param [Result] other

@return [Boolean]

# File lib/bundler/audit/results/unpatched_gem.rb, line 62
def ==(other)
  self.class == other.class && (
    @gem.name == other.gem.name &&
    @gem.version == other.gem.version &&
    @advisory == other.advisory
  )
end
to_h() click to toggle source

Converts the unpatched gem to a Hash.

@return [Hash{Symbol => Object}]

# File lib/bundler/audit/results/unpatched_gem.rb, line 84
def to_h
  {
    type: :unpatched_gem,
    gem:  {
      name: @gem.name,
      version: @gem.version
    },
    advisory: @advisory.to_h
  }
end
to_s() click to toggle source

Converts the unpatched gem result into a String.

@return [String]

# File lib/bundler/audit/results/unpatched_gem.rb, line 75
def to_s
  @advisory.id
end