inspec_tools 2.0.4 → 2.0.5

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: 22680d948ef0c9745db5983c3ae8dea966cfa05f2aa2977e2f0409a0d4416a14
4
- data.tar.gz: 60954f2699569649f559a4071c97e70a1b0d77eb0f695207106dd4b06887c8b9
3
+ metadata.gz: ef9a2fbe955cc2987994718c481836d482839c4c51835de93bfcb31dbaeb0dd3
4
+ data.tar.gz: d9ade5418a103cb10b32cead3717dda4cdbad2b8d596ae7fb40c851f2cfab8fc
5
5
  SHA512:
6
- metadata.gz: 5eab94b7c0f08fe13b37a2c0483e7991c8b625c2134f502e94f8c194d4ef4aee73001d9ccc52686a924ff6d1b4436511706e4ab5cb274476765ebc6e97d42a45
7
- data.tar.gz: 07d82a9e11bfb00ee867893cbecbe1ce0d9d7bb0a156ec1e81a80f862ede193c1cb9b4abefcd45bb5d068a7719b9c18a1fbd9053b51e68d9854792b4b90674a5
6
+ metadata.gz: e76748d26a430e10fbe6ca5e4d8c7bd8a00b3b7cabdadbfd013125a5bdac146257d03a4fc546243bcee76c44f164b98181294e1f89abb3c245a845325d14889a
7
+ data.tar.gz: bb7ea67481d4a4879b82a34be20a8c20a4df3cbb35867ad3c8ede8d35207e44c7fb49200fb5fc3cc9664b5df98025479b86dabad047b43a7c1a4cc9586a77e49
@@ -2,7 +2,19 @@
2
2
 
3
3
  ## [Unreleased](https://github.com/mitre/inspec_tools/tree/HEAD)
4
4
 
