Skip to content

Commit

Permalink
sanitizeShellString() and other security improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sebhildebrandt committed Mar 15, 2021
1 parent 7922366 commit 0be6fcd
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/docker.js
Expand Up @@ -470,7 +470,7 @@ function dockerContainerStats(containerIDs, callback) {
if (containerIDsSanitized !== '*') {
containerIDsSanitized = '';
const s = (util.isPrototypePolluted() ? '' : util.sanitizeShellString(containerIDs, true)).trim();
for (let i = 0; i <= 2000; i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
Expand Down
6 changes: 2 additions & 4 deletions lib/internet.js
Expand Up @@ -46,8 +46,7 @@ function inetChecksite(url, callback) {
}
let urlSanitized = '';
const s = util.sanitizeShellString(url, true);
const mathMin = util.mathMin;
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
Expand Down Expand Up @@ -145,8 +144,7 @@ function inetLatency(host, callback) {
}
let hostSanitized = '';
const s = (util.isPrototypePolluted() ? '8.8.8.8' : util.sanitizeShellString(host, true)).trim();
const mathMin = util.mathMin;
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
s[i].__proto__.toLowerCase = util.stringToLower;
const sl = s[i].toLowerCase();
Expand Down
3 changes: 1 addition & 2 deletions lib/network.js
Expand Up @@ -1061,8 +1061,7 @@ function networkStatsSingle(iface) {
process.nextTick(() => {
let ifaceSanitized = '';
const s = util.isPrototypePolluted() ? '---' : util.sanitizeShellString(iface);
const mathMin = util.mathMin;
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
ifaceSanitized = ifaceSanitized + s[i];
}
Expand Down
6 changes: 2 additions & 4 deletions lib/processes.js
Expand Up @@ -111,8 +111,7 @@ function services(srv, callback) {
srvString.__proto__.trim = util.stringTrim;

const s = util.sanitizeShellString(srv);
const mathMin = util.mathMin;
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
srvString = srvString + s[i];
}
Expand Down Expand Up @@ -911,8 +910,7 @@ function processLoad(proc, callback) {
processesString.__proto__.trim = util.stringTrim;

const s = util.sanitizeShellString(proc);
const mathMin = util.mathMin;
for (let i = 0; i <= mathMin(s.length, 2000); i++) {
for (let i = 0; i <= util.mathMin(s.length, 2000); i++) {
if (!(s[i] === undefined)) {
processesString = processesString + s[i];
}
Expand Down

0 comments on commit 0be6fcd

Please sign in to comment.