Class: Nipper::Issue
- Inherits:
-
Object
show all
- Defined in:
- lib/nipper/issue.rb
Instance Method Summary
collapse
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
22
23
24
25
26
27
28
29
|
# 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
|
Instance Method Details
#process_cvss_field(method) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# 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')
@xml.xpath("./#{translations_table[base_method]}").first.try(:text)
else
@xml.xpath("./#{translations_table[base_method]}").attr('score')
end
end
|
#process_field_value(method) ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# 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
@xml.xpath("./#{translations_table[method]}").first.try(:text)
end
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
17
18
19
20
|
# 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
|
7
8
9
10
11
12
13
14
15
|
# File 'lib/nipper/issue.rb', line 7
def supported_tags
[
:cvss_base, :cvss_base_vector,
:cvss_environmental, :cvss_environmental_vector,
:cvss_temporal, :cvss_temporal_vector,
:ease, :finding, :impact, :recommendation,
:title
]
end
|