5
- [Full Changelog](https://github.com/mitre/inspec_tools/compare/v2.0.3...HEAD)
5
+ [Full Changelog](https://github.com/mitre/inspec_tools/compare/v2.0.4...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Remove Debug Files When Running Tests [\#175](https://github.com/mitre/inspec_tools/issues/175)
10
+
11
+ **Merged pull requests:**
12
+
13
+ - Add additional error checking and documentation surrounding the xccdf… [\#194](https://github.com/mitre/inspec_tools/pull/194) ([Bialogs](https://github.com/Bialogs))
14
+
15
+ ## [v2.0.4](https://github.com/mitre/inspec_tools/tree/v2.0.4) (2020-06-18)
16
+
17
+ [Full Changelog](https://github.com/mitre/inspec_tools/compare/v2.0.3...v2.0.4)
6
18
 
7
19
  **Closed issues:**
8
20
 
@@ -11,6 +23,7 @@
11
23
 
12
24
  **Merged pull requests:**
13
25
 
26
+ - Respect debug env variable when running tests [\#193](https://github.com/mitre/inspec_tools/pull/193) ([Bialogs](https://github.com/Bialogs))
14
27
  - 191 single quote replacement [\#192](https://github.com/mitre/inspec_tools/pull/192) ([Bialogs](https://github.com/Bialogs))
15
28
 
16
29
  ## [v2.0.3](https://github.com/mitre/inspec_tools/tree/v2.0.3) (2020-05-26)
@@ -33,10 +46,6 @@
33
46
  - inspec\_tools docker container doesn't let me go into a bash shell [\#184](https://github.com/mitre/inspec_tools/issues/184)
34
47
  - Add a Dockerfile so folks can eaily add this into their ci/cd container workflows [\#162](https://github.com/mitre/inspec_tools/issues/162)
35
48
 
36
- **Merged pull requests:**
37
-
38
- - Add parameter to InspecUtils\#control\_status to specify when used for summary. [\#170](https://github.com/mitre/inspec_tools/pull/170) ([Bialogs](https://github.com/Bialogs))
39
-
40
49
  ## [v2.0.2.pre13](https://github.com/mitre/inspec_tools/tree/v2.0.2.pre13) (2020-05-22)
41
50
 
42
51
  [Full Changelog](https://github.com/mitre/inspec_tools/compare/v2.0.2.pre12...v2.0.2.pre13)
@@ -96,6 +105,7 @@
96
105
  **Merged pull requests:**
97
106
 
98
107
  - Apply fixes from CodeFactor [\#172](https://github.com/mitre/inspec_tools/pull/172) ([aaronlippold](https://github.com/aaronlippold))
108
+ - Add parameter to InspecUtils\#control\_status to specify when used for summary. [\#170](https://github.com/mitre/inspec_tools/pull/170) ([Bialogs](https://github.com/Bialogs))
99
109
  - Generate Ruby with Single Quoted Strings [\#169](https://github.com/mitre/inspec_tools/pull/169) ([Bialogs](https://github.com/Bialogs))
100
110
  - Update CKL parse method to dig into sub descriptions [\#168](https://github.com/mitre/inspec_tools/pull/168) ([Bialogs](https://github.com/Bialogs))
101
111
 
@@ -553,7 +563,6 @@
553
563
 
554
564
  **Merged pull requests:**
555
565
 
556
- - Update Profile logic include control exceptions [\#75](https://github.com/mitre/inspec_tools/pull/75) ([rx294](https://github.com/rx294))
557
566
  - Null Byte in json report causes inspec2ckl to bomb-out [\#73](https://github.com/mitre/inspec_tools/pull/73) ([kevin-j-smith](https://github.com/kevin-j-smith))
558
567
 
559
568
  ## [v1.6.0](https://github.com/mitre/inspec_tools/tree/v1.6.0) (2019-10-04)
@@ -601,6 +610,7 @@
601
610
 
602
611
  **Merged pull requests:**
603
612
 
613
+ - Update Profile logic include control exceptions [\#75](https://github.com/mitre/inspec_tools/pull/75) ([rx294](https://github.com/rx294))
604
614
  - Apply fixes from CodeFactor [\#61](https://github.com/mitre/inspec_tools/pull/61) ([aaronlippold](https://github.com/aaronlippold))
605
615
 
606
616
  ## [v1.3.6](https://github.com/mitre/inspec_tools/tree/v1.3.6) (2019-05-02)
data/README.md CHANGED
@@ -65,7 +65,7 @@ For Docker usage, replace the `inspec_tools` command with the correct Docker com
65
65
 
66
66
  - **On Linux and Mac**: `docker run -it -v$(pwd):/share mitre/inspec_tools`
67
67
  - **On Windows CMD**: `docker run -it -v%cd%:/share mitre/inspec_tools`
68
-
68
+
69
69
  Note that all of the above Docker commands will mount your current directory on the Docker container. Ensure that you have navigated to the directory you intend to convert files in before executing the command.
70
70
 
71
71
  ### generate_map
@@ -181,9 +181,9 @@ error
181
181
  low : 0
182
182
  ```
183
183
 
184
- Using additional flags will override the normal output and only display the output that flag specifies.
184
+ Using additional flags will override the normal output and only display the output that flag specifies.
185
185
 
186
- USAGE: inspec_tools summary [OPTIONS] -j <inspec-json>
186
+ USAGE: inspec_tools summary [OPTIONS] -j <inspec-json>
187
187
 
188
188
  ```
189
189
  FLAGS:
@@ -211,7 +211,7 @@ FLAGS:
211
211
  -f --format [ruby | hash] : the format you would like (default: ruby) [optional]
212
212
  -s --separate-files [true | false] : output the resulting controls as one or mutiple files (default: true) [optional]
213
213
  -m --metadata <metadata-json> : path to json file with additional metadata for the inspec.yml file [optional]
214
- -r --replace-tags <array> : A case-sensitive, comma separated list to replace tags with a $ if found in a group rules description tag [optional]
214
+ -r --replace-tags <array> : A case-sensitive, space separated list to replace tags with a $ if found in a group rules description tag [optional]
215
215
 
216
216
  example: inspec_tools xccdf2inspec -x xccdf_file.xml -a attributes.yml -o myprofile -f ruby -s false
217
217
  ```
@@ -140,57 +140,75 @@ module HappyMapperTools
140
140
  end
141
141
 
142
142
  class DescriptionDetailsType
143
- def self.type
144
- DescriptionDetails
145
- end
143
+ class << self
144
+ def type
145
+ DescriptionDetails
146
+ end
146
147
 
147
- def self.apply(value) # rubocop:disable Metrics/AbcSize
148
- value = value.gsub('&', 'and')
149
- DescriptionDetails.parse "<Details>#{value}</Details>"
150
- rescue Nokogiri::XML::SyntaxError
151
- allowed_tags = %w{VulnDiscussion FalsePositives FalseNegatives Documentable
152
- Mitigations SeverityOverrideGuidance PotentialImpacts
153
- PotentialImpacts ThirdPartyTools MitigationControl
154
- Responsibility IAControls}
155
-
156
- tags_found = value.scan(%r{(?<=<)([^\/]*?)((?= \/>)|(?=>))}).to_a
157
-
158
- tags_found = tags_found.uniq.flatten.reject!(&:empty?)
159
- offending_tags = tags_found - allowed_tags
160
-
161
- if offending_tags.count > 1
162
- puts "\n\nThe non-standard tags: #{offending_tags.to_s.colorize(:red)}" \
163
- ' were found in: ' + "\n\n#{value}"
164
- else
165
- puts "\n\nThe non-standard tag: #{offending_tags.to_s.colorize(:red)}" \
166
- ' was found in: ' + "\n\n#{value}"
148
+ def apply(value)
149
+ value = value.gsub('&', 'and')
150
+ DescriptionDetails.parse "<Details>#{value}</Details>"
151
+ rescue Nokogiri::XML::SyntaxError => e
152
+ if e.to_s.include?('StartTag')
153
+ report_invalid_start_tag(value, e)
154
+ else
155
+ report_disallowed_tags(value)
156
+ end
157
+ end
158
+
159
+ def apply?(value, _convert_to_type)
160
+ value.is_a?(String)
167
161
  end
168
- puts "\n\nPlease:\n "
169
- option_one = '(1) ' + '(best)'.colorize(:green) + ' Use the ' +
170
- '`-r --replace-tags array` '.colorize(:light_yellow) +
171
- '(case sensitive) option to replace the offending tags ' \
172
- 'during processing of the XCCDF ' \
173
- 'file to use the ' +
174
- "`$#{offending_tags[0]}` " .colorize(:light_green) +
175
- 'syntax in your InSpec profile.'
176
- option_two = '(2) Update your XCCDF file to *not use* non-standard XCCDF ' \
177
- 'elements within ' +
178
- '`&lt;`,`&gt;`, `<` '.colorize(:red) +
179
- 'or '.colorize(:default) +
180
- '`>` '.colorize(:red) +
181
- 'as "placeholders", and use something that doesn\'t confuse ' \
182
- 'the XML parser, such as : ' +
183
- "`$#{offending_tags[0]}`" .colorize(:light_green)
184
- puts option_one
185
- puts "\n"
186
- puts option_two
187
- # exit
188
- end
189
162
 
190
- def self.apply?(value, _convert_to_type)
191
- value.is_a?(String)
163
+ private
164
+
165
+ def report_invalid_start_tag(value, error)
166
+ puts error.to_s.colorize(:red)
167
+ column = error.column - '<Details>'.length - 2
168
+ puts "Error around #{value[column-10..column+10].colorize(:light_yellow)}"
169
+ exit(1)
170
+ end
171
+
172
+ def report_disallowed_tags(value)
173
+ allowed_tags = %w{VulnDiscussion FalsePositives FalseNegatives Documentable
174
+ Mitigations SeverityOverrideGuidance PotentialImpacts
175
+ PotentialImpacts ThirdPartyTools MitigationControl
176
+ Responsibility IAControl SecurityOverrideGuidance}
177
+
178
+ tags_found = value.scan(%r{(?<=<)([^\/]*?)((?= \/>)|(?=>))}).to_a
179
+
180
+ tags_found = tags_found.uniq.flatten.reject!(&:empty?)
181
+ offending_tags = tags_found - allowed_tags
182
+
183
+ if offending_tags.count > 1
184
+ puts "\n\nThe non-standard tags: #{offending_tags.to_s.colorize(:red)}" \
185
+ ' were found in: ' + "\n\n#{value}"
186
+ else
187
+ puts "\n\nThe non-standard tag: #{offending_tags.to_s.colorize(:red)}" \
188
+ ' was found in: ' + "\n\n#{value}"
189
+ end
190
+ puts "\n\nPlease:\n "
191
+ option_one = '(1) ' + '(best)'.colorize(:green) + ' Use the ' +
192
+ '`-r --replace-tags array` '.colorize(:light_yellow) +
193
+ '(case sensitive) option to replace the offending tags ' \
194
+ 'during processing of the XCCDF ' \
195
+ 'file to use the ' +
196
+ "`$#{offending_tags[0]}` " .colorize(:light_green) +
197
+ 'syntax in your InSpec profile.'
198
+ option_two = '(2) Update your XCCDF file to *not use* non-standard XCCDF ' \
199
+ 'elements within ' +
200
+ '`&lt;`,`&gt;`, `<` '.colorize(:red) +
201
+ 'or '.colorize(:default) +
202
+ '`>` '.colorize(:red) +
203
+ 'as "placeholders", and use something that doesn\'t confuse ' \
204
+ 'the XML parser, such as : ' +
205
+ "`$#{offending_tags[0]}`" .colorize(:light_green)
206
+ puts option_one
207
+ puts "\n"
208
+ puts option_two
209
+ end
192
210
  end
211
+ HappyMapper::SupportedTypes.register DescriptionDetailsType
193
212
  end
194
- HappyMapper::SupportedTypes.register DescriptionDetailsType
195
213
  end
196
214
  end
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.0.4
4
+ version: 2.0.5
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: 2020-06-18 00:00:00.000000000 Z
14
+ date: 2020-06-23 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: colorize