From 610774754b6ffea551823fec4746bcc0882a0c43 Mon Sep 17 00:00:00 2001 From: Jaco Greeff Date: Fri, 12 Feb 2021 22:03:06 +0100 Subject: [PATCH] Check addesses against known list (#98) --- known.json | 8 ++++++++ packages/phishing/src/index.spec.ts | 11 +++++++++++ tsconfig.json | 1 + 3 files changed, 20 insertions(+) create mode 100644 known.json diff --git a/known.json b/known.json new file mode 100644 index 000000000..385a6f097 --- /dev/null +++ b/known.json @@ -0,0 +1,8 @@ +{ + "binance": [ + "1exaAg2VJRQbyUBAeXcktChCAqjVP9TUxF3zo23R2T6EGdE" + ], + "simpleswap.io": [ + "14QsifyV7XyEDay8C862PNLRngid2AGZmtCwz1K88x5gpf58" + ] +} diff --git a/packages/phishing/src/index.spec.ts b/packages/phishing/src/index.spec.ts index 23d9b3433..18d11a530 100644 --- a/packages/phishing/src/index.spec.ts +++ b/packages/phishing/src/index.spec.ts @@ -1,6 +1,8 @@ // Copyright 2020-2021 @polkadot/phishing authors & contributors // SPDX-License-Identifier: Apache-2.0 +import denied from '../../../address.json'; +import allowed from '../../../known.json'; import { checkAddress, checkIfDenied } from '.'; describe('checkIfDenied', (): void => { @@ -60,3 +62,12 @@ describe('checkAddress', (): void => { ).toEqual('polkadots.network'); }); }); + +describe('check additions', (): void => { + it('has no entries on the known addresses list', (): void => { + const added = Object.values(denied as Record).reduce((all: string[], addrs: string[]) => all.concat(addrs), []); + const dupes = Object.entries(allowed as Record).reduce((all: [string, string][], [site, addrs]) => all.concat(addrs.map((a) => [site, a])), []).filter(([, a]) => added.includes(a)); + + expect(dupes).toEqual([]); + }); +}); diff --git a/tsconfig.json b/tsconfig.json index 8c6e26fd2..1172a5488 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -11,6 +11,7 @@ "@polkadot/phishing": ["packages/phishing/src"], "@polkadot/phishing/*": ["packages/phishing/src/*"] }, + "resolveJsonModule": true, "skipLibCheck": true, "typeRoots": [ "./node_modules/@types"