From 1a605c417135ad22854e88297f7fe47ce430c5c1 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Fri, 12 Jun 2020 09:25:11 +1000 Subject: [PATCH] Fix for implies with confidence value --- src/drivers/webextension/css/styles.css | 2 +- src/drivers/webextension/js/popup.js | 2 +- src/wappalyzer.js | 24 ++++++++++++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/drivers/webextension/css/styles.css b/src/drivers/webextension/css/styles.css index 9a0dac141..05136baca 100644 --- a/src/drivers/webextension/css/styles.css +++ b/src/drivers/webextension/css/styles.css @@ -153,7 +153,7 @@ a:hover { .technology__confidence { opacity: .5; font-size: .7rem; - margin-left: .2rem; + margin-left: .4rem; } .technology__version { diff --git a/src/drivers/webextension/js/popup.js b/src/drivers/webextension/js/popup.js index f0bad8266..b365cc5fa 100644 --- a/src/drivers/webextension/js/popup.js +++ b/src/drivers/webextension/js/popup.js @@ -133,7 +133,7 @@ const Popup = { ) technologies - .filter(({ confidence }) => confidence) + .filter(({ confidence }) => confidence >= 50) .forEach(({ name, slug, confidence, version, icon, website }) => { const technologyNode = Popup.templates.technology.cloneNode(true) diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 379b558a1..ea8a40698 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -108,7 +108,7 @@ const Wappalyzer = { resolveExcludes(resolved) { resolved.forEach(({ technology }) => { - technology.excludes.forEach((name) => { + technology.excludes.forEach(({ name }) => { const excluded = Wappalyzer.getTechnology(name) if (!excluded) { @@ -131,7 +131,7 @@ const Wappalyzer = { resolved.forEach(({ technology, confidence }) => { done = true - technology.implies.forEach((name) => { + technology.implies.forEach(({ name, confidence: _confidence }) => { const implied = Wappalyzer.getTechnology(name) if (!implied) { @@ -143,7 +143,11 @@ const Wappalyzer = { ({ technology: { name } }) => name === implied.name ) === -1 ) { - resolved.push({ technology: implied, confidence, version: '' }) + resolved.push({ + technology: implied, + confidence: Math.min(confidence, _confidence), + version: '' + }) done = false } @@ -209,8 +213,13 @@ const Wappalyzer = { meta: transform(meta), scripts: transform(script), js: transform(js), - implies: typeof implies === 'string' ? [implies] : implies || [], - excludes: typeof excludes === 'string' ? [excludes] : excludes || [], + implies: transform(implies).map(({ value, confidence }) => ({ + name: value, + confidence + })), + excludes: transform(excludes).map(({ value }) => ({ + name: value + })), icon: icon || 'default.svg', website: website || '' }) @@ -248,7 +257,7 @@ const Wappalyzer = { const parsed = Object.keys(patterns).reduce((parsed, key) => { parsed[key.toLowerCase()] = toArray(patterns[key]).map((pattern) => { - const { regex, confidence, version } = pattern + const { value, regex, confidence, version } = pattern .split('\\;') .reduce((attrs, attr, i) => { if (i) { @@ -259,6 +268,8 @@ const Wappalyzer = { attrs[attr.shift()] = attr.join(':') } } else { + attrs.value = attr + // Escape slashes in regular expression attrs.regex = new RegExp(attr.replace(/\//g, '\\/'), 'i') } @@ -267,6 +278,7 @@ const Wappalyzer = { }, {}) return { + value, regex, confidence: parseInt(confidence || 100, 10), version: version || ''