Improve stats data scrubbing (#6041)

Include Darwin (OSX) in the Linux hostname scrubbing, add underscores too.
Way more generic serial number replacement.  Preserves the format of the serial number, but removes the data.
This commit is contained in:
Tony Murray
2017-03-01 04:23:38 -06:00
committed by Neil Lathwood
parent 312f74d6d6
commit 6ecb3acc51

View File

@@ -79,8 +79,25 @@ if ($enabled == 1) {
// sanitize sysDescr
$device_info = array_map(function ($entry) {
$entry['sysDescr'] = preg_replace('/^Linux [A-Za-z\-0-9\.]+ (?=[0-9\.]{5,9})/', 'Linux hostname ', $entry['sysDescr']);
$entry['sysDescr'] = preg_replace('/ SN: [A-Z0-9]{12}/', ' SN: 0A0A0A0A0A0A ', $entry['sysDescr']);
// remove hostnames from linux and macosx
$entry['sysDescr'] = preg_replace_callback('/^(Linux |Darwin )[A-Za-z0-9._\-]+ ([0-9.]{5,9})/', function ($matches) {
return $matches[1] . 'hostname ' .$matches[2];
}, $entry['sysDescr']);
// wipe serial numbers, preserve the format
$entry['sysDescr'] = preg_replace_callback('/(SN[:=]? ?)([A-Za-z0-9.\-]{4,16})/', function ($matches) {
$patterns = array(
'/[A-Z]/',
'/[a-z]/',
'/[0-9]/'
);
$replacements = array(
'A',
'a',
'0'
);
return $matches[1] . preg_replace($patterns, $replacements, $matches[2]);
}, $entry['sysDescr']);
return $entry;
}, $device_info);