class Proxy::OpenSCAP::ProfilesParser
Public Instance Methods
profiles(file_type, scap_file)
click to toggle source
# File lib/smart_proxy_openscap/profiles_parser.rb, line 7 def profiles(file_type, scap_file) profiles = [] error_msg = 'Failed to parse profiles' begin case file_type when 'scap_content' profiles = ::OpenscapParser::DatastreamFile.new(scap_file).benchmark.profiles when 'tailoring_file' profiles = ::OpenscapParser::TailoringFile.new(scap_file).tailoring.profiles else raise OpenSCAPException, "Unknown file type, expected 'scap_content' or 'tailoring_file'" end rescue Nokogiri::XML::SyntaxError raise OpenSCAPException, error_msg end raise OpenSCAPException, error_msg if profiles.empty? result = profiles.reduce({}) do |memo, profile| memo.tap { |acc| acc[profile.id] = profile.title } end.to_json end