inspec-core 4.18.111 → 4.18.114

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: e2000adb104d46be6fd057f235fddeea28dd51509d5be6b1fb77552838c90220
4
- data.tar.gz: 700c678406bb53c0681e680de4dabb5b6172e1140f73032dff27036293bdf971
3
+ metadata.gz: bee754e41f53d26552da0d2972a28cf55127effcad8c93df678227e99061e676
4
+ data.tar.gz: 60bd7f57517db8c4e1848ded6ac1fd580b61c29a9b2d24168480b3d62e37557f
5
5
  SHA512:
6
- metadata.gz: 4c17a414d212c51baff7e7958d404aaa525edd3bd7d081df1a8d20a931e1f0a4d1dfe0d6bb9db4f3c46783c64bcb9071c2ac97631afc2ba969c701de6865602c
7
- data.tar.gz: 6a75a992e3369658a4648ad4dee0501c871094b174b6484e6f1f4935474db867169d445ee25e1bee9dc95d524169d45963ba60bffef7e8c72e5dbd8e9af9a9a8
6
+ metadata.gz: 7c9b443a572925dd12dc846c094256aff3f9fabcc4508ee51ab813f0ec6221088c500ce9a1c77cca693258b48a94212043d2ffd4eb8c49052dbb15bc8d93cc00
7
+ data.tar.gz: 55c2e45a2ef2e8c9da30a24eb4b09e213320e1d33d2c50e30856754038d75f59576dd76f084a59ee2028920baa37674c0683b426dce6bb3dc06bc5a8c879566b
data/README.md CHANGED
@@ -141,7 +141,7 @@ That requires [bundler](http://bundler.io/):
141
141
 
142
142
  ```bash
143
143
  bundle install
144
- bundle exec bin/inspec help
144
+ bundle exec inspec help
145
145
  ```
146
146
 
147
147
  To install it as a gem locally, run:
@@ -135,6 +135,10 @@ module Inspec
135
135
  option :reporter, type: :array,
136
136
  banner: "one two:/output/file/path",
137
137
  desc: "Enable one or more output reporters: cli, documentation, html, progress, json, json-min, json-rspec, junit, yaml"
138
+ option :reporter_message_truncation, type: :string,
139
+ desc: "Number of characters to truncate failure messages in report data to (default: no truncation)"
140
+ option :reporter_backtrace_inclusion, type: :boolean,
141
+ desc: "Include a code backtrace in report data (default: true)"
138
142
  option :input, type: :array, banner: "name1=value1 name2=value2",
139
143
  desc: "Specify one or more inputs directly on the command line, as --input NAME=VALUE"
140
144
  option :input_file, type: :array,
data/lib/inspec/config.rb CHANGED
@@ -360,6 +360,13 @@ module Inspec
360
360
  end
361
361
 
362
362
  raise ArgumentError, "The option --reporter can only have a single report outputting to stdout." if stdout_reporters > 1
363
+
364
+ # reporter_message_truncation needs to either be the string "ALL", an Integer, or a string representing an integer
365
+ if (truncation = @merged_options["reporter_message_truncation"])
366
+ unless truncation == "ALL" || truncation.is_a?(Integer) || truncation.to_i.to_s == truncation
367
+ raise ArgumentError, "reporter_message_truncation is set to #{truncation}. It must be set to an integer value or ALL to indicate no truncation."
368
+ end
369
+ end
363
370
  end
364
371
 
365
372
  def validate_plugins!
@@ -5,9 +5,31 @@ module Inspec::Reporters
5
5
  def initialize(config)
6
6
  @config = config
7
7
  @run_data = config[:run_data]
8
+ apply_report_resize_options unless @run_data.nil?
8
9
  @output = ""
9
10
  end
10
11
 
12
+ # Apply options such as message truncation and removal of backtraces
13
+ def apply_report_resize_options
14
+ runtime_config = Inspec::Config.cached.respond_to?(:final_options) ? Inspec::Config.cached.final_options : {}
15
+
16
+ message_truncation = runtime_config[:reporter_message_truncation] || "ALL"
17
+ trunc = message_truncation == "ALL" ? -1 : message_truncation.to_i
18
+ include_backtrace = runtime_config[:reporter_backtrace_inclusion].nil? ? true : runtime_config[:reporter_backtrace_inclusion]
19
+
20
+ @run_data[:profiles]&.each do |p|
21
+ p[:controls].each do |c|
22
+ c[:results]&.map! do |r|
23
+ r.delete(:backtrace) unless include_backtrace
24
+ if r.key?(:message) && r[:message] != "" && trunc > -1
25
+ r[:message] = r[:message][0...trunc] + "[Truncated to #{trunc} characters]"
26
+ end
27
+ r
28
+ end
29
+ end
30
+ end
31
+ end
32
+
11
33
  def output(str, newline = true)
12
34
  @output << str
13
35
  @output << "\n" if newline
@@ -1,3 +1,3 @@
1
1
  module Inspec
2
- VERSION = "4.18.111".freeze
2
+ VERSION = "4.18.114".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.18.111
4
+ version: 4.18.114
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef InSpec Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-05 00:00:00.000000000 Z
11
+ date: 2020-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-telemetry