code cleanup

This commit is contained in:
Sebastian Hildebrandt 2020-11-27 15:05:40 +01:00
parent 78c6e558ec
commit 5093145506
2 changed files with 5 additions and 5 deletions

View File

@ -1103,7 +1103,7 @@ function networkStatsSingle(iface) {
}
}
if (_freebsd || _openbsd || _netbsd) {
cmd = 'netstat -ibndI ' + ifaceSanitized;
cmd = 'netstat -ibndI ' + ifaceSanitized; // lgtm [js/shell-command-constructed-from-input]
exec(cmd, function (error, stdout) {
if (!error) {
lines = stdout.toString().split('\n');
@ -1125,12 +1125,12 @@ function networkStatsSingle(iface) {
});
}
if (_darwin) {
cmd = 'ifconfig ' + ifaceSanitized + ' | grep "status"';
cmd = 'ifconfig ' + ifaceSanitized + ' | grep "status"'; // lgtm [js/shell-command-constructed-from-input]
exec(cmd, function (error, stdout) {
result.operstate = (stdout.toString().split(':')[1] || '').trim();
result.operstate = (result.operstate || '').toLowerCase();
result.operstate = (result.operstate === 'active' ? 'up' : (result.operstate === 'inactive' ? 'down' : 'unknown'));
cmd = 'netstat -bdI ' + ifaceSanitized;
cmd = 'netstat -bdI ' + ifaceSanitized; // lgtm [js/shell-command-constructed-from-input]
exec(cmd, function (error, stdout) {
if (!error) {
lines = stdout.toString().split('\n');

View File

@ -137,7 +137,7 @@ function services(srv, callback) {
}
let comm = (_darwin) ? 'ps -caxo pcpu,pmem,pid,command' : 'ps -axo pcpu,pmem,pid,command';
if (srvString !== '' && srvs.length > 0) {
exec(comm + ' | grep -v grep | grep -iE "' + srvString + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
exec(comm + ' | grep -v grep | grep -iE "' + srvString + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) { // lgtm [js/shell-command-constructed-from-input]
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {
@ -233,7 +233,7 @@ function services(srv, callback) {
resolve(result);
}
} else {
exec('ps -o comm | grep -v grep | egrep "' + srvString + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) {
exec('ps -o comm | grep -v grep | egrep "' + srvString + '"', { maxBuffer: 1024 * 20000 }, function (error, stdout) { // lgtm [js/shell-command-constructed-from-input]
if (!error) {
let lines = stdout.toString().replace(/ +/g, ' ').replace(/,+/g, '.').split('\n');
srvs.forEach(function (srv) {