aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <kumavis@users.noreply.github.com>2017-08-04 12:02:01 +0800
committerGitHub <noreply@github.com>2017-08-04 12:02:01 +0800
commit5a9257208c858d11b94659518ef2375384aeac46 (patch)
tree6341d6693513ae731aa7092e4816d891e36cbc45 /app
parent17c9fd450f4c05ae39457abc8459d0353c07973b (diff)
parentc4cb371ce8ddad10d575b4ddb6cb85fe4689ca59 (diff)
downloadtangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar.gz
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar.bz2
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar.lz
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar.xz
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.tar.zst
tangerine-wallet-browser-5a9257208c858d11b94659518ef2375384aeac46.zip
Merge branch 'master' into NewUI
Diffstat (limited to 'app')
-rw-r--r--app/manifest.json2
-rw-r--r--app/scripts/controllers/blacklist.js28
-rw-r--r--app/scripts/lib/is-phish.js23
-rw-r--r--app/scripts/lib/nodeify.js3
4 files changed, 21 insertions, 35 deletions
diff --git a/app/manifest.json b/app/manifest.json
index 1eaf6f26a..6c02120c1 100644
--- a/app/manifest.json
+++ b/app/manifest.json
@@ -1,7 +1,7 @@
{
"name": "MetaMask",
"short_name": "Metamask",
- "version": "3.9.2",
+ "version": "3.9.3",
"manifest_version": 2,
"author": "https://metamask.io",
"description": "Ethereum Browser Extension",
diff --git a/app/scripts/controllers/blacklist.js b/app/scripts/controllers/blacklist.js
index 11e26d5b2..7e01fa386 100644
--- a/app/scripts/controllers/blacklist.js
+++ b/app/scripts/controllers/blacklist.js
@@ -1,13 +1,9 @@
const ObservableStore = require('obs-store')
const extend = require('xtend')
-const communityBlacklistedDomains = require('etheraddresslookup/blacklists/domains.json')
-const communityWhitelistedDomains = require('etheraddresslookup/whitelists/domains.json')
-const checkForPhishing = require('../lib/is-phish')
+const PhishingDetector = require('eth-phishing-detect/src/detector')
// compute phishing lists
-const PHISHING_BLACKLIST = communityBlacklistedDomains.concat(['metamask.com'])
-const PHISHING_WHITELIST = communityWhitelistedDomains.concat(['metamask.io', 'www.metamask.io'])
-const PHISHING_FUZZYLIST = ['myetherwallet', 'myetheroll', 'ledgerwallet', 'metamask']
+const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json')
// every ten minutes
const POLLING_INTERVAL = 10 * 60 * 1000
@@ -15,9 +11,12 @@ class BlacklistController {
constructor (opts = {}) {
const initState = extend({
- phishing: PHISHING_BLACKLIST,
+ phishing: PHISHING_DETECTION_CONFIG,
}, opts.initState)
this.store = new ObservableStore(initState)
+ // phishing detector
+ this._phishingDetector = null
+ this._setupPhishingDetector(initState.phishing)
// polling references
this._phishingUpdateIntervalRef = null
}
@@ -28,14 +27,15 @@ class BlacklistController {
checkForPhishing (hostname) {
if (!hostname) return false
- const { blacklist } = this.store.getState()
- return checkForPhishing({ hostname, blacklist, whitelist: PHISHING_WHITELIST, fuzzylist: PHISHING_FUZZYLIST })
+ const { result } = this._phishingDetector.check(hostname)
+ return result
}
async updatePhishingList () {
- const response = await fetch('https://api.infura.io/v1/blacklist')
+ const response = await fetch('https://api.infura.io/v2/blacklist')
const phishing = await response.json()
this.store.updateState({ phishing })
+ this._setupPhishingDetector(phishing)
return phishing
}
@@ -45,6 +45,14 @@ class BlacklistController {
this.updatePhishingList()
}, POLLING_INTERVAL)
}
+
+ //
+ // PRIVATE METHODS
+ //
+
+ _setupPhishingDetector (config) {
+ this._phishingDetector = new PhishingDetector(config)
+ }
}
module.exports = BlacklistController
diff --git a/app/scripts/lib/is-phish.js b/app/scripts/lib/is-phish.js
deleted file mode 100644
index ce51c353d..000000000
--- a/app/scripts/lib/is-phish.js
+++ /dev/null
@@ -1,23 +0,0 @@
-const levenshtein = require('fast-levenshtein')
-const LEVENSHTEIN_TOLERANCE = 4
-
-// credit to @sogoiii and @409H for their help!
-// Return a boolean on whether or not a phish is detected.
-function isPhish({ hostname, blacklist, whitelist, fuzzylist }) {
-
- // check if the domain is part of the whitelist.
- if (whitelist && whitelist.includes(hostname)) return false
-
- // check if the domain is part of the blacklist.
- if (blacklist && blacklist.includes(hostname)) return true
-
- // check for similar values.
- const levenshteinForm = hostname.replace(/\./g, '')
- const levenshteinMatched = fuzzylist.some((element) => {
- return levenshtein.get(element, levenshteinForm) <= LEVENSHTEIN_TOLERANCE
- })
-
- return levenshteinMatched
-}
-
-module.exports = isPhish
diff --git a/app/scripts/lib/nodeify.js b/app/scripts/lib/nodeify.js
index 299bfe624..832d6c6d3 100644
--- a/app/scripts/lib/nodeify.js
+++ b/app/scripts/lib/nodeify.js
@@ -1,9 +1,10 @@
const promiseToCallback = require('promise-to-callback')
-module.exports = function(fn, context) {
+module.exports = function nodeify (fn, context) {
return function(){
const args = [].slice.call(arguments)
const callback = args.pop()
+ if (typeof callback !== 'function') throw new Error('callback is not a function')
promiseToCallback(fn.apply(context, args))(callback)
}
}