|
|
@ -11,6 +11,7 @@ var tabCache = {};
|
|
|
|
var headersCache = {};
|
|
|
|
var headersCache = {};
|
|
|
|
var categoryOrder = [];
|
|
|
|
var categoryOrder = [];
|
|
|
|
var options = {};
|
|
|
|
var options = {};
|
|
|
|
|
|
|
|
var robotsTxtQueue = {};
|
|
|
|
|
|
|
|
|
|
|
|
browser.tabs.onRemoved.addListener(tabId => {
|
|
|
|
browser.tabs.onRemoved.addListener(tabId => {
|
|
|
|
tabCache[tabId] = null;
|
|
|
|
tabCache[tabId] = null;
|
|
|
@ -287,7 +288,13 @@ wappalyzer.driver.displayApps = (detected, meta, context) => {
|
|
|
|
* Fetch and cache robots.txt for host
|
|
|
|
* Fetch and cache robots.txt for host
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
wappalyzer.driver.getRobotsTxt = (host, secure = false) => {
|
|
|
|
wappalyzer.driver.getRobotsTxt = (host, secure = false) => {
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
if ( robotsTxtQueue.hasOwnProperty(host) ) {
|
|
|
|
|
|
|
|
wappalyzer.log('robotTxt fetch already in queue');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return robotsTxtQueue[host];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
robotsTxtQueue[host] = new Promise((resolve, reject) => {
|
|
|
|
getOption('tracking', true)
|
|
|
|
getOption('tracking', true)
|
|
|
|
.then(tracking => {
|
|
|
|
.then(tracking => {
|
|
|
|
if ( !tracking ) {
|
|
|
|
if ( !tracking ) {
|
|
|
@ -299,21 +306,16 @@ wappalyzer.driver.getRobotsTxt = (host, secure = false) => {
|
|
|
|
robotsTxtCache = robotsTxtCache || {};
|
|
|
|
robotsTxtCache = robotsTxtCache || {};
|
|
|
|
|
|
|
|
|
|
|
|
if ( host in robotsTxtCache ) {
|
|
|
|
if ( host in robotsTxtCache ) {
|
|
|
|
resolve(robotsTxtCache[host]);
|
|
|
|
return resolve(robotsTxtCache[host]);
|
|
|
|
} else {
|
|
|
|
}
|
|
|
|
const url = 'http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt';
|
|
|
|
|
|
|
|
|
|
|
|
const timeout = setTimeout(() => resolve([]), 3000);
|
|
|
|
|
|
|
|
|
|
|
|
fetch('http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt')
|
|
|
|
fetch('http' + ( secure ? 's' : '' ) + '://' + host + '/robots.txt', { redirect: 'follow' })
|
|
|
|
.then(response => {
|
|
|
|
.then(response => {
|
|
|
|
if ( !response.ok ) {
|
|
|
|
clearTimeout(timeout);
|
|
|
|
if ( response.status === 404 ) {
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
throw 'GET ' + response.url + ' was not ok';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return response.text();
|
|
|
|
return response.ok ? response.text() : '';
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.then(robotsTxt => {
|
|
|
|
.then(robotsTxt => {
|
|
|
|
robotsTxtCache[host] = wappalyzer.parseRobotsTxt(robotsTxt);
|
|
|
|
robotsTxtCache[host] = wappalyzer.parseRobotsTxt(robotsTxt);
|
|
|
@ -322,11 +324,13 @@ wappalyzer.driver.getRobotsTxt = (host, secure = false) => {
|
|
|
|
|
|
|
|
|
|
|
|
resolve(robotsTxtCache[host]);
|
|
|
|
resolve(robotsTxtCache[host]);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(reject);
|
|
|
|
.catch(err => resolve([]));
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.finally(() => delete robotsTxtQueue[host]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return robotsTxtQueue[host];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|