inetChecksite() possible security issue fix

This commit is contained in:
Sebastian Hildebrandt
2021-02-15 14:41:44 +01:00
parent fbb5c2adcd
commit c28b46d492
10 changed files with 64 additions and 7 deletions
+10
View File
@@ -58,6 +58,11 @@ function inetChecksite(url, callback) {
result.url = urlSanitized;
try {
if (urlSanitized && !util.isPrototypePolluted()) {
urlSanitized.__proto__.startsWith = util.stringStartWith;
if (urlSanitized.startsWith('file:')) {
if (callback) { callback(result); }
return resolve(result);
}
let t = Date.now();
if (_linux || _freebsd || _openbsd || _netbsd || _darwin || _sunos) {
let args = ' -I --connect-timeout 5 -m 5 ' + urlSanitized + ' 2>/dev/null | head -n 1 | cut -d " " -f2';
@@ -146,6 +151,11 @@ function inetLatency(host, callback) {
}
}
}
hostSanitized.__proto__.startsWith = util.stringStartWith;
if (hostSanitized.startsWith('file:')) {
if (callback) { callback(null); }
return resolve(null);
}
let params;
let filt;
if (_linux || _freebsd || _openbsd || _netbsd || _darwin) {
+2
View File
@@ -57,6 +57,7 @@ const stringToLower = new String().toLowerCase;
const stringToString = new String().toString;
const stringSubstr = new String().substr;
const stringTrim = new String().trim;
const stringStartWith = new String().startsWith;
function isFunction(functionToCheck) {
let getType = {};
@@ -939,5 +940,6 @@ exports.stringToLower = stringToLower;
exports.stringToString = stringToString;
exports.stringSubstr = stringSubstr;
exports.stringTrim = stringTrim;
exports.stringStartWith = stringStartWith;
exports.WINDIR = WINDIR;
exports.getFilesInPath = getFilesInPath;