openscap_parser 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec101e20e8153fa638aa705ab0bfdcf48624a8c70e74670727454f3811adc175
4
- data.tar.gz: 0b2fe6ab34ff284a586709cc6d4a91054d54e4f41749b1fdecffd8af3cc6a37e
3
+ metadata.gz: 65cd8f383c3d40c907ecab37235ac6c50eeddced32dc9173b7b4b8e7526c869a
4
+ data.tar.gz: a1150af6f99b020a31f174b83a1b405b1375dd0e37300ced57daa633988a8be1
5
5
  SHA512:
6
- metadata.gz: b4dc7ff782e6d0b2dc61c066462291b039f649d70fc56adef4507c99d55e90626adc839c1ac23352e39b2401011f5e7196e8b63a066d1402b3754b2fee6d94e0
7
- data.tar.gz: 0b9141c770ba031dadb3a720e80d61ef3077895c6d6356db39ee1be5b92338b13cf935e1e7a3f83cf4c77abb05a725cb34cef7d6e0fb0c5288ce8f66a45cd7d9
6
+ metadata.gz: 696960d718a5eefbd435af227822ce48144c07be20df1a85ec2a93c1328bba7d8f92e823b57feafe38f479a3c3b0a3f26d365595cf247cf13de3f2160b11ccda
7
+ data.tar.gz: a40766e4211f052ad1ab60c1e41dbb2bb70ab26ee221aeaa5eca664287a86b5cd1cf199f1fe47a3be23372b5723c11cf394c68db13203333abf3e0639dd1f841
@@ -13,6 +13,7 @@ require 'openscap_parser/xml_file'
13
13
  require 'openscap_parser/datastream_file'
14
14
  require 'openscap_parser/test_result_file'
15
15
  require 'openscap_parser/tailoring_file'
16
+ require 'openscap_parser/oval_report'
16
17
 
17
18
  require 'date'
18
19
  require 'railtie' if defined?(Rails)
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+ require 'openscap_parser/xml_file'
3
+ require 'oval/definition_result'
4
+ require 'oval/definition'
5
+
6
+ module OpenscapParser
7
+ class OvalReport < XmlFile
8
+ def definition_results
9
+ @definition_results ||= definition_result_nodes.map { |node| ::Oval::DefinitionResult.new parsed_xml: node }
10
+ end
11
+
12
+ def definition_result_nodes(xpath = "./oval_results/results/system/definitions/definition")
13
+ xpath_nodes(xpath)
14
+ end
15
+
16
+ def definitions
17
+ @definitions ||= definition_nodes.map { |node| Oval::Definition.new parsed_xml: node }
18
+ end
19
+
20
+ def definition_nodes(xpath = "./oval_results/oval_definitions/definitions/definition")
21
+ xpath_nodes(xpath)
22
+ end
23
+ end
24
+ end
@@ -1,4 +1,7 @@
1
1
  # frozen_string_literal: true
2
+ require 'openscap_parser/xml_file'
3
+ require 'openscap_parser/benchmarks'
4
+ require 'openscap_parser/test_results'
2
5
 
3
6
  module OpenscapParser
4
7
  # A class to represent an XmlFile which contains a <TestResult /> Xccdf type
@@ -1,3 +1,3 @@
1
1
  module OpenscapParser
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
@@ -0,0 +1,47 @@
1
+ require "openscap_parser/xml_node"
2
+ require "oval/reference"
3
+
4
+ module Oval
5
+ class Definition < ::OpenscapParser::XmlNode
6
+ def id
7
+ @id ||= @parsed_xml['id']
8
+ end
9
+
10
+ def version
11
+ @version ||= @parsed_xml['version']
12
+ end
13
+
14
+ def klass
15
+ @klass ||= @parsed_xml['class']
16
+ end
17
+
18
+ def title
19
+ xml = @parsed_xml.at_xpath("./metadata/title")
20
+ @title ||= xml && xml.text
21
+ end
22
+
23
+ def description
24
+ xml = @parsed_xml.at_xpath("./metadata/description")
25
+ @description ||= xml && xml.text
26
+ end
27
+
28
+ def reference_nodes
29
+ @reference_nodes ||= @parsed_xml.xpath("./metadata/reference")
30
+ end
31
+
32
+ def references
33
+ @references ||= reference_nodes.map { |node| Reference.new parsed_xml: node }
34
+ end
35
+
36
+ def to_h
37
+ {
38
+ :id => id,
39
+ :version => version,
40
+ :klass => klass,
41
+ :title => title,
42
+ :description => description,
43
+ :references => references.map(&:to_h)
44
+ }
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,17 @@
1
+ require 'openscap_parser/xml_node'
2
+
3
+ module Oval
4
+ class DefinitionResult < ::OpenscapParser::XmlNode
5
+ def definition_id
6
+ @definition_id ||= @parsed_xml['definition_id']
7
+ end
8
+
9
+ def result
10
+ @result ||= @parsed_xml['result']
11
+ end
12
+
13
+ def to_h
14
+ { :id => definition_id, :result => result }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,21 @@
1
+ require "openscap_parser/xml_node"
2
+
3
+ module Oval
4
+ class Reference < ::OpenscapParser::XmlNode
5
+ def source
6
+ @source ||= @parsed_xml['source']
7
+ end
8
+
9
+ def ref_id
10
+ @ref_id ||= @parsed_xml['ref_id']
11
+ end
12
+
13
+ def ref_url
14
+ @ref_url ||= @parsed_xml['ref_url']
15
+ end
16
+
17
+ def to_h
18
+ { :source => source, :ref_id => ref_id, :ref_url => ref_url }
19
+ end
20
+ end
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openscap_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lobato Garcia
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-01-29 00:00:00.000000000 Z
12
+ date: 2020-12-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -151,6 +151,7 @@ files:
151
151
  - lib/openscap_parser/datastream_file.rb
152
152
  - lib/openscap_parser/fix.rb
153
153
  - lib/openscap_parser/fixes.rb
154
+ - lib/openscap_parser/oval_report.rb
154
155
  - lib/openscap_parser/profile.rb
155
156
  - lib/openscap_parser/profiles.rb
156
157
  - lib/openscap_parser/rule.rb
@@ -175,6 +176,9 @@ files:
175
176
  - lib/openscap_parser/version.rb
176
177
  - lib/openscap_parser/xml_file.rb
177
178
  - lib/openscap_parser/xml_node.rb
179
+ - lib/oval/definition.rb
180
+ - lib/oval/definition_result.rb
181
+ - lib/oval/reference.rb
178
182
  - lib/railtie.rb
179
183
  - lib/ssg.rb
180
184
  - lib/ssg/downloader.rb
@@ -200,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
204
  - !ruby/object:Gem::Version
201
205
  version: '0'
202
206
  requirements: []
203
- rubygems_version: 3.0.3
207
+ rubygems_version: 3.1.4
204
208
  signing_key:
205
209
  specification_version: 4
206
210
  summary: Parse OpenSCAP content