class Inspec::Resources::UserInfo
This is an abstract class that every user provoider has to implement. A user provider implements a system abstracts and helps the InSpec resource hand-over system specific behavior to those providers
Attributes
inspec[R]
Public Class Methods
new(inspec)
click to toggle source
# File lib/inspec/resources/users.rb, line 324 def initialize(inspec) @inspec = inspec end
Public Instance Methods
collect_user_details()
click to toggle source
returns the full information list for a user
# File lib/inspec/resources/users.rb, line 374 def collect_user_details list_users.map do |username| user_details(username.chomp) end end
credentials(_username)
click to toggle source
returns a hash with meta-data about user credentials {
mindays: 1, maxdays: 1, warndays: 1,
} this method is optional and may not be implemented by each provider
# File lib/inspec/resources/users.rb, line 352 def credentials(_username) nil end
identity(_username)
click to toggle source
returns a hash with user-specific values: {
uid: '', user: '', gid: '', group: '', groups: '',
}
# File lib/inspec/resources/users.rb, line 336 def identity(_username) raise "user provider must implement the `identity` method" end
list_users()
click to toggle source
returns an array with users
# File lib/inspec/resources/users.rb, line 357 def list_users raise "user provider must implement the `list_users` method" end
meta_info(_username)
click to toggle source
returns optional information about a user, eg shell
# File lib/inspec/resources/users.rb, line 341 def meta_info(_username) nil end
user_details(username)
click to toggle source
retuns all aspects of the user as one hash
# File lib/inspec/resources/users.rb, line 362 def user_details(username) item = {} id = identity(username) item.merge!(id) unless id.nil? meta = meta_info(username) item.merge!(meta) unless meta.nil? cred = credentials(username) item.merge!(cred) unless cred.nil? item end