Skip to content

Commit

Permalink
RHICOMPL-3348: Parse values for rules
Browse files Browse the repository at this point in the history
  • Loading branch information
marleystipich2 authored and skateman committed Nov 29, 2022
1 parent 0c0c10f commit d58c657
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/openscap_parser/rule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def parent_type
end
end

def values
parsed_xml.xpath("check/check-export").map { |r| r.at_xpath('@value-id')&.text }
end

def to_h
{
:id => id,
Expand All @@ -95,7 +99,8 @@ def to_h
:rationale => rationale,
:identifier => rule_identifier.to_h,
:parent_id => parent_id,
:parent_type => parent_type
:parent_type => parent_type,
:values => values
}
end
end
Expand Down
7 changes: 7 additions & 0 deletions test/openscap_parser/test_result_file_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ def setup
assert_match(/^Group/,
@test_result_file2.benchmark.rules[1].parent_type)
end

test 'values' do
rule = @test_result_file2.benchmark.rules.select { |r| r.id == "xccdf_org.ssgproject.content_rule_accounts_password_pam_pwhistory_remember_password_auth" }
assert_equal(["xccdf_org.ssgproject.content_value_var_password_pam_remember_control_flag", "xccdf_org.ssgproject.content_value_var_password_pam_remember"],
rule[0].values)
assert_equal([], @test_result_file2.benchmark.rules[1].values)
end
end

context 'value_definitions' do
Expand Down

0 comments on commit d58c657

Please sign in to comment.