From eb8c2f056a4295ba8a29b4ae60d4aa6b9fe32597 Mon Sep 17 00:00:00 2001 From: Oliver Gorwits Date: Tue, 24 Mar 2015 21:15:44 +0000 Subject: [PATCH] [#207] Reject 0.0.0.0 from netdisco-do device or renumber --- Netdisco/Changes | 13 +++++++------ Netdisco/bin/netdisco-do | 8 +++++--- .../Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm | 2 +- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Netdisco/Changes b/Netdisco/Changes index 02035be7..a53d4e45 100644 --- a/Netdisco/Changes +++ b/Netdisco/Changes @@ -9,15 +9,16 @@ [ENHANCEMENTS] - * show page and total records number on DataTables tables - * be more strict about Node Search matching ports/wifi within date range - * allow filtering out of Device Ports on Node (MAC) search - * display Voice VLAN on Cisco devices + * Show page and total records number on DataTables tables + * Be more strict about Node Search matching ports/wifi within date range + * Allow filtering out of Device Ports on Node (MAC) search + * Display Voice VLAN on Cisco devices [BUG FIXES] - * only exclude discover_no on Undiscovered Neighbors report when few (<50) results - * mention expire in netdisco-do docs + * Only exclude discover_no on Undiscovered Neighbors report when few (<50) results + * Mention expire in netdisco-do docs + * [#207] Reject 0.0.0.0 from netdisco-do device or renumber 2.031012 - 2015-02-28 diff --git a/Netdisco/bin/netdisco-do b/Netdisco/bin/netdisco-do index a53064d2..af6f9863 100755 --- a/Netdisco/bin/netdisco-do +++ b/Netdisco/bin/netdisco-do @@ -159,8 +159,10 @@ unless ($action) { return ('error', 'Missing device (-d).') if !defined $device; my $old_ip = $device->ip; - my $new_ip = NetAddr::IP::Lite->new($extra) - or return ('error', "Bad host or IP: $extra"); + my $new_ip = NetAddr::IP::Lite->new($extra); + unless ($new_ip and $new_ip->addr ne '0.0.0.0') { + return ('error', "Bad host or IP: ".($extra || '0.0.0.0')); + } my $new_dev = get_device($new_ip->addr); unless ($new_dev and not $new_dev->in_storage) { return ('error', sprintf "Already know new device: %s.", $device->ip); @@ -214,7 +216,7 @@ if (not $worker->can( $action )) { } my $net = NetAddr::IP->new($device); -if ($device and (!$net or $net->num == 0)) { +if ($device and (!$net or $net->num == 0 or $net->addr eq '0.0.0.0')) { info sprintf '%s: error - Bad host, IP or prefix: %s', $action, $device; exit 1; } diff --git a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm index 740d0885..d3a1c641 100644 --- a/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm +++ b/Netdisco/lib/App/Netdisco/Web/Plugin/AdminTask/PseudoDevice.pm @@ -19,7 +19,7 @@ sub _sanity_ok { and param('dns') !~ m/[[:space:]]/; my $ip = NetAddr::IP::Lite->new(param('ip')); - return 0 unless ($ip and$ip->addr ne '0.0.0.0'); + return 0 unless ($ip and $ip->addr ne '0.0.0.0'); return 0 unless param('ports') and param('ports') =~ m/^[[:digit:]]+$/;