-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathrule.rb
More file actions
58 lines (47 loc) · 1.35 KB
/
rule.rb
File metadata and controls
58 lines (47 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# frozen_string_literal: true
require 'openscap_results_parser/rule_identifier'
require 'openscap_results_parser/rule_references'
require 'openscap_results_parser/xml_file'
# Mimics openscap-ruby Rule interface
module OpenscapParser
class Rule < XmlNode
include OpenscapParser::Util
include OpenscapParser::RuleReferences
def id
@id ||= parsed_xml['id']
end
def selected
@selected ||= parsed_xml['selected']
end
def severity
@severity ||= parsed_xml['severity']
end
def title
@title ||= parsed_xml.at_css('title') &&
parsed_xml.at_css('title').text
end
def description
@description ||= newline_to_whitespace(
parsed_xml.at_css('description') &&
parsed_xml.at_css('description').text || ''
)
end
def rationale
@rationale ||= newline_to_whitespace(
parsed_xml.at_css('rationale') &&
parsed_xml.at_css('rationale').text || ''
)
end
alias :rule_reference_nodes_old :rule_reference_nodes
def rule_reference_nodes(xpath = "reference")
rule_reference_nodes_old(xpath)
end
def rule_identifier
@identifier ||= RuleIdentifier.new(parsed_xml: identifier_node)
end
alias :identifier :rule_identifier
def identifier_node
@identifier_node ||= parsed_xml.at_xpath('ident')
end
end
end