module Bundler::Audit::CLI::Formats::Text
The plain-text output format.
Public Instance Methods
print_report(report,output=$stdout)
click to toggle source
Prints any findings as plain-text.
@param [Report] report
The results from the {Scanner}.
@param [IO, File] output
Optional output stream.
# File lib/bundler/audit/cli/formats/text.rb, line 37 def print_report(report,output=$stdout) original_stdout = $stdout $stdout = output report.each do |result| case result when Results::InsecureSource print_warning "Insecure Source URI found: #{result.source}" when Results::UnpatchedGem print_advisory result.gem, result.advisory end end if report.vulnerable? say "Vulnerabilities found!", :red else say("No vulnerabilities found", :green) unless options.quiet? end $stdout = original_stdout end
Private Instance Methods
print_advisory(gem, advisory)
click to toggle source
# File lib/bundler/audit/cli/formats/text.rb, line 65 def print_advisory(gem, advisory) say "Name: ", :red say gem.name say "Version: ", :red say gem.version if advisory.cve say "CVE: ", :red say advisory.cve_id end if advisory.ghsa say "GHSA: ", :red say advisory.ghsa_id end say "Criticality: ", :red case advisory.criticality when :none then say "None" when :low then say "Low" when :medium then say "Medium", :yellow when :high then say "High", [:red, :bold] when :critical then say "Critical", [:red, :bold] else say "Unknown" end say "URL: ", :red say advisory.url if options.verbose? say "Description:", :red say print_wrapped advisory.description, indent: 2 say else say "Title: ", :red say advisory.title end unless advisory.patched_versions.empty? say "Solution: update to ", :red say advisory.patched_versions.map { |v| "'#{v}'" }.join(', ') else say "Solution: ", :red say "remove or disable this gem until a patch is available!", [:red, :bold] end say end
print_warning(message)
click to toggle source
# File lib/bundler/audit/cli/formats/text.rb, line 61 def print_warning(message) say message, :yellow end