Class: Proxy::OpenSCAP::ContentParser

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/smart_proxy_openscap/content_parser.rb

Instance Method Summary collapse

Instance Method Details

#validate(file_type, scap_file) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/smart_proxy_openscap/content_parser.rb', line 8

def validate(file_type, scap_file)
  msg = 'Invalid XML format'
  errors = []
  begin
    case file_type
    when 'scap_content'
      ::OpenscapParser::DatastreamFile.new(scap_file)
    when 'tailoring_file'
      ::OpenscapParser::TailoringFile.new(scap_file)
    end
  rescue Nokogiri::XML::SyntaxError => e
    logger.error msg
    logger.error e.backtrace.join("\n")
    errors << msg
  end
  { errors: errors }
end