Class: Bundler::Plumber::Advisory
- Inherits:
-
Struct
- Object
- Struct
- Bundler::Plumber::Advisory
- Defined in:
- lib/bundler/plumber/advisory.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#description ⇒ Object
Returns the value of attribute description.
-
#gem ⇒ Object
Returns the value of attribute gem.
-
#id ⇒ Object
(also: #to_s)
Returns the value of attribute id.
-
#patched_versions ⇒ Object
Returns the value of attribute patched_versions.
-
#path ⇒ Object
Returns the value of attribute path.
-
#title ⇒ Object
Returns the value of attribute title.
-
#unaffected_versions ⇒ Object
Returns the value of attribute unaffected_versions.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
-
.load(path) ⇒ Advisory
Loads the advisory from a YAML file.
- .load_advisory_from_yaml(path) ⇒ Object
Instance Method Summary collapse
-
#leaky?(version) ⇒ Boolean
Checks whether the version is leaky to the advisory.
-
#patched?(version) ⇒ Boolean
Checks whether the version is patched against the advisory.
-
#unaffected?(version) ⇒ Boolean
Checks whether the version is not affected by the advisory.
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def date @date end |
#description ⇒ Object
Returns the value of attribute description
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def description @description end |
#gem ⇒ Object
Returns the value of attribute gem
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def gem @gem end |
#id ⇒ Object Also known as: to_s
Returns the value of attribute id
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def id @id end |
#patched_versions ⇒ Object
Returns the value of attribute patched_versions
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def patched_versions @patched_versions end |
#path ⇒ Object
Returns the value of attribute path
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def path @path end |
#title ⇒ Object
Returns the value of attribute title
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def title @title end |
#unaffected_versions ⇒ Object
Returns the value of attribute unaffected_versions
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def unaffected_versions @unaffected_versions end |
#url ⇒ Object
Returns the value of attribute url
23 24 25 |
# File 'lib/bundler/plumber/advisory.rb', line 23 def url @url end |
Class Method Details
.load(path) ⇒ Advisory
Loads the advisory from a YAML file.
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/bundler/plumber/advisory.rb', line 45 def self.load(path) id = File.basename(path).chomp('.yml') data = load_advisory_from_yaml(path) unless data.kind_of?(Hash) raise("advisory data in #{path.dump} was not a Hash") end parse_versions = lambda { |versions| Array(versions).map do |version| Gem::Requirement.new(*version.split(', ')) end } return new( data['gem'], path, id, data['url'], data['title'], data['date'], data['description'], parse_versions[data['unaffected_versions']], parse_versions[data['patched_versions']] ) end |
.load_advisory_from_yaml(path) ⇒ Object
72 73 74 75 76 |
# File 'lib/bundler/plumber/advisory.rb', line 72 def self.load_advisory_from_yaml(path) return YAML.load_file(path, permitted_classes: [Date]) if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('4') YAML.load_file(path) end |
Instance Method Details
#leaky?(version) ⇒ Boolean
Checks whether the version is leaky to the advisory.
121 122 123 |
# File 'lib/bundler/plumber/advisory.rb', line 121 def leaky?(version) !patched?(version) && !unaffected?(version) end |
#patched?(version) ⇒ Boolean
Checks whether the version is patched against the advisory.
106 107 108 109 110 |
# File 'lib/bundler/plumber/advisory.rb', line 106 def patched?(version) patched_versions.any? do |patched_version| patched_version === version end end |
#unaffected?(version) ⇒ Boolean
Checks whether the version is not affected by the advisory.
89 90 91 92 93 |
# File 'lib/bundler/plumber/advisory.rb', line 89 def unaffected?(version) unaffected_versions.any? do |unaffected_version| unaffected_version === version end end |