class Proxy::OpenSCAP::ScapValidation
Public Instance Methods
allowed_types()
click to toggle source
# File lib/smart_proxy_openscap/scap_validation.rb, line 8 def allowed_types { 'tailoring_file' => 'XCCDF Tailoring', 'scap_content' => 'SCAP Source Datastream' } end
validate(in_file, out_file, type)
click to toggle source
# File lib/smart_proxy_openscap/scap_validation.rb, line 15 def validate(in_file, out_file, type) errors = [] ::OpenSCAP.oscap_init source = ::OpenSCAP::Source.new(in_file) if source.type != allowed_types[type] errors << "Uploaded file is #{source.type}, unexpected file type" end begin source.validate! rescue ::OpenSCAP::OpenSCAPError errors << "Invalid SCAP file type" end File.write out_file, { :errors => errors }.to_json source.destroy ::OpenSCAP.oscap_cleanup end