From dc0031e917d9c3e45273989adb99e4908aa9b6bc Mon Sep 17 00:00:00 2001 From: Elbert Alias <77259+AliasIO@users.noreply.github.com> Date: Sat, 21 Apr 2018 09:50:55 +1000 Subject: [PATCH] Show icon when no technologies are identified, add htmlMaxCols and htmlMaxRows options in NPM driver --- src/drivers/npm/README.md | 20 +++++---- src/drivers/npm/driver.js | 14 +++--- src/drivers/webextension/css/popup.css | 2 +- src/drivers/webextension/js/driver.js | 62 +++++++++++++------------- src/drivers/webextension/manifest.json | 2 - 5 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/drivers/npm/README.md b/src/drivers/npm/README.md index d77b2270a..a661bb198 100644 --- a/src/drivers/npm/README.md +++ b/src/drivers/npm/README.md @@ -27,14 +27,16 @@ node index.js [url] [options] ### Options ``` - --chunk-size=num Process links in chunks. - --debug=0|1 Output debug messages. - --delay=ms Wait for ms milliseconds between requests. - --max-depth=num Don't analyse pages more than num levels deep. - --max-urls=num Exit when num URLs have been analysed. - --max-wait=ms Wait no more than ms milliseconds for page resources to load. - --recursive=0|1 Follow links on pages (crawler). - --user-agent=str Set the user agent string. + --chunk-size=num Process links in chunks. + --debug=0|1 Output debug messages. + --delay=ms Wait for ms milliseconds between requests. + --max-depth=num Don't analyse pages more than num levels deep. + --max-urls=num Exit when num URLs have been analysed. + --max-wait=ms Wait no more than ms milliseconds for page resources to load. + --recursive=0|1 Follow links on pages (crawler). + --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, recursive: true, userAgent: 'Wappalyzer', + htmlMaxCols: 2000, + htmlMaxRows: 2000, }; const wappalyzer = new Wappalyzer('https://www.wappalyzer.com', options); diff --git a/src/drivers/npm/driver.js b/src/drivers/npm/driver.js index 37928839d..0dcaac739 100644 --- a/src/drivers/npm/driver.js +++ b/src/drivers/npm/driver.js @@ -21,6 +21,8 @@ class Driver { maxWait: 5000, recursive: false, userAgent: 'Mozilla/5.0 (compatible; Wappalyzer)', + htmlMaxCols: 2000, + htmlMaxRows: 2000, }, options || {}); this.options.debug = Boolean(this.options.debug); @@ -28,6 +30,8 @@ class Driver { this.options.maxDepth = parseInt(this.options.maxDepth, 10); this.options.maxUrls = parseInt(this.options.maxUrls, 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.origPageUrl = url.parse(pageUrl); @@ -216,11 +220,11 @@ class Driver { let html = ''; try { - html = browser.html(); - - if ( html.length > 50000 ) { - html = html.substring(0, 25000) + html.substring(html.length - 25000, html.length); - } + html = browser.html() + .split('\n') + .slice(0, this.options.htmlMaxRows / 2).concat(html.slice(html.length - this.options.htmlMaxRows / 2)) + .map(line => line.substring(0, this.options.htmlMaxCols)) + .join('\n'); } catch ( error ) { this.wappalyzer.log(error.message, 'browser', 'error'); } diff --git a/src/drivers/webextension/css/popup.css b/src/drivers/webextension/css/popup.css index 83725397b..b9d7c90fb 100644 --- a/src/drivers/webextension/css/popup.css +++ b/src/drivers/webextension/css/popup.css @@ -148,7 +148,7 @@ body { .empty { display: flex; - height: 16rem; + height: 14.5rem; align-items: center; justify-content: center; } diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index 653b3bb4e..a08a0580e 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -240,47 +240,45 @@ wappalyzer.driver.displayApps = (detected, meta, context) => { tabCache[tab.id].detected = detected; - if ( Object.keys(detected).length ) { - var appName, found = false; + var appName, found = false; - // Find the main application to display - [ options.pinnedCategory ].concat(categoryOrder).forEach(match => { - Object.keys(detected).forEach(appName => { - var app = detected[appName]; + // Find the main application to display + [ options.pinnedCategory ].concat(categoryOrder).forEach(match => { + Object.keys(detected).forEach(appName => { + var app = detected[appName]; - app.props.cats.forEach(category => { - if ( category === match && !found ) { - var icon = app.props.icon || 'default.svg'; + app.props.cats.forEach(category => { + if ( category === match && !found ) { + var icon = app.props.icon || 'default.svg'; - if ( !options.dynamicIcon ) { - icon = 'default.svg'; - } - - if ( /\.svg$/i.test(icon) ) { - icon = 'converted/' + icon.replace(/\.svg$/, '.png'); - } + if ( !options.dynamicIcon ) { + icon = 'default.svg'; + } - 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 - } + if ( /\.svg$/i.test(icon) ) { + icon = 'converted/' + icon.replace(/\.svg$/, '.png'); + } - 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' ) { - // Browser polyfill doesn't seem to work here - chrome.pageAction.show(tab.id); - } else { - browser.pageAction.show(tab.id); - } + if ( typeof chrome !== 'undefined' ) { + // Browser polyfill doesn't seem to work here + chrome.pageAction.show(tab.id); + } else { + browser.pageAction.show(tab.id); } }; diff --git a/src/drivers/webextension/manifest.json b/src/drivers/webextension/manifest.json index e8cc0c002..2f4dff398 100644 --- a/src/drivers/webextension/manifest.json +++ b/src/drivers/webextension/manifest.json @@ -72,5 +72,3 @@ ], "content_security_policy": "script-src 'self'; object-src 'self'" } - -