Add test for allowed top-level domains (#1120)

* Add test for allowed top-level domains

* Update packages/phishing/src/additions.spec.ts

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
Jaco
2022-02-17 09:46:21 +01:00
committed by GitHub
parent e7b4a7775c
commit 27f7be5f43
+20 -1
View File
@@ -7,7 +7,20 @@ import { decodeAddress } from '@polkadot/util-crypto';
const addresses = JSON.parse(fs.readFileSync('address.json', 'utf-8')) as Record<string, string[]>;
const allowed = JSON.parse(fs.readFileSync('known.json', 'utf-8')) as Record<string, string[]>;
const all = JSON.parse(fs.readFileSync('all.json', 'utf8')) as { deny: string[] };
const all = JSON.parse(fs.readFileSync('all.json', 'utf8')) as { allow: string[]; deny: string[] };
const TOP_LEVEL = [
'pages.dev',
'servehttp.com',
'vercel.app',
'web.app',
'hopto.org',
'zapto.org',
'sytes.net',
'ddns.net',
'webflow.io',
'plesk.page'
];
describe('added addresses', (): void => {
it('has no malformed addresses', (): void => {
@@ -45,6 +58,12 @@ describe('added addresses', (): void => {
});
describe('added urls', (): void => {
it('has no entries for allowed top-level domains', (): void => {
const invalids = all.deny.filter((u) => TOP_LEVEL.includes(u));
expect(invalids).toEqual([]);
});
it('has no malformed domain-only entries', (): void => {
const invalids = all.deny.filter((u) =>
u.includes('/') || // don't allow paths