Method: Inspec::Resources::LinuxPorts#info
- Defined in:
- lib/resources/port.rb
#info ⇒ Object
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/resources/port.rb', line 267 def info cmd = inspec.command('netstat -tulpen') return nil if cmd.exit_status.to_i != 0 ports = [] # parse all lines cmd.stdout.each_line do |line| port_info = parse_netstat_line(line) # only push protocols we are interested in next unless %w{tcp tcp6 udp udp6}.include?(port_info['protocol']) ports.push(port_info) end ports end |