Ignore entries in the discover form that dont look like IP/hostname

This commit is contained in:
Oliver Gorwits
2014-12-24 18:57:53 +00:00
parent f366576027
commit 87fe634231
2 changed files with 9 additions and 5 deletions

View File

@@ -9,6 +9,7 @@
[BUG FIXES] [BUG FIXES]
* Fix for node search on some formats of IPv6 addr being seen as MAC * Fix for node search on some formats of IPv6 addr being seen as MAC
* [#190] Ignore entries in the discover form that don't look like IP/hostname
2.029014 - 2014-11-19 2.029014 - 2014-11-19

View File

@@ -12,8 +12,7 @@ sub add_job {
if ($device) { if ($device) {
$device = NetAddr::IP::Lite->new($device); $device = NetAddr::IP::Lite->new($device);
return send_error('Bad device', 400) return if ! $device or $device->addr eq '0.0.0.0';
if ! $device or $device->addr eq '0.0.0.0';
} }
jq_insert({ jq_insert({
@@ -23,18 +22,22 @@ sub add_job {
username => session('logged_in_user'), username => session('logged_in_user'),
userip => request->remote_address, userip => request->remote_address,
}); });
true;
} }
foreach my $action (@{ setting('job_prio')->{high} }, foreach my $action (@{ setting('job_prio')->{high} },
@{ setting('job_prio')->{normal} }) { @{ setting('job_prio')->{normal} }) {
ajax "/ajax/control/admin/$action" => require_role admin => sub { ajax "/ajax/control/admin/$action" => require_role admin => sub {
add_job($action, param('device'), param('extra')); add_job($action, param('device'), param('extra'))
or send_error('Bad device', 400);
}; };
post "/admin/$action" => require_role admin => sub { post "/admin/$action" => require_role admin => sub {
add_job($action, param('device'), param('extra')); add_job($action, param('device'), param('extra'))
redirect uri_for('/admin/jobqueue')->path; ? redirect uri_for('/admin/jobqueue')->path
: redirect uri_for('/')->path;
}; };
} }