Class: Inspec::Resources::Port

Inherits:
Object
  • Object
show all
Defined in:
lib/resources/port.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Port

Returns a new instance of Port.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/resources/port.rb', line 36

def initialize(*args)
  args.unshift(nil) if args.length <= 1 # add the ip address to the front
  @ip = args[0]
  @port = args[1]

  @port_manager = nil
  @cache = nil
  os = inspec.os
  if os.linux?
    @port_manager = LinuxPorts.new(inspec)
  elsif %w{darwin aix}.include?(os[:family])
    # AIX: see http://www.ibm.com/developerworks/aix/library/au-lsof.html#resources
    #      and https://www-01.ibm.com/marketing/iwm/iwm/web/reg/pick.do?source=aixbp
    # Darwin: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/lsof.8.html
    @port_manager = LsofPorts.new(inspec)
  elsif os.windows?
    @port_manager = WindowsPorts.new(inspec)
  elsif ['freebsd'].include?(os[:family])
    @port_manager = FreeBsdPorts.new(inspec)
  elsif os.solaris?
    @port_manager = SolarisPorts.new(inspec)
  elsif os.hpux?
    @port_manager = HpuxPorts.new(inspec)
  else
    return skip_resource 'The `port` resource is not supported on your OS yet.'
  end
end

Instance Method Details

#to_sObject



75
76
77
# File 'lib/resources/port.rb', line 75

def to_s
  "Port #{@port}"
end