Skip to content

Commit b1311b4

Browse files
authored
Merge pull request #1852 from MetaMask/blacklist-refactor2
blacklist - use module eth-phishing-detect
2 parents 15bcbb4 + 34b1e80 commit b1311b4

File tree

3 files changed

+20
-35
lines changed

3 files changed

+20
-35
lines changed
Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
const ObservableStore = require('obs-store')
22
const extend = require('xtend')
3-
const communityBlacklistedDomains = require('etheraddresslookup/blacklists/domains.json')
4-
const communityWhitelistedDomains = require('etheraddresslookup/whitelists/domains.json')
5-
const checkForPhishing = require('../lib/is-phish')
3+
const PhishingDetector = require('eth-phishing-detect/src/detector')
64

75
// compute phishing lists
8-
const PHISHING_BLACKLIST = communityBlacklistedDomains.concat(['metamask.com'])
9-
const PHISHING_WHITELIST = communityWhitelistedDomains.concat(['metamask.io', 'www.metamask.io'])
10-
const PHISHING_FUZZYLIST = ['myetherwallet', 'myetheroll', 'ledgerwallet', 'metamask']
6+
const PHISHING_DETECTION_CONFIG = require('eth-phishing-detect/src/config.json')
117
// every ten minutes
128
const POLLING_INTERVAL = 10 * 60 * 1000
139

1410
class BlacklistController {
1511

1612
constructor (opts = {}) {
1713
const initState = extend({
18-
phishing: PHISHING_BLACKLIST,
14+
phishing: PHISHING_DETECTION_CONFIG,
1915
}, opts.initState)
2016
this.store = new ObservableStore(initState)
17+
// phishing detector
18+
this._phishingDetector = null
19+
this._setupPhishingDetector(initState.phishing)
2120
// polling references
2221
this._phishingUpdateIntervalRef = null
2322
}
@@ -28,14 +27,15 @@ class BlacklistController {
2827

2928
checkForPhishing (hostname) {
3029
if (!hostname) return false
31-
const { blacklist } = this.store.getState()
32-
return checkForPhishing({ hostname, blacklist, whitelist: PHISHING_WHITELIST, fuzzylist: PHISHING_FUZZYLIST })
30+
const { result } = this._phishingDetector.check(hostname)
31+
return result
3332
}
3433

3534
async updatePhishingList () {
36-
const response = await fetch('https://api.infura.io/v1/blacklist')
35+
const response = await fetch('https://api.infura.io/v2/blacklist')
3736
const phishing = await response.json()
3837
this.store.updateState({ phishing })
38+
this._setupPhishingDetector(phishing)
3939
return phishing
4040
}
4141

@@ -45,6 +45,14 @@ class BlacklistController {
4545
this.updatePhishingList()
4646
}, POLLING_INTERVAL)
4747
}
48+
49+
//
50+
// PRIVATE METHODS
51+
//
52+
53+
_setupPhishingDetector (config) {
54+
this._phishingDetector = new PhishingDetector(config)
55+
}
4856
}
4957

5058
module.exports = BlacklistController

app/scripts/lib/is-phish.js

Lines changed: 0 additions & 23 deletions
This file was deleted.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"start": "npm run dev",
88
"dev": "gulp dev --debug",
99
"disc": "gulp disc --debug",
10-
"clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/etheraddresslookup",
10+
"clear": "rm -rf node_modules/eth-contract-metadata && rm -rf node_modules/eth-phishing-detect",
1111
"dist": "npm run clear && npm install && gulp dist",
1212
"test": "npm run lint && npm run test-unit && npm run test-integration",
1313
"test-unit": "METAMASK_ENV=test mocha --require test/helper.js --recursive \"test/unit/**/*.js\"",
@@ -68,11 +68,11 @@
6868
"eth-bin-to-ops": "^1.0.1",
6969
"eth-contract-metadata": "^1.1.4",
7070
"eth-hd-keyring": "^1.1.1",
71+
"eth-phishing-detect": "^1.0.2",
7172
"eth-query": "^2.1.2",
7273
"eth-sig-util": "^1.2.2",
7374
"eth-simple-keyring": "^1.1.1",
7475
"eth-token-tracker": "^1.1.2",
75-
"etheraddresslookup": "github:409H/EtherAddressLookup",
7676
"ethereumjs-tx": "^1.3.0",
7777
"ethereumjs-util": "ethereumjs/ethereumjs-util#ac5d0908536b447083ea422b435da27f26615de9",
7878
"ethereumjs-wallet": "^0.6.0",

0 commit comments

Comments
 (0)