Sha256: 55804144d28be6e8223ee965eb6a2514d9035d944142ac1164e7a8a98454438c
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
require 'openscap' require 'openscap/ds/arf' require 'openscap/xccdf/testresult' require 'openscap/xccdf/ruleresult' module Scaptimony class ArfReportRaw < ActiveRecord::Base set_primary_key :arf_report_id belongs_to :arf_report after_create :save_dependent_entities def to_html arf = build_arf html = arf.html arf.destroy OpenSCAP.oscap_cleanup html end private def save_dependent_entities return if arf_report.xccdf_rule_results.any? return if size < 0 begin arf = build_arf test_result = arf.test_result create_rule_results(test_result) rescue StandardError => e arf_report.xccdf_rule_results.destroy_all raise e ensure test_result.destroy unless test_result.nil? arf.destroy unless arf.nil? OpenSCAP.oscap_cleanup end end def create_rule_results(test_result) test_result.rr.each {|rr_id, rr| rule = ::Scaptimony::XccdfRule.where(:xid => rr_id).first_or_create! arf_report.xccdf_rule_results.create!(:xccdf_rule_id => rule.id, :xccdf_result_id => XccdfResult.f(rr.result).id) } end def build_arf OpenSCAP.oscap_init OpenSCAP::DS::Arf.new :content => bzip_data, :path => 'arf.xml.bz2', :length => size end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
scaptimony-0.3.2 | app/models/scaptimony/arf_report_raw.rb |
scaptimony-0.3.1 | app/models/scaptimony/arf_report_raw.rb |
scaptimony-0.3.0 | app/models/scaptimony/arf_report_raw.rb |