@@ -42,72 +42,43 @@ def to_issue
42
42
43
43
attr_reader :advisory , :gem , :gemfile_lock
44
44
45
- def_delegators :gem , :name , :version
46
- def_delegators :advisory , :criticality , :title , :cve , :patched_versions , :url
47
-
48
45
def content_body
49
46
[
50
47
"**Advisory**: #{ identifier } " ,
51
- "**Criticality**: #{ criticality . capitalize } " ,
52
- "**URL**: #{ url } " ,
48
+ "**Criticality**: #{ advisory . criticality . capitalize } " ,
49
+ "**URL**: #{ advisory . url } " ,
53
50
"**Solution**: #{ solution } " ,
54
51
] . join ( "\n \n " )
55
52
end
56
53
57
54
def line_number
58
55
@line_number ||= begin
59
56
gemfile_lock . find_index do |line |
60
- ( match = GEM_REGEX . match ( line ) ) && match [ :name ] == name
57
+ ( match = GEM_REGEX . match ( line ) ) && match [ :name ] == gem . name
61
58
end + 1
62
59
end
63
60
end
64
61
65
62
def remediation_points
66
- if patched_versions . any?
67
- upgrade_versions . map do |upgrade_version |
68
- case
69
- when current_version . major != upgrade_version . major
70
- 50_000_000
71
- when current_version . minor != upgrade_version . minor
72
- 5_000_000
73
- when current_version . tiny != upgrade_version . tiny
74
- 500_000
75
- end
76
- end . min
77
- else
78
- 500_000_000
79
- end
63
+ Remediation . new ( gem . version , advisory . patched_versions ) . points
80
64
end
81
65
82
66
def severity
83
- SEVERITIES [ criticality ]
67
+ SEVERITIES [ advisory . criticality ]
84
68
end
85
69
86
70
def solution
87
- if patched_versions . any?
88
- "upgrade to #{ patched_versions . join ( ', ' ) } "
71
+ if advisory . patched_versions . any?
72
+ "upgrade to #{ advisory . patched_versions . join ( ', ' ) } "
89
73
else
90
74
"remove or disable this gem until a patch is available!"
91
75
end
92
76
end
93
77
94
78
def identifier
95
79
case
96
- when cve then "CVE-#{ cve } "
97
- when osvdb then osvdb
98
- end
99
- end
100
-
101
- def current_version
102
- Versionomy . parse ( version . to_s )
103
- end
104
-
105
- def upgrade_versions
106
- patched_versions . map do |gem_requirement |
107
- requirements = Gem ::Requirement . parse ( gem_requirement )
108
- unqualified_version = requirements . last
109
-
110
- Versionomy . parse ( unqualified_version . to_s )
80
+ when advisory . cve then "CVE-#{ advisory . cve } "
81
+ when advisory . osvdb then advisory . osvdb
111
82
end
112
83
end
113
84
end
0 commit comments