Class: Inspec::Resources::WindowsPorts
- Defined in:
- lib/resources/port.rb
Overview
TODO: Add UDP infromation Get-NetUDPEndpoint TODO: currently Windows only supports tcp ports TODO: Get-NetTCPConnection does not return PIDs TODO: double-check output with ‘netstat -ano’
Instance Attribute Summary
Attributes inherited from PortsInfo
Instance Method Summary collapse
Methods inherited from PortsInfo
Constructor Details
This class inherits a constructor from Inspec::Resources::PortsInfo
Instance Method Details
#info ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/resources/port.rb', line 120 def info # get all port information cmd = inspec.command('Get-NetTCPConnection | Select-Object -Property State, Caption, Description, LocalAddress, LocalPort, RemoteAddress, RemotePort, DisplayName, Status | ConvertTo-Json') begin ports = JSON.parse(cmd.stdout) rescue JSON::ParserError => _e return nil end return nil if ports.nil? ports.map { |x| { port: x['LocalPort'], address: x['LocalAddress'], protocol: 'tcp', process: nil, pid: nil, } } end |