2015-09-20 21:55:00 +00:00
|
|
|
# encoding: utf-8
|
2015-10-06 16:55:44 +00:00
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
2015-09-20 21:55:00 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
module Inspec::Resources
|
|
|
|
class OS < Inspec.resource(1)
|
|
|
|
name 'os'
|
|
|
|
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
|
|
|
|
example "
|
|
|
|
describe os[:family] do
|
|
|
|
it { should eq 'redhat' }
|
|
|
|
end
|
|
|
|
"
|
2015-09-20 21:55:00 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
# reuse helper methods from backend
|
|
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows?}.each do |os_family|
|
|
|
|
define_method(os_family.to_sym) do
|
|
|
|
inspec.backend.os.send(os_family)
|
|
|
|
end
|
2015-10-07 16:28:34 +00:00
|
|
|
end
|
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
def [](name)
|
|
|
|
# convert string to symbol
|
|
|
|
name = name.to_sym if name.is_a? String
|
|
|
|
inspec.backend.os[name]
|
|
|
|
end
|
2015-10-12 11:01:58 +00:00
|
|
|
|
2016-03-08 18:06:55 +00:00
|
|
|
def to_s
|
|
|
|
'Operating System Detection'
|
|
|
|
end
|
2015-09-20 21:55:00 +00:00
|
|
|
end
|
|
|
|
end
|