[#207] Reject 0.0.0.0 from netdisco-do device or renumber

This commit is contained in:
Oliver Gorwits
2015-03-24 21:15:44 +00:00
parent 03d3098545
commit eb8c2f056a
3 changed files with 13 additions and 10 deletions

View File

@@ -9,15 +9,16 @@
[ENHANCEMENTS] [ENHANCEMENTS]
* show page and total records number on DataTables tables * Show page and total records number on DataTables tables
* be more strict about Node Search matching ports/wifi within date range * Be more strict about Node Search matching ports/wifi within date range
* allow filtering out of Device Ports on Node (MAC) search * Allow filtering out of Device Ports on Node (MAC) search
* display Voice VLAN on Cisco devices * Display Voice VLAN on Cisco devices
[BUG FIXES] [BUG FIXES]
* only exclude discover_no on Undiscovered Neighbors report when few (<50) results * Only exclude discover_no on Undiscovered Neighbors report when few (<50) results
* mention expire in netdisco-do docs * Mention expire in netdisco-do docs
* [#207] Reject 0.0.0.0 from netdisco-do device or renumber
2.031012 - 2015-02-28 2.031012 - 2015-02-28

View File

@@ -159,8 +159,10 @@ unless ($action) {
return ('error', 'Missing device (-d).') if !defined $device; return ('error', 'Missing device (-d).') if !defined $device;
my $old_ip = $device->ip; my $old_ip = $device->ip;
my $new_ip = NetAddr::IP::Lite->new($extra) my $new_ip = NetAddr::IP::Lite->new($extra);
or return ('error', "Bad host or IP: $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); my $new_dev = get_device($new_ip->addr);
unless ($new_dev and not $new_dev->in_storage) { unless ($new_dev and not $new_dev->in_storage) {
return ('error', sprintf "Already know new device: %s.", $device->ip); 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); 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; info sprintf '%s: error - Bad host, IP or prefix: %s', $action, $device;
exit 1; exit 1;
} }

View File

@@ -19,7 +19,7 @@ sub _sanity_ok {
and param('dns') !~ m/[[:space:]]/; and param('dns') !~ m/[[:space:]]/;
my $ip = NetAddr::IP::Lite->new(param('ip')); 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') return 0 unless param('ports')
and param('ports') =~ m/^[[:digit:]]+$/; and param('ports') =~ m/^[[:digit:]]+$/;