From f9038fb496b747a087f8a2729e381e402c329549 Mon Sep 17 00:00:00 2001 From: Jaco Date: Wed, 21 Apr 2021 14:25:31 +0300 Subject: [PATCH] Add polkastater.link (#274) * Add polkastater.link * Use matching fo category --- all.json | 1 + packages/phishing/src/crosscheck.spec.ts | 17 +++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/all.json b/all.json index 8aa1d5be9..2bb5b49d4 100644 --- a/all.json +++ b/all.json @@ -113,6 +113,7 @@ "polkastarter.eu.com", "polkastarter.fund", "polkastarter.ws", + "polkastater.link", "polkaswitch.online", "polkawallets.site", "polkdot-live.network", diff --git a/packages/phishing/src/crosscheck.spec.ts b/packages/phishing/src/crosscheck.spec.ts index af0540de8..95e0ce30e 100644 --- a/packages/phishing/src/crosscheck.spec.ts +++ b/packages/phishing/src/crosscheck.spec.ts @@ -6,7 +6,7 @@ import { load as yamlParse } from 'js-yaml'; import { fetch } from '@polkadot/x-fetch'; -import { retrieveHostList } from '.'; +import ourSiteList from '../../../all.json'; interface CryptoScamEntry { addresses: Record; @@ -39,15 +39,20 @@ ${TICKS} } } +function matchName (_url: string): boolean { + const url = (_url || '').toLowerCase(); + + return !!url && (url.includes('polka') || url.includes('kusa')); +} + const CRYPTODB = 'https://raw.githubusercontent.com/CryptoScamDB/blacklist/master/data/urls.yaml'; const ETHPHISH = 'https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/master/src/config.json'; describe('crosscheck', (): void => { - let ours: string[]; + const ours: string[] = ourSiteList.deny; - beforeAll(async (): Promise => { + beforeAll((): void => { jest.setTimeout(120000); - ours = (await retrieveHostList()).deny; }); it('has all the relevant entries from CryptoScamDb', async (): Promise => { @@ -55,7 +60,7 @@ describe('crosscheck', (): void => { // this is a hack, the text slipped in upstream const scamDb = yamlParse(raw.replace('∂ç', '')) as CryptoScamEntry[]; - const filtered = scamDb.filter(({ subcategory }) => subcategory === 'Polkadot'); + const filtered = scamDb.filter(({ name, subcategory }) => matchName(subcategory) || matchName(name)); const missing = filtered.filter(({ url }) => !ours.includes(url.replace(/https:\/\/|http:\/\//, '').split('/')[0]) ); @@ -68,7 +73,7 @@ describe('crosscheck', (): void => { it('has polkadot/kusama entries from eth-phishing-detect', async (): Promise => { const ethDb = await (await fetch(ETHPHISH)).json() as EthPhishing; - const filtered = ethDb.blacklist.filter((url) => url.includes('polkadot') || url.includes('kusama')); + const filtered = ethDb.blacklist.filter((url) => matchName(url)); const missing = filtered.filter((url) => !ours.includes(url)); console.log('eth-phishing-detect found\n', JSON.stringify(filtered, null, 2));