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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$rrd_name = ['app', $name, $app->app_id];
|
|
||||||
$rrd_def = RrdDefinition::make()
|
$rrd_def = RrdDefinition::make()
|
||||||
->addDataset('mruntime', 'GAUGE', 0)
|
->addDataset('mruntime', 'GAUGE', 0)
|
||||||
->addDataset('pcapacity', 'GAUGE', 0, 100)
|
->addDataset('pcapacity', 'GAUGE', 0, 100)
|
||||||
@@ -31,36 +30,25 @@ $rrd_def = RrdDefinition::make()
|
|||||||
|
|
||||||
$metrics = [];
|
$metrics = [];
|
||||||
foreach ($pwrstatd_data as $data) {
|
foreach ($pwrstatd_data as $data) {
|
||||||
$sn = is_string($data['sn']) ? filter_var($data['sn'], FILTER_SANITIZE_STRING) : null;
|
if (! is_string($data['sn'])) {
|
||||||
|
|
||||||
if (is_null($data['sn'])) {
|
|
||||||
echo PHP_EOL . $name . ':' . ' Invalid or no psu serial number found.' . PHP_EOL;
|
echo PHP_EOL . $name . ':' . ' Invalid or no psu serial number found.' . PHP_EOL;
|
||||||
|
|
||||||
continue;
|
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 = [
|
$fields = [
|
||||||
'mruntime' => $mruntime,
|
'mruntime' => $data['mruntime'],
|
||||||
'pcapacity' => $pcapacity,
|
'pcapacity' => $data['pcapacity'],
|
||||||
'pload' => $pload,
|
'pload' => $data['pload'],
|
||||||
'voutput' => $voutput,
|
'voutput' => $data['voutput'],
|
||||||
'vrating' => $vrating,
|
'vrating' => $data['vrating'],
|
||||||
'vutility' => $vutility,
|
'vutility' => $data['vutility'],
|
||||||
'wload' => $wload,
|
'wload' => $data['wload'],
|
||||||
'wrating' => $wrating,
|
'wrating' => $data['wrating'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
$sn = \LibreNMS\Util\Clean::fileName($data['sn']);
|
||||||
|
$rrd_name = ['app', $name, $app->app_id, $sn];
|
||||||
$metrics[$sn] = $fields;
|
$metrics[$sn] = $fields;
|
||||||
$tags = ['name' => $sn, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name];
|
$tags = ['name' => $sn, 'app_id' => $app->app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name];
|
||||||
data_update($device, 'app', $tags, $fields);
|
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)) {
|
} elseif (in_array($gen_type, $ss_af_list)) {
|
||||||
array_push($allowed_afs, $gen_type);
|
array_push($allowed_afs, $gen_type);
|
||||||
} else {
|
} 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: ' . $gen_type;
|
||||||
$log_message = 'Socket Statistics Invalid Socket or AF Returned by Script: ' . $fgen_type;
|
|
||||||
log_event($log_message, $device, 'application');
|
log_event($log_message, $device, 'application');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -135,8 +134,7 @@ foreach ($ss_section_list as $gen_type) {
|
|||||||
if (in_array($netid, $ss_socket_list)) {
|
if (in_array($netid, $ss_socket_list)) {
|
||||||
array_push($allowed_sockets, $netid);
|
array_push($allowed_sockets, $netid);
|
||||||
} else {
|
} else {
|
||||||
$fgen_type = is_string($gen_type) ? filter_var($gen_type, FILTER_SANITIZE_STRING) : null;
|
$log_message = 'Socket Statistics Invalid Socket Returned by Script: ' . $gen_type;
|
||||||
$log_message = 'Socket Statistics Invalid Socket Returned by Script: ' . $fgen_type;
|
|
||||||
log_event($log_message, $device, 'application');
|
log_event($log_message, $device, 'application');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@@ -53,11 +53,7 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
$bytes_rcvd_total_intf = null;
|
$bytes_rcvd_total_intf = null;
|
||||||
$bytes_sent_total_intf = null;
|
$bytes_sent_total_intf = null;
|
||||||
|
|
||||||
$finterface = is_string($interface)
|
if (! is_string($interface)) {
|
||||||
? filter_var($interface, FILTER_SANITIZE_STRING)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (is_null($finterface)) {
|
|
||||||
echo PHP_EOL .
|
echo PHP_EOL .
|
||||||
$name .
|
$name .
|
||||||
':' .
|
':' .
|
||||||
@@ -66,14 +62,11 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
$interface = \LibreNMS\Util\Clean::fileName($interface);
|
||||||
|
|
||||||
$mappings[$finterface] = [];
|
$mappings[$interface] = [];
|
||||||
foreach ($client_list as $client => $client_data) {
|
foreach ($client_list as $client => $client_data) {
|
||||||
$fclient = is_string($client)
|
if (! is_string($client)) {
|
||||||
? filter_var($client, FILTER_SANITIZE_STRING)
|
|
||||||
: null;
|
|
||||||
|
|
||||||
if (is_null($fclient)) {
|
|
||||||
echo PHP_EOL .
|
echo PHP_EOL .
|
||||||
$name .
|
$name .
|
||||||
':' .
|
':' .
|
||||||
@@ -82,8 +75,9 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
|
|
||||||
continue;
|
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'])
|
$bytes_rcvd = is_numeric($client_data['bytes_rcvd'])
|
||||||
? $client_data['bytes_rcvd']
|
? $client_data['bytes_rcvd']
|
||||||
: null;
|
: null;
|
||||||
@@ -113,7 +107,7 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// create flattened metrics
|
// create flattened metrics
|
||||||
$metrics['intf_' . $finterface . '_client_' . $fclient] = $fields_intfclient;
|
$metrics['intf_' . $interface . '_client_' . $client] = $fields_intfclient;
|
||||||
$tags_intfclient = [
|
$tags_intfclient = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'app_id' => $app->app_id,
|
'app_id' => $app->app_id,
|
||||||
@@ -122,8 +116,8 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
$polling_type,
|
$polling_type,
|
||||||
$name,
|
$name,
|
||||||
$app->app_id,
|
$app->app_id,
|
||||||
$finterface,
|
$interface,
|
||||||
$fclient,
|
$client,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
data_update($device, $polling_type, $tags_intfclient, $fields_intfclient);
|
data_update($device, $polling_type, $tags_intfclient, $fields_intfclient);
|
||||||
@@ -136,13 +130,13 @@ foreach ($interface_client_map as $interface => $client_list) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// create interface metrics
|
// create interface metrics
|
||||||
$metrics['intf_' . $finterface] = $fields_intf;
|
$metrics['intf_' . $interface] = $fields_intf;
|
||||||
|
|
||||||
$tags_intf = [
|
$tags_intf = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'app_id' => $app->app_id,
|
'app_id' => $app->app_id,
|
||||||
'rrd_def' => $rrd_def_intf,
|
'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);
|
data_update($device, $polling_type, $tags_intf, $fields_intf);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user