Skip to content

Commit 1378bfb

Browse files
authored
Land rapid7#18294, pick up netifaces updates, improve error catching
2 parents ba9f879 + a13d45e commit 1378bfb

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ GEM
308308
net-smtp (0.3.3)
309309
net-protocol
310310
net-ssh (7.1.0)
311-
network_interface (0.0.2)
311+
network_interface (0.0.4)
312312
nexpose (7.3.0)
313313
nio4r (2.5.9)
314314
nokogiri (1.14.5)

lib/msf/core/opt_address_local.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ module Msf
1010
###
1111
class OptAddressLocal < OptAddress
1212
def interfaces
13-
NetworkInterface.interfaces || []
13+
begin
14+
NetworkInterface.interfaces || []
15+
rescue NetworkInterface::Error => e
16+
elog(e)
17+
[]
18+
end
1419
end
1520

1621
def normalize(value)

spec/lib/msf/core/opt_address_local_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,4 +94,17 @@
9494
end
9595
end
9696
end
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+
end
108+
end
109+
end
97110
end

0 commit comments

Comments
 (0)