Class: Inspec::Resources::DarwinHostProvider
Instance Attribute Summary
Attributes inherited from HostProvider
#inspec
Instance Method Summary
collapse
#resolve_with_dig, #resolve_with_getent
#initialize
Instance Method Details
#missing_requirements(protocol) ⇒ Object
194
195
196
197
198
199
200
201
202
|
# File 'lib/resources/host.rb', line 194
def missing_requirements(protocol)
missing = []
if protocol == 'tcp'
missing << 'netcat must be installed' unless inspec.command('nc').exist?
end
missing
end
|
#ping(hostname, port, protocol) ⇒ Object
204
205
206
207
208
209
210
211
212
213
214
215
216
|
# File 'lib/resources/host.rb', line 204
def ping(hostname, port, protocol)
if protocol == 'tcp'
resp = inspec.command("nc -vz -G 1 #{hostname} #{port}")
else
resp = inspec.command("ping -W 1 -c 1 #{hostname}")
end
{
success: resp.exit_status.to_i.zero?,
connection: resp.stderr,
socket: resp.stdout,
}
end
|
#resolve(hostname) ⇒ Object
218
219
220
|
# File 'lib/resources/host.rb', line 218
def resolve(hostname)
resolve_with_dig(hostname)
end
|