Class: Bundler::Audit::Results::UnpatchedGem

Inherits:
Result
  • Object
show all
Defined in:
lib/bundler/audit/results/unpatched_gem.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem, advisory) ⇒ UnpatchedGem

Initializes the unpatched gem result.

Parameters:

  • gem (Gem::Specification)

    The specification of the vulnerable gem.

  • advisory (Advisory)

    The advisory documenting the vulnerability.



50
51
52
53
# File 'lib/bundler/audit/results/unpatched_gem.rb', line 50

def initialize(gem,advisory)
  @gem      = gem
  @advisory = advisory
end

Instance Attribute Details

#advisoryAdvisory (readonly)

The advisory documenting the vulnerability.

Returns:



39
40
41
# File 'lib/bundler/audit/results/unpatched_gem.rb', line 39

def advisory
  @advisory
end

#gemGem::Specification (readonly)

The specification of the vulnerable gem.

Returns:

  • (Gem::Specification)


34
35
36
# File 'lib/bundler/audit/results/unpatched_gem.rb', line 34

def gem
  @gem
end

Instance Method Details

#==(other) ⇒ Boolean

Compares the unpatched gem to another result.

Parameters:

Returns:

  • (Boolean)


62
63
64
65
66
67
68
# 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_hHash{Symbol => Object}

Converts the unpatched gem to a Hash.

Returns:

  • (Hash{Symbol => Object})


84
85
86
87
88
89
90
91
92
93
# 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_sString

Converts the unpatched gem result into a String.

Returns:

  • (String)


75
76
77
# File 'lib/bundler/audit/results/unpatched_gem.rb', line 75

def to_s
  @advisory.id
end