Class: OpenSCAP::Xccdf::Benchmark
- Inherits:
-
Object
- Object
- OpenSCAP::Xccdf::Benchmark
show all
- Includes:
- ItemCommon
- Defined in:
- lib/openscap/xccdf/benchmark.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from ItemCommon
#description, #id, #references, #title, #version
Constructor Details
Returns a new instance of Benchmark.
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/openscap/xccdf/benchmark.rb', line 16
def initialize p
case p
when OpenSCAP::Source
@raw = OpenSCAP.xccdf_benchmark_import_source p.raw
else
raise OpenSCAP::OpenSCAPError,
"Cannot initialize OpenSCAP::Xccdf::Benchmark with '#{p}'"
end
OpenSCAP.raise! if @raw.null?
begin
yield self
ensure
destroy
end if block_given?
end
|
Instance Attribute Details
#raw ⇒ Object
Returns the value of attribute raw.
14
15
16
|
# File 'lib/openscap/xccdf/benchmark.rb', line 14
def raw
@raw
end
|
Instance Method Details
#destroy ⇒ Object
76
77
78
79
80
81
82
83
84
|
# File 'lib/openscap/xccdf/benchmark.rb', line 76
def destroy
if @policy_model
@policy_model.destroy
else
OpenSCAP.xccdf_benchmark_free @raw
end
@raw = nil
end
|
#each_item ⇒ Object
49
50
51
52
53
|
# File 'lib/openscap/xccdf/benchmark.rb', line 49
def each_item(&)
OpenSCAP._iterate over: OpenSCAP.xccdf_item_get_content(@raw), as: 'xccdf_item' do |pointer|
yield OpenSCAP::Xccdf::Item.build(pointer)
end
end
|
#each_profile ⇒ Object
55
56
57
58
59
|
# File 'lib/openscap/xccdf/benchmark.rb', line 55
def each_profile(&)
OpenSCAP._iterate over: OpenSCAP.xccdf_benchmark_get_profiles(@raw), as: 'xccdf_profile' do |pointer|
yield OpenSCAP::Xccdf::Profile.new pointer
end
end
|
#each_value ⇒ Object
61
62
63
64
65
|
# File 'lib/openscap/xccdf/benchmark.rb', line 61
def each_value(&)
OpenSCAP._iterate over: OpenSCAP.xccdf_benchmark_get_values(@raw), as: 'xccdf_value' do |pointer|
yield OpenSCAP::Xccdf::Value.new pointer
end
end
|
#items ⇒ Object
45
46
47
|
# File 'lib/openscap/xccdf/benchmark.rb', line 45
def items
@items ||= items_init
end
|
#policy_model ⇒ Object
67
68
69
|
# File 'lib/openscap/xccdf/benchmark.rb', line 67
def policy_model
@policy_model ||= PolicyModel.new self
end
|
#profiles ⇒ Object
41
42
43
|
# File 'lib/openscap/xccdf/benchmark.rb', line 41
def profiles
@profiles ||= profiles_init
end
|
#resolved? ⇒ Boolean
33
34
35
|
# File 'lib/openscap/xccdf/benchmark.rb', line 33
def resolved?
OpenSCAP.xccdf_benchmark_get_resolved @raw
end
|
#schema_version ⇒ Object
71
72
73
74
|
# File 'lib/openscap/xccdf/benchmark.rb', line 71
def schema_version
pointer = OpenSCAP.xccdf_benchmark_get_schema_version @raw
OpenSCAP.xccdf_version_info_get_version pointer
end
|
#status_current ⇒ Object
37
38
39
|
# File 'lib/openscap/xccdf/benchmark.rb', line 37
def status_current
Status.new OpenSCAP.xccdf_benchmark_get_status_current(@raw)
end
|