2015-09-20 23:55:00 +02:00
|
|
|
# encoding: utf-8
|
2015-10-06 18:55:44 +02:00
|
|
|
# author: Dominik Richter
|
|
|
|
# author: Christoph Hartmann
|
2015-09-20 23:55:00 +02:00
|
|
|
|
2015-10-26 04:04:18 +01:00
|
|
|
class OS < Inspec.resource(1)
|
2015-10-12 13:01:58 +02:00
|
|
|
name 'os'
|
2015-11-27 14:02:38 +01:00
|
|
|
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 23:55:00 +02:00
|
|
|
|
2015-10-12 13:01:58 +02:00
|
|
|
# reuse helper methods from backend
|
2016-01-29 21:54:48 +01:00
|
|
|
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows?}.each do |os_family|
|
2016-01-15 03:59:00 +01:00
|
|
|
define_method(os_family.to_sym) do
|
2015-10-26 04:04:18 +01:00
|
|
|
inspec.backend.os.send(os_family)
|
2015-10-07 18:28:34 +02:00
|
|
|
end
|
2015-10-12 13:01:58 +02:00
|
|
|
end
|
2015-10-07 18:28:34 +02:00
|
|
|
|
2015-10-12 13:01:58 +02:00
|
|
|
def [](name)
|
2015-12-06 12:59:35 +01:00
|
|
|
# convert string to symbol
|
|
|
|
name = name.to_sym if name.is_a? String
|
2015-10-26 04:04:18 +01:00
|
|
|
inspec.backend.os[name]
|
2015-10-12 13:01:58 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
'Operating System Detection'
|
2015-09-20 23:55:00 +02:00
|
|
|
end
|
|
|
|
end
|