You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When ini resource tries to open an unreadable file (file mode = 000), InSpec dies with backtrace.
InSpec and Platform Version
InSpec 1.8.0, Debian 7.10
Replication Case
% ls -l /tmp/unreadable
---------- 1 makoto group1 10 Dec 28 21:43 /tmp/unreadable
% cat ../test_unreadable.rb
control test_unreadable do
describe ini('/tmp/unreadable') do
its('foo') { should eq 'abc'}
end
end
% bin/inspec exec ../test_unreadable.rb
/home/makoto/inspec/lib/resources/json.rb:52:in `initialize': undefined method `empty?' for nil:NilClass (NoMethodError)
....
(complete stacktrace below)
Happy to add a unit test if you could guide me to the standard way to mock Train objects.
Stacktrace
% bin/inspec exec ../test_unreadable.rb
/home/makoto/inspec/lib/resources/json.rb:52:in `initialize': undefined method `empty?' for nil:NilClass (NoMethodError)
from /home/makoto/inspec/lib/inspec/plugins/resource.rb:48:in `initialize'
from /home/makoto/inspec/lib/inspec/resource.rb:48:in `new'
from /home/makoto/inspec/lib/inspec/resource.rb:48:in `block (3 levels) in create_dsl'
from ../test_unreadable.rb:2:in `block in load_with_context'
from /home/makoto/inspec/lib/inspec/rule.rb:51:in `instance_eval'
from /home/makoto/inspec/lib/inspec/rule.rb:51:in `initialize'
from /home/makoto/inspec/lib/inspec/control_eval_context.rb:73:in `new'
from /home/makoto/inspec/lib/inspec/control_eval_context.rb:73:in `block (2 levels) in create'
from ../test_unreadable.rb:1:in `load_with_context'
from /home/makoto/inspec/lib/inspec/profile_context.rb:146:in `instance_eval'
from /home/makoto/inspec/lib/inspec/profile_context.rb:146:in `load_with_context'
from /home/makoto/inspec/lib/inspec/profile_context.rb:130:in `load_control_file'
from /home/makoto/inspec/lib/inspec/profile.rb:144:in `block in collect_tests'
from /home/makoto/inspec/lib/inspec/profile.rb:141:in `each'
from /home/makoto/inspec/lib/inspec/profile.rb:141:in `collect_tests'
from /home/makoto/inspec/lib/inspec/runner.rb:90:in `block in load'
from /home/makoto/inspec/lib/inspec/runner.rb:79:in `each'
from /home/makoto/inspec/lib/inspec/runner.rb:79:in `load'
from /home/makoto/inspec/lib/inspec/runner.rb:100:in `run'
from /home/makoto/inspec/lib/inspec/base_cli.rb:82:in `run_tests'
from /home/makoto/inspec/lib/inspec/cli.rb:157:in `exec'
from /home/makoto/local/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /home/makoto/local/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /home/makoto/local/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /home/makoto/local/lib/ruby/gems/2.2.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
from bin/inspec:12:in `<main>'
%
The text was updated successfully, but these errors were encountered:
Description
When ini resource tries to open an unreadable file (file mode = 000), InSpec dies with backtrace.
InSpec and Platform Version
InSpec 1.8.0, Debian 7.10
Replication Case
Possible Solutions
When a given file is unreadable, Train returns file.content = nil.
Expected result is returned with a patch at #1381:
Happy to add a unit test if you could guide me to the standard way to mock Train objects.
Stacktrace
The text was updated successfully, but these errors were encountered: