Class: Bundler::Audit::Presenter::Plain
- Defined in:
- lib/bundler/audit/presenter/plain.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #print_advisory(gem, advisory) ⇒ Object protected
- #print_report ⇒ Object
- #print_warning(message) ⇒ Object protected
- #say(message = '', color = nil) ⇒ Object protected
Methods inherited from Base
#exit_code, #initialize, #problematic?, #push_advisory, #push_warning
Constructor Details
This class inherits a constructor from Bundler::Audit::Presenter::Base
Instance Method Details
#print_advisory(gem, advisory) ⇒ Object (protected)
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/bundler/audit/presenter/plain.rb', line 34 def print_advisory(gem, advisory) say "Name: ", :red say gem.name say "Version: ", :red say gem.version say "Advisory: ", :red if advisory.cve say "CVE-#{advisory.cve}" elsif advisory.osvdb say advisory.osvdb end say "Criticality: ", :red case advisory.criticality when :low then say "Low" when :medium then say "Medium", :yellow when :high then say "High", [:red, :bold] else say "Unknown" end say "URL: ", :red say advisory.url if .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: upgrade to ", :red say advisory.patched_versions.join(', ') else say "Solution: ", :red say "remove or disable this gem until a patch is available!", [:red, :bold] end say end |
#print_report ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bundler/audit/presenter/plain.rb', line 7 def print_report @warnings.each do |warning| print_warning warning end @advisory_bundles.each do |bundle| print_advisory bundle.gem, bundle.advisory end if problematic? say "Vulnerabilities found!", :red else say("No vulnerabilities found", :green) unless .quiet? end end |
#print_warning(message) ⇒ Object (protected)
30 31 32 |
# File 'lib/bundler/audit/presenter/plain.rb', line 30 def print_warning() say , :yellow end |
#say(message = '', color = nil) ⇒ Object (protected)
25 26 27 28 |
# File 'lib/bundler/audit/presenter/plain.rb', line 25 def say( = '', color = nil) color = nil unless $stdout.tty? shell.say(.to_s, color) end |