Filter ping payload

main
Elbert Alias 4 years ago
parent 9575493057
commit 4b53c4af1b

@ -263,12 +263,12 @@ const Driver = {
return return
} }
const { hostname } = new URL(url) const { protocol, hostname } = new URL(url)
// Cache detections // Cache detections
const cache = (Driver.cache.hostnames[hostname] = { const cache = (Driver.cache.hostnames[hostname] = {
...(Driver.cache.hostnames[hostname] || { ...(Driver.cache.hostnames[hostname] || {
url, url: `${protocol}//${hostname}`,
detections: [], detections: [],
hits: incrementHits ? 0 : 1 hits: incrementHits ? 0 : 1
}), }),
@ -508,47 +508,50 @@ const Driver = {
agent === 'chrome' || (await getOption('termsAccepted', false)) agent === 'chrome' || (await getOption('termsAccepted', false))
if (tracking && termsAccepted) { if (tracking && termsAccepted) {
const count = Object.keys(Driver.cache.hostnames).length const hostnames = Object.keys(Driver.cache.hostnames).reduce(
(hostnames, hostname) => {
// eslint-disable-next-line standard/computed-property-even-spacing
const { url, language, detections, hits } = Driver.cache.hostnames[
hostname
]
if (count && (count >= 50 || Driver.lastPing < Date.now() - expiry)) { if (
await Driver.post( /((local|dev(elopment)?|stag(e|ing)?|test(ing)?|demo(shop)?|admin|google|cache)\.|\/admin|\.local)/.test(
'https://api.wappalyzer.com/ping/v1/',
Object.keys(Driver.cache.hostnames).reduce((hostnames, hostname) => {
if (
/((local|dev(elopment)?|stag(e|ing)?|test(ing)?|demo(shop)?|admin|google|cache)\.|\/admin|\.local)/.test(
hostname
)
) {
return
}
// eslint-disable-next-line standard/computed-property-even-spacing
const { url, language, detections, hits } = Driver.cache.hostnames[
hostname hostname
] ) ||
hits < 3
hostnames[url] = hostnames[url] || { ) {
applications: resolve(detections).reduce( return
(technologies, { name, confidence, version }) => { }
if (confidence === 100) {
technologies[name] = { hostnames[url] = hostnames[url] || {
version, applications: resolve(detections).reduce(
hits (technologies, { name, confidence, version }) => {
} if (confidence === 100) {
technologies[name] = {
return technologies version,
hits
} }
},
{} return technologies
), }
meta: { },
language {}
} ),
meta: {
language
} }
}
return hostnames return hostnames
}, {}) },
) {}
)
const count = Object.keys(hostnames).length
if (count && (count >= 50 || Driver.lastPing < Date.now() - expiry)) {
await Driver.post('https://api.wappalyzer.com/ping/v1/', hostnames)
await setOption('hostnames', (Driver.cache.hostnames = {})) await setOption('hostnames', (Driver.cache.hostnames = {}))

Loading…
Cancel
Save