aboutsummaryrefslogtreecommitdiffstats
path: root/app/scripts/controllers/blacklist.js
diff options
context:
space:
mode:
authorDan Finlay <542863+danfinlay@users.noreply.github.com>2018-10-02 23:45:58 +0800
committerGitHub <noreply@github.com>2018-10-02 23:45:58 +0800
commit8dc8fd09031e1719f2da4e950a08e677d2752f56 (patch)
tree3f14c6f103d14bfd462a4bda977f2e49fffc6ad1 /app/scripts/controllers/blacklist.js
parent5fc2c4250b7c8aad24f713e8c31d0fd1f80eeec5 (diff)
parent5539494a5ead91fc4b35654a620ec915ce482f4d (diff)
downloadtangerine-wallet-browser-8dc8fd09031e1719f2da4e950a08e677d2752f56.tar.gz
tangerine-wallet-browser-8dc8fd09031e1719f2da4e950a08e677d2752f56.tar.zst
tangerine-wallet-browser-8dc8fd09031e1719f2da4e950a08e677d2752f56.zip
Merge pull request #5406 from whymarrh/bypass-phishing-warning
Allow users to bypass phishing warning
Diffstat (limited to 'app/scripts/controllers/blacklist.js')
-rw-r--r--app/scripts/controllers/blacklist.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js
index 1d2191433..89c7cc888 100644
--- a/app/scripts/controllers/blacklist.js
+++ b/app/scripts/controllers/blacklist.js
@@ -29,6 +29,7 @@ class BlacklistController {
constructor (opts = {}) {
const initState = extend({
phishing: PHISHING_DETECTION_CONFIG,
+ whitelist: [],
}, opts.initState)
this.store = new ObservableStore(initState)
// phishing detector
@@ -39,6 +40,21 @@ class BlacklistController {
}
/**
+ * Adds the given hostname to the runtime whitelist
+ * @param {string} hostname the hostname to whitelist
+ */
+ whitelistDomain (hostname) {
+ if (!hostname) {
+ return
+ }
+
+ const { whitelist } = this.store.getState()
+ this.store.updateState({
+ whitelist: [...new Set([hostname, ...whitelist])],
+ })
+ }
+
+ /**
* Given a url, returns the result of checking if that url is in the store.phishing blacklist
*
* @param {string} hostname The hostname portion of a url; the one that will be checked against the white and
@@ -48,6 +64,12 @@ class BlacklistController {
*/
checkForPhishing (hostname) {
if (!hostname) return false
+
+ const { whitelist } = this.store.getState()
+ if (whitelist.some((e) => e === hostname)) {
+ return false
+ }
+
const { result } = this._phishingDetector.check(hostname)
return result
}