Class: Proxy::OpenSCAP::ScapValidation
- Inherits:
-
Object
- Object
- Proxy::OpenSCAP::ScapValidation
- Defined in:
- lib/smart_proxy_openscap/scap_validation.rb
Instance Method Summary collapse
Instance Method Details
#allowed_types ⇒ Object
8 9 10 11 12 13 |
# 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) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# 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 |