Class: Inspec::Resources::SshKey
Instance Attribute Summary
Attributes inherited from FileResource
#file, #mount_options, #path
Instance Method Summary
collapse
Methods included from FileReader
#read_file_content
#allowed?, #contain, #content, #content_as_json, #content_as_yaml, #executable?, #immutable?, #inherited?, #more_permissive_than?, #mounted?, #readable?, #sgid, #sticky, #suid, #user_permissions, #writable?
#includes_whitespaces?, #parse_mount_options
#select_file_perms_style
Constructor Details
#initialize(keypath, passphrase = nil) ⇒ SshKey
Returns a new instance of SshKey.
27
28
29
30
31
32
33
|
# File 'lib/inspec/resources/ssh_key.rb', line 27
def initialize(keypath, passphrase = nil)
skip_resource "The `ssh_key` resource is not yet available on your OS." unless inspec.os.unix? || inspec.os.windows?
@key_path = set_ssh_key_path(keypath)
@passphrase = passphrase
@key = read_ssh_key
super(@key_path)
end
|
Instance Method Details
#key_length ⇒ Object
47
48
49
50
51
|
# File 'lib/inspec/resources/ssh_key.rb', line 47
def key_length
return if @key.nil?
@key[:key_length]
end
|
#private? ⇒ Boolean
41
42
43
44
45
|
# File 'lib/inspec/resources/ssh_key.rb', line 41
def private?
return if @key.nil?
@key[:private]
end
|
#public? ⇒ Boolean
35
36
37
38
39
|
# File 'lib/inspec/resources/ssh_key.rb', line 35
def public?
return if @key.nil?
@key[:public]
end
|
#resource_id ⇒ Object
Define a resource ID. This is used in reporting engines to uniquely identify the individual resource. This might be a file path, or a process ID, or a cloud instance ID. Only meaningful to the implementation. Must be a string. Defaults to the empty string if not implemented.
62
63
64
|
# File 'lib/inspec/resources/ssh_key.rb', line 62
def resource_id
@key_path || "SSH key"
end
|
#to_s ⇒ Object
66
67
68
|
# File 'lib/inspec/resources/ssh_key.rb', line 66
def to_s
"ssh_key #{@key_path}"
end
|
#type ⇒ Object
53
54
55
56
57
|
# File 'lib/inspec/resources/ssh_key.rb', line 53
def type
return if @key.nil?
@key[:type]
end
|