Add resilience for cases where Array has been extended (#2287)

main
Patrick Meenan 7 years ago committed by Elbert Alias
parent 49b3db1d8d
commit 98f8691b70

@ -92,7 +92,9 @@ class Wappalyzer {
if ( data.js ) { if ( data.js ) {
Object.keys(data.js).forEach(appName => { Object.keys(data.js).forEach(appName => {
promises.push(this.analyzeJs(apps[appName], data.js[appName])); if (typeof data.js[appName] != 'function') {
promises.push(this.analyzeJs(apps[appName], data.js[appName]));
}
}); });
} }
@ -296,7 +298,7 @@ class Wappalyzer {
// Remove excluded applications // Remove excluded applications
Object.keys(apps).forEach(appName => { Object.keys(apps).forEach(appName => {
if ( excludes.indexOf(appName) !== -1 ) { if ( excludes.indexOf(appName) > -1 ) {
delete apps[appName]; delete apps[appName];
} }
}) })
@ -495,17 +497,19 @@ class Wappalyzer {
const promises = []; const promises = [];
Object.keys(patterns).forEach(headerName => { Object.keys(patterns).forEach(headerName => {
promises.push(this.asyncForEach(patterns[headerName], pattern => { if (typeof patterns[headerName] != 'function') {
headerName = headerName.toLowerCase(); promises.push(this.asyncForEach(patterns[headerName], pattern => {
headerName = headerName.toLowerCase();
if ( headerName in headers ) {
headers[headerName].forEach(headerValue => { if ( headerName in headers ) {
if ( pattern.regex.test(headerValue) ) { headers[headerName].forEach(headerValue => {
this.addDetected(app, pattern, 'headers', headerValue, headerName); if ( pattern.regex.test(headerValue) ) {
} this.addDetected(app, pattern, 'headers', headerValue, headerName);
}); }
} });
})); }
}));
}
}); });
return promises ? Promise.all(promises) : Promise.resolve(); return promises ? Promise.all(promises) : Promise.resolve();
@ -519,15 +523,17 @@ class Wappalyzer {
const promises = []; const promises = [];
Object.keys(patterns).forEach(cookieName => { Object.keys(patterns).forEach(cookieName => {
cookieName = cookieName.toLowerCase(); if (typeof patterns[cookieName] != 'function') {
cookieName = cookieName.toLowerCase();
promises.push(this.asyncForEach(patterns[cookieName], pattern => { promises.push(this.asyncForEach(patterns[cookieName], pattern => {
const cookie = cookies.find(cookie => cookie.name.toLowerCase() === cookieName); const cookie = cookies.find(cookie => cookie.name.toLowerCase() === cookieName);
if ( cookie && pattern.regex.test(cookie.value) ) { if ( cookie && pattern.regex.test(cookie.value) ) {
this.addDetected(app, pattern, 'cookies', cookie.value, cookieName); this.addDetected(app, pattern, 'cookies', cookie.value, cookieName);
} }
})); }));
}
}); });
return promises ? Promise.all(promises) : Promise.resolve(); return promises ? Promise.all(promises) : Promise.resolve();
@ -540,14 +546,16 @@ class Wappalyzer {
const promises = []; const promises = [];
Object.keys(results).forEach(string => { Object.keys(results).forEach(string => {
promises.push(this.asyncForEach(Object.keys(results[string]), index => { if (typeof results[string] != 'function') {
const pattern = this.jsPatterns[app.name][string][index]; promises.push(this.asyncForEach(Object.keys(results[string]), index => {
const value = results[string][index]; const pattern = this.jsPatterns[app.name][string][index];
const value = results[string][index];
if ( pattern && pattern.regex.test(value) ) { if ( pattern && pattern.regex.test(value) ) {
this.addDetected(app, pattern, 'js', value); this.addDetected(app, pattern, 'js', value);
} }
})); }));
}
}); });
return promises ? Promise.all(promises) : Promise.resolve(); return promises ? Promise.all(promises) : Promise.resolve();