diff --git a/inspec.gemspec b/inspec.gemspec index 689334fd1..ce3de76b0 100644 --- a/inspec.gemspec +++ b/inspec.gemspec @@ -24,7 +24,7 @@ Gem::Specification.new do |spec| spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) spec.require_paths = ['lib'] - spec.add_dependency 'train', '~> 0.13' + spec.add_dependency 'train', '>=0.15.1', '<1.0' spec.add_dependency 'thor', '~> 0.19' spec.add_dependency 'json', '~> 1.8' spec.add_dependency 'rainbow', '~> 2' diff --git a/lib/resources/file.rb b/lib/resources/file.rb index c871efcd7..f14deedaf 100644 --- a/lib/resources/file.rb +++ b/lib/resources/file.rb @@ -91,6 +91,18 @@ module Inspec::Resources end end + def suid + (mode & 04000) > 0 + end + + def sgid + (mode & 02000) > 0 + end + + def sticky + (mode & 01000) > 0 + end + def to_s "File #{source_path}" end diff --git a/test/cookbooks/os_prepare/recipes/file.rb b/test/cookbooks/os_prepare/recipes/file.rb index 9810b76b9..d599523d5 100644 --- a/test/cookbooks/os_prepare/recipes/file.rb +++ b/test/cookbooks/os_prepare/recipes/file.rb @@ -25,6 +25,13 @@ if node['platform_family'] != 'windows' content 'hello world' end + file '/tmp/sfile' do + mode '7765' + owner 'root' + group gid + content 'hello suid/sgid/sticky' + end + directory '/tmp/folder' do mode '0567' owner 'root' diff --git a/test/integration/default/file_spec.rb b/test/integration/default/file_spec.rb index b8bf6efb4..840c85534 100644 --- a/test/integration/default/file_spec.rb +++ b/test/integration/default/file_spec.rb @@ -61,6 +61,9 @@ if os.unix? it { should be_mode 00765 } its('mode') { should cmp 0765 } its('mode') { should_not cmp 0777 } + its('suid') { should eq false } + its('sgid') { should eq false } + its('sticky') { should eq false } it { should be_readable } it { should be_readable.by('owner') } @@ -107,6 +110,12 @@ if os.unix? its('type') { should eq :file } end + describe file('/tmp/file') do + its('suid') { should eq true } + its('sgid') { should eq true } + its('sticky') { should eq true } + end + describe file('/tmp/folder') do it { should exist } it { should be_directory }