Modify WebGUI IP fields to use CIDR format instead of a regular expression.
Multiple IPs are separated by commas, whitespace is ignored. In groups, that affects the ipFilter field, User::isInGroup. In settings, that affects Settings::debugIp and Session::ErrorHandler::canShowDebug. Fixed a bug in WebGUI::Utility::isInSubnet where Net::Subnets->check needs a scalar. Modified t/User.t to use addresses in CIDR format.
This commit is contained in:
parent
c6bc09f79c
commit
cd6759f311
7 changed files with 55 additions and 26 deletions
|
|
@ -22,6 +22,11 @@
|
|||
- fix [ 1410577 ] WebGUI::Session not included
|
||||
- Strengthened security of Captcha validation.
|
||||
- Added Captcha form control type.
|
||||
- All IPs used by WebGUI (Settings: debugIp and Group: ipFilter) now accept
|
||||
IP addresses in CIDR format. They also will accept multiple IP addresses
|
||||
if they are separated by commas. Whitespace is ignored. The upgrade
|
||||
script will migrate the data automatically, and hoverHelp documentation
|
||||
has been updated to reflect the changes as well.
|
||||
|
||||
6.8.7
|
||||
- fix [ 1431098 ] op=becomeUser can become non-existent userIds
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ addEMSTables();
|
|||
updateTemplates();
|
||||
updateDatabaseLinksAndSQLReport();
|
||||
addWorkflow();
|
||||
ipsToCIDR();
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
|
@ -392,6 +393,39 @@ sub removeFiles {
|
|||
rmtree('../../lib/WebGUI/Asset/Wobject/IndexedSearch');
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub ipsToCIDR {
|
||||
print "\tTranslating IP addresses to CIDR format.\n" unless ($quiet);
|
||||
print "\t\tStarting with Group ipFilters.\n" unless ($quiet);
|
||||
my $sth = $session->db->read('select groupId, ipFilter from groups');
|
||||
while (my $hash = $sth->hashRef) {
|
||||
next unless $hash->{ipFilter};
|
||||
$hash->{ipFilter} =~ s/\s//g;
|
||||
my @ips = split /;/, $hash->{ipFilter};
|
||||
@ips = map { ip2cidr($_) } @ips;
|
||||
$session->db->write('update groups set ipFilter=? where groupId=?',
|
||||
[join(',', @ips), $hash->{groupId}]);
|
||||
}
|
||||
print "\t\tUpdating debug Ip.\n" unless ($quiet);
|
||||
$sth = $session->db->read("select * from settings where name='debugIp'");
|
||||
while (my $hash = $sth->hashRef) {
|
||||
next unless $hash->{value};
|
||||
my @ips = split /\s+/, $hash->{value};
|
||||
@ips = map { ip2cidr($_) } @ips;
|
||||
$session->db->write('update settings set value=? where name=?',
|
||||
[join(',', @ips), $hash->{name}]);
|
||||
}
|
||||
}
|
||||
|
||||
sub ip2cidr {
|
||||
my ($ip) = @_;
|
||||
$ip =~ s/\.$//;
|
||||
my $bytes = $ip =~ tr/././;
|
||||
my $new_bytes = 3-$bytes;
|
||||
my $prefixLength = 32 - 8*$new_bytes;
|
||||
$ip .= ('.0' x $new_bytes) . "/$prefixLength";
|
||||
return $ip;
|
||||
}
|
||||
|
||||
|
||||
# ---- DO NOT EDIT BELOW THIS LINE ----
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue