class Inspec::Resources::HpuxPorts
def info
def info ## Can't use 'netstat -an -f inet -f inet6' as the latter -f option overrides the former one and return only inet ports cmd1 = inspec.command('netstat -an -f inet') return nil if cmd1.exit_status.to_i != 0 cmd2 = inspec.command('netstat -an -f inet6') return nil if cmd2.exit_status.to_i != 0 cmd = cmd1.stdout + cmd2.stdout ports = [] # parse all lines cmd.each_line do |line| port_info = parse_netstat_line(line) next unless %w{tcp tcp6 udp udp6}.include?(port_info['protocol']) ports.push(port_info) end # select all ports, where we `listen` ports.select { |val| val if 'listen'.casecmp(val['state']) == 0 } end