ignore www in fuzzy & add EAL whitelist and blacklist tests

This commit is contained in:
kumavis 2017-08-04 09:18:46 -07:00
parent 2489f63b05
commit 36b5cba9d1
4 changed files with 3277 additions and 1 deletions

View File

@ -59,11 +59,16 @@
"myetherweb.com.de",
"myetherieumwallet.com",
"myethervallet.com",
"myetherwallet.com.cm",
"myetherwallet.com.co",
"myetherwallet.com.de",
"myetherwallet.com.gl",
"myetherwallet.com.im",
"myetherwallet.com.ua",
"xn--mytherwallet-fvb.com",
"xn--myetherwallt-7db.com",
"xn--myetherwallt-leb.com",
"xn--myetherwallt-yeb.com",
"secure-myetherwallet.com",
"update-myetherwallet.com",
"etherclassicwallet.com",

View File

@ -22,7 +22,10 @@ class PhishingDetector {
if (blacklistMatch) return { type: 'blacklist', result: true }
// check if near-match of whitelist domain, FAIL
const fuzzyForm = domainPartsToFuzzyForm(source)
let fuzzyForm = domainPartsToFuzzyForm(source)
// strip www
fuzzyForm = fuzzyForm.replace('www.', '')
// check against fuzzylist
const levenshteinMatched = this.fuzzylist.find((targetParts) => {
const fuzzyTarget = domainPartsToFuzzyForm(targetParts)
const distance = levenshtein.get(fuzzyForm, fuzzyTarget)

3256
test/ealBlacklist.json Normal file

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,8 @@ const PhishingDetector = require("../src/detector")
const config = require("../src/config.json")
const alexaTopSites = require("./alexa.json")
const popularDapps = require("./dapps.json")
const ealWhitelist = require("./ealWhitelist.json")
const ealBlacklist = require("./ealBlacklist.json")
const detector = new PhishingDetector(config)
@ -121,6 +123,16 @@ test("popular dapps", (t) => {
t.end()
})
test("eal whitelist", (t) => {
testAnyType(t, false, ealWhitelist)
t.end()
})
test("eal blacklist", (t) => {
testAnyType(t, true, ealBlacklist.filter((domain) => !domain.includes('/')))
t.end()
})
function testBlacklist(t, domains) {
domains.forEach((domain) => {