Module: Dawn::Kb::GemCheck

Includes:
BasicCheck
Included in:
CVE_2015_4020
Defined in:
lib/dawn/kb/gem_check.rb

Constant Summary

Constants included from BasicCheck

BasicCheck::ALLOWED_FAMILIES

Instance Attribute Summary collapse

Attributes included from BasicCheck

#applies, #aux_links, #check_family, #cve, #cvss, #cwe, #debug, #evidences, #fixes_version, #kind, #message, #mitigated, #name, #osvdb, #owasp, #priority, #release_date, #remediation, #ruby_version, #ruby_vulnerable_versions, #severity, #status, #target_version, #title

Instance Method Summary collapse

Methods included from BasicCheck

#applies_to?, #cve_link, #cvss_score, families, #family, #family=, #lint, #mitigated?, #nvd_link, #osvdb_link, #rubysec_advisories_link

Methods included from Utils

#__debug_me_and_return, #debug_me, #debug_me_and_return_false, #debug_me_and_return_true

Instance Attribute Details

#my_gem_versionObject

Returns the value of attribute my_gem_version


8
9
10
# File 'lib/dawn/kb/gem_check.rb', line 8

def my_gem_version
  @my_gem_version
end

#safe_versionsObject

Returns the value of attribute safe_versions


7
8
9
# File 'lib/dawn/kb/gem_check.rb', line 7

def safe_versions
  @safe_versions
end

Instance Method Details

#initialize(options) ⇒ Object


10
11
12
13
14
15
16
# File 'lib/dawn/kb/gem_check.rb', line 10

def initialize(options)
  super(options)
  @safe_versions  ||= options[:safe_versions]
  @my_gem_version ||= options[:my_gem_version]

  @my_gem_version = take_gem_version_from_system if @my_gem_version.nil?
end

#take_gem_version_from_systemObject


18
19
20
21
# File 'lib/dawn/kb/gem_check.rb', line 18

def take_gem_version_from_system
  require 'rubygems'
  return Gem::VERSION
end

#vuln?Boolean

Returns:

  • (Boolean)

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dawn/kb/gem_check.rb', line 23

def vuln?
  debug_me "here"
  @safe_versions.each do |sv|
    v = Dawn::Kb::VersionCheck.new(
      {
        :safe=>sv[:version],
        :detected=>@my_gem_version,
        :save_minor => true,
        :save_major => false,
      }
    )
    v.debug = self.debug
    return true if v.vuln?
  end

  return false
end