Skip to content

Commit e991252

Browse files
authored
Merge pull request #16 from dev-sec/dom/patch-printing
print system patches in a nicer way
2 parents f2d5c09 + e3c5fc9 commit e991252

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

libraries/linux_updates.rb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ def parse_json(script)
9696
end
9797
end
9898

99+
PatchEntry = Struct.new(:name, :version, :arch, :category, :severity) do
100+
def to_s
101+
r = "System Patch #{name} (v#{version} #{arch}"
102+
r+= ", #{category}" unless category.nil?
103+
r+= ", #{severity}" unless severity.nil?
104+
r + ')'
105+
end
106+
end
107+
99108
class SuseUpdateFetcher < UpdateFetcher
100109
def patches
101110
out = zypper_xml('list-updates -t patch')
@@ -131,12 +140,9 @@ def extract_xml_updates(updates_el)
131140

132141
REXML::XPath.each(updates_el, 'update') do |el|
133142
a = el.attributes
134-
r = { 'name' => a['name'] }
135-
r['version'] = a['edition'] unless a['arch'].nil?
136-
r['arch'] = a['arch'] unless a['arch'].nil?
137-
r['category'] = a['category'] unless a['category'].nil?
138-
r['severity'] = a['severity'] unless a['severity'].nil?
139-
res.push(r)
143+
res.push(
144+
PatchEntry.new(a['name'], a['edition'], a['arch'], a['category'], a['severity']),
145+
)
140146
end
141147
res
142148
end

0 commit comments

Comments
 (0)