class OpenSCAP::Xccdf::TestResult
Attributes
raw[R]
rr[R]
Public Class Methods
new(t)
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 14 def initialize(t) case t when OpenSCAP::Source @raw = OpenSCAP.xccdf_result_import_source(t.raw) OpenSCAP.raise! if @raw.null? when FFI::Pointer @raw = OpenSCAP.xccdf_result_import_source(t) OpenSCAP.raise! if @raw.null? else raise OpenSCAP::OpenSCAPError, "Cannot initialize #{self.class.name} with #{t}" end init_ruleresults end
Public Instance Methods
destroy()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 52 def destroy OpenSCAP.xccdf_result_free @raw @raw = nil end
id()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 28 def id OpenSCAP.xccdf_result_get_id(@raw) end
profile()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 32 def profile OpenSCAP.xccdf_result_get_profile(@raw) end
score()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 36 def score @score ||= score_init end
score!(benchmark)
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 40 def score!(benchmark) # recalculate the scores in the scope of given benchmark @score = nil OpenSCAP.raise! unless OpenSCAP.xccdf_result_recalculate_scores(@raw, benchmark.raw).zero? score end
source()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 47 def source source_p = OpenSCAP.xccdf_result_export_source(raw, nil) OpenSCAP::Source.new source_p end
Private Instance Methods
init_ruleresults()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 59 def init_ruleresults @rr = {} rr_it = OpenSCAP.xccdf_result_get_rule_results(@raw) while OpenSCAP.xccdf_rule_result_iterator_has_more(rr_it) rr_raw = OpenSCAP.xccdf_rule_result_iterator_next(rr_it) rr = OpenSCAP::Xccdf::RuleResult.new rr_raw @rr[rr.id] = rr end OpenSCAP.xccdf_rule_result_iterator_free(rr_it) end
score_init()
click to toggle source
# File lib/openscap/xccdf/testresult.rb, line 70 def score_init scores = {} scorit = OpenSCAP.xccdf_result_get_scores(@raw) while OpenSCAP.xccdf_score_iterator_has_more(scorit) s = OpenSCAP.xccdf_score_iterator_next(scorit) scores[OpenSCAP.xccdf_score_get_system(s)] = { :system => OpenSCAP.xccdf_score_get_system(s), :value => OpenSCAP.xccdf_score_get_score(s), :max => OpenSCAP.xccdf_score_get_maximum(s) } end OpenSCAP.xccdf_score_iterator_free(scorit) scores end