openscap_parser 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/openscap_parser.rb +1 -0
- data/lib/openscap_parser/ds.rb +27 -0
- data/lib/openscap_parser/profile.rb +9 -0
- data/lib/openscap_parser/profiles.rb +1 -1
- data/lib/openscap_parser/rule.rb +13 -0
- data/lib/openscap_parser/rules.rb +1 -1
- data/lib/openscap_parser/version.rb +1 -1
- data/lib/openscap_parser/xml_file.rb +11 -0
- data/lib/openscap_parser/xml_report.rb +3 -5
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04a15bff1610dd289e619dfe869fa31f0af4309acac276aae1f5c10b15197238
|
4
|
+
data.tar.gz: 0706ef0b61d96b7d3dfa73ed7f6696caaa18bbeb6a4d81eb922ef8ca75b5f4f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b066da57a23d5da4c235b97ce59c560f2c132e2275750e3861f7951905b5b56911388380aa81ff73ffe0e01c6b69b82821fa23a36738ed085548116a748b12b
|
7
|
+
data.tar.gz: 66aa26a5e7a4bf1cd89392304eb1d0cb77d4716384dd4a920684534ab4f3a5d360a0941419add841e003d724810acc08f07542ce01825a902cd2902cc5d1917d
|
data/.gitignore
CHANGED
data/lib/openscap_parser.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'openscap_parser/xml_file'
|
3
|
+
|
4
|
+
module OpenscapParser
|
5
|
+
class Ds
|
6
|
+
include OpenscapParser::XmlFile
|
7
|
+
|
8
|
+
def initialize(report)
|
9
|
+
report_xml report
|
10
|
+
end
|
11
|
+
|
12
|
+
def profiles
|
13
|
+
@profiles ||= profile_nodes
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def profile_nodes
|
19
|
+
@report_xml.xpath(".//Profile").map do |node|
|
20
|
+
id = node.attribute('id')&.value
|
21
|
+
title = node.at_xpath('./title')&.text
|
22
|
+
description = node.at_xpath('./description')&.text
|
23
|
+
{ :id => id, :title => title, :description => description }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/openscap_parser/rule.rb
CHANGED
@@ -26,6 +26,19 @@ module OpenscapParser
|
|
26
26
|
def rationale
|
27
27
|
@rationale ||= @rule_xml.at_css('rationale').children.text.delete("\n")
|
28
28
|
end
|
29
|
+
|
30
|
+
def references
|
31
|
+
@references ||= @rule_xml.css('reference').map do |node|
|
32
|
+
{ href: node['href'], label: node.text }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def identifier
|
37
|
+
@identifier ||= {
|
38
|
+
label: @rule_xml.at_css('ident')&.text,
|
39
|
+
system: (ident = @rule_xml.at_css('ident')) && ident['system']
|
40
|
+
}
|
41
|
+
end
|
29
42
|
end
|
30
43
|
end
|
31
44
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'nokogiri'
|
3
|
+
require 'openscap_parser/xml_file'
|
3
4
|
|
4
5
|
module OpenscapParser
|
5
6
|
# Methods related with parsing directly the XML from the Report
|
@@ -7,6 +8,8 @@ module OpenscapParser
|
|
7
8
|
module XMLReport
|
8
9
|
def self.included(base)
|
9
10
|
base.class_eval do
|
11
|
+
include OpenscapParser::XmlFile
|
12
|
+
|
10
13
|
def host
|
11
14
|
@report_xml.search('target').text
|
12
15
|
end
|
@@ -14,11 +17,6 @@ module OpenscapParser
|
|
14
17
|
def description
|
15
18
|
@report_xml.search('description').first.text
|
16
19
|
end
|
17
|
-
|
18
|
-
def report_xml(report_contents = '')
|
19
|
-
@report_xml ||= ::Nokogiri::XML.parse(report_contents)
|
20
|
-
@report_xml.remove_namespaces! if @report_xml.namespaces.keys.include? 'xmlns:arf'
|
21
|
-
end
|
22
20
|
end
|
23
21
|
end
|
24
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openscap_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Lobato Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-06-
|
11
|
+
date: 2019-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -97,11 +97,14 @@ files:
|
|
97
97
|
- bin/console
|
98
98
|
- bin/setup
|
99
99
|
- lib/openscap_parser.rb
|
100
|
+
- lib/openscap_parser/ds.rb
|
101
|
+
- lib/openscap_parser/profile.rb
|
100
102
|
- lib/openscap_parser/profiles.rb
|
101
103
|
- lib/openscap_parser/rule.rb
|
102
104
|
- lib/openscap_parser/rule_result.rb
|
103
105
|
- lib/openscap_parser/rules.rb
|
104
106
|
- lib/openscap_parser/version.rb
|
107
|
+
- lib/openscap_parser/xml_file.rb
|
105
108
|
- lib/openscap_parser/xml_report.rb
|
106
109
|
- openscap_parser.gemspec
|
107
110
|
homepage:
|