Fix for intermittent no detections issue

main
Elbert Alias 2 years ago
parent c3a3a05fc8
commit 1df71527a3

@ -12,7 +12,9 @@ const {
} = Wappalyzer } = Wappalyzer
const { agent, promisify, getOption, setOption, open, globEscape } = Utils const { agent, promisify, getOption, setOption, open, globEscape } = Utils
const expiry = 1000 * 60 * 60 * 24 const expiry = 1000 * 60 * 60 * 12
const maxHostnames = 100
const hostnameIgnoreList = const hostnameIgnoreList =
/\b((local|dev(elop(ment)?)?|sandbox|stag(e|ing)?|preprod|production|preview|test(ing)?|[^a-z]demo(shop)?|cache)[.-]|dev\d|localhost|((wappalyzer|google|bing|baidu|microsoft|duckduckgo|facebook|adobe|twitter|reddit|yahoo|wikipedia|amazon|amazonaws|youtube|stackoverflow|github|stackexchange|w3schools|twitch)\.)|(live|office|herokuapp|shopifypreview)\.com|\.local|\.test|\.netlify\.app|web\.archive\.org|zoom\.us|^([0-9.]+|[\d.]+)$|^([a-f0-9:]+:+)+[a-f0-9]+$)/ /\b((local|dev(elop(ment)?)?|sandbox|stag(e|ing)?|preprod|production|preview|test(ing)?|[^a-z]demo(shop)?|cache)[.-]|dev\d|localhost|((wappalyzer|google|bing|baidu|microsoft|duckduckgo|facebook|adobe|twitter|reddit|yahoo|wikipedia|amazon|amazonaws|youtube|stackoverflow|github|stackexchange|w3schools|twitch)\.)|(live|office|herokuapp|shopifypreview)\.com|\.local|\.test|\.netlify\.app|web\.archive\.org|zoom\.us|^([0-9.]+|[\d.]+)$|^([a-f0-9:]+:+)+[a-f0-9]+$)/
@ -593,18 +595,24 @@ const Driver = {
cache.language = cache.language || language cache.language = cache.language || language
// Expire cache // Expire cache
Driver.cache.hostnames = Object.keys(Driver.cache.hostnames).reduce( Driver.cache.hostnames = Object.keys(Driver.cache.hostnames)
(hostnames, hostname) => { .sort((a, b) =>
Driver.cache.hostnames[a].dateTime > Driver.cache.hostnames[b].dateTime
? -1
: 1
)
.reduce((hostnames, hostname) => {
const cache = Driver.cache.hostnames[hostname] const cache = Driver.cache.hostnames[hostname]
if (cache.dateTime > Date.now() - expiry) { if (
cache.dateTime > Date.now() - expiry &&
Object.keys(hostnames).length < maxHostnames
) {
hostnames[hostname] = cache hostnames[hostname] = cache
} }
return hostnames return hostnames
}, }, {})
{}
)
await setOption( await setOption(
'hostnames', 'hostnames',
@ -905,7 +913,7 @@ const Driver = {
const url = `http${https ? 's' : ''}://${hostname}` const url = `http${https ? 's' : ''}://${hostname}`
if (!hostnameIgnoreList.test(hostname) && hits >= 3) { if (!hostnameIgnoreList.test(hostname) && hits) {
urls[url] = urls[url] || { urls[url] = urls[url] || {
technologies: resolve(detections).reduce( technologies: resolve(detections).reduce(
(technologies, { name, confidence, version }) => { (technologies, { name, confidence, version }) => {
@ -939,7 +947,9 @@ const Driver = {
urls, urls,
}) })
await setOption('hostnames', (Driver.cache.hostnames = {})) Object.keys(Driver.cache.hostnames).forEach((hostname) => {
Driver.cache.hostnames[hostname].hits = 0
})
Driver.lastPing = Date.now() Driver.lastPing = Date.now()
} }

@ -565,6 +565,7 @@ const Popup = {
el.empty.classList.add('empty--hidden') el.empty.classList.add('empty--hidden')
el.detections.classList.remove('detections--hidden') el.detections.classList.remove('detections--hidden')
el.issue.classList.remove('issue--hidden')
el.plusDownload.classList.remove('plus-download--hidden') el.plusDownload.classList.remove('plus-download--hidden')
while (el.detections.firstChild) { while (el.detections.firstChild) {