openscap_parser 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 159fcf26b6fe71666a9d057d89d772589ac8436d783b7773556121b6b5c11654
4
- data.tar.gz: f8181135885961c284b2dabfd4de0408d8888e7cf4271da699f0e42fc0e30bf6
3
+ metadata.gz: c5c95f01a6f86db68b3d0561858c9d39af294872d3d0e6689f0bc6d37d39e660
4
+ data.tar.gz: c14ce4fb133683267862decac1f6db27e84f8f504026b135a04e642d849bad52
5
5
  SHA512:
6
- metadata.gz: be89da681f6a355591027ce73b0dd3a68bcbd73bcc442a2d4e21c2a51485a9e841d493bafef8757aff5f85025e0a5251d3b1519801b2fdb1343fe070b165fe6b
7
- data.tar.gz: 8949839744c203ec9074e3069097a3d98739eb65c7a76841c117f456eb02c55c3eee1576cf3b550501012b52f549d8aaaac0f601350d5f92e37a79e2a6602117
6
+ metadata.gz: 59ed3d7a867fe0b5b230943068be977ce2d4aadc5edc0df79df5b4ce2e7c817420a3251569c70155a7f4c9626d5c0b2f51e35883770f0aeb848b23d3e345adab
7
+ data.tar.gz: b0d13aabf1dd555a7a376ea74a7092815c91e591f5cb40457ff06ac6f195e379246d31a7a1a0d5bd650c087bf654d26de6ef2cf6002d2a3163ca51626f863221
@@ -1,3 +1,5 @@
1
+ require 'openscap_parser/regex_handler'
2
+
1
3
  module OpenscapParser
2
4
  class Profile < XmlNode
3
5
  def id
@@ -20,7 +22,27 @@ module OpenscapParser
20
22
  end
21
23
 
22
24
  def selected_rule_ids
23
- @selected_rule_ids ||= @parsed_xml.xpath("select[@selected='true']/@idref") &&
25
+ # Look for selected rule ids where the idref contains '_rule_' that is not preceded by 'group'
26
+ @selected_rule_ids ||= @parsed_xml.xpath("select[@selected='true']
27
+ [regex(@idref, '^((?!_group_).)*?(_rule_).*$')]
28
+ /@idref", RegexHandler) &&
29
+ @parsed_xml.xpath("select[@selected='true']
30
+ [regex(@idref, '^((?!_group_).)*?(_rule_).*$')]
31
+ /@idref", RegexHandler).map(&:text)
32
+ end
33
+
34
+ def selected_group_ids
35
+ # Look for selected group ids where the idref contains '_group_' that is not preceded by 'rule'
36
+ @selected_group_ids ||= @parsed_xml.xpath("select[@selected='true']
37
+ [regex(@idref, '^((?!_rule_).)*?(_group_).*$')]
38
+ /@idref", RegexHandler) &&
39
+ @parsed_xml.xpath("select[@selected='true']
40
+ [regex(@idref, '^((?!_rule_).)*?(_group_).*$')]
41
+ /@idref", RegexHandler).map(&:text)
42
+ end
43
+
44
+ def selected_entity_ids
45
+ @selected_entity_ids ||= @parsed_xml.xpath("select[@selected='true']/@idref") &&
24
46
  @parsed_xml.xpath("select[@selected='true']/@idref").map(&:text)
25
47
  end
26
48
 
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module OpenscapParser
4
+ class RegexHandler < XmlNode
5
+ def self.regex node_set, regex
6
+ node_set.find_all { |node| node.to_s =~ /#{regex}/ }
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,3 @@
1
1
  module OpenscapParser
2
- VERSION = "1.1.0"
2
+ VERSION = "1.2.0"
3
3
  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.1.0
4
+ version: 1.2.0
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: 2022-03-01 00:00:00.000000000 Z
12
+ date: 2022-03-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -156,6 +156,7 @@ files:
156
156
  - lib/openscap_parser/oval_report.rb
157
157
  - lib/openscap_parser/profile.rb
158
158
  - lib/openscap_parser/profiles.rb
159
+ - lib/openscap_parser/regex_handler.rb
159
160
  - lib/openscap_parser/rule.rb
160
161
  - lib/openscap_parser/rule_identifier.rb
161
162
  - lib/openscap_parser/rule_reference.rb