Skip to content

Commit

Permalink
feat - add fuzzy list
Browse files Browse the repository at this point in the history
  • Loading branch information
kumavis committed Aug 3, 2017
1 parent fd51133 commit 8a3572b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ console.log(value) // true
```js
const PhishingDetector = require('eth-phishing-detect/src/detector')

const detector = new PhishingDetector({ whitelist, blacklist, tolerance })
const detector = new PhishingDetector({ whitelist, blacklist, fuzzylist, tolerance })
const value = detector.check('etherclassicwallet.com')
console.log(value)
/*
Expand Down
13 changes: 12 additions & 1 deletion src/config.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
{
"tolerance": 3,
"fuzzylist": [
"ethereum.org",
"metamask.io",
"myetherwallet.com"
],
"whitelist": [
"ethereum.org",
"metamask.io",
"myetherwallet.com",
"myetheroll.com",
"myetherapi.com",
"ledgerwallet.com"
"ledgerwallet.com",
"etherscan.io",
"etherid.org",
"ether.cards",
"etheroll.com"
],
"blacklist": [
"wallet-ethereum.net",
Expand Down
7 changes: 4 additions & 3 deletions src/detector.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const levenshtein = require('fast-levenshtein')
const DEFAULT_TOLERANCE = 4
const DEFAULT_TOLERANCE = 3

class PhishingDetector {

constructor (opts) {
this.blacklist = processDomainList(opts.blacklist || [])
this.whitelist = processDomainList(opts.whitelist || [])
this.blacklist = processDomainList(opts.blacklist || [])
this.fuzzylist = processDomainList(opts.fuzzylist || [])
this.tolerance = ('tolerance' in opts) ? opts.tolerance : DEFAULT_TOLERANCE
}

Expand All @@ -22,7 +23,7 @@ class PhishingDetector {

// check if near-match of whitelist domain, FAIL
const fuzzyForm = domainPartsToFuzzyForm(source)
const levenshteinMatched = this.whitelist.find((targetParts) => {
const levenshteinMatched = this.fuzzylist.find((targetParts) => {
const fuzzyTarget = domainPartsToFuzzyForm(targetParts)
const distance = levenshtein.get(fuzzyForm, fuzzyTarget)
return distance <= this.tolerance
Expand Down

0 comments on commit 8a3572b

Please sign in to comment.