mirror of
https://github.com/inspec/inspec
synced 2024-11-27 15:10:44 +00:00
e77b99235f
This does the following to `inspec detect`: - Modifies it to use the `platform` resource - Changes the output to mention Platform and show the family hierarchy - Changes the JSON output by changing `family` to `families` - Adds better error messaging (no more stacktraces!) - Adds support for APIs such as AWS/Azure - Hides Arch from API platforms (not applicable) Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
36 lines
817 B
Ruby
36 lines
817 B
Ruby
# encoding: utf-8
|
|
# author: Dominik Richter
|
|
# author: Christoph Hartmann
|
|
|
|
require 'resources/platform'
|
|
|
|
module Inspec::Resources
|
|
class OSResource < PlatformResource
|
|
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
|
|
|
|
describe os.redhat? do
|
|
it { should eq true }
|
|
end
|
|
|
|
describe os.linux? do
|
|
it { should eq true }
|
|
end
|
|
"
|
|
|
|
# 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)
|
|
end
|
|
end
|
|
|
|
def to_s
|
|
'Operating System Detection'
|
|
end
|
|
end
|
|
end
|