lib/bundler/audit/advisory.rb in mrjoy-bundler-audit-0.1.4 vs lib/bundler/audit/advisory.rb in mrjoy-bundler-audit-0.2.1
- old
+ new
@@ -20,11 +20,11 @@
require 'yaml'
module Bundler
module Audit
class Advisory < Struct.new(:path,
- :cve,
+ :id,
:url,
:title,
:description,
:cvss_v2,
:unaffected_versions,
@@ -39,12 +39,12 @@
# @return [Advisory]
#
# @api semipublic
#
def self.load(path)
+ id = File.basename(path).chomp('.yml')
data = YAML.load_file(path)
- cve = data['cve']
unless data.kind_of?(Hash)
raise("advisory data in #{path.dump} was not a Hash")
end
@@ -54,11 +54,11 @@
end
}
return new(
path,
- cve,
+ id,
data['url'],
data['title'],
data['description'],
data['cvss_v2'],
parse_versions[data['unaffected_versions']],
@@ -125,18 +125,10 @@
#
def vulnerable?(version)
!patched?(version) && !unaffected?(version)
end
- #
- # Converts the advisory to a String.
- #
- # @return [String]
- # The CVE identifier.
- #
- def to_s
- "CVE-#{cve}"
- end
+ alias to_s id
end
end
end