From 781af5047128127fb9fc6feebe444157b9b9cbf4 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Thu, 18 Jun 2020 14:51:38 +1000 Subject: [PATCH] Gracefully handle removed technologies --- src/drivers/webextension/js/driver.js | 34 +++++++++++++++------------ src/wappalyzer.js | 22 +++++++++-------- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index 84713e98b..cb418f4b3 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -275,7 +275,9 @@ const Driver = { }) // Remove duplicates - cache.detections = cache.detections.concat(detections) + cache.detections = cache.detections + .concat(detections) + .filter(({ technology }) => technology) cache.detections.filter( ({ technology: { name }, pattern: { regex } }, index) => @@ -309,20 +311,22 @@ const Driver = { ...cache, [hostname]: { ...Driver.cache.hostnames[hostname], - detections: Driver.cache.hostnames[hostname].detections.map( - ({ - technology: { name: technology }, - pattern: { regex, confidence }, - version - }) => ({ - technology, - pattern: { - regex: regex.source, - confidence - }, - version - }) - ) + detections: Driver.cache.hostnames[hostname].detections + .filter(({ technology }) => technology) + .map( + ({ + technology: { name: technology }, + pattern: { regex, confidence }, + version + }) => ({ + technology, + pattern: { + regex: regex.source, + confidence + }, + version + }) + ) } }), {} diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 250728995..d00fc8e1d 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -34,17 +34,19 @@ const Wappalyzer = { let version = '' let confidence = 0 - detections.forEach( - ({ technology: { name }, pattern, version: _version = '' }) => { - if (name === technology.name) { - confidence = Math.min(100, confidence + pattern.confidence) - version = - _version.length > version.length && _version.length <= 10 - ? _version - : version + detections + .filter(({ technology }) => technology) + .forEach( + ({ technology: { name }, pattern, version: _version = '' }) => { + if (name === technology.name) { + confidence = Math.min(100, confidence + pattern.confidence) + version = + _version.length > version.length && _version.length <= 10 + ? _version + : version + } } - } - ) + ) resolved.push({ technology, confidence, version }) }