Fix excludes

main
Elbert Alias 7 years ago
parent 3ce87fe503
commit cfc43567d0

@ -102,14 +102,14 @@ class Wappalyzer {
Promise.all(promises) Promise.all(promises)
.then(() => { .then(() => {
Object.keys(apps).forEach(appName => { Object.keys(apps).forEach(appName => {
var app = apps[appName]; let app = apps[appName];
if ( !app.detected || !app.getConfidence() ) { if (!app.detected || !app.getConfidence()) {
delete apps[app.name]; delete apps[app.name];
} }
}); });
this.resolveExcludes(apps); this.resolveExcludes(apps, this.detected[url]);
this.resolveImplies(apps, url.canonical); this.resolveImplies(apps, url.canonical);
this.cacheDetectedApps(apps, url.canonical); this.cacheDetectedApps(apps, url.canonical);
@ -281,32 +281,32 @@ class Wappalyzer {
*/ */
parseJsPatterns() { parseJsPatterns() {
Object.keys(this.apps).forEach(appName => { Object.keys(this.apps).forEach(appName => {
if ( this.apps[appName].js ) { if (this.apps[appName].js) {
this.jsPatterns[appName] = this.parsePatterns(this.apps[appName].js); this.jsPatterns[appName] = this.parsePatterns(this.apps[appName].js);
} }
}); });
} }
resolveExcludes(apps) { resolveExcludes(apps, detected) {
var excludes = []; let excludes = [];
// Exclude app in detected apps only // Exclude app in detected apps only
Object.keys(apps).forEach(appName => { Object.keys(Object.assign({}, apps, detected)).forEach(appName => {
var app = apps[appName]; let app = apps[appName];
if ( app.props.excludes ) { if (app.props.excludes) {
this.asArray(app.props.excludes).forEach(excluded => { this.asArray(app.props.excludes).forEach(excluded => {
excludes.push(excluded); excludes.push(excluded);
}); });
} }
}) });
// 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];
} }
}) });
} }
resolveImplies(apps, url) { resolveImplies(apps, url) {
@ -351,17 +351,15 @@ class Wappalyzer {
*/ */
cacheDetectedApps(apps, url) { cacheDetectedApps(apps, url) {
Object.keys(apps).forEach(appName => { Object.keys(apps).forEach(appName => {
var app = apps[appName]; let app = apps[appName];
// Per URL // Per URL
this.detected[url][appName] = app; this.detected[url][appName] = app;
Object.keys(app.confidence).forEach(id => { Object.keys(app.confidence).forEach(id => this.detected[url][appName].confidence[id] = app.confidence[id]);
this.detected[url][appName].confidence[id] = app.confidence[id];
});
}) })
if ( this.driver.ping instanceof Function ) { if (this.driver.ping instanceof Function) {
this.ping(); this.ping();
} }
} }