Class: Nipper::Issue
- Inherits:
-
Object
- Object
- Nipper::Issue
- Defined in:
- lib/nipper/issue.rb
Instance Method Summary collapse
-
#initialize(xml_node) ⇒ Issue
constructor
A new instance of Issue.
- #method_missing(method, *args) ⇒ Object
- #process_cvss_field(method) ⇒ Object
- #process_field_value(method) ⇒ Object
- #process_nipperv1_field(method) ⇒ Object
- #respond_to?(method, include_private = false) ⇒ Boolean
- #supported_tags ⇒ Object
Constructor Details
#initialize(xml_node) ⇒ Issue
Returns a new instance of Issue.
3 4 5 |
# File 'lib/nipper/issue.rb', line 3 def initialize(xml_node) @xml = xml_node end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
23 24 25 26 27 28 29 30 |
# File 'lib/nipper/issue.rb', line 23 def method_missing(method, *args) unless .include?(method) super return end process_field_value(method) end |
Instance Method Details
#process_cvss_field(method) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/nipper/issue.rb', line 51 def process_cvss_field(method) translations_table = { cvss_base: 'issuedetails/ratings[@type="CVSSv2"]/cvssv2-base', cvss_temporal: 'issuedetails/ratings[@type="CVSSv2"]/cvssv2-temporal', cvss_environmental: 'issuedetails/ratings[@type="CVSSv2"]/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) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/nipper/issue.rb', line 32 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) elsif method.to_s.starts_with?('nipperv1') process_nipperv1_field(method) else collect_text(@xml.xpath("./#{translations_table[method]}")) end end |
#process_nipperv1_field(method) ⇒ Object
67 68 69 70 71 72 73 74 75 76 |
# File 'lib/nipper/issue.rb', line 67 def process_nipperv1_field(method) translations_table = { nipperv1_ease: 'issuedetails/ratings[@type="Nipperv1"]/ease', nipperv1_fix: 'issuedetails/ratings[@type="Nipperv1"]/fix', nipperv1_impact: 'issuedetails/ratings[@type="Nipperv1"]/impact', nipperv1_rating: 'issuedetails/ratings[@type="Nipperv1"]/rating' } @xml.xpath("./#{translations_table[method]}").text end |
#respond_to?(method, include_private = false) ⇒ Boolean
18 19 20 21 |
# File 'lib/nipper/issue.rb', line 18 def respond_to?(method, include_private = false) return true if .include?(method.to_sym) super end |
#supported_tags ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/nipper/issue.rb', line 7 def [ :cvss_base, :cvss_base_vector, :cvss_environmental, :cvss_environmental_vector, :cvss_temporal, :cvss_temporal_vector, :ease, :finding, :impact, :nipperv1_ease, :nipperv1_fix, :nipperv1_impact, :nipperv1_rating, :recommendation, :title ] end |