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

parse_config error when searching for fs.suid_dumpable #866

Closed
anniehedgpeth opened this issue Aug 3, 2016 · 2 comments
Closed

parse_config error when searching for fs.suid_dumpable #866

anniehedgpeth opened this issue Aug 3, 2016 · 2 comments
Milestone

Comments

@anniehedgpeth
Copy link
Contributor

parse_config error

I wanted to use the parse_config resource instead of a file resource to match content for fs.suid_dumpable in /etc/systctl.conf. So I tried using

  describe parse_config('/etc/sysctl.conf') do
    its('fs.suid_dumpable') { should eq '0' }
  end

See:
https://github.com/anniehedgpeth/ubuntu-14-cis-profile/blob/master/controls/4.rb#L22

But it gets this error

  ✖  4.1: 4.1 Restrict Core Dumps (Scored) (1 failed)
     undefined method `suid_dumpable' for nil:NilClass

InSpec and Platform Version

InSpec version 0.28.1
MacOs 10.11.6

Replication Case

Run kitchen verify on this cookbook.

Possible Solutions

notsomuch

Stacktrace

I, [2016-08-03T12:41:05.019700 #7211]  INFO -- default-bento-ubuntu-1404: -----> Verifying <default-bento-ubuntu-1404>...
I, [2016-08-03T12:41:05.387584 #7211]  INFO -- default-bento-ubuntu-1404: Detected alternative framework tests for `serverspec`
I, [2016-08-03T12:41:05.387788 #7211]  INFO -- default-bento-ubuntu-1404: Use `/Users/anniehedgpeth/chef_repo/cookbooks/ubuntu-14-hardening/test/integration/default/inspec` for testing
E, [2016-08-03T12:41:05.550415 #7211] ERROR -- default-bento-ubuntu-1404: Verify failed on instance <default-bento-ubuntu-1404>.
E, [2016-08-03T12:41:05.550582 #7211] ERROR -- default-bento-ubuntu-1404: ------Exception-------
E, [2016-08-03T12:41:05.550616 #7211] ERROR -- default-bento-ubuntu-1404: Class: Kitchen::ActionFailed
E, [2016-08-03T12:41:05.550636 #7211] ERROR -- default-bento-ubuntu-1404: Message: Inspec Runner returns 1
E, [2016-08-03T12:41:05.550654 #7211] ERROR -- default-bento-ubuntu-1404: ----------------------
E, [2016-08-03T12:41:05.550671 #7211] ERROR -- default-bento-ubuntu-1404: ------Backtrace-------
E, [2016-08-03T12:41:05.550687 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/kitchen-inspec-0.15.0/lib/kitchen/verifier/inspec.rb:77:in `call'
E, [2016-08-03T12:41:05.550705 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:423:in `block in verify_action'
E, [2016-08-03T12:41:05.550722 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:513:in `call'
E, [2016-08-03T12:41:05.550740 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:513:in `synchronize_or_call'
E, [2016-08-03T12:41:05.550757 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:478:in `block in action'
E, [2016-08-03T12:41:05.550774 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/2.1.0/benchmark.rb:279:in `measure'
E, [2016-08-03T12:41:05.550802 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:477:in `action'
E, [2016-08-03T12:41:05.550827 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:415:in `verify_action'
E, [2016-08-03T12:41:05.550845 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:348:in `block in transition_to'
E, [2016-08-03T12:41:05.550862 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:347:in `each'
E, [2016-08-03T12:41:05.550879 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:347:in `transition_to'
E, [2016-08-03T12:41:05.550895 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/instance.rb:160:in `verify'
E, [2016-08-03T12:41:05.550930 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/command.rb:201:in `public_send'
E, [2016-08-03T12:41:05.550948 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/command.rb:201:in `run_action_in_thread'
E, [2016-08-03T12:41:05.550964 #7211] ERROR -- default-bento-ubuntu-1404: /opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/test-kitchen-1.10.2/lib/kitchen/command.rb:173:in `block (2 levels) in run_action'
E, [2016-08-03T12:41:05.550981 #7211] ERROR -- default-bento-ubuntu-1404: ----End Backtrace-----
@chris-rock chris-rock added Type: Enhancement Improves an existing feature and removed Type: Enhancement Improves an existing feature labels Aug 5, 2016
@chris-rock
Copy link
Contributor

@anniehedgpeth You run into a specific issue :-)

# What should work, but isnt
options = {
  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
}

output = file('/etc/sysctl.conf', options).content
describe parse_config(output) do
 its('kernel.domainname') { should eq 'example.com' }
 its('fs.suid_dumpable') { should eq '0' }
end

also, the same should work with parse_config_file:

options = {
  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
}
describe parse_config_file('/etc/sysctl.conf', options) do
 its('kernel.domainname') { should eq 'example.com' }
 its('fs.suid_dumpable') { should eq '0' }
end

For now, we need to circumvent the issue #875 with the following code:

# What we need to do right now until # is fixed
describe parse_config_file('/etc/sysctl.conf', options).params['kernel.domainname'] do
 it { should eq 'example.com' }
end
describe parse_config_file('/etc/sysctl.conf', options).params['fs.suid_dumpable'] do
 it { should eq '0' }
end

This functionality has been added with #876.

@anniehedgpeth Also be aware the the regular expression you used was not working. I used:

options = {
  assignment_re: /^\s*([^=]*?)\s*=\s*(.*?)\s*$/
}

@chris-rock
Copy link
Contributor

The RSpec issues is tracked in #875, improvements #876 for parse_config will be shipped with the next InSpec release.

@chris-rock chris-rock added this to the 0.29.0 milestone Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants