mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove FILTER_SANITIZE_STRING (#16264)
It is deprecated, all the code using it is sus
This commit is contained in:
@@ -18,7 +18,6 @@ try {
|
||||
return;
|
||||
}
|
||||
|
||||
$rrd_name = ['app', $name, $app->app_id];
|
||||
$rrd_def = RrdDefinition::make()
|
||||
->addDataset('mruntime', 'GAUGE', 0)
|
||||
->addDataset('pcapacity', 'GAUGE', 0, 100)
|
||||
@@ -31,36 +30,25 @@ $rrd_def = RrdDefinition::make()
|
||||
|
||||
$metrics = [];
|
||||
foreach ($pwrstatd_data as $data) {
|
||||
$sn = is_string($data['sn']) ? filter_var($data['sn'], FILTER_SANITIZE_STRING) : null;
|
||||
|
||||
if (is_null($data['sn'])) {
|
||||
if (! is_string($data['sn'])) {
|
||||
echo PHP_EOL . $name . ':' . ' Invalid or no psu serial number found.' . PHP_EOL;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$mruntime = $data['mruntime'];
|
||||
$pcapacity = $data['pcapacity'];
|
||||
$pload = $data['pload'];
|
||||
$voutput = $data['voutput'];
|
||||
$vrating = $data['vrating'];
|
||||
$vutility = $data['vutility'];
|
||||
$wload = $data['wload'];
|
||||
$wrating = $data['wrating'];
|
||||
|
||||
$rrd_name = ['app', $name, $app->app_id, $sn];
|
||||
|
||||
$fields = [
|
||||
'mruntime' => $mruntime,
|
||||
'pcapacity' => $pcapacity,
|
||||
'pload' => $pload,
|
||||
'voutput' => $voutput,
|
||||
'vrating' => $vrating,
|
||||
'vutility' => $vutility,
|
||||
'wload' => $wload,
|
||||
'wrating' => $wrating,
|
||||
'mruntime' => $data['mruntime'],
|
||||
'pcapacity' => $data['pcapacity'],
|
||||
'pload' => $data['pload'],
|
||||
'voutput' => $data['voutput'],
|
||||
'vrating' => $data['vrating'],
|
||||
'vutility' => $data['vutility'],
|
||||
'wload' => $data['wload'],
|
||||
'wrating' => $data['wrating'],
|
||||
];
|
||||
|
||||
$sn = \LibreNMS\Util\Clean::fileName($data['sn']);
|
||||
$rrd_name = ['app', $name, $app->app_id, $sn];
|
||||
$metrics[$sn] = $fields;
|
||||
$tags = ['name' => $sn, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name];
|
||||
data_update($device, 'app', $tags, $fields);
|
||||
|
@@ -82,8 +82,7 @@ foreach ($ss_section_list as $gen_type) {
|
||||
} elseif (in_array($gen_type, $ss_af_list)) {
|
||||
array_push($allowed_afs, $gen_type);
|
||||
} else {
|
||||
$fgen_type = is_string($gen_type) ? filter_var($gen_type, FILTER_SANITIZE_STRING) : null;
|
||||
$log_message = 'Socket Statistics Invalid Socket or AF Returned by Script: ' . $fgen_type;
|
||||
$log_message = 'Socket Statistics Invalid Socket or AF Returned by Script: ' . $gen_type;
|
||||
log_event($log_message, $device, 'application');
|
||||
continue;
|
||||
}
|
||||
@@ -135,8 +134,7 @@ foreach ($ss_section_list as $gen_type) {
|
||||
if (in_array($netid, $ss_socket_list)) {
|
||||
array_push($allowed_sockets, $netid);
|
||||
} else {
|
||||
$fgen_type = is_string($gen_type) ? filter_var($gen_type, FILTER_SANITIZE_STRING) : null;
|
||||
$log_message = 'Socket Statistics Invalid Socket Returned by Script: ' . $fgen_type;
|
||||
$log_message = 'Socket Statistics Invalid Socket Returned by Script: ' . $gen_type;
|
||||
log_event($log_message, $device, 'application');
|
||||
continue;
|
||||
}
|
||||
|
@@ -53,11 +53,7 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
$bytes_rcvd_total_intf = null;
|
||||
$bytes_sent_total_intf = null;
|
||||
|
||||
$finterface = is_string($interface)
|
||||
? filter_var($interface, FILTER_SANITIZE_STRING)
|
||||
: null;
|
||||
|
||||
if (is_null($finterface)) {
|
||||
if (! is_string($interface)) {
|
||||
echo PHP_EOL .
|
||||
$name .
|
||||
':' .
|
||||
@@ -66,14 +62,11 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
|
||||
continue;
|
||||
}
|
||||
$interface = \LibreNMS\Util\Clean::fileName($interface);
|
||||
|
||||
$mappings[$finterface] = [];
|
||||
$mappings[$interface] = [];
|
||||
foreach ($client_list as $client => $client_data) {
|
||||
$fclient = is_string($client)
|
||||
? filter_var($client, FILTER_SANITIZE_STRING)
|
||||
: null;
|
||||
|
||||
if (is_null($fclient)) {
|
||||
if (! is_string($client)) {
|
||||
echo PHP_EOL .
|
||||
$name .
|
||||
':' .
|
||||
@@ -82,8 +75,9 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
|
||||
continue;
|
||||
}
|
||||
$client = \LibreNMS\Util\Clean::fileName($client);
|
||||
|
||||
array_push($mappings[$finterface], $fclient);
|
||||
array_push($mappings[$interface], $client);
|
||||
$bytes_rcvd = is_numeric($client_data['bytes_rcvd'])
|
||||
? $client_data['bytes_rcvd']
|
||||
: null;
|
||||
@@ -113,7 +107,7 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
];
|
||||
|
||||
// create flattened metrics
|
||||
$metrics['intf_' . $finterface . '_client_' . $fclient] = $fields_intfclient;
|
||||
$metrics['intf_' . $interface . '_client_' . $client] = $fields_intfclient;
|
||||
$tags_intfclient = [
|
||||
'name' => $name,
|
||||
'app_id' => $app->app_id,
|
||||
@@ -122,8 +116,8 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
$polling_type,
|
||||
$name,
|
||||
$app->app_id,
|
||||
$finterface,
|
||||
$fclient,
|
||||
$interface,
|
||||
$client,
|
||||
],
|
||||
];
|
||||
data_update($device, $polling_type, $tags_intfclient, $fields_intfclient);
|
||||
@@ -136,13 +130,13 @@ foreach ($interface_client_map as $interface => $client_list) {
|
||||
];
|
||||
|
||||
// create interface metrics
|
||||
$metrics['intf_' . $finterface] = $fields_intf;
|
||||
$metrics['intf_' . $interface] = $fields_intf;
|
||||
|
||||
$tags_intf = [
|
||||
'name' => $name,
|
||||
'app_id' => $app->app_id,
|
||||
'rrd_def' => $rrd_def_intf,
|
||||
'rrd_name' => [$polling_type, $name, $app->app_id, $finterface],
|
||||
'rrd_name' => [$polling_type, $name, $app->app_id, $interface],
|
||||
];
|
||||
data_update($device, $polling_type, $tags_intf, $fields_intf);
|
||||
}
|
||||
|
Reference in New Issue
Block a user