We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 615aa8d commit a13d45eCopy full SHA for a13d45e
lib/msf/core/opt_address_local.rb
@@ -12,7 +12,7 @@ class OptAddressLocal < OptAddress
12
def interfaces
13
begin
14
NetworkInterface.interfaces || []
15
- rescue
+ rescue NetworkInterface::Error => e
16
elog(e)
17
[]
18
end
spec/lib/msf/core/opt_address_local_spec.rb
@@ -94,4 +94,17 @@
94
95
96
97
+ describe '#interfaces' do
98
+ context 'getting errors' do
99
+ before(:each) do
100
+ allow(NetworkInterface).to receive(:interfaces).and_raise(NetworkInterface::Error)
101
+ end
102
+
103
+ it 'rescues and returns an empty array' do
104
+ expect(required_opt).to receive(:elog).with(an_instance_of(NetworkInterface::Error))
105
+ result = required_opt.interfaces()
106
+ expect(result).to eq([])
107
108
109
110
0 commit comments