inspec_tools 2.3.2 → 2.3.3

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: f1facda0eab24bdef7fafd9c8c92c5c94efedee3465bbf589b98fd4a61011be2
4
- data.tar.gz: a38564b26ff610046007e427c8b45950b743087703224470b0513e94941d6cc7
3
+ metadata.gz: 84cf060364796b3cfd7e3c758498a76379c743452b0ce119e19160b803e81ad8
4
+ data.tar.gz: dc01762be82174930cb3ba6b59ab02ec1541218ac2567c408f8338d1d6e83e60
5
5
  SHA512:
6
- metadata.gz: 45b1990c5f4a2e5fa1fd21af344ac9cd9cdf5b60fce134ed80e7e4593a2c315ad09e994d5efc711fa0d6485f26899a5c35dec5e8ba0c37686cfaca9f483304da
7
- data.tar.gz: 1022c5eae8dd7e6645e39fae3fbcb4babc195c2876d76d5f6496bb976a7515cb004d476176e19d70bba0507f8c8f1c355f48899c00fb39e79adcc2f26333fc08
6
+ metadata.gz: a37d714accd3ea9a04d48f60864a5a1701c15f8a8b88072829c933e1f68be6a61af99b2c1d0c9d59ff830c0754adb165bc34c8925f53a2a90168bee783d8f4c5
7
+ data.tar.gz: feb725f4dd11cf0db94fa9dd7dbbd8108984f4308d5b266da380fa242da8191ea80fdea495c9a4af722630334a823a65da1c075a7a0756d4c35e6fc422a1d3df
@@ -77,6 +77,15 @@ module HappyMapperTools
77
77
  element :dc_identifier, String, tag: 'identifier', namespace: 'dc'
78
78
  end
79
79
 
80
+ class Ident
81
+ include HappyMapper
82
+ attr_accessor :legacy
83
+ attr_accessor :cci
84
+ tag 'ident'
85
+ attribute :system, String, tag: 'system'
86
+ content :ident, String
87
+ end
88
+
80
89
  class Rule
81
90
  include HappyMapper
82
91
  tag 'Rule'
@@ -87,7 +96,7 @@ module HappyMapperTools
87
96
  element :title, String, tag: 'title'
88
97
  has_one :description, Description, tag: 'description'
89
98
  element :reference, ReferenceInfo, tag: 'reference'
90
- has_many :idents, String, tag: 'ident'
99
+ has_many :idents, Ident, tag: 'ident'
91
100
  element :fixtext, String, tag: 'fixtext'
92
101
  has_one :fix, Fix, tag: 'fix'
93
102
  has_one :check, Check, tag: 'check'
@@ -17,7 +17,7 @@ module InspecTools
17
17
  @xccdf = replace_tags_in_xccdf(replace_tags, @xccdf) unless replace_tags.nil?
18
18
  cci_list_path = File.join(File.dirname(__FILE__), '../data/U_CCI_List.xml')
19
19
  @cci_items = HappyMapperTools::CCIAttributes::CCI_List.parse(File.read(cci_list_path))
20
- # @cci_items = HappyMapperTools::CCIAttributes::CCI_List.parse(File.read('./data/U_CCI_List.xml'))
20
+ register_after_parse_callbacks
21
21
  @benchmark = HappyMapperTools::StigAttributes::Benchmark.parse(@xccdf)
22
22
  end
23
23
 
@@ -89,6 +89,14 @@ module InspecTools
89
89
 
90
90
  private
91
91
 
92
+ def register_after_parse_callbacks
93
+ # Determine if the parsed Ident is refrencing a legacy ID number.
94
+ HappyMapperTools::StigAttributes::Ident.after_parse do |object|
95
+ object.cci = object.system.eql?('http://cyber.mil/cci')
96
+ object.legacy = !object.cci
97
+ end
98
+ end
99
+
92
100
  def replace_tags_in_xccdf(replace_tags, xccdf_xml)
93
101
  replace_tags.each do |tag|
94
102
  xccdf_xml = xccdf_xml.gsub(/(&lt;|<)#{tag}(&gt;|>)/, "$#{tag}")
@@ -133,8 +141,9 @@ module InspecTools
133
141
  control['tags']['rid'] = group.rule.id
134
142
  control['tags']['stig_id'] = group.rule.version
135
143
  control['tags']['fix_id'] = group.rule.fix.id
136
- control['tags']['cci'] = group.rule.idents
137
- control['tags']['nist'] = @cci_items.fetch_nists(group.rule.idents)
144
+ control['tags']['cci'] = group.rule.idents.select { |i| i.cci }.map { |i| i.ident }
145
+ control['tags']['legacy'] = group.rule.idents.select { |i| i.legacy}.map { |i| i.ident }
146
+ control['tags']['nist'] = @cci_items.fetch_nists(control['tags']['cci'])
138
147
  control['tags']['false_negatives'] = group.rule.description.false_negatives if group.rule.description.false_negatives != ''
139
148
  control['tags']['false_positives'] = group.rule.description.false_positives if group.rule.description.false_positives != ''
140
149
  control['tags']['documentable'] = group.rule.description.documentable if group.rule.description.documentable != ''
@@ -246,6 +246,7 @@ module Utils
246
246
  control.add_tag(::Inspec::Object::Tag.new('stig_id', json_control['tags']['stig_id']))
247
247
  control.add_tag(::Inspec::Object::Tag.new('fix_id', json_control['tags']['fix_id']))
248
248
  control.add_tag(::Inspec::Object::Tag.new('cci', json_control['tags']['cci']))
249
+ control.add_tag(::Inspec::Object::Tag.new('legacy', json_control['tags']['legacy']))
249
250
  control.add_tag(::Inspec::Object::Tag.new('nist', json_control['tags']['nist']))
250
251
  control.add_tag(::Inspec::Object::Tag.new('cis_level', json_control['tags']['cis_level'])) unless json_control['tags']['cis_level'].blank?
251
252
  control.add_tag(::Inspec::Object::Tag.new('cis_controls', json_control['tags']['cis_controls'])) unless json_control['tags']['cis_controls'].blank?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Thew
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2021-01-22 00:00:00.000000000 Z
14
+ date: 2021-03-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: colorize
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  - !ruby/object:Gem::Version
359
359
  version: '0'
360
360
  requirements: []
361
- rubygems_version: 3.1.4
361
+ rubygems_version: 3.2.3
362
362
  signing_key:
363
363
  specification_version: 4
364
364
  summary: Converter utils for Inspec