Sha256: 56ec952e5913dd0eebb8d872e513546fc1820255cd0a438e5851b72d8204a43b

Contents?: true

Size: 635 Bytes

Versions: 4

Compression:

Stored size: 635 Bytes

Contents

require 'openscap_parser/datastream_file'
require 'openscap_parser/tailoring_file'

module Proxy::OpenSCAP
  class ContentParser
    def validate(file_type, scap_file)
      msg = 'Invalid SCAP file type'
      errors = []
      file = nil
      begin
        case file_type
        when 'scap_content'
          file = ::OpenscapParser::DatastreamFile.new(scap_file)
        when 'tailoring_file'
          file = ::OpenscapParser::TailoringFile.new(scap_file)
        end
        errors << msg unless file.valid?
      rescue Nokogiri::XML::SyntaxError => e
        errors << msg
      end
      { errors: errors }
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
smart_proxy_openscap-0.9.1 lib/smart_proxy_openscap/content_parser.rb
smart_proxy_openscap-0.9.0 lib/smart_proxy_openscap/content_parser.rb
smart_proxy_openscap-0.8.1 lib/smart_proxy_openscap/content_parser.rb
smart_proxy_openscap-0.8.0 lib/smart_proxy_openscap/content_parser.rb