mirror of
https://github.com/FlipsideCrypto/eth-phishing-detect.git
synced 2026-02-06 03:06:43 +00:00
test - add alexa top 50 to test
This commit is contained in:
parent
72e20022da
commit
27d76f7944
52
test/alexa.json
Normal file
52
test/alexa.json
Normal file
@ -0,0 +1,52 @@
|
||||
[
|
||||
"google.com",
|
||||
"youtube.com",
|
||||
"facebook.com",
|
||||
"baidu.com",
|
||||
"wikipedia.org",
|
||||
"yahoo.com",
|
||||
"google.co.in",
|
||||
"qq.com",
|
||||
"reddit.com",
|
||||
"amazon.com",
|
||||
"taobao.com",
|
||||
"twitter.com",
|
||||
"google.co.jp",
|
||||
"tmall.com",
|
||||
"vk.com",
|
||||
"live.com",
|
||||
"sohu.com",
|
||||
"instagram.com",
|
||||
"sina.com.cn",
|
||||
"jd.com",
|
||||
"weibo.com",
|
||||
"360.cn",
|
||||
"google.de",
|
||||
"google.co.uk",
|
||||
"linkedin.com",
|
||||
"list.tmall.com",
|
||||
"google.fr",
|
||||
"google.com.br",
|
||||
"google.ru",
|
||||
"yandex.ru",
|
||||
"google.com.hk",
|
||||
"netflix.com",
|
||||
"yahoo.co.jp",
|
||||
"google.it",
|
||||
"t.co",
|
||||
"google.es",
|
||||
"ebay.com",
|
||||
"pornhub.com",
|
||||
"imgur.com",
|
||||
"bing.com",
|
||||
"twitch.tv",
|
||||
"alipay.com",
|
||||
"google.ca",
|
||||
"msn.com",
|
||||
"google.com.mx",
|
||||
"tumblr.com",
|
||||
"xvideos.com",
|
||||
"ok.ru",
|
||||
"mail.ru",
|
||||
"microsoft.com"
|
||||
]
|
||||
@ -1,6 +1,7 @@
|
||||
const test = require('tape')
|
||||
const PhishingDetector = require('../src/detector')
|
||||
const config = require('../src/config.json')
|
||||
const alexaTopSites = require('./alexa.json')
|
||||
|
||||
const detector = new PhishingDetector(config)
|
||||
|
||||
@ -60,6 +61,13 @@ test('basic test', (t) => {
|
||||
t.end()
|
||||
})
|
||||
|
||||
test('alexa top sites', (t) => {
|
||||
// alexa top sites
|
||||
testAnyType(t, false, alexaTopSites)
|
||||
t.end()
|
||||
})
|
||||
|
||||
|
||||
function testBlacklist(t, domains) {
|
||||
domains.forEach((domain) => {
|
||||
testDomain(t, {
|
||||
@ -100,11 +108,25 @@ function testNoMatch(t, domains) {
|
||||
})
|
||||
}
|
||||
|
||||
function testAnyType(t, expected, domains) {
|
||||
domains.forEach((domain) => {
|
||||
testDomain(t, {
|
||||
domain: domain,
|
||||
expected,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function testDomain(t, { domain, type, expected }) {
|
||||
const value = detector.check(domain)
|
||||
// log fuzzy match for debugging
|
||||
if (value.type === 'fuzzy') {
|
||||
t.comment(`"${domain}" fuzzy matches against "${value.match}"`)
|
||||
}
|
||||
t.equal(value.type, type, `type: "${domain}" should be "${type}"`)
|
||||
// enforcing type is optional
|
||||
if (type) {
|
||||
t.equal(value.type, type, `type: "${domain}" should be "${type}"`)
|
||||
}
|
||||
// enforcing result is required
|
||||
t.equal(value.result, expected, `result: "${domain}" should be match "${expected}"`)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user