Skip to content

Commit 6f2194c

Browse files
committed
Query all useful policies by default
Requires OpenSCAP-1.2.9+
1 parent 1646648 commit 6f2194c

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/openscap/xccdf/policy_model.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def destroy
4242

4343
def policies_init
4444
policies = {}
45+
OpenSCAP.raise! unless OpenSCAP.xccdf_policy_model_build_all_useful_policies(raw) == 0
4546
polit = OpenSCAP.xccdf_policy_model_get_policies raw
4647
while OpenSCAP.xccdf_policy_iterator_has_more polit
4748
policy_p = OpenSCAP.xccdf_policy_iterator_next polit
@@ -56,6 +57,7 @@ def policies_init
5657

5758
attach_function :xccdf_policy_model_new, [:pointer], :pointer
5859
attach_function :xccdf_policy_model_free, [:pointer], :void
60+
attach_function :xccdf_policy_model_build_all_useful_policies, [:pointer], :int
5961

6062
attach_function :xccdf_policy_model_get_policies, [:pointer], :pointer
6163
attach_function :xccdf_policy_iterator_has_more, [:pointer], :bool

test/xccdf/policy_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ def test_new_policy_model
2222
b = OpenSCAP::Xccdf::Benchmark.new @s
2323
pm = OpenSCAP::Xccdf::PolicyModel.new b
2424
assert !b.nil?
25-
assert pm.policies.size == 0, pm.policies.to_s
25+
assert pm.policies.size == 1, pm.policies.to_s
26+
assert pm.policies['xccdf_org.ssgproject.content_profile_common']
2627
pm.destroy
2728
end
2829
end

0 commit comments

Comments
 (0)