class Nipper::Issue
Public Class Methods
new(xml_node)
click to toggle source
# File lib/nipper/issue.rb, line 3 def initialize(xml_node) @xml = xml_node end
Public Instance Methods
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/nipper/issue.rb, line 22 def method_missing(method, *args) unless supported_tags.include?(method) super return end process_field_value(method) end
process_cvss_field(method)
click to toggle source
# File lib/nipper/issue.rb, line 48 def process_cvss_field(method) translations_table = { cvss_base: 'issuedetails/ratings/cvssv2-base', cvss_temporal: 'issuedetails/ratings/cvssv2-temporal', cvss_environmental: 'issuedetails/ratings/cvssv2-environmental', } base_method = method.to_s.sub('_vector', '').to_sym if method.to_s.ends_with?('vector') collect_text(@xml.xpath("./#{translations_table[base_method]}")) else @xml.xpath("./#{translations_table[base_method]}").attr('score') end end
process_field_value(method)
click to toggle source
# File lib/nipper/issue.rb, line 31 def process_field_value(method) translations_table = { finding: 'section[@ref="FINDING"]/text', impact: 'section[@ref="IMPACT"]/text', ease: 'section[@ref="EASE"]/text', recommendation: 'section[@ref="RECOMMENDATION"]/text' } if method == :title @xml.attr('title') elsif method.to_s.starts_with?('cvss') process_cvss_field(method) else collect_text(@xml.xpath("./#{translations_table[method]}")) end end
respond_to?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/nipper/issue.rb, line 17 def respond_to?(method, include_private = false) return true if supported_tags.include?(method.to_sym) super end
Private Instance Methods
collect_text(xml_field)
click to toggle source
# File lib/nipper/issue.rb, line 66 def collect_text(xml_field) xml_field.children.map { |xml_text| xml_text.text }.join("\n") end