Class: Dependabot::SecurityAdvisory
- Inherits:
-
Object
- Object
- Dependabot::SecurityAdvisory
- Defined in:
- lib/dependabot/security_advisory.rb
Instance Attribute Summary collapse
-
#package_manager ⇒ Object
readonly
Returns the value of attribute package_manager.
-
#safe_versions ⇒ Object
readonly
Returns the value of attribute safe_versions.
-
#vulnerable_versions ⇒ Object
readonly
Returns the value of attribute vulnerable_versions.
Instance Method Summary collapse
-
#initialize(vulnerable_versions: [], safe_versions: [], package_manager:) ⇒ SecurityAdvisory
constructor
A new instance of SecurityAdvisory.
- #vulnerable?(version) ⇒ Boolean
Constructor Details
#initialize(vulnerable_versions: [], safe_versions: [], package_manager:) ⇒ SecurityAdvisory
Returns a new instance of SecurityAdvisory.
9 10 11 12 13 14 15 16 |
# File 'lib/dependabot/security_advisory.rb', line 9 def initialize(vulnerable_versions: [], safe_versions: [], package_manager:) @vulnerable_versions = vulnerable_versions || [] @safe_versions = safe_versions || [] @package_manager = package_manager convert_string_version_requirements check_version_requirements end |
Instance Attribute Details
#package_manager ⇒ Object (readonly)
Returns the value of attribute package_manager.
7 8 9 |
# File 'lib/dependabot/security_advisory.rb', line 7 def package_manager @package_manager end |
#safe_versions ⇒ Object (readonly)
Returns the value of attribute safe_versions.
7 8 9 |
# File 'lib/dependabot/security_advisory.rb', line 7 def safe_versions @safe_versions end |
#vulnerable_versions ⇒ Object (readonly)
Returns the value of attribute vulnerable_versions.
7 8 9 |
# File 'lib/dependabot/security_advisory.rb', line 7 def vulnerable_versions @vulnerable_versions end |
Instance Method Details
#vulnerable?(version) ⇒ Boolean
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dependabot/security_advisory.rb', line 18 def vulnerable?(version) unless version.is_a?(version_class) raise ArgumentError, "must be a #{version_class}" end in_safe_range = safe_versions. any? { |r| r.satisfied_by?(version) } # If version is known safe for this advisory, it's not vulnerable return false if in_safe_range in_vulnerable_range = vulnerable_versions. any? { |r| r.satisfied_by?(version) } # If in the vulnerable range and not known safe, it's vulnerable return true if in_vulnerable_range # If a vulnerable range present but not met, it's not vulnerable return false if vulnerable_versions.any? # Finally, if no vulnerable range provided, but a safe range provided, # and this versions isn't included (checked earler), it's vulnerable safe_versions.any? end |