Class: Dobby::Defect
- Inherits:
-
Object
- Object
- Dobby::Defect
- Defined in:
- lib/dobby/defect.rb
Overview
A vulnerability which affects a particular Package
Instance Attribute Summary collapse
-
#description ⇒ String
readonly
A description of the defect.
-
#fixed_in ⇒ Array<Package>
readonly
Set of Packages representing the minimum fix version.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#identifier ⇒ String
readonly
Unique identifier for this defect, usually a CVE ID.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#severity ⇒ String
readonly
(low, medium, high) the priority category assigned to this Defect.
Instance Method Summary collapse
- #filtered?(filter: :default, flag_filter: :default) ⇒ Boolean
-
#fix_available? ⇒ Boolean
The Defect has at least one released fix version.
- #flag_filtered?(filter) ⇒ Boolean
- #flagged? ⇒ Boolean
-
#initialize(identifier:, description:, severity:, link: nil, fixed_in: []) ⇒ Defect
constructor
A new instance of Defect.
-
#to_hash ⇒ Hash
Simple hash serializer for a Defect.
Constructor Details
#initialize(identifier:, description:, severity:, link: nil, fixed_in: []) ⇒ Defect
Returns a new instance of Defect.
40 41 42 43 44 45 46 |
# File 'lib/dobby/defect.rb', line 40 def initialize(identifier:, description:, severity:, link: nil, fixed_in: []) @identifier = identifier @description = description @severity = severity @fixed_in = fixed_in @link = link end |
Instance Attribute Details
#description ⇒ String (readonly)
Returns a description of the defect.
10 11 12 |
# File 'lib/dobby/defect.rb', line 10 def description @description end |
#fixed_in ⇒ Array<Package> (readonly)
Set of Packages representing the minimum fix version
14 15 16 |
# File 'lib/dobby/defect.rb', line 14 def fixed_in @fixed_in end |
#flag ⇒ Object
Returns the value of attribute flag.
22 23 24 |
# File 'lib/dobby/defect.rb', line 22 def flag @flag end |
#identifier ⇒ String (readonly)
Returns unique identifier for this defect, usually a CVE ID.
7 8 9 |
# File 'lib/dobby/defect.rb', line 7 def identifier @identifier end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
20 21 22 |
# File 'lib/dobby/defect.rb', line 20 def link @link end |
#severity ⇒ String (readonly)
Returns (low, medium, high) the priority category assigned to this Defect.
18 19 20 |
# File 'lib/dobby/defect.rb', line 18 def severity @severity end |
Instance Method Details
#filtered?(filter: :default, flag_filter: :default) ⇒ Boolean
55 56 57 58 59 60 61 |
# File 'lib/dobby/defect.rb', line 55 def filtered?(filter: :default, flag_filter: :default) return true if flag_filtered?(flag_filter) return false if filter == :default return !fix_available? if filter == :only_fixed raise UnknownFilterError, filter end |
#fix_available? ⇒ Boolean
The Defect has at least one released fix version
51 52 53 |
# File 'lib/dobby/defect.rb', line 51 def fix_available? fixed_in.any? { |v| v.version != Package::MAX_VERSION } end |
#flag_filtered?(filter) ⇒ Boolean
67 68 69 70 71 72 |
# File 'lib/dobby/defect.rb', line 67 def flag_filtered?(filter) return !flag.nil? if filter == :default return false if flag == filter true end |
#flagged? ⇒ Boolean
63 64 65 |
# File 'lib/dobby/defect.rb', line 63 def flagged? !flag.nil? end |
#to_hash ⇒ Hash
Simple hash serializer for a Defect
26 27 28 29 30 31 32 33 |
# File 'lib/dobby/defect.rb', line 26 def to_hash { identifier: identifier, description: description, severity: severity.to_s, fixed_in: fixed_in.map(&:to_s) } end |