From 83de59fcc0813aa143297d4313261e3acf0ee8cd Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Mon, 29 Jun 2020 14:05:44 +0100 Subject: [PATCH] #729 Discovery partially fails on invalid indexes --- Changes | 6 ++++++ lib/App/Netdisco/Worker/Plugin/Discover/Entities.pm | 8 ++++++++ lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/Changes b/Changes index 3f37f63f..12636f2e 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,9 @@ +2.046000 - 2020-06-29 + + [BUG FIXES] + + * #729 Discovery partially fails on invalid indexes + 2.045007 - 2020-06-05 [BUG FIXES] diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/Entities.pm b/lib/App/Netdisco/Worker/Plugin/Discover/Entities.pm index d901df66..e49862c6 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/Entities.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/Entities.pm @@ -72,7 +72,15 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { # build device modules list for DBIC my (@modules, %seen_idx); foreach my $entry (keys %$e_index) { + next unless defined $e_index->{$entry}; next if $seen_idx{ $e_index->{$entry} }++; + + if ($e_index->{$entry} !~ m/^[0-9]+$/) { + debug sprintf ' [%s] modules - index %s is not an integer', + $device->ip, $e_index->{$entry}; + next; + } + push @modules, { index => $e_index->{$entry}, type => $e_type->{$entry}, diff --git a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm index 5803cc6c..c7e046f1 100644 --- a/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm +++ b/lib/App/Netdisco/Worker/Plugin/Discover/PortProperties.pm @@ -102,13 +102,21 @@ register_worker({ phase => 'main', driver => 'snmp' }, sub { } foreach my $idx (keys %$interfaces) { + next unless defined $idx; my $port = $interfaces->{$idx} or next; + if (!defined $device_ports->{$port}) { debug sprintf ' [%s] properties/ifindex - local port %s already skipped, ignoring', $device->ip, $port; next; } + if ($idx !~ m/^[0-9]+$/) { + debug sprintf ' [%s] properties/ifindex - port %s ifindex %s is not an integer', + $device->ip, $port, $idx; + next; + } + $properties{ $port }->{ifindex} = $idx; }