dev-sec / nginx-baseline

DevSec Nginx Baseline - InSpec Profile
https://dev-sec.io/baselines/nginx/
Apache License 2.0
104 stars 45 forks source link

Profile fails `inspec json` #33

Closed james-stocks closed 5 years ago

james-stocks commented 5 years ago

Describe the bug

Using InSpec 4.3.2

bundle exec inspec json nginx-baseline-2.3.0.tar.gz > nginx-baseline-2.3.0.tar.gz.json
--
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:22)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:28)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:34)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:40)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:46)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:52)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:58)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:64)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:70)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:76)
  | [2019-05-21T12:15:44+00:00] WARN: DEPRECATION: The 'default' option for attributes is being replaced by 'value' - please use it instead. attribute name: 'Inspec::Input' (used at nginx-baseline-2.3.0/controls/nginx_spec.rb:82)
  | bundler: failed to load command: inspec (/workdir/vendor/bundle/ruby/2.6.0/bin/inspec)
  | Encoding::UndefinedConversionError: "\xE2" from ASCII-8BIT to UTF-8
  | /workdir/vendor/bundle/ruby/2.6.0/gems/json-2.2.0/lib/json/common.rb:224:in `encode'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/json-2.2.0/lib/json/common.rb:224:in `generate'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/json-2.2.0/lib/json/common.rb:224:in `generate'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/json-2.2.0/lib/json/common.rb:394:in `dump'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/inspec-4.3.2/lib/inspec/cli.rb:70:in `json'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
  | /workdir/vendor/bundle/ruby/2.6.0/gems/inspec-bin-4.3.2/bin/inspec:15:in `<top (required)>'
  | /workdir/vendor/bundle/ruby/2.6.0/bin/inspec:23:in `load'
  | /workdir/vendor/bundle/ruby/2.6.0/bin/inspec:23:in `<top (required)>'

There are a number of issues open and closed for encoding in InSpec profiles https://github.com/inspec/inspec/issues?utf8=%E2%9C%93&q=is%3Aissue+encoding

To work in all versions of InSpec currently supported, this profile should either keep the # encoding: UTF-8 declarations, or should limit the InSpec control source to ASCII characters.

chris-rock commented 5 years ago

I recommend going with encoding, any PR to make it happen is welcome.

james-stocks commented 5 years ago

I raised an InSpec issue with a small reproduction profile: https://github.com/inspec/inspec/issues/4135