inspec/lib/resources/os.rb

37 lines
840 B
Ruby
Raw Normal View History

2015-09-20 21:55:00 +00:00
# encoding: utf-8
require 'resources/platform'
module Inspec::Resources
class OSResource < PlatformResource
name 'os'
supports platform: 'unix'
supports platform: 'windows'
desc 'Use the os InSpec audit resource to test the platform on which the system is running.'
example <<~EXAMPLE
describe os[:family] do
it { should eq 'redhat' }
end
2016-05-30 08:32:28 +00:00
describe os.redhat? do
it { should eq true }
end
describe os.linux? do
it { should eq true }
end
EXAMPLE
2015-09-20 21:55:00 +00:00
# reuse helper methods from backend
%w{aix? redhat? debian? suse? bsd? solaris? linux? unix? windows? hpux? darwin?}.each do |os_family|
define_method(os_family.to_sym) do
@platform.send(os_family)
2016-05-30 08:32:28 +00:00
end
end
def to_s
'Operating System Detection'
end
2015-09-20 21:55:00 +00:00
end
end