class Bundler::Audit::Report
Represents the result of a scan.
Attributes
The time when the report was generated.
@return [Time]
The insecure sources results.
@return [Array<Results::InsecureSources>]
The list of all results.
@return [Array<Results::Result>]
The unpatched gems results.
@return [Array<Results::UnpatchedGems>]
The version of ‘bundler-audit` which created the report object.
@return [String]
Public Class Methods
Initializes the report.
@param [#each] results
# 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
Public Instance Methods
Appends a result to the report.
@param [InsecureSource, UnpatchedGem] result
# 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
@return [Array<Advisory>]
# File lib/bundler/audit/report.rb, line 112 def advisories @unpatched_gems.map(&:advisory) end
Enumerates over the results.
@yield [result]
@yieldparam [Results::InsecureSource, Results::UnpatchedGem
] result
@return [Enumerator]
# File lib/bundler/audit/report.rb, line 65 def each(&block) @results.each(&block) end
@yield [advisory]
@yieldparam [Advisory] advisory
@return [Enumerator]
# 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
@yield [gem]
@yieldparam [Gem::Specification]
@return [Enumerator]
# 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
@return [Hash{Symbol => Object}]
# File lib/bundler/audit/report.rb, line 139 def to_h { version: @version, created_at: @created_at, results: @results.map(&:to_h) } end
Determines if there were vulnerabilities found.
@return [Boolean]
# File lib/bundler/audit/report.rb, line 92 def vulnerable? !@results.empty? end
@return [Array<Gem::Specification>]
# File lib/bundler/audit/report.rb, line 132 def vulnerable_gems @unpatched_gems.map(&:gem) end