Add language detection

main
Elbert Alias 7 years ago
parent 62de97a496
commit 0f9cc90553

@ -31,6 +31,7 @@ class Driver {
this.origPageUrl = url.parse(pageUrl);
this.analyzedPageUrls = [];
this.apps = [];
this.meta = {};
this.wappalyzer = new Wappalyzer();
@ -38,7 +39,7 @@ class Driver {
this.wappalyzer.categories = json.categories;
this.wappalyzer.driver.log = (message, source, type) => this.log(message, source, type);
this.wappalyzer.driver.displayApps = detected => this.displayApps(detected);
this.wappalyzer.driver.displayApps = (detected, meta, context) => this.displayApps(detected, meta, context);
}
analyze() {
@ -54,9 +55,11 @@ class Driver {
this.options.debug && console.log('[wappalyzer ' + type + ']', '[' + source + ']', message);
}
displayApps(detected) {
displayApps(detected, meta) {
this.timer('displayApps');
this.meta = meta;
Object.keys(detected).forEach(appName => {
const app = detected[appName];
@ -179,7 +182,10 @@ class Driver {
.then(() => {
this.timer('done');
resolve(this.apps)
resolve({
applications: this.apps,
meta: this.meta
});
});
});
}

@ -211,7 +211,7 @@ wappalyzer.driver.log = (message, source, type) => {
/**
* Display apps
*/
wappalyzer.driver.displayApps = (detected, context) => {
wappalyzer.driver.displayApps = (detected, meta, context) => {
var tab = context.tab;
tabCache[tab.id] = tabCache[tab.id] || { detected: [] };

@ -51,6 +51,11 @@ class Wappalyzer {
this.detected[url] = {};
}
// Additional information
const matches = data.html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i);
const language = matches && matches.length ? matches[1] : null;
Object.keys(this.apps).forEach(appName => {
apps[appName] = this.detected[url] && this.detected[url][appName] ? this.detected[url][appName] : new Application(appName, this.apps[appName]);
@ -94,13 +99,13 @@ class Wappalyzer {
this.resolveImplies(apps, url);
this.cacheDetectedApps(apps, url);
this.trackDetectedApps(apps, url, hostname, data.html);
this.trackDetectedApps(apps, url, hostname, language);
if ( Object.keys(apps).length ) {
this.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core');
}
this.driver.displayApps(this.detected[url], context);
this.driver.displayApps(this.detected[url], { language }, context);
}
/**
@ -326,7 +331,7 @@ class Wappalyzer {
/**
* Track detected applications
*/
trackDetectedApps(apps, url, hostname, html) {
trackDetectedApps(apps, url, hostname, language) {
if ( !( this.driver.ping instanceof Function ) ) {
return;
}
@ -362,13 +367,8 @@ class Wappalyzer {
}
});
// Additional information
if ( hostname in this.hostnameCache ) {
var match = html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i);
if ( match && match.length ) {
this.hostnameCache[hostname].meta['language'] = match[1];
}
this.hostnameCache[hostname].meta['language'] = language;
}
this.ping();

Loading…
Cancel
Save