Sha256: 2e333f41180956362c3bb74b9eb68aa9bee6f2a1fa31e9256ae276364a4359ed
Contents?: true
Size: 1.53 KB
Versions: 1
Compression:
Stored size: 1.53 KB
Contents
module Pluginscan class VulnerabilitiesPrinter < Printer def print(advisories, plugin_slug) raise ArgumentError, "Can't print a nil list of advisories" if advisories.nil? print_headline(advisories, plugin_slug) advisories.reverse.each do |advisory| print_advisory(advisory) end print_blank_line end private def print_headline(advisories, plugin_slug) if advisories.any? @output.puts "#{advisories.count} advisories were found for '#{plugin_slug}':".color(:blue) else @output.puts "No advisories were found for '#{plugin_slug}'".color(:blue) end end private def print_advisory(advisory) printer = VulnerabilityPrinter.new(@output) printer.print(advisory) end end class VulnerabilityPrinter < Printer def print(advisory) title = highlight_version_number(advisory.title) date = format_date(advisory.date) fixed = fixed_data(advisory.fixed_in) @output.puts " #{date} #{title} #{fixed}" @output.puts " #{advisory.url}" end private def highlight_version_number(title) version_number_regex = '([\<\>\=]+\ )?[\d\.]+' title.gsub( /(?<version>#{version_number_regex})/, '\k<version>'.color(:yellow) ) end private def format_date(date) date.strftime('%Y-%m-%d').color(:green) end private def fixed_data(fixed_version) return "(no fixed version!)".color(:red) if fixed_version.nil? "(fixed in #{fixed_version})".color(:red) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pluginscan-0.9.0 | lib/pluginscan/reports/vulnerability_report/vulnerabilities_printer.rb |