Class: Bundler::Audit::Report
- Inherits:
-
Object
- Object
- Bundler::Audit::Report
- Includes:
- Enumerable
- Defined in:
- lib/bundler/audit/report.rb
Overview
Represents the result of a scan.
Instance Attribute Summary collapse
-
#created_at ⇒ Time
readonly
The time when the report was generated.
-
#insecure_sources ⇒ Array<Results::InsecureSources>
readonly
The insecure sources results.
-
#results ⇒ Array<Results::Result>
readonly
The list of all results.
-
#unpatched_gems ⇒ Array<Results::UnpatchedGems>
readonly
The unpatched gems results.
-
#version ⇒ String
readonly
The version of
bundler-audit
which created the report object.
Instance Method Summary collapse
-
#<<(result) ⇒ Object
Appends a result to the report.
- #advisories ⇒ Array<Advisory>
-
#each {|result| ... } ⇒ Enumerator
Enumerates over the results.
- #each_advisory {|advisory| ... } ⇒ Enumerator
- #each_vulnerable_gem {|gem| ... } ⇒ Enumerator
-
#initialize(results = []) ⇒ Report
constructor
Initializes the report.
- #to_h ⇒ Hash{Symbol => Object}
-
#vulnerable? ⇒ Boolean
Determines if there were vulnerabilities found.
- #vulnerable_gems ⇒ Array<Gem::Specification>
Constructor Details
#initialize(results = []) ⇒ Report
Initializes the report.
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bundler/audit/report.rb', line 45 def initialize(results=[]) @version = VERSION @created_at = Time.now @results = [] @insecure_sources = [] @unpatched_gems = [] results.each { |result| self << result } end |
Instance Attribute Details
#created_at ⇒ Time (readonly)
The time when the report was generated.
23 24 25 |
# File 'lib/bundler/audit/report.rb', line 23 def created_at @created_at end |
#insecure_sources ⇒ Array<Results::InsecureSources> (readonly)
The insecure sources results.
33 34 35 |
# File 'lib/bundler/audit/report.rb', line 33 def insecure_sources @insecure_sources end |
#results ⇒ Array<Results::Result> (readonly)
The list of all results.
28 29 30 |
# File 'lib/bundler/audit/report.rb', line 28 def results @results end |
#unpatched_gems ⇒ Array<Results::UnpatchedGems> (readonly)
The unpatched gems results.
38 39 40 |
# File 'lib/bundler/audit/report.rb', line 38 def unpatched_gems @unpatched_gems end |
#version ⇒ String (readonly)
The version of bundler-audit
which created the report object.
18 19 20 |
# File 'lib/bundler/audit/report.rb', line 18 def version @version end |
Instance Method Details
#<<(result) ⇒ Object
Appends a result to the report.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/bundler/audit/report.rb', line 74 def <<(result) @results << result case result when Results::InsecureSource @insecure_sources << result when Results::UnpatchedGem @unpatched_gems << result end return self end |
#advisories ⇒ Array<Advisory>
112 113 114 |
# File 'lib/bundler/audit/report.rb', line 112 def advisories @unpatched_gems.map(&:advisory) end |
#each {|result| ... } ⇒ Enumerator
Enumerates over the results.
65 66 67 |
# File 'lib/bundler/audit/report.rb', line 65 def each(&block) @results.each(&block) end |
#each_advisory {|advisory| ... } ⇒ Enumerator
103 104 105 106 107 |
# File 'lib/bundler/audit/report.rb', line 103 def each_advisory return enum_for(__method__) unless block_given? @unpatched_gems.each { |result| yield result.advisory } end |
#each_vulnerable_gem {|gem| ... } ⇒ Enumerator
123 124 125 126 127 |
# File 'lib/bundler/audit/report.rb', line 123 def each_vulnerable_gem return enum_for(__method__) unless block_given? @unpatched_gems.each { |result| yield result.gem } end |
#to_h ⇒ Hash{Symbol => Object}
139 140 141 142 143 144 145 |
# File 'lib/bundler/audit/report.rb', line 139 def to_h { version: @version, created_at: @created_at, results: @results.map(&:to_h) } end |
#vulnerable? ⇒ Boolean
Determines if there were vulnerabilities found.
92 93 94 |
# File 'lib/bundler/audit/report.rb', line 92 def vulnerable? !@results.empty? end |
#vulnerable_gems ⇒ Array<Gem::Specification>
132 133 134 |
# File 'lib/bundler/audit/report.rb', line 132 def vulnerable_gems @unpatched_gems.map(&:gem) end |