Change wappalyzer object to Wappalyzer class to allow running of multiple instances

main
Elbert Alias 7 years ago
parent f0654e5bc0
commit 3057e396d9

@ -1,19 +1,21 @@
'use strict'; 'use strict';
const wappalyzer = require('./wappalyzer'); const Wappalyzer = require('./wappalyzer');
const request = require('request'); const request = require('request');
const fs = require('fs'); const fs = require('fs');
const Browser = require('zombie'); const Browser = require('zombie');
const json = JSON.parse(fs.readFileSync(__dirname + '/apps.json')); const json = JSON.parse(fs.readFileSync(__dirname + '/apps.json'));
wappalyzer.apps = json.apps;
wappalyzer.categories = json.categories;
const driver = { const driver = {
quiet: true, quiet: true,
analyze: url => { analyze: url => {
const wappalyzer = new Wappalyzer();
wappalyzer.apps = json.apps;
wappalyzer.categories = json.categories;
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wappalyzer.driver.log = (message, source, type) => { wappalyzer.driver.log = (message, source, type) => {
if ( type === 'error' ) { if ( type === 'error' ) {
@ -51,6 +53,8 @@ const driver = {
}); });
}); });
console.log('resolve ' + url);
resolve(apps); resolve(apps);
}; };

@ -2,7 +2,7 @@
"name": "wappalyzer", "name": "wappalyzer",
"description": "Uncovers the technologies used on websites", "description": "Uncovers the technologies used on websites",
"homepage": "https://github.com/AliasIO/Wappalyzer", "homepage": "https://github.com/AliasIO/Wappalyzer",
"version": "5.0.5", "version": "5.0.7",
"author": "Elbert Alias", "author": "Elbert Alias",
"license": "GPL-3.0", "license": "GPL-3.0",
"repository": { "repository": {

@ -3,7 +3,9 @@
*/ */
/** global: browser */ /** global: browser */
/** global: wappalyzer */ /** global: Wappalyzer */
const wappalyzer = new Wappalyzer();
var tabCache = {}; var tabCache = {};
var headersCache = {}; var headersCache = {};

@ -4,7 +4,7 @@
"author": "Elbert Alias", "author": "Elbert Alias",
"homepage_url": "https://wappalyzer.com/", "homepage_url": "https://wappalyzer.com/",
"description": "Identify web technologies", "description": "Identify web technologies",
"version": "5.0.5", "version": "5.0.7",
"default_locale": "en", "default_locale": "en",
"manifest_version": 2, "manifest_version": 2,
"icons": { "icons": {

@ -4,7 +4,7 @@
"author": "Elbert Alias", "author": "Elbert Alias",
"homepage_url": "https://wappalyzer.com/", "homepage_url": "https://wappalyzer.com/",
"description": "Identify web technologies", "description": "Identify web technologies",
"version": "5.0.5", "version": "5.0.7",
"default_locale": "en", "default_locale": "en",
"manifest_version": 2, "manifest_version": 2,
"icons": { "icons": {

@ -13,517 +13,519 @@ const validation = {
hostnameBlacklist: /((local|dev(elopment)?|stag(e|ing)?|test(ing)?|demo(shop)?|admin|google|cache)\.|\/admin|\.local)/ hostnameBlacklist: /((local|dev(elopment)?|stag(e|ing)?|test(ing)?|demo(shop)?|admin|google|cache)\.|\/admin|\.local)/
}; };
var wappalyzer = { class Wappalyzer {
apps: {}, constructor() {
categories: {}, this.apps = {};
driver: {} this.categories = {};
}; this.driver = {};
this.detected = {};
this.hostnameCache = {};
this.adCache = [];
this.config = {
websiteURL: 'https://wappalyzer.com/',
twitterURL: 'https://twitter.com/Wappalyzer',
githubURL: 'https://github.com/AliasIO/Wappalyzer',
};
}
var detected = {}; /**
var hostnameCache = {}; * Log messages to console
var adCache = []; */
log(message, source, type) {
this.driver.log(message, source || '', type || 'debug');
}
wappalyzer.config = { analyze(hostname, url, data, context) {
websiteURL: 'https://wappalyzer.com/', var apps = {};
twitterURL: 'https://twitter.com/Wappalyzer',
githubURL: 'https://github.com/AliasIO/Wappalyzer',
};
/** // Remove hash from URL
* Log messages to console data.url = url = url.split('#')[0];
*/
wappalyzer.log = (message, source, type) => {
wappalyzer.driver.log(message, source || '', type || 'debug');
};
wappalyzer.analyze = (hostname, url, data, context) => { if ( typeof data.html !== 'string' ) {
var apps = {}; data.html = '';
}
// Remove hash from URL
data.url = url = url.split('#')[0];
if ( typeof data.html !== 'string' ) { if ( this.detected[url] === undefined ) {
data.html = ''; this.detected[url] = {};
} }
if ( detected[url] === undefined ) { Object.keys(this.apps).forEach(appName => {
detected[url] = {}; apps[appName] = this.detected[url] && this.detected[url][appName] ? this.detected[url][appName] : new Application(appName, this.apps[appName]);
}
Object.keys(wappalyzer.apps).forEach(appName => { var app = apps[appName];
apps[appName] = detected[url] && detected[url][appName] ? detected[url][appName] : new Application(appName, wappalyzer.apps[appName]);
var app = apps[appName]; if ( url ) {
this.analyzeUrl(app, url);
}
if ( url ) { if ( data.html ) {
analyzeUrl(app, url); this.analyzeHtml(app, data.html);
} this.analyzeScript(app, data.html);
this.analyzeMeta(app, data.html);
}
if ( data.html ) { if ( data.headers ) {
analyzeHtml(app, data.html); this.analyzeHeaders(app, data.headers);
analyzeScript(app, data.html); }
analyzeMeta(app, data.html);
}
if ( data.headers ) { if ( data.env ) {
analyzeHeaders(app, data.headers); this.analyzeEnv(app, data.env);
} }
if ( data.env ) { if ( data.robotsTxt ) {
analyzeEnv(app, data.env); this.analyzeRobotsTxt(app, data.robotsTxt);
} }
})
if ( data.robotsTxt ) { Object.keys(apps).forEach(appName => {
analyzeRobotsTxt(app, data.robotsTxt); var app = apps[appName];
}
})
Object.keys(apps).forEach(appName => { if ( !app.detected || !app.getConfidence() ) {
var app = apps[appName]; delete apps[app.name];
}
});
if ( !app.detected || !app.getConfidence() ) { this.resolveExcludes(apps);
delete apps[app.name]; this.resolveImplies(apps, url);
}
});
resolveExcludes(apps); this.cacheDetectedApps(apps, url);
resolveImplies(apps, url); this.trackDetectedApps(apps, url, hostname, data.html);
cacheDetectedApps(apps, url); if ( Object.keys(apps).length ) {
trackDetectedApps(apps, url, hostname, data.html); this.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core');
}
if ( Object.keys(apps).length ) { this.driver.displayApps(this.detected[url], context);
wappalyzer.log(Object.keys(apps).length + ' apps detected: ' + Object.keys(apps).join(', ') + ' on ' + url, 'core');
} }
wappalyzer.driver.displayApps(detected[url], context); /**
} * Cache detected ads
*/
cacheDetectedAds(ad) {
this.adCache.push(ad);
}
/** /**
* Cache detected ads *
*/ */
wappalyzer.cacheDetectedAds = ad => { robotsTxtAllows(url) {
adCache.push(ad); return new Promise((resolve, reject) => {
} var parsed = this.parseUrl(url);
this.driver.getRobotsTxt(parsed.host, parsed.protocol === 'https:')
.then(robotsTxt => {
robotsTxt.forEach(disallow => {
if ( parsed.pathname.indexOf(disallow) === 0 ) {
reject();
}
});
/** resolve();
*
*/
wappalyzer.robotsTxtAllows = url => {
return new Promise((resolve, reject) => {
var parsed = wappalyzer.parseUrl(url);
wappalyzer.driver.getRobotsTxt(parsed.host, parsed.protocol === 'https:')
.then(robotsTxt => {
robotsTxt.forEach(disallow => {
if ( parsed.pathname.indexOf(disallow) === 0 ) {
reject();
}
}); });
});
};
resolve(); /**
}); * Parse a URL
}); */
}; parseUrl(url) {
var a = this.driver.document.createElement('a');
/**
* Parse a URL
*/
wappalyzer.parseUrl = url => {
var a = wappalyzer.driver.document.createElement('a');
a.href = url; a.href = url;
a.canonical = a.protocol + '//' + a.host + a.pathname; a.canonical = a.protocol + '//' + a.host + a.pathname;
return a; return a;
} }
/** /**
* *
*/ */
wappalyzer.parseRobotsTxt = robotsTxt => { parseRobotsTxt(robotsTxt) {
var userAgent; var userAgent;
var disallow = []; var disallow = [];
robotsTxt.split('\n').forEach(line => { robotsTxt.split('\n').forEach(line => {
var matches = /^User-agent:\s*(.+)$/i.exec(line); var matches = /^User-agent:\s*(.+)$/i.exec(line);
if ( matches ) { if ( matches ) {
userAgent = matches[1].toLowerCase(); userAgent = matches[1].toLowerCase();
} else { } else {
if ( userAgent === '*' || userAgent === 'wappalyzer' ) { if ( userAgent === '*' || userAgent === 'wappalyzer' ) {
matches = /^Disallow:\s*(.+)$/i.exec(line); matches = /^Disallow:\s*(.+)$/i.exec(line);
if ( matches ) { if ( matches ) {
disallow.push(matches[1]); disallow.push(matches[1]);
}
} }
} }
} });
});
return disallow;
}
/**
*
*/
wappalyzer.ping = () => {
if ( Object.keys(hostnameCache).length >= 50 || adCache.length >= 50 ) {
wappalyzer.driver.ping(hostnameCache, adCache);
hostnameCache = {}; return disallow;
adCache = [];
} }
}
/** /**
* Enclose string in array *
*/ */
function asArray(value) { ping() {
return typeof value === 'string' ? [ value ] : value; if ( Object.keys(this.hostnameCache).length >= 50 || this.adCache.length >= 50 ) {
} this.driver.ping(this.hostnameCache, this.adCache);
/**
* Parse apps.json patterns
*/
function parsePatterns(patterns) {
var parsed = {};
// Convert string to object containing array containing string this.hostnameCache = {};
if ( typeof patterns === 'string' || patterns instanceof Array ) { this.adCache = [];
patterns = { }
main: asArray(patterns)
};
} }
for ( var key in patterns ) { /**
parsed[key] = []; * Enclose string in array
*/
asArray(patterns[key]).forEach(pattern => { asArray(value) {
var attrs = {}; return typeof value === 'string' ? [ value ] : value;
}
pattern.split('\\;').forEach((attr, i) => {
if ( i ) {
// Key value pairs
attr = attr.split(':');
if ( attr.length > 1 ) {
attrs[attr.shift()] = attr.join(':');
}
} else {
attrs.string = attr;
try { /**
attrs.regex = new RegExp(attr.replace('/', '\/'), 'i'); // Escape slashes in regular expression * Parse apps.json patterns
} catch (e) { */
attrs.regex = new RegExp(); parsePatterns(patterns) {
var parsed = {};
// Convert string to object containing array containing string
if ( typeof patterns === 'string' || patterns instanceof Array ) {
patterns = {
main: this.asArray(patterns)
};
}
wappalyzer.log(e + ': ' + attr, 'error', 'core'); for ( var key in patterns ) {
} parsed[key] = [];
}
});
parsed[key].push(attrs); this.asArray(patterns[key]).forEach(pattern => {
}); var attrs = {};
}
// Convert back to array if the original pattern list was an array (or string) pattern.split('\\;').forEach((attr, i) => {
if ( 'main' in parsed ) { if ( i ) {
parsed = parsed.main; // Key value pairs
} attr = attr.split(':');
return parsed; if ( attr.length > 1 ) {
} attrs[attr.shift()] = attr.join(':');
}
} else {
attrs.string = attr;
function resolveExcludes(apps) { try {
var excludes = []; attrs.regex = new RegExp(attr.replace('/', '\/'), 'i'); // Escape slashes in regular expression
} catch (e) {
attrs.regex = new RegExp();
// Exclude app in detected apps only this.log(e + ': ' + attr, 'error', 'core');
Object.keys(apps).forEach(appName => { }
var app = apps[appName]; }
});
if ( app.props.excludes ) { parsed[key].push(attrs);
asArray(app.props.excludes).forEach(excluded => {
excludes.push(excluded);
}); });
} }
})
// Remove excluded applications // Convert back to array if the original pattern list was an array (or string)
Object.keys(apps).forEach(appName => { if ( 'main' in parsed ) {
if ( excludes.indexOf(appName) !== -1 ) { parsed = parsed.main;
delete apps[appName];
} }
})
}
function resolveImplies(apps, url) { return parsed;
var checkImplies = true; }
// Implied applications resolveExcludes(apps) {
// Run several passes as implied apps may imply other apps var excludes = [];
while ( checkImplies ) {
checkImplies = false;
// Exclude app in detected apps only
Object.keys(apps).forEach(appName => { Object.keys(apps).forEach(appName => {
var app = apps[appName]; var app = apps[appName];
if ( app && app.implies ) { if ( app.props.excludes ) {
asArray(app.props.implies).forEach(implied => { this.asArray(app.props.excludes).forEach(excluded => {
implied = parsePatterns(implied)[0]; excludes.push(excluded);
if ( !wappalyzer.apps[implied.string] ) {
wappalyzer.log('Implied application ' + implied.string + ' does not exist', 'core', 'warn');
return;
}
if ( !( implied.string in apps ) ) {
apps[implied.string] = detected[url] && detected[url][implied.string] ? detected[url][implied.string] : new Application(implied.string, true);
checkImplies = true;
}
// Apply app confidence to implied app
Object.keys(app.confidence).forEach(id => {
apps[implied.string].confidence[id + ' implied by ' + appName] = app.confidence[id] * ( implied.confidence ? implied.confidence / 100 : 1 );
});
}); });
} }
}); })
}
}
/** // Remove excluded applications
* Cache detected applications Object.keys(apps).forEach(appName => {
*/ if ( excludes.indexOf(appName) !== -1 ) {
function cacheDetectedApps(apps, url) { delete apps[appName];
if (!wappalyzer.driver.ping instanceof Function) return; }
})
}
Object.keys(apps).forEach(appName => { resolveImplies(apps, url) {
var app = apps[appName]; var checkImplies = true;
// Per URL // Implied applications
detected[url][appName] = app; // Run several passes as implied apps may imply other apps
while ( checkImplies ) {
checkImplies = false;
Object.keys(app.confidence).forEach(id => { Object.keys(apps).forEach(appName => {
detected[url][appName].confidence[id] = app.confidence[id]; var app = apps[appName];
});
})
wappalyzer.ping(); if ( app && app.implies ) {
} this.asArray(app.props.implies).forEach(implied => {
implied = this.parsePatterns(implied)[0];
/** if ( !this.apps[implied.string] ) {
* Track detected applications this.log('Implied application ' + implied.string + ' does not exist', 'core', 'warn');
*/
function trackDetectedApps(apps, url, hostname, html) {
if (!wappalyzer.driver.ping instanceof Function) return;
Object.keys(apps).forEach(appName => {
var app = apps[appName];
if ( detected[url][appName].getConfidence() >= 100 ) {
if ( validation.hostname.test(hostname) && !validation.hostnameBlacklist.test(url) ) {
wappalyzer.robotsTxtAllows(url)
.then(() => {
if ( !( hostname in hostnameCache ) ) {
hostnameCache[hostname] = {
applications: {},
meta: {}
};
}
if ( !( appName in hostnameCache[hostname].applications ) ) { return;
hostnameCache[hostname].applications[appName] = {
hits: 0
};
} }
hostnameCache[hostname].applications[appName].hits ++; if ( !( implied.string in apps ) ) {
apps[implied.string] = this.detected[url] && this.detected[url][implied.string] ? this.detected[url][implied.string] : new Application(implied.string, true);
if ( apps[appName].version ) { checkImplies = true;
hostnameCache[hostname].applications[appName].version = app.version;
} }
})
.catch(() => console.log('Disallowed in robots.txt: ' + url)) // Apply app confidence to implied app
} Object.keys(app.confidence).forEach(id => {
apps[implied.string].confidence[id + ' implied by ' + appName] = app.confidence[id] * ( implied.confidence ? implied.confidence / 100 : 1 );
});
});
}
});
} }
}); }
// Additional information /**
if ( hostname in hostnameCache ) { * Cache detected applications
var match = html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i); */
cacheDetectedApps(apps, url) {
if (!this.driver.ping instanceof Function) return;
if ( match && match.length ) { Object.keys(apps).forEach(appName => {
hostnameCache[hostname].meta['language'] = match[1]; var app = apps[appName];
}
// Per URL
this.detected[url][appName] = app;
Object.keys(app.confidence).forEach(id => {
this.detected[url][appName].confidence[id] = app.confidence[id];
});
})
this.ping();
} }
wappalyzer.ping(); /**
} * Track detected applications
*/
trackDetectedApps(apps, url, hostname, html) {
if (!this.driver.ping instanceof Function) return;
/** Object.keys(apps).forEach(appName => {
* Analyze URL var app = apps[appName];
*/
function analyzeUrl(app, url) {
var patterns = parsePatterns(app.props.url);
if ( patterns.length ) { if ( this.detected[url][appName].getConfidence() >= 100 ) {
patterns.forEach(pattern => { if ( validation.hostname.test(hostname) && !validation.hostnameBlacklist.test(url) ) {
if ( pattern.regex.test(url) ) { this.robotsTxtAllows(url)
addDetected(app, pattern, 'url', url); .then(() => {
if ( !( hostname in this.hostnameCache ) ) {
this.hostnameCache[hostname] = {
applications: {},
meta: {}
};
}
if ( !( appName in this.hostnameCache[hostname].applications ) ) {
this.hostnameCache[hostname].applications[appName] = {
hits: 0
};
}
this.hostnameCache[hostname].applications[appName].hits ++;
if ( apps[appName].version ) {
this.hostnameCache[hostname].applications[appName].version = app.version;
}
})
.catch(() => console.log('Disallowed in robots.txt: ' + url))
}
} }
}); });
}
}
/** // Additional information
* Analyze HTML if ( hostname in this.hostnameCache ) {
*/ var match = html.match(/<html[^>]*[: ]lang="([a-z]{2}((-|_)[A-Z]{2})?)"/i);
function analyzeHtml(app, html) {
var patterns = parsePatterns(app.props.html);
if ( patterns.length ) { if ( match && match.length ) {
patterns.forEach(pattern => { this.hostnameCache[hostname].meta['language'] = match[1];
if ( pattern.regex.test(html) ) {
addDetected(app, pattern, 'html', html);
} }
}); }
this.ping();
} }
}
/** /**
* Analyze script tag * Analyze URL
*/ */
function analyzeScript(app, html) { analyzeUrl(app, url) {
var regex = new RegExp('<script[^>]+src=("|\')([^"\']+)', 'ig'); var patterns = this.parsePatterns(app.props.url);
var patterns = parsePatterns(app.props.script);
if ( patterns.length ) { if ( patterns.length ) {
patterns.forEach(pattern => { patterns.forEach(pattern => {
var match; if ( pattern.regex.test(url) ) {
this.addDetected(app, pattern, 'url', url);
}
});
}
}
/**
* Analyze HTML
*/
analyzeHtml(app, html) {
var patterns = this.parsePatterns(app.props.html);
while ( ( match = regex.exec(html) ) ) { if ( patterns.length ) {
if ( pattern.regex.test(match[2]) ) { patterns.forEach(pattern => {
addDetected(app, pattern, 'script', match[2]); if ( pattern.regex.test(html) ) {
this.addDetected(app, pattern, 'html', html);
} }
} });
}); }
} }
}
/** /**
* Analyze meta tag * Analyze script tag
*/ */
function analyzeMeta(app, html) { analyzeScript(app, html) {
var regex = /<meta[^>]+>/ig; var regex = new RegExp('<script[^>]+src=("|\')([^"\']+)', 'ig');
var patterns = parsePatterns(app.props.meta); var patterns = this.parsePatterns(app.props.script);
var content;
var match; if ( patterns.length ) {
patterns.forEach(pattern => {
while ( patterns && ( match = regex.exec(html) ) ) { var match;
for ( var meta in patterns ) {
if ( new RegExp('(name|property)=["\']' + meta + '["\']', 'i').test(match) ) { while ( ( match = regex.exec(html) ) ) {
content = match.toString().match(/content=("|')([^"']+)("|')/i); if ( pattern.regex.test(match[2]) ) {
this.addDetected(app, pattern, 'script', match[2]);
patterns[meta].forEach(pattern => {
if ( content && content.length === 4 && pattern.regex.test(content[2]) ) {
addDetected(app, pattern, 'meta', content[2], meta);
} }
}); }
});
}
}
/**
* Analyze meta tag
*/
analyzeMeta(app, html) {
var regex = /<meta[^>]+>/ig;
var patterns = this.parsePatterns(app.props.meta);
var content;
var match;
while ( patterns && ( match = regex.exec(html) ) ) {
for ( var meta in patterns ) {
if ( new RegExp('(name|property)=["\']' + meta + '["\']', 'i').test(match) ) {
content = match.toString().match(/content=("|')([^"']+)("|')/i);
patterns[meta].forEach(pattern => {
if ( content && content.length === 4 && pattern.regex.test(content[2]) ) {
this.addDetected(app, pattern, 'meta', content[2], meta);
}
});
}
} }
} }
} }
}
/** /**
* analyze response headers * analyze response headers
*/ */
function analyzeHeaders(app, headers) { analyzeHeaders(app, headers) {
var patterns = parsePatterns(app.props.headers); var patterns = this.parsePatterns(app.props.headers);
if ( headers ) { if ( headers ) {
Object.keys(patterns).forEach(header => { Object.keys(patterns).forEach(header => {
patterns[header].forEach(pattern => { patterns[header].forEach(pattern => {
header = header.toLowerCase(); header = header.toLowerCase();
if ( header in headers && pattern.regex.test(headers[header]) ) { if ( header in headers && pattern.regex.test(headers[header]) ) {
addDetected(app, pattern, 'headers', headers[header], header); this.addDetected(app, pattern, 'headers', headers[header], header);
} }
});
}); });
}); }
} }
}
/** /**
* Analyze environment variables * Analyze environment variables
*/ */
function analyzeEnv(app, envs) { analyzeEnv(app, envs) {
var patterns = parsePatterns(app.props.env); var patterns = this.parsePatterns(app.props.env);
if ( patterns.length ) { if ( patterns.length ) {
patterns.forEach(pattern => { patterns.forEach(pattern => {
Object.keys(envs).forEach(env => { Object.keys(envs).forEach(env => {
if ( pattern.regex.test(envs[env]) ) { if ( pattern.regex.test(envs[env]) ) {
addDetected(app, pattern, 'env', envs[env]); this.addDetected(app, pattern, 'env', envs[env]);
} }
}) })
}); });
}
} }
}
/** /**
* Analyze robots.txt * Analyze robots.txt
*/ */
function analyzeRobotsTxt(app, robotsTxt) { analyzeRobotsTxt(app, robotsTxt) {
var patterns = parsePatterns(app.props.robotsTxt); var patterns = this.parsePatterns(app.props.robotsTxt);
if ( patterns.length ) { if ( patterns.length ) {
patterns.forEach(pattern => { patterns.forEach(pattern => {
if ( pattern.regex.test(robotsTxt) ) { if ( pattern.regex.test(robotsTxt) ) {
addDetected(app, pattern, 'robotsTxt', robotsTxt); this.addDetected(app, pattern, 'robotsTxt', robotsTxt);
} }
}); });
}
} }
}
/** /**
* Mark application as detected, set confidence and version * Mark application as detected, set confidence and version
*/ */
function addDetected(app, pattern, type, value, key) { addDetected(app, pattern, type, value, key) {
app.detected = true; app.detected = true;
// Set confidence level // Set confidence level
app.confidence[type + ' ' + ( key ? key + ' ' : '' ) + pattern.regex] = pattern.confidence || 100; app.confidence[type + ' ' + ( key ? key + ' ' : '' ) + pattern.regex] = pattern.confidence || 100;
// Detect version number // Detect version number
if ( pattern.version ) { if ( pattern.version ) {
var versions = []; var versions = [];
var version = pattern.version; var version = pattern.version;
var matches = pattern.regex.exec(value); var matches = pattern.regex.exec(value);
if ( matches ) { if ( matches ) {
matches.forEach((match, i) => { matches.forEach((match, i) => {
// Parse ternary operator // Parse ternary operator
var ternary = new RegExp('\\\\' + i + '\\?([^:]+):(.*)$').exec(version); var ternary = new RegExp('\\\\' + i + '\\?([^:]+):(.*)$').exec(version);
if ( ternary && ternary.length === 3 ) { if ( ternary && ternary.length === 3 ) {
version = version.replace(ternary[0], match ? ternary[1] : ternary[2]); version = version.replace(ternary[0], match ? ternary[1] : ternary[2]);
} }
// Replace back references // Replace back references
version = version.replace(new RegExp('\\\\' + i, 'g'), match || ''); version = version.replace(new RegExp('\\\\' + i, 'g'), match || '');
}); });
if ( version && versions.indexOf(version) === -1 ) { if ( version && versions.indexOf(version) === -1 ) {
versions.push(version); versions.push(version);
} }
if ( versions.length ) { if ( versions.length ) {
// Use the longest detected version number // Use the longest detected version number
app.version = versions.reduce((a, b) => a.length > b.length ? a : b); app.version = versions.reduce((a, b) => a.length > b.length ? a : b);
}
} }
} }
} }
@ -558,5 +560,5 @@ class Application {
} }
if ( typeof module === 'object' ) { if ( typeof module === 'object' ) {
module.exports = wappalyzer; module.exports = Wappalyzer;
} }

Loading…
Cancel
Save