inspec_tools 2.3.7 → 2.3.8

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: a9633cda4bf3fedc9702dd91ba4ed6b40b68ec8e054eb87ad6ca32d32dfc11e5
4
- data.tar.gz: 22f5ab86d76ccbc7f7fc0a684371b791c26f9771e369be54c359121d8c28f4d3
3
+ metadata.gz: b6f754f4816775d8bb360ed2ce768b1f4a443f647a440a1fe04a371388af6fe0
4
+ data.tar.gz: d31e79fb1477ab0b9fed85df8847f59f487d1ca5dc0bfc369e201dd2e0b87ba8
5
5
  SHA512:
6
- metadata.gz: 0e50a5db32e542cd5a66b8bab09a8613c9b8b6ea62513d073a3eb71717397d5c54cf3ccea2c48dd3c0dbc21dbb5d0f9c550744bb8ed6f27f37335a88b0184ea8
7
- data.tar.gz: af786d30584f7bf79108b44d9cb653e7673c2716ea7ce72f24fa1c494b4dfc7801f032aeca8829c23f5a1ed9ca8be542b5bf7f4d72fa315400a0b0d1349a3c64
6
+ metadata.gz: 5f4fe6b5f733d4654d179e0bbe651276afa3ccfff6527e6088f50c13da23324b1be9c6b695cad464895f13e53b442dd674d546c826b31632def647b73d50d26e
7
+ data.tar.gz: bee2b9f2a53efa941413308ea6eaeb340493c8d581b07a4d348094ba1278c4177fd3de7ee6575226896d41d0156bf6eaf0934a5f0eb597956c1b4c5ff2c07c67
@@ -158,12 +158,13 @@ module HappyMapperTools
158
158
 
159
159
  def apply(value)
160
160
  value = value.gsub('&', 'and')
161
- DescriptionDetails.parse "<Details>#{value}</Details>"
161
+ value = value.gsub('"<"', 'less than (converted less than)')
162
+ DescriptionDetails.parse("<Details>#{value}</Details>")
162
163
  rescue Nokogiri::XML::SyntaxError => e
163
- if e.to_s.include?('StartTag')
164
- report_invalid_start_tag(value, e)
164
+ if report_disallowed_tags(value) # if there was a bad tag
165
+ exit(1)
165
166
  else
166
- report_disallowed_tags(value)
167
+ report_error(value, e)
167
168
  end
168
169
  end
169
170
 
@@ -173,7 +174,7 @@ module HappyMapperTools
173
174
 
174
175
  private
175
176
 
176
- def report_invalid_start_tag(value, error)
177
+ def report_error(value, error)
177
178
  puts error.to_s.colorize(:red)
178
179
  column = error.column - '<Details>'.length - 2
179
180
  puts "Error around #{value[column-10..column+10].colorize(:light_yellow)}"
@@ -184,39 +185,38 @@ module HappyMapperTools
184
185
  allowed_tags = %w{VulnDiscussion FalsePositives FalseNegatives Documentable
185
186
  Mitigations SeverityOverrideGuidance PotentialImpacts
186
187
  PotentialImpacts ThirdPartyTools MitigationControl
187
- Responsibility IAControl SecurityOverrideGuidance}
188
+ Responsibility IAControl IAControls SecurityOverrideGuidance}
188
189
 
189
190
  tags_found = value.scan(%r{(?<=<)([^\/]*?)((?= \/>)|(?=>))}).to_a
190
191
 
191
192
  tags_found = tags_found.uniq.flatten.reject!(&:empty?)
192
193
  offending_tags = tags_found - allowed_tags
193
194
 
194
- if offending_tags.count > 1
195
- puts "\n\nThe non-standard tags: #{offending_tags.to_s.colorize(:red)}" \
195
+ unless offending_tags.count.zero?
196
+ puts "\n\nThe non-standard tag(s): #{offending_tags.to_s.colorize(:red)}" \
196
197
  ' were found in: ' + "\n\n#{value}"
197
- else
198
- puts "\n\nThe non-standard tag: #{offending_tags.to_s.colorize(:red)}" \
199
- ' was found in: ' + "\n\n#{value}"
198
+ puts "\n\nPlease:\n "
199
+ option_one = '(1) ' + '(best)'.colorize(:green) + ' Use the ' +
200
+ '`-r --replace-tags array` '.colorize(:light_yellow) +
201
+ '(case sensitive) option to replace the offending tags ' \
202
+ 'during processing of the XCCDF ' \
203
+ 'file to use the ' +
204
+ "`$#{offending_tags[0]}` ".colorize(:light_green) +
205
+ 'syntax in your InSpec profile.'
206
+ option_two = '(2) Update your XCCDF file to *not use* non-standard XCCDF ' \
207
+ 'elements within ' +
208
+ '`&lt;`,`&gt;`, `<` '.colorize(:red) +
209
+ 'or '.colorize(:default) +
210
+ '`>` '.colorize(:red) +
211
+ 'as "placeholders", and use something that doesn\'t confuse ' \
212
+ 'the XML parser, such as : ' +
213
+ "`$#{offending_tags[0]}`".colorize(:light_green)
214
+ puts option_one
215
+ puts "\n"
216
+ puts option_two
217
+ return true
200
218
  end
201
- puts "\n\nPlease:\n "
202
- option_one = '(1) ' + '(best)'.colorize(:green) + ' Use the ' +
203
- '`-r --replace-tags array` '.colorize(:light_yellow) +
204
- '(case sensitive) option to replace the offending tags ' \
205
- 'during processing of the XCCDF ' \
206
- 'file to use the ' +
207
- "`$#{offending_tags[0]}` ".colorize(:light_green) +
208
- 'syntax in your InSpec profile.'
209
- option_two = '(2) Update your XCCDF file to *not use* non-standard XCCDF ' \
210
- 'elements within ' +
211
- '`&lt;`,`&gt;`, `<` '.colorize(:red) +
212
- 'or '.colorize(:default) +
213
- '`>` '.colorize(:red) +
214
- 'as "placeholders", and use something that doesn\'t confuse ' \
215
- 'the XML parser, such as : ' +
216
- "`$#{offending_tags[0]}`".colorize(:light_green)
217
- puts option_one
218
- puts "\n"
219
- puts option_two
219
+ false
220
220
  end
221
221
  end
222
222
  HappyMapper::SupportedTypes.register DescriptionDetailsType
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.7
4
+ version: 2.3.8
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-06-07 00:00:00.000000000 Z
14
+ date: 2021-07-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: colorize