Method: Inspec::Resources::AixPorts#ports_via_netstat
- Defined in:
- lib/inspec/resources/port.rb
#ports_via_netstat ⇒ Object
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/inspec/resources/port.rb', line 280 def ports_via_netstat return nil unless inspec.command("netstat").exist? cmd = inspec.command("netstat -Aan | grep LISTEN") return nil unless 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 |