mirror of
https://github.com/pezkuwichain/phishing.git
synced 2026-06-14 21:21:03 +00:00
Nightly addrcheck (#63)
This commit is contained in:
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
title: Missing address entries
|
||||||
|
labels: ['ci', '@all.json']
|
||||||
|
---
|
||||||
|
|
||||||
|
cc @polkadot-js/notifications
|
||||||
|
|
||||||
|
Additional entries for addresses have been detected.
|
||||||
|
|
||||||
|
Check the nightly cron output or run `yarn phishing:addrcheck` locally. The output as found from the test includes:
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
title: Phishing missing cross-check entries
|
title: Missing cross-check entries
|
||||||
labels: ['ci', '@all.json']
|
labels: ['ci', '@all.json']
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
yarn install --immutable | grep -v 'YN0013'
|
yarn install --immutable | grep -v 'YN0013'
|
||||||
yarn phishing:crosscheck
|
yarn phishing:crosscheck
|
||||||
|
|
||||||
- name: issue
|
- name: issue
|
||||||
if: ${{ failure() }}
|
if: ${{ failure() }}
|
||||||
uses: JasonEtco/create-an-issue@v2
|
uses: JasonEtco/create-an-issue@v2
|
||||||
@@ -22,3 +21,21 @@ jobs:
|
|||||||
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
with:
|
with:
|
||||||
filename: .github/crosscheck.md
|
filename: .github/crosscheck.md
|
||||||
|
|
||||||
|
addrcheck:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: check
|
||||||
|
env:
|
||||||
|
CI_LOG: 123
|
||||||
|
run: |
|
||||||
|
yarn install --immutable | grep -v 'YN0013'
|
||||||
|
yarn phishing:addrcheck
|
||||||
|
- name: issue
|
||||||
|
if: ${{ failure() }}
|
||||||
|
uses: JasonEtco/create-an-issue@v2
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
|
||||||
|
with:
|
||||||
|
filename: .github/addrcheck.md
|
||||||
|
|||||||
+2
-1
@@ -15,9 +15,10 @@
|
|||||||
"build:release": "polkadot-ci-ghact-build --skip-beta",
|
"build:release": "polkadot-ci-ghact-build --skip-beta",
|
||||||
"lint": "polkadot-dev-run-lint",
|
"lint": "polkadot-dev-run-lint",
|
||||||
"clean": "polkadot-dev-clean-build",
|
"clean": "polkadot-dev-clean-build",
|
||||||
|
"phishing:addrcheck": "polkadot-dev-run-test packages/phishing/src/addrcheck",
|
||||||
"phishing:crosscheck": "polkadot-dev-run-test packages/phishing/src/crosscheck",
|
"phishing:crosscheck": "polkadot-dev-run-test packages/phishing/src/crosscheck",
|
||||||
"postinstall": "polkadot-dev-yarn-only",
|
"postinstall": "polkadot-dev-yarn-only",
|
||||||
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns crosscheck"
|
"test": "polkadot-dev-run-test --coverage --runInBand --testPathIgnorePatterns addrcheck --testPathIgnorePatterns crosscheck"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.12.10",
|
"@babel/core": "^7.12.10",
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// Copyright 2020-2021 @polkadot/phishing authors & contributors
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
import fs from 'fs';
|
||||||
|
|
||||||
|
import { fetch } from '@polkadot/x-fetch';
|
||||||
|
|
||||||
|
import { retrieveAddrList } from '.';
|
||||||
|
|
||||||
|
function assertAndLog (check: boolean, error: string): void {
|
||||||
|
if (!check) {
|
||||||
|
process.env.CI_LOG && fs.appendFileSync('./.github/addrcheck.md', `
|
||||||
|
|
||||||
|
${error}
|
||||||
|
`);
|
||||||
|
|
||||||
|
throw new Error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function delayLoop (): Promise<void> {
|
||||||
|
return new Promise((resolve): void => {
|
||||||
|
setTimeout(() => resolve(), 1500);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('addrcheck', (): void => {
|
||||||
|
let ours: Record<string, string[]>;
|
||||||
|
|
||||||
|
beforeAll(async (): Promise<void> => {
|
||||||
|
jest.setTimeout(120000);
|
||||||
|
ours = await retrieveAddrList();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has all entries from polkadot.center', async (): Promise<void> => {
|
||||||
|
const found: string[] = [];
|
||||||
|
|
||||||
|
for (let i = 0; i < 25; i++) {
|
||||||
|
const result = await (await fetch('https://polkadot.center/get_wallet.php')).json() as Record<string, string>;
|
||||||
|
const wallet = result.wallet.replace('\r', '');
|
||||||
|
|
||||||
|
if (!found.includes(wallet)) {
|
||||||
|
found.push(wallet);
|
||||||
|
}
|
||||||
|
|
||||||
|
await delayLoop();
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('polkadot.center', JSON.stringify(found));
|
||||||
|
|
||||||
|
const missing = found.filter((a) => !ours['polkadot.center'].includes(a));
|
||||||
|
|
||||||
|
assertAndLog(missing.length === 0, `Missing entries found for polkadot.center: ${JSON.stringify(missing)}`);
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -40,6 +40,7 @@ describe('crosscheck', (): void => {
|
|||||||
let ours: string[];
|
let ours: string[];
|
||||||
|
|
||||||
beforeAll(async (): Promise<void> => {
|
beforeAll(async (): Promise<void> => {
|
||||||
|
jest.setTimeout(120000);
|
||||||
ours = (await retrieveHostList()).deny;
|
ours = (await retrieveHostList()).deny;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user