From 50cb0ba2889eb8c2360fb5c1574e19987d660b78 Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Tue, 25 Jan 2022 07:39:05 +1100 Subject: [PATCH] Return match in extended output --- src/drivers/npm/driver.js | 3 ++- src/wappalyzer.js | 33 +++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index 51f180350..c11f16075 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -998,7 +998,7 @@ class Site { patterns, { technology: { name, implies, excludes }, - pattern: { regex, value, confidence, type, version }, + pattern: { regex, value, match, confidence, type, version }, } ) => { patterns[name] = patterns[name] || [] @@ -1007,6 +1007,7 @@ class Site { type, regex: regex.source, value: value.length <= 250 ? value : null, + match: match.length <= 250 ? match : null, confidence, version, implies: implies.map(({ name }) => name), diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 2d41342f5..a4481b4fa 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -554,10 +554,17 @@ const Wappalyzer = { return technology[type].reduce((technologies, pattern) => { const startTime = Date.now() - if (pattern.regex.test(value)) { + const matches = pattern.regex.exec(value) + + if (matches) { technologies.push({ technology, - pattern: { ...pattern, type, value }, + pattern: { + ...pattern, + type, + value, + match: matches[0], + }, version: Wappalyzer.resolveVersion(pattern, value), }) } @@ -581,10 +588,17 @@ const Wappalyzer = { patterns.forEach((pattern) => { const startTime = Date.now() - if (pattern.regex.test(value)) { + const matches = pattern.regex.exec(value) + + if (matches) { technologies.push({ technology, - pattern: { ...pattern, type, value }, + pattern: { + ...pattern, + type, + value, + match: matches[0], + }, version: Wappalyzer.resolveVersion(pattern, value), }) } @@ -618,10 +632,17 @@ const Wappalyzer = { values.forEach((value) => { const startTime = Date.now() - if (pattern.regex.test(value)) { + const matches = pattern.regex.exec(value) + + if (matches) { technologies.push({ technology, - pattern: { ...pattern, type, value }, + pattern: { + ...pattern, + type, + value, + match: matches[0], + }, version: Wappalyzer.resolveVersion(pattern, value), }) }