class Chelsea::XMLFormatter
Produce output in xml format
Public Class Methods
new(options)
click to toggle source
Calls superclass method
Formatter::new
# File lib/chelsea/formatters/xml.rb, line 24 def initialize(options) super() @options = options end
Public Instance Methods
do_print(results)
click to toggle source
# File lib/chelsea/formatters/xml.rb, line 61 def do_print(results) puts Ox.dump(results) end
fetch_results(server_response, _reverse_deps)
click to toggle source
# File lib/chelsea/formatters/xml.rb, line 29 def fetch_results(server_response, _reverse_deps) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize doc = Ox::Document.new instruct = Ox::Instruct.new(:xml) instruct[:version] = '1.0' instruct[:encoding] = 'UTF-8' instruct[:standalone] = 'yes' doc << instruct testsuite = Ox::Element.new('testsuite') testsuite[:name] = 'purl' testsuite[:tests] = server_response.count doc << testsuite server_response.each do |coord| testcase = Ox::Element.new('testcase') testcase[:classname] = coord['coordinates'] testcase[:name] = coord['coordinates'] if coord['vulnerabilities'].length.positive? failure = Ox::Element.new('failure') failure[:type] = 'Vulnerable Dependency' failure << get_vulnerability_block(coord['vulnerabilities']) testcase << failure testsuite << testcase elsif @options[:verbose] testsuite << testcase end end doc end
get_vulnerability_block(vulnerabilities)
click to toggle source
# File lib/chelsea/formatters/xml.rb, line 65 def get_vulnerability_block(vulnerabilities) # rubocop:disable Metrics/MethodLength vuln_block = '' vulnerabilities.each do |vuln| vuln_block += "Vulnerability Title: #{vuln['title']}\n"\ "ID: #{vuln['id']}\n"\ "Description: #{vuln['description']}\n"\ "CVSS Score: #{vuln['cvssScore']}\n"\ "CVSS Vector: #{vuln['cvssVector']}\n"\ "CVE: #{vuln['cve']}\n"\ "Reference: #{vuln['reference']}"\ "\n" end vuln_block end