Class: Vulnerability

Inherits:
Object
  • Object
show all
Includes:
Output, Urls
Defined in:
lib/common/models/vulnerability.rb,
lib/common/models/vulnerability/urls.rb,
lib/common/models/vulnerability/output.rb

Defined Under Namespace

Modules: Output, Urls

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Urls

#url_cve, #url_exploitdb, #url_id, #url_metasploit, #url_osvdb, #url_secunia, #url_url

Methods included from Output

#output

Constructor Details

#initialize(title, type, references = {}, fixed_in = '') ⇒ Vulnerability

Parameters:

  • title (String)

    The title of the vulnerability

  • type (String)

    The type of the vulnerability

  • references (Hash) (defaults to: {})

    References

  • fixed_in (String) (defaults to: '')

    Vuln fixed in Version X


19
20
21
22
23
24
# File 'lib/common/models/vulnerability.rb', line 19

def initialize(title, type, references = {}, fixed_in = '')
  @title              = title
  @type               = type
  @references         = references
  @fixed_in           = fixed_in
end

Instance Attribute Details

#fixed_inObject

Returns the value of attribute fixed_in


10
11
12
# File 'lib/common/models/vulnerability.rb', line 10

def fixed_in
  @fixed_in
end

#referencesObject

Returns the value of attribute references


10
11
12
# File 'lib/common/models/vulnerability.rb', line 10

def references
  @references
end

#titleObject

Returns the value of attribute title


10
11
12
# File 'lib/common/models/vulnerability.rb', line 10

def title
  @title
end

#typeObject

Returns the value of attribute type


10
11
12
# File 'lib/common/models/vulnerability.rb', line 10

def type
  @type
end

Class Method Details

.load_from_json_item(json_item) ⇒ Vulnerability

Create the Vulnerability from the json_item

Parameters:

  • json_item (Hash)

Returns:


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/common/models/vulnerability.rb', line 43

def self.load_from_json_item(json_item)
  references = {}

  %w(id url cve secunia osvdb metasploit exploitdb).each do |key|
    if json_item[key]
      json_item[key]  = [json_item[key]] if json_item[key].class != Array
      references[key] = json_item[key]
    end
  end

  new(
    json_item['title'],
    json_item['type'],
    references,
    json_item['fixed_in'],
  )
end

Instance Method Details

#==(other) ⇒ Boolean

:nocov:

Parameters:

Returns:

  • (Boolean)

30
31
32
33
34
35
# File 'lib/common/models/vulnerability.rb', line 30

def ==(other)
  title == other.title &&
      type == other.type &&
      references == other.references &&
      fixed_in == other.fixed_in
end