summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Legler <alex@a3li.li>2015-12-25 17:16:14 +0100
committerAlex Legler <alex@a3li.li>2015-12-25 17:16:14 +0100
commitf02847608d9dbde44947588286c8c0cc01237a87 (patch)
treedc066280f8adfc35c9ef06633d1c7bb79efee6d1 /lib/glsav1.rb
parentMake parsing more resilient to weird advisories (diff)
downloadsecurity-f02847608d9dbde44947588286c8c0cc01237a87.tar.gz
security-f02847608d9dbde44947588286c8c0cc01237a87.tar.bz2
security-f02847608d9dbde44947588286c8c0cc01237a87.zip
Ruby style settings and fixes
Diffstat (limited to 'lib/glsav1.rb')
-rw-r--r--lib/glsav1.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/glsav1.rb b/lib/glsav1.rb
index 22ec1f1..d2c1692 100644
--- a/lib/glsav1.rb
+++ b/lib/glsav1.rb
@@ -3,7 +3,7 @@ require 'date'
# A version 1 GLSA
class GLSAv1
attr_reader :id, :title, :synopsis, :product, :date, :revised, :revision, :bugs, :access, :packages,
- :background, :description, :severity, :impact, :workaround, :resolution, :references
+ :background, :description, :severity, :impact, :workaround, :resolution, :references
def parse(xml)
@id = xml.root['id']
@@ -15,15 +15,15 @@ class GLSAv1
@revision = xml.xpath('/glsa/revised/text()').first.content.split(': ')
@revised = DateTime.parse(@revised)
- @bugs = xml.xpath('/glsa/bug/text()').map {|bug_node| bug_node.content.to_i }
+ @bugs = xml.xpath('/glsa/bug/text()').map { |bug_node| bug_node.content.to_i }
@access = xml.xpath('/glsa/access/text()').first.content
@packages = {}
xml.xpath('/glsa/affected/package').each do |package|
@packages[package['name'] + ':' + package['arch']] = {
auto: package['auto'] == 'yes',
- unaffected: package.xpath('./unaffected').map {|ver| [ver['range'], ver.content] },
- vulnerable: package.xpath('./vulnerable').map {|ver| [ver['range'], ver.content] }
+ unaffected: package.xpath('./unaffected').map { |ver| [ver['range'], ver.content] },
+ vulnerable: package.xpath('./vulnerable').map { |ver| [ver['range'], ver.content] }
}
end
@@ -33,12 +33,13 @@ class GLSAv1
@impact = xml_content xml, '/glsa/impact'
@workaround = xml_content xml, '/glsa/workaround'
@resolution = xml_content xml, '/glsa/resolution'
- @references = xml.xpath('/glsa/references/uri').map {|uri| [uri.content, uri['link']] }
+ @references = xml.xpath('/glsa/references/uri').map { |uri| [uri.content, uri['link']] }
self
end
private
+
def xml_content(xml, xpath)
xml.xpath(xpath).first.children.to_xml.strip
rescue
@@ -50,4 +51,4 @@ class GLSAv1
rescue
''
end
-end \ No newline at end of file
+end