Fix IPv6 in service check host (#13939)

* Add hostName cleaning to Clean

* Apply RFC 5952 formatting to Clean::hostName output

* Use more liberal cleaning for hostnames

* Remove unwanted whitespace

* Apply Clean::hostName() to all relevant fields

* Fix docstring

* Use IP::isValid inline

* Update Clean.php

* Update services.inc.php

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Sander Steffann 2022-04-22 17:05:55 +02:00 committed by Tony Murray
parent 15feac7297
commit a71ea964b6

View File

@ -5,6 +5,7 @@ use LibreNMS\Alert\AlertRules;
use LibreNMS\Config;
use LibreNMS\RRD\RrdDefinition;
use LibreNMS\Util\Clean;
use LibreNMS\Util\IP;
function get_service_status($device = null)
{
@ -122,9 +123,9 @@ function poll_service($service)
$update = [];
$old_status = $service['service_status'];
$service['service_type'] = Clean::fileName($service['service_type']);
$service['service_ip'] = Clean::fileName($service['service_ip']);
$service['hostname'] = Clean::fileName($service['hostname']);
$service['overwrite_ip'] = Clean::fileName($service['overwrite_ip']);
$service['service_ip'] = IP::isValid($service['service_ip']) ? $service['service_ip'] : Clean::fileName($service['service_ip']);
$service['hostname'] = IP::isValid($service['hostname']) ? $service['hostname'] : Clean::fileName($service['hostname']);
$service['overwrite_ip'] = IP::isValid($service['overwrite_ip']) ? $service['overwrite_ip'] : Clean::fileName($service['overwrite_ip']);
$check_cmd = '';
// if we have a script for this check, use it.