mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
add suid sgid and sticky support for file resource
This commit is contained in:
parent
0a42d75a73
commit
68cf88f701
4 changed files with 29 additions and 1 deletions
|
@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
||||||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
||||||
spec.require_paths = ['lib']
|
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 'thor', '~> 0.19'
|
||||||
spec.add_dependency 'json', '~> 1.8'
|
spec.add_dependency 'json', '~> 1.8'
|
||||||
spec.add_dependency 'rainbow', '~> 2'
|
spec.add_dependency 'rainbow', '~> 2'
|
||||||
|
|
|
@ -91,6 +91,18 @@ module Inspec::Resources
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def suid
|
||||||
|
(mode & 04000) > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def sgid
|
||||||
|
(mode & 02000) > 0
|
||||||
|
end
|
||||||
|
|
||||||
|
def sticky
|
||||||
|
(mode & 01000) > 0
|
||||||
|
end
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
"File #{source_path}"
|
"File #{source_path}"
|
||||||
end
|
end
|
||||||
|
|
|
@ -25,6 +25,13 @@ if node['platform_family'] != 'windows'
|
||||||
content 'hello world'
|
content 'hello world'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
file '/tmp/sfile' do
|
||||||
|
mode '7765'
|
||||||
|
owner 'root'
|
||||||
|
group gid
|
||||||
|
content 'hello suid/sgid/sticky'
|
||||||
|
end
|
||||||
|
|
||||||
directory '/tmp/folder' do
|
directory '/tmp/folder' do
|
||||||
mode '0567'
|
mode '0567'
|
||||||
owner 'root'
|
owner 'root'
|
||||||
|
|
|
@ -61,6 +61,9 @@ if os.unix?
|
||||||
it { should be_mode 00765 }
|
it { should be_mode 00765 }
|
||||||
its('mode') { should cmp 0765 }
|
its('mode') { should cmp 0765 }
|
||||||
its('mode') { should_not cmp 0777 }
|
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 }
|
||||||
it { should be_readable.by('owner') }
|
it { should be_readable.by('owner') }
|
||||||
|
@ -107,6 +110,12 @@ if os.unix?
|
||||||
its('type') { should eq :file }
|
its('type') { should eq :file }
|
||||||
end
|
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
|
describe file('/tmp/folder') do
|
||||||
it { should exist }
|
it { should exist }
|
||||||
it { should be_directory }
|
it { should be_directory }
|
||||||
|
|
Loading…
Reference in a new issue