Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: do not send nil to command on unsupported OS #1865

Merged
merged 1 commit into from
May 30, 2017

Conversation

arlimus
Copy link
Contributor

@arlimus arlimus commented May 30, 2017

Unsupported operating systems AND the mockloader when using inspec analysis tools may lead to powershell being called with the command being nil, because the resource skips during the initialize phase. Instead, propagate an empty string so that command has a valid input and then skip the resource.

Signed-off-by: Dominik Richter dominik.richter@gmail.com

Unsupported operating systems AND the mockloader when using inspec analysis tools may lead to powershell being called with the command being `nil`, because the resource skips during the initialize phase. Instead, propagate an empty string so that `command` has a valid input and then skip the resource.

Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
@arlimus arlimus added in progress Type: Bug Feature not working as expected labels May 30, 2017
@arlimus
Copy link
Contributor Author

arlimus commented May 30, 2017

As experienced by @billmeyer :

[bmeyer@mbp2-disp supported]$ inspec compliance upload cis-windows8_1-level2-bitlocker-2.2.0.tar.gz
I, [2017-05-30T10:32:13.360362 #54854]  INFO -- : Checking profile in cis-windows8_1-level2-bitlocker-2.2.0.tar.gz
I, [2017-05-30T10:32:13.360678 #54854]  INFO -- : Metadata OK.
/opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:338:in `exec': no implicit conversion of nil into String (TypeError)
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:338:in `block in fork_subprocess'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:316:in `fork'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:316:in `fork_subprocess'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout/unix.rb:93:in `run_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/mixlib-shellout-2.2.7/lib/mixlib/shellout.rb:259:in `run_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/train-0.23.0/lib/train/transports/local.rb:32:in `run_command'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.25.1/lib/resources/command.rb:31:in `result'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.25.1/lib/resources/command.rb:35:in `stdout'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.25.1/lib/resources/registry_key.rb:213:in `children_keys'
    from /opt/chefdk/embedded/lib/ruby/gems/2.3.0/gems/inspec-1.25.1/lib/resources/registry_key.rb:106:in `children'
    from controls/translated-controls.rb:8260:in `block in load_with_context'
...

Copy link
Contributor

@chris-rock chris-rock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great improvement

@chris-rock chris-rock merged commit 1f647e1 into master May 30, 2017
@chris-rock chris-rock deleted the dr/unsupported-os-powershell branch May 30, 2017 23:14
@@ -23,4 +23,10 @@
# string should be the same
_(resource.command.to_s).must_equal ps1_script
end

it 'will return an empty array when called on a non-supported OS with children' do
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This really isn't an "empty array" but rather an "empty string"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants