Gracefully handle removed technologies

main
Elbert Alias 4 years ago
parent 1cd2915f52
commit 781af50471

@ -275,7 +275,9 @@ const Driver = {
}) })
// Remove duplicates // Remove duplicates
cache.detections = cache.detections.concat(detections) cache.detections = cache.detections
.concat(detections)
.filter(({ technology }) => technology)
cache.detections.filter( cache.detections.filter(
({ technology: { name }, pattern: { regex } }, index) => ({ technology: { name }, pattern: { regex } }, index) =>
@ -309,20 +311,22 @@ const Driver = {
...cache, ...cache,
[hostname]: { [hostname]: {
...Driver.cache.hostnames[hostname], ...Driver.cache.hostnames[hostname],
detections: Driver.cache.hostnames[hostname].detections.map( detections: Driver.cache.hostnames[hostname].detections
({ .filter(({ technology }) => technology)
technology: { name: technology }, .map(
pattern: { regex, confidence }, ({
version technology: { name: technology },
}) => ({ pattern: { regex, confidence },
technology, version
pattern: { }) => ({
regex: regex.source, technology,
confidence pattern: {
}, regex: regex.source,
version confidence
}) },
) version
})
)
} }
}), }),
{} {}

@ -34,17 +34,19 @@ const Wappalyzer = {
let version = '' let version = ''
let confidence = 0 let confidence = 0
detections.forEach( detections
({ technology: { name }, pattern, version: _version = '' }) => { .filter(({ technology }) => technology)
if (name === technology.name) { .forEach(
confidence = Math.min(100, confidence + pattern.confidence) ({ technology: { name }, pattern, version: _version = '' }) => {
version = if (name === technology.name) {
_version.length > version.length && _version.length <= 10 confidence = Math.min(100, confidence + pattern.confidence)
? _version version =
: version _version.length > version.length && _version.length <= 10
? _version
: version
}
} }
} )
)
resolved.push({ technology, confidence, version }) resolved.push({ technology, confidence, version })
} }

Loading…
Cancel
Save