This commit is contained in:
Jaco
2023-02-22 09:35:50 +02:00
committed by GitHub
parent 8ac03a8d61
commit d8f9064e7d
6 changed files with 362 additions and 1508 deletions
-10
View File
@@ -1,10 +0,0 @@
// Copyright 2020-2023 @polkadot/phishing authors & contributors
// SPDX-License-Identifier: Apache-2.0
const config = require('@polkadot/dev/config/jest.cjs');
module.exports = {
...config,
moduleNameMapper: {},
testTimeout: 2 * 60 * 1000
};
+5 -5
View File
@@ -28,18 +28,18 @@
"clean": "polkadot-dev-clean-build",
"deno": "yarn polkadot-dev-deno-map && yarn build && deno check --import-map=import_map.json mod.ts",
"lint": "polkadot-dev-run-lint",
"phishing:addrcheck": "polkadot-dev-run-test --env jest addrcheck -- --runInBand --detectOpenHandles",
"phishing:crosscheck": "polkadot-dev-run-test --env jest crosscheck -- --runInBand --detectOpenHandles",
"phishing:addrcheck": "polkadot-dev-run-test --env node addrcheck",
"phishing:crosscheck": "polkadot-dev-run-test --env node crosscheck",
"postinstall": "polkadot-dev-yarn-only",
"test": "polkadot-dev-run-test --env jest ^addrcheck ^crosscheck -- --coverage"
"test": "polkadot-dev-run-test --env node ^addrcheck ^crosscheck"
},
"dependencies": {
"@pinata/sdk": "^1.2.1",
"dnslink-cloudflare": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.20.12",
"@polkadot/dev": "^0.68.38",
"@babel/core": "^7.21.0",
"@polkadot/dev": "^0.69.5",
"@types/jest": "^29.4.0",
"mkdirp": "^2.1.3",
"rimraf": "^4.1.2"
+1 -1
View File
@@ -20,7 +20,7 @@
"version": "0.19.4-23-x",
"main": "index.js",
"dependencies": {
"@babel/runtime": "^7.20.13",
"@babel/runtime": "^7.21.0",
"@polkadot/util": "^10.4.2",
"@polkadot/util-crypto": "^10.4.2",
"@polkadot/x-fetch": "^10.4.2"
+11 -2
View File
@@ -158,11 +158,18 @@ function checkAll (): Promise<[string, string[]][]> {
}
describe('addrcheck', (): void => {
beforeAll((): void => {
jest.setTimeout(2 * 60 * 1000);
let counter = 0;
let errors = 0;
afterEach((): void => {
if (++counter === 1) {
process.exit(errors);
}
});
it('has all known addresses', async (): Promise<void> => {
errors++;
const _results = await checkAll();
const results = _results.map(([url, addrs]): [string, string[]] => {
return [url, addrs.filter((a) => {
@@ -198,5 +205,7 @@ describe('addrcheck', (): void => {
sites.length && process.env.CI_LOG && fs.appendFileSync('./.github/addrcheck.md', `\n\n${sites.length} urls with missing entries found at ${new Date().toUTCString()}:\n\n${TICKS}\n${JSON.stringify(mapMiss, null, 2)}\n${TICKS}\n`);
expect(sites).toEqual([]);
errors--;
});
});
+15 -2
View File
@@ -3,6 +3,7 @@
import fs from 'fs';
import { load as yamlParse } from 'js-yaml';
import process from 'process';
import { fetchJson, fetchText } from './fetch';
@@ -50,12 +51,18 @@ const ETHPHISH = 'https://raw.githubusercontent.com/MetaMask/eth-phishing-detect
describe('crosscheck', (): void => {
const ours: string[] = ourSiteList.deny;
let counter = 0;
let errors = 0;
beforeAll((): void => {
jest.setTimeout(120000);
afterEach((): void => {
if (++counter === 2) {
process.exit(errors);
}
});
it('has all the relevant entries from CryptoScamDb', async (): Promise<void> => {
errors++;
const raw = await fetchText(CRYPTODB);
// this is a hack, the text slipped in upstream
@@ -69,9 +76,13 @@ describe('crosscheck', (): void => {
console.log('CryptoScamDb missing\n', JSON.stringify(missing, null, 2));
assertAndLog(missing.length === 0, 'CryptoScamDB', missing);
errors--;
});
it('has polkadot/kusama entries from eth-phishing-detect', async (): Promise<void> => {
errors++;
const ethDb = await fetchJson<EthPhishing>(ETHPHISH);
const filtered = ethDb.blacklist.filter((url) => matchName(url));
const missing = filtered.filter((url) => !ours.includes(url));
@@ -80,5 +91,7 @@ describe('crosscheck', (): void => {
console.log('eth-phishing-detect missing\n', JSON.stringify(missing, null, 2));
assertAndLog(missing.length === 0, 'eth-phishing-detect', missing);
errors--;
});
});
+330 -1488
View File
File diff suppressed because it is too large Load Diff