Class: Inspec::Resources::Interfaces::BsdInterfaceLister

Inherits:
InterfaceLister show all
Defined in:
lib/inspec/resources/interfaces.rb

Instance Attribute Summary

Attributes inherited from InterfaceLister

#inspec

Instance Method Summary collapse

Methods inherited from InterfaceLister

#initialize

Constructor Details

This class inherits a constructor from Inspec::Resources::Interfaces::InterfaceLister

Instance Method Details

#scan_interfacesObject



75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/inspec/resources/interfaces.rb', line 75

def scan_interfaces
  iface_data = []
  cmd = inspec.command("ifconfig -a")
  cmd.stdout.split("\n").each do |line|
    # lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
    m = line.match(/^(\S+):/)
    if m
      iface_data << { "name" => m[1] }
    end
  end
  iface_data
end