Show icon when no technologies are identified, add htmlMaxCols and htmlMaxRows options in NPM driver

main
Elbert Alias 7 years ago
parent 2b57a2c97b
commit dc0031e917

@ -27,14 +27,16 @@ node index.js [url] [options]
### Options ### Options
``` ```
--chunk-size=num Process links in chunks. --chunk-size=num Process links in chunks.
--debug=0|1 Output debug messages. --debug=0|1 Output debug messages.
--delay=ms Wait for ms milliseconds between requests. --delay=ms Wait for ms milliseconds between requests.
--max-depth=num Don't analyse pages more than num levels deep. --max-depth=num Don't analyse pages more than num levels deep.
--max-urls=num Exit when num URLs have been analysed. --max-urls=num Exit when num URLs have been analysed.
--max-wait=ms Wait no more than ms milliseconds for page resources to load. --max-wait=ms Wait no more than ms milliseconds for page resources to load.
--recursive=0|1 Follow links on pages (crawler). --recursive=0|1 Follow links on pages (crawler).
--user-agent=str Set the user agent string. --user-agent=str Set the user agent string.
--html-max-cols=num Limit the number of HTML characters per line processed.
--html-max-rows=num Limit the number of HTML lines processed.
``` ```
@ -49,6 +51,8 @@ const options = {
maxWait: 5000, maxWait: 5000,
recursive: true, recursive: true,
userAgent: 'Wappalyzer', userAgent: 'Wappalyzer',
htmlMaxCols: 2000,
htmlMaxRows: 2000,
}; };
const wappalyzer = new Wappalyzer('https://www.wappalyzer.com', options); const wappalyzer = new Wappalyzer('https://www.wappalyzer.com', options);

@ -21,6 +21,8 @@ class Driver {
maxWait: 5000, maxWait: 5000,
recursive: false, recursive: false,
userAgent: 'Mozilla/5.0 (compatible; Wappalyzer)', userAgent: 'Mozilla/5.0 (compatible; Wappalyzer)',
htmlMaxCols: 2000,
htmlMaxRows: 2000,
}, options || {}); }, options || {});
this.options.debug = Boolean(this.options.debug); this.options.debug = Boolean(this.options.debug);
@ -28,6 +30,8 @@ class Driver {
this.options.maxDepth = parseInt(this.options.maxDepth, 10); this.options.maxDepth = parseInt(this.options.maxDepth, 10);
this.options.maxUrls = parseInt(this.options.maxUrls, 10); this.options.maxUrls = parseInt(this.options.maxUrls, 10);
this.options.maxWait = parseInt(this.options.maxWait, 10); this.options.maxWait = parseInt(this.options.maxWait, 10);
this.options.htmlMaxCols = parseInt(this.options.htmlMaxCols, 10);
this.options.htmlMaxRows = parseInt(this.options.htmlMaxRows, 10);
this.options.recursive = Boolean(this.options.recursive); this.options.recursive = Boolean(this.options.recursive);
this.origPageUrl = url.parse(pageUrl); this.origPageUrl = url.parse(pageUrl);
@ -216,11 +220,11 @@ class Driver {
let html = ''; let html = '';
try { try {
html = browser.html(); html = browser.html()
.split('\n')
if ( html.length > 50000 ) { .slice(0, this.options.htmlMaxRows / 2).concat(html.slice(html.length - this.options.htmlMaxRows / 2))
html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); .map(line => line.substring(0, this.options.htmlMaxCols))
} .join('\n');
} catch ( error ) { } catch ( error ) {
this.wappalyzer.log(error.message, 'browser', 'error'); this.wappalyzer.log(error.message, 'browser', 'error');
} }

@ -148,7 +148,7 @@ body {
.empty { .empty {
display: flex; display: flex;
height: 16rem; height: 14.5rem;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
} }

@ -240,47 +240,45 @@ wappalyzer.driver.displayApps = (detected, meta, context) => {
tabCache[tab.id].detected = detected; tabCache[tab.id].detected = detected;
if ( Object.keys(detected).length ) { var appName, found = false;
var appName, found = false;
// Find the main application to display // Find the main application to display
[ options.pinnedCategory ].concat(categoryOrder).forEach(match => { [ options.pinnedCategory ].concat(categoryOrder).forEach(match => {
Object.keys(detected).forEach(appName => { Object.keys(detected).forEach(appName => {
var app = detected[appName]; var app = detected[appName];
app.props.cats.forEach(category => { app.props.cats.forEach(category => {
if ( category === match && !found ) { if ( category === match && !found ) {
var icon = app.props.icon || 'default.svg'; var icon = app.props.icon || 'default.svg';
if ( !options.dynamicIcon ) { if ( !options.dynamicIcon ) {
icon = 'default.svg'; icon = 'default.svg';
} }
if ( /\.svg$/i.test(icon) ) {
icon = 'converted/' + icon.replace(/\.svg$/, '.png');
}
try { if ( /\.svg$/i.test(icon) ) {
browser.pageAction.setIcon({ icon = 'converted/' + icon.replace(/\.svg$/, '.png');
tabId: tab.id, }
path: '../images/icons/' + icon
});
} catch(e) {
// Firefox for Android does not support setIcon see https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
}
found = true; try {
browser.pageAction.setIcon({
tabId: tab.id,
path: '../images/icons/' + icon
});
} catch(e) {
// Firefox for Android does not support setIcon see https://bugzilla.mozilla.org/show_bug.cgi?id=1331746
} }
});
found = true;
}
}); });
}); });
});
if ( typeof chrome !== 'undefined' ) { if ( typeof chrome !== 'undefined' ) {
// Browser polyfill doesn't seem to work here // Browser polyfill doesn't seem to work here
chrome.pageAction.show(tab.id); chrome.pageAction.show(tab.id);
} else { } else {
browser.pageAction.show(tab.id); browser.pageAction.show(tab.id);
}
} }
}; };

@ -72,5 +72,3 @@
], ],
"content_security_policy": "script-src 'self'; object-src 'self'" "content_security_policy": "script-src 'self'; object-src 'self'"
} }