Fix incorrect object iteration

main
Elbert Alias 7 years ago
parent 85ec4c6945
commit 727215463c

@ -114,12 +114,12 @@ class Driver {
headers[header[0]].push(header[1]);
});
let html = '';
try {
const html = browser.html();
html = browser.html();
} catch ( e ) {
this.wappalyzer.log(error.message, 'browser', 'error');
const html = '';
}
const vars = Object.getOwnPropertyNames(browser.window);

@ -68,7 +68,7 @@ class Wappalyzer {
if ( data.scripts ) {
this.analyzeScripts(app, data.scripts);
}
if ( data.headers ) {
this.analyzeHeaders(app, data.headers);
}
@ -181,13 +181,17 @@ class Wappalyzer {
* Enclose string in array
*/
asArray(value) {
return typeof value === 'string' ? [ value ] : value;
return value instanceof Array ? value : [ value ];
}
/**
* Parse apps.json patterns
*/
parsePatterns(patterns) {
if ( !patterns ) {
return [];
}
var parsed = {};
// Convert string to object containing array containing string
@ -197,7 +201,7 @@ class Wappalyzer {
};
}
for ( var key in patterns ) {
Object.keys(patterns).forEach(key => {
parsed[key] = [];
this.asArray(patterns[key]).forEach(pattern => {
@ -226,7 +230,7 @@ class Wappalyzer {
parsed[key].push(attrs);
});
}
});
// Convert back to array if the original pattern list was an array (or string)
if ( 'main' in parsed ) {