mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-07-19 15:45:44 +00:00
Add crosscheck action (#13)
This commit is contained in:
@@ -23,6 +23,10 @@
|
||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/phishing#readme",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.12.1",
|
||||
"@polkadot/x-fetch": "0.3.3"
|
||||
"@polkadot/x-fetch": "^0.3.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/js-yaml": "^3.12.5",
|
||||
"js-yaml": "^3.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2020 @polkadot/phishing authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import fs from 'fs';
|
||||
import { safeLoad } from 'js-yaml';
|
||||
import fetch from '@polkadot/x-fetch';
|
||||
|
||||
import { retrieveHostList } from '.';
|
||||
|
||||
interface CryptoScamEntry {
|
||||
addresses: Record<string, string[]>;
|
||||
category: string;
|
||||
description: string;
|
||||
name: string;
|
||||
resporter: string;
|
||||
subcategory: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
function assertAndLog (check: boolean, error: string): void {
|
||||
if (!check) {
|
||||
process.env.CI_LOG && fs.appendFileSync('./.github/crosscheck.md', `
|
||||
|
||||
${error}
|
||||
`);
|
||||
|
||||
throw new Error(error);
|
||||
}
|
||||
}
|
||||
|
||||
const CRYPTOSCAM = 'https://raw.githubusercontent.com/CryptoScamDB/blacklist/master/data/urls.yaml';
|
||||
|
||||
describe('crosscheck', (): void => {
|
||||
let scamDb: CryptoScamEntry[];
|
||||
let ours: string[];
|
||||
|
||||
beforeAll(async (): Promise<void> => {
|
||||
ours = (await retrieveHostList()).deny;
|
||||
scamDb = safeLoad(await (await fetch(CRYPTOSCAM)).text()) as CryptoScamEntry[];
|
||||
});
|
||||
|
||||
it('has all the relevant entries from CryptoScamDb', (): void => {
|
||||
const filtered = scamDb.filter(({ subcategory }) => subcategory === 'Polkadot');
|
||||
const missing = filtered.filter(({ url }) =>
|
||||
!ours.includes(url.replace(/https:\/\/|http:\/\//, '').split('/')[0])
|
||||
);
|
||||
|
||||
console.log(JSON.stringify(filtered, null, 2));
|
||||
|
||||
assertAndLog(missing.length === 0, `Missing entries found from CryptoScamDB: ${JSON.stringify(missing, null, 2)}`);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user