Class: OpenscapParser::Profile
Instance Attribute Summary
Attributes inherited from XmlNode
#namespaces
Instance Method Summary
collapse
Methods inherited from XmlNode
#initialize, #parsed_xml, #text, #xpath_node, #xpath_nodes
Instance Method Details
#description ⇒ Object
19
20
21
22
|
# File 'lib/openscap_parser/profile.rb', line 19
def description
@description ||= @parsed_xml.at_css('description') &&
@parsed_xml.at_css('description').text
end
|
#extends_profile_id ⇒ Object
9
10
11
|
# File 'lib/openscap_parser/profile.rb', line 9
def extends_profile_id
@extends ||= @parsed_xml['extends']
end
|
#id ⇒ Object
5
6
7
|
# File 'lib/openscap_parser/profile.rb', line 5
def id
@id ||= @parsed_xml['id']
end
|
#refined_values ⇒ Object
49
50
51
52
53
|
# File 'lib/openscap_parser/profile.rb', line 49
def refined_values
@refined_values ||= @parsed_xml.xpath("refine-value").each_with_object({}) do |element, rv|
rv[element.at_xpath('@idref').text] = element.at_xpath('@selector').text
end
end
|
#selected_entity_ids ⇒ Object
44
45
46
47
|
# File 'lib/openscap_parser/profile.rb', line 44
def selected_entity_ids
@selected_entity_ids ||= @parsed_xml.xpath("select[@selected='true']/@idref") &&
@parsed_xml.xpath("select[@selected='true']/@idref").map(&:text)
end
|
#selected_rule_ids ⇒ Object
24
25
26
27
28
29
30
31
32
|
# File 'lib/openscap_parser/profile.rb', line 24
def selected_rule_ids
@selected_rule_ids ||= @parsed_xml.xpath("select[@selected='true']
[regex(@idref, '^((?!_group_).)*?(_rule_).*$')]
/@idref", RegexHandler) &&
@parsed_xml.xpath("select[@selected='true']
[regex(@idref, '^((?!_group_).)*?(_rule_).*$')]
/@idref", RegexHandler).map(&:text)
end
|
#title ⇒ Object
Also known as:
name
13
14
15
16
|
# File 'lib/openscap_parser/profile.rb', line 13
def title
@title ||= @parsed_xml.at_css('title') &&
@parsed_xml.at_css('title').text
end
|
#to_h ⇒ Object
55
56
57
58
59
60
61
62
|
# File 'lib/openscap_parser/profile.rb', line 55
def to_h
{
:id => id,
:title => title,
:description => description,
:refined_values => refined_values
}
end
|
#unselected_group_ids ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'lib/openscap_parser/profile.rb', line 34
def unselected_group_ids
@unselected_group_ids ||= @parsed_xml.xpath("select[@selected='false']
[regex(@idref, '^((?!_rule_).)*?(_group_).*$')]
/@idref", RegexHandler) &&
@parsed_xml.xpath("select[@selected='false']
[regex(@idref, '^((?!_rule_).)*?(_group_).*$')]
/@idref", RegexHandler).map(&:text)
end
|