17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/inspec/resources/security_identifier.rb', line 17
def initialize(opts = {})
supported_opt_keys = %i{user group unspecified}
raise ArgumentError, "Invalid security_identifier param '#{opts}'. Please pass a hash with these supported keys: #{supported_opt_keys}" unless opts.respond_to?(:keys)
raise ArgumentError, "Unsupported security_identifier options '#{opts.keys - supported_opt_keys}'. Supported keys: #[supported_opt_keys]" unless (opts.keys - supported_opt_keys).empty?
raise ArgumentError, "Specifying more than one of :user :group or :unspecified for security_identifier is not supported" unless opts.keys && (opts.keys & supported_opt_keys).length == 1
if opts[:user]
@type = :user
@name = opts[:user]
end
if opts[:group]
@type = :group
@name = opts[:group]
end
if opts[:unspecified]
@type = :unspecified
@name = opts[:unspecified]
end
raise ArgumentError, "Specify one of :user :group or :unspecified for security_identifier" unless @name
@sids = nil
end
|