Performance improvements

main
Elbert Alias 3 years ago
parent 791fe5e828
commit 460a97d5d9

@ -10,10 +10,6 @@ const Wappalyzer = require('./wappalyzer')
const { setTechnologies, setCategories, analyze, analyzeManyToMany, resolve } = const { setTechnologies, setCategories, analyze, analyzeManyToMany, resolve } =
Wappalyzer Wappalyzer
function next() {
return new Promise((resolve) => setImmediate(resolve))
}
const { CHROMIUM_BIN, CHROMIUM_DATA_DIR, CHROMIUM_WEBSOCKET } = process.env const { CHROMIUM_BIN, CHROMIUM_DATA_DIR, CHROMIUM_WEBSOCKET } = process.env
const chromiumArgs = [ const chromiumArgs = [
@ -98,21 +94,16 @@ function getJs(page, technologies = Wappalyzer.technologies) {
}, technologies) }, technologies)
} }
async function analyzeJs(js, technologies = Wappalyzer.technologies) { function analyzeJs(js, technologies = Wappalyzer.technologies) {
return Array.prototype.concat.apply( return js
[], .map(({ name, chain, value }) => {
await Promise.all(
js.map(async ({ name, chain, value }) => {
await next()
return analyzeManyToMany( return analyzeManyToMany(
technologies.find(({ name: _name }) => name === _name), technologies.find(({ name: _name }) => name === _name),
'js', 'js',
{ [chain]: [value] } { [chain]: [value] }
) )
}) })
) .flat()
)
} }
function getDom(page, technologies = Wappalyzer.technologies) { function getDom(page, technologies = Wappalyzer.technologies) {
@ -200,25 +191,10 @@ function getDom(page, technologies = Wappalyzer.technologies) {
}, technologies) }, technologies)
} }
async function analyzeDom(dom, technologies = Wappalyzer.technologies) { function analyzeDom(dom, technologies = Wappalyzer.technologies) {
return Array.prototype.concat.apply( return dom
[], .map(({ name, selector, exists, text, property, attribute, value }) => {
await Promise.all( const technology = technologies.find(({ name: _name }) => name === _name)
dom.map(
async ({
name,
selector,
exists,
text,
property,
attribute,
value,
}) => {
await next()
const technology = technologies.find(
({ name: _name }) => name === _name
)
if (typeof exists !== 'undefined') { if (typeof exists !== 'undefined') {
return analyzeManyToMany(technology, 'dom.exists', { return analyzeManyToMany(technology, 'dom.exists', {
@ -239,20 +215,12 @@ async function analyzeDom(dom, technologies = Wappalyzer.technologies) {
} }
if (typeof attribute !== 'undefined') { if (typeof attribute !== 'undefined') {
return analyzeManyToMany( return analyzeManyToMany(technology, `dom.attributes.${attribute}`, {
technology,
`dom.attributes.${attribute}`,
{
[selector]: [value], [selector]: [value],
})
} }
) })
} .flat()
return []
}
)
)
)
} }
function get(url, options = {}) { function get(url, options = {}) {
@ -860,8 +828,7 @@ class Site {
await this.onDetect( await this.onDetect(
url, url,
( [
await Promise.all([
analyzeDom(dom), analyzeDom(dom),
analyzeJs(js), analyzeJs(js),
analyze({ analyze({
@ -874,8 +841,7 @@ class Site {
scriptSrc, scriptSrc,
meta, meta,
}), }),
]) ].flat()
).flat()
) )
const reducedLinks = Array.prototype.reduce.call( const reducedLinks = Array.prototype.reduce.call(
@ -1189,11 +1155,10 @@ class Site {
await this.onDetect( await this.onDetect(
url, url,
( [
await Promise.all([
analyzeDom(dom, technologies), analyzeDom(dom, technologies),
analyzeJs(js, technologies), analyzeJs(js, technologies),
analyze( await analyze(
{ {
url, url,
cookies, cookies,
@ -1206,8 +1171,7 @@ class Site {
}, },
technologies technologies
), ),
]) ].flat()
).flat()
) )
} }
}) })

@ -288,7 +288,9 @@ const Content = {
// Delayed second pass to capture async JS // Delayed second pass to capture async JS
await new Promise((resolve) => setTimeout(resolve, 5000)) await new Promise((resolve) => setTimeout(resolve, 5000))
await Content.onGetTechnologies(technologies) const js = await getJs(technologies)
await Content.driver('analyzeJs', [url, js])
} catch (error) { } catch (error) {
Content.driver('error', error) Content.driver('error', error)
} }

@ -1,6 +1,6 @@
'use strict' 'use strict'
/* eslint-env browser */ /* eslint-env browser */
/* globals chrome, Wappalyzer, Utils, next */ /* globals chrome, Wappalyzer, Utils */
const { const {
setTechnologies, setTechnologies,
@ -217,27 +217,22 @@ const Driver = {
* @param {String} url * @param {String} url
* @param {Array} js * @param {Array} js
*/ */
async analyzeJs(url, js, requires, categoryRequires) { analyzeJs(url, js, requires, categoryRequires) {
const technologies = const technologies =
getRequiredTechnologies(requires, categoryRequires) || getRequiredTechnologies(requires, categoryRequires) ||
Wappalyzer.technologies Wappalyzer.technologies
return Driver.onDetect( return Driver.onDetect(
url, url,
Array.prototype.concat.apply( js
[], .map(({ name, chain, value }) => {
await Promise.all(
js.map(async ({ name, chain, value }) => {
await next()
return analyzeManyToMany( return analyzeManyToMany(
technologies.find(({ name: _name }) => name === _name), technologies.find(({ name: _name }) => name === _name),
'js', 'js',
{ [chain]: [value] } { [chain]: [value] }
) )
}) })
) .flat()
)
) )
}, },
@ -246,23 +241,19 @@ const Driver = {
* @param {String} url * @param {String} url
* @param {Array} dom * @param {Array} dom
*/ */
async analyzeDom(url, dom, requires, categoryRequires) { analyzeDom(url, dom, requires, categoryRequires) {
const technologies = const technologies =
getRequiredTechnologies(requires, categoryRequires) || getRequiredTechnologies(requires, categoryRequires) ||
Wappalyzer.technologies Wappalyzer.technologies
return Driver.onDetect( return Driver.onDetect(
url, url,
Array.prototype.concat.apply( dom
[], .map(
await Promise.all( (
dom.map(
async (
{ name, selector, exists, text, property, attribute, value }, { name, selector, exists, text, property, attribute, value },
index index
) => { ) => {
await next()
const technology = technologies.find( const technology = technologies.find(
({ name: _name }) => name === _name ({ name: _name }) => name === _name
) )
@ -298,12 +289,9 @@ const Driver = {
} }
) )
} }
return []
} }
) )
) .flat()
)
) )
}, },
@ -673,11 +661,7 @@ const Driver = {
), ),
] ]
try { Driver.content(url, 'analyzeRequires', [url, requires])
await Driver.content(url, 'analyzeRequires', [url, requires])
} catch (error) {
// Continue
}
await Driver.setIcon(url, resolved) await Driver.setIcon(url, resolved)

@ -1105,7 +1105,7 @@
], ],
"description": "LottieFiles is an open-source animation file format that's tiny, high quality, interactive, and can be manipulated at runtime.", "description": "LottieFiles is an open-source animation file format that's tiny, high quality, interactive, and can be manipulated at runtime.",
"icon": "LottieFiles.svg", "icon": "LottieFiles.svg",
"dom": "clipPath[id*='__lottie_element_']", "dom": "lottie-player, div[data-animation-type='lottie'], div[data-testid='lottie-player'], clipPath[id*='__lottie_element_']",
"scriptSrc": [ "scriptSrc": [
"/dist/lottie-player\\.js", "/dist/lottie-player\\.js",
"/dist/tgs-player\\.js" "/dist/tgs-player\\.js"