60 lines
1.5 KiB
Ruby
Executable File
60 lines
1.5 KiB
Ruby
Executable File
# encoding: UTF-8
|
|
|
|
require 'vulnerability/output'
|
|
require 'vulnerability/urls'
|
|
|
|
class Vulnerability
|
|
include Vulnerability::Output
|
|
include Vulnerability::Urls
|
|
|
|
attr_accessor :title, :references, :type, :fixed_in
|
|
|
|
#
|
|
# @param [ String ] title The title of the vulnerability
|
|
# @param [ String ] type The type of the vulnerability
|
|
# @param [ Hash ] references References
|
|
# @param [ String ] fixed_in Vuln fixed in Version X
|
|
#
|
|
# @return [ Vulnerability ]
|
|
def initialize(title, type, references = {}, fixed_in = '')
|
|
@title = title
|
|
@type = type
|
|
@references = references
|
|
@fixed_in = fixed_in
|
|
end
|
|
|
|
# @param [ Vulnerability ] other
|
|
#
|
|
# @return [ Boolean ]
|
|
# :nocov:
|
|
def ==(other)
|
|
title == other.title &&
|
|
type == other.type &&
|
|
references == other.references &&
|
|
fixed_in == other.fixed_in
|
|
end
|
|
# :nocov:
|
|
|
|
# Create the Vulnerability from the json_item
|
|
#
|
|
# @param [ Hash ] json_item
|
|
#
|
|
# @return [ Vulnerability ]
|
|
def self.load_from_json_item(json_item)
|
|
references = {}
|
|
|
|
[:url, :cve, :secunia, :osvdb, :metasploit, :exploitdb].each do |key|
|
|
json_item['id'] = json_item['id'].to_s.split(',')
|
|
references[key] = json_item[key.to_s] if json_item[key.to_s]
|
|
end
|
|
|
|
new(
|
|
json_item['title'],
|
|
json_item['type'],
|
|
references,
|
|
json_item['fixed_in'],
|
|
)
|
|
end
|
|
|
|
end
